Received: by 10.223.176.46 with SMTP id f43csp1304250wra; Fri, 26 Jan 2018 15:53:58 -0800 (PST) X-Google-Smtp-Source: AH8x225iW7R1fjzvqE9Bzq8y0sDXe5yVP2nSB1TtpxE7h3ATfpFsQGXDsSmLmzEoQ7n1HxmWbuYW X-Received: by 10.98.189.8 with SMTP id a8mr20473769pff.125.1517010838314; Fri, 26 Jan 2018 15:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517010838; cv=none; d=google.com; s=arc-20160816; b=pT/CcvPzkh+6nH0/RTl4o8FM8lo4HVmU0nzt/ZkGB25DL2AeAfm3MCB70gX0lmpFzN +cGU+gqao/y+S1oV2dxO/S3SRBQpJMxfzAI56eRcneNseP2rgwhTCy7Qn0ceJgL5bZ6W BeLIRdgjdzBIBmhGQ/moVgIOO4Tg/NiNfeYx9+nNvaK6CC0zIg6lFtFARu8jIfCw6MLI FdtTolgiTawNRhgChwek0C3sWkmwjQyD0v64RV03LhssK0FnlDpcH4lPuU3lQqNxO89j 1JNUwyZcSyYkMUZomjsHCP2GhpohFcvRYaZrYmRtWKZI0fzXMQQ1y7QWvV+K6mEHxuC5 ii/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:arc-authentication-results; bh=hcK5Xd7dbfedUaIRyDDB/eyz3t38a9TdWUW7h8d8rMM=; b=gGTVHjnTL66IpZgIhsABBaaFjxn9Yi+vGzuog2BQpp1PPkfD802ieyLcgNnyUgqOhE l6qF2JizpHHiQfvJi5YkpBEfN/S+61kjJLtS2B0cQlkzroyipItoUCXm9LDW92UExEzZ KV9mVQuW8LUm8Z4q7BQNe+4cBXCwxCx3gKQNQsejTZYaWm7l3uOZ/r6ExP6rvyT/AkiN QDJlqSvE017kmYpgyCrLur126rJwh+HnGsvq8lQ3rVxNO2JAVBwrecx9ULKd9Ku5kkBY DzitmMUk7LhvdwW3+FKoWwLE7e93pZT+igtbqeIlPLLi4HbFHuhxE5HND53mupAjT1jd oHAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=eHxTJvNe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si7099801pfa.245.2018.01.26.15.53.44; Fri, 26 Jan 2018 15:53:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=eHxTJvNe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbeAZXxF (ORCPT + 99 others); Fri, 26 Jan 2018 18:53:05 -0500 Received: from mail-by2nam01on0078.outbound.protection.outlook.com ([104.47.34.78]:1915 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752205AbeAZXxC (ORCPT ); Fri, 26 Jan 2018 18:53:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hcK5Xd7dbfedUaIRyDDB/eyz3t38a9TdWUW7h8d8rMM=; b=eHxTJvNe1mS2ypIYplXh7SibZL9rOx8KCijHtaR+IqTGe4AlmhP+MTFkwxhZhi+uxa1w1rO+d/2+4Op5mLCycCGiBpsozSnof9fYTTlg9mopvr+TSICkLsnug0tjm1YVlQImh2rUSljzbOMSLE3A1iGr2z+aLyYSZxfKD5OS2lA= Received: from [127.0.1.1] (165.204.78.1) by MWHPR12MB1214.namprd12.prod.outlook.com (10.169.204.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Fri, 26 Jan 2018 23:53:00 +0000 Subject: [PATCH 5/5] iommu/amd - Add a debugfs entry to specify a IOMMU device table entry From: Gary R Hook To: iommu@lists.linux-foundation.org Cc: joro@8bytes.org, linux-kernel@vger.kernel.org Date: Fri, 26 Jan 2018 17:52:55 -0600 Message-ID: <151701077595.16448.10705468886498056095.stgit@taos> In-Reply-To: <151701071164.16448.3611271062222336838.stgit@taos> References: <151701071164.16448.3611271062222336838.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BL0PR1501CA0002.namprd15.prod.outlook.com (52.132.16.15) To MWHPR12MB1214.namprd12.prod.outlook.com (10.169.204.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ef6a9e16-2e23-44de-5f6e-08d56517eed5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:MWHPR12MB1214; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1214;3:tOniCMBv6hLjWJO7lQMg4zLKuQLfrfX38bov3GQzCLviDP+g6GAc3nzaGN9bkdRaOBGBaU7JOS9+7386JmaXsneiQr9WVEBA4X6M2JFprQ72mCWL515z5DFLelTpG7i0yGNvbacFXuEmGYi3kUUc/smjklJZtKviZCk6Rs2oZegZonUAiDPMyaVPNgEwnLN2da0tQyRnq8zOZEDf8s5e2tWKDVJPHFd/mMGuElTy+XJHyjDKE+cA27EQkz9n6UmK;25:uU+lF4g1HXouHZrAqtgK6530SJWVAFZ5X9eidiiehLi5LyAj92Zr9fgUC3y9Me2QBHKcuy94xVoffpuumqbiFb61+JOHPBGhdXan+dHOzb5oTF0VwjcY1XZReuj8mdU+XcDLZ9RfCoWNTDA1MBFGpqiIuhQ5YZuTKMWofkKXSgBNMtGknh7yxNmD6IXbXJceH0VGD33+YnjaycHDbELB/GZqBdgpqNynfiVCCEwdxsOh3fplwI9+iO2O3yRJlKfjwIYtaQjmpabwYerimK5FfCur/b31JhVzNuC15GuBoEMr5MeFMwE8LQ+2RjM5/K7hiuXDR7lIt0lw+goWDGZ9lA==;31:YSrEUt1VLXacUFRDZE7DP2oeBd4bXi/Kvotx0ls/lYVqS3sx3pehoVDoIaaWXw9SZG+QsqRN9MTabJ8Fw38oNYfyV7+1jKn2zu8IkFmdI6BJGJ/Xz4TbPBTN1t43EuMG6MrzO8We3amHp2O4NS5k5TpPE4Z/jYKgJDWLTYxSoMH70lm4tRB6P2b2M6UfUqB6BashEuBZc4Pox7dn0oZOjIvuSHW6O7UdFvNGcU+JRU0= X-MS-TrafficTypeDiagnostic: MWHPR12MB1214: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1214;20:TMtvJEf4mfkERb0XSIasOweU1BEZ6ftwDN+4OlshhwH1RG1f6oekMzEr1fpfaa1BL1rnfZszVNDBNOdpqFyRqhYbA3PJp7GX4miUuRO+3EtqRgOLtJMA+uDGcGy8TGZPOIB5WCFomUS7WALP61gn23Sv74KcvGkaMGr37xRRfunbFEMKausa0TB3JgqCZCzndKfgJ1ijDu5Gh+fVlu0lD/tBUET/T+cECkeH5FcoFYUWKCjqnR2nTl9ErMVPPSbc+sdrHN4q8STC6LT1TMXyxVRZ9NDckCrLCQTTsx5wm5g170JpsBGVymEE7D3PyvrybyG1bwZCJ8WDzcxkp8WwpWoKK7saFKXIm2zpFqqoq05pZl4JwdUaWOlm3mapMUi0rCSBgbACElDszmdb1/PN4Hx3zANE8RoupA7eSg+nrKQikSmqRPKVwN52rvoQxbAoY3bX5MtZb4i6U+eNaAIDQE38ms2Cj4o19qAZx1qKc32eb+p4lM7w7m5ThC4poykN;4:SFknnTW+8jixouU9titIvuA+OrlqPQX3WDz90nP2KjSgLjfIsBrDT+OuVHrfpWDs2kE6YbLM3vIDQVu4HqbSIK+P4JvGEuqGKaX2Vf03BbrY5bVMgjVH5JfMvIq3QGdSCSeZIMLc2ttIaHTkQY5V0gq3pxyHHrYjeojHq7oXwxpSk+BnHiu0yqUNbXDz8FLJV+myFhkD8o6mCsPW9tYNoPvzVwkzLGSw6svYFUKU/dXYJwIwP5qLs74t2jMO5SiEVBCgiruKcpGak5wKpzHn9dH0m5jM/XF/BRQf30citiOQ3DiZZPu+naw9v4rARfCb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231078)(2400081)(944501161)(10201501046)(3002001)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:MWHPR12MB1214;BCL:0;PCL:0;RULEID:;SRVR:MWHPR12MB1214; X-Forefront-PRVS: 05641FD966 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(7916004)(346002)(376002)(366004)(39380400002)(39860400002)(396003)(189003)(199004)(86362001)(2351001)(7736002)(2361001)(68736007)(106356001)(66066001)(25786009)(305945005)(2906002)(97736004)(4326008)(47776003)(33716001)(5660300001)(50466002)(6116002)(230700001)(3846002)(26005)(6666003)(6916009)(81156014)(2950100002)(59450400001)(81166006)(105586002)(8676002)(72206003)(386003)(83506002)(8936002)(33896004)(2486003)(16576012)(76176011)(77096007)(103116003)(9686003)(23676004)(52116002)(53936002)(90366009)(6486002)(16526019)(186003)(478600001)(316002)(58126008);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1214;H:[127.0.1.1];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMjE0OzIzOjBZUHc5eHFSdm5SWnBGQW55UHpYNkF0NU1o?= =?utf-8?B?b25XNmNJVkZtL2RpZGlCeDI3U1VIVmszc1FVUUJSZTRGSy9VTW9QZkY1Ymw3?= =?utf-8?B?dzRhY2dVaW5pcVdRNkNCaldLTEtuSURnV29VdkQrVUV4T0JiTVkydlFKMVQ3?= =?utf-8?B?bHMzYzl6TkcrS1RPc1daZkQyZDhsTDNsQkx5MmlSeVBVR1RXbDZtTDJpbytL?= =?utf-8?B?K1RhUUVIRGRZY2k0Q08xdEVhcENzRVAwUkJIemw3VWJYakdvd0t2b202RlBv?= =?utf-8?B?bFhHdmhKRU5FYmJMOGMxbWpOU2dNMmFJQUZXT1UyTVY2TGo5MENveXJjS0Fx?= =?utf-8?B?bFZBWGgwdjZMUStrUTl6Vm5vamNSMTVlVEZ6OUN4UDFUcHBXOU02OFA2d0t2?= =?utf-8?B?bm9CSll0UHlZRSs3dE9jZVRCdG92bGRuTWtjQ0ZRL1M4NTBSZHc2VlJTcktK?= =?utf-8?B?blhVOEhJcXpEdmpUM3lWbXFMRzZKMU1wdURkY0dOR00zL2hZV2d1NDM4UmJp?= =?utf-8?B?YWxnZU5pSVVlZ05KamVFUHRUTjBQTXFjT21Tb0pTTlVrYkpGL1RtbzBXWEIy?= =?utf-8?B?RmpZWkF6TTVTNkhCSDZlQ0d5OU0yQ1IrQ2Yzc2dDQ3VUZThKemJJSlVVTW9F?= =?utf-8?B?cWY3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EKP8LeZPJEd4uCfV7WAcV5SYl82Z+gkfmnsPHpzJLU+9V0KI4tdibTtRsiTIKjm08LpxgyvtfrcEr/qLk7PgTtuXxT8KJNJYXp2ds95fX//aptiW4RLie1wvHPkhUwwlgGpUmeexpHVWQqwl1PHPior9LUO7l2/Q1wFkrFlUNFjcOUrLdvbGnLRnSs6Z5FsxESKS2yDI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1214;20:o9rFIPhsKMGnnO1acTCiYksh/Ty0DLNFNYyxEZHERHoig6i2kvuKrY5qKmDT33sRL1ucehCWs1ROir4q9FvlWxBQF70RVy6ij8oDkWdg8ix/2Eo89qqm/GB6/jodfoNAqsTl/h1+9Czvbra9mhuSgFIv1pbHE6321/HRoGwhcOifOpOCCMxI95ORSpxaq6gHKqTFR1OXq0/NWpCU93TBQpboUPgqj584TyMLlwP+04qUkdR6EWl8GXArcPlMNcpD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2018 23:53:00.0282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef6a9e16-2e23-44de-5f6e-08d56517eed5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1214 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initially (at boot) the device table values dumped are all of the active devices. Add a devid debugfs file to allow the user to select a single device table entry to dump (active or not). Let any devid value greater than the maximum allowable PCI ID (0xFFFF) restore the behavior to that effective at boot. Signed-off-by: Gary R Hook --- drivers/iommu/amd_iommu_debugfs.c | 127 ++++++++++++++++++++++++++++++++----- 1 file changed, 109 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/amd_iommu_debugfs.c b/drivers/iommu/amd_iommu_debugfs.c index 87840ae9889d..efb666873daa 100644 --- a/drivers/iommu/amd_iommu_debugfs.c +++ b/drivers/iommu/amd_iommu_debugfs.c @@ -38,6 +38,7 @@ static DEFINE_RWLOCK(iommu_debugfs_lock); #define MAX_NAME_LEN 20 static unsigned int amd_iommu_verbose; +static unsigned int amd_iommu_devid = ~0; static unsigned int amd_iommu_count_valid_dtes(int start, int end) { @@ -91,6 +92,72 @@ static const struct file_operations amd_iommu_debugfs_dtecount_ops = { .write = NULL, }; +static ssize_t amd_iommu_debugfs_devid_read(struct file *filp, + char __user *ubuf, + size_t count, loff_t *offp) +{ + struct amd_iommu *iommu = filp->private_data; + unsigned int obuflen = 512; + unsigned int oboff = 0; + ssize_t ret; + char *obuf; + + if (!iommu) + return 0; + + obuf = kmalloc(OBUFLEN, GFP_KERNEL); + if (!obuf) + return -ENOMEM; + + if (amd_iommu_verbose) + oboff += OSCNPRINTF("%02x:%02x.%x 0x%04x %u\n", + PCI_BUS_NUM(amd_iommu_devid), + PCI_SLOT(amd_iommu_devid), + PCI_FUNC(amd_iommu_devid), + amd_iommu_devid, amd_iommu_devid); + else + oboff += OSCNPRINTF("%u\n", amd_iommu_devid); + + ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff); + kfree(obuf); + + return ret; +} + +static ssize_t amd_iommu_debugfs_devid_write(struct file *filp, + const char __user *ubuf, + size_t count, loff_t *offp) +{ + unsigned int pci_id, pci_slot, pci_func; + unsigned int obuflen = 80; + ssize_t ret; + char *obuf; + int n; + + obuf = kmalloc(OBUFLEN, GFP_KERNEL); + if (!obuf) + return -ENOMEM; + + ret = simple_write_to_buffer(obuf, OBUFLEN, offp, ubuf, count); + + if (strnchr(obuf, OBUFLEN, ':')) { + n = sscanf(obuf, "%x:%x.%x", &pci_id, &pci_slot, &pci_func); + if (n == 3) + amd_iommu_devid = PCI_DEVID(pci_id, PCI_DEVFN(pci_slot, pci_func)); + } else + n = kstrtouint(obuf, 0, &amd_iommu_devid); + kfree(obuf); + + return ret; +} + +static const struct file_operations amd_iommu_debugfs_devid_ops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = amd_iommu_debugfs_devid_read, + .write = amd_iommu_debugfs_devid_write, +}; + struct bits { uint bit; uint len; @@ -211,9 +278,13 @@ static ssize_t amd_iommu_debugfs_dte_read(struct file *filp, return 0; /* Count the number of valid entries in the device table */ - istart = 0; - iend = MAX_PCI_ID; - n = amd_iommu_count_valid_dtes(istart, iend); + if (amd_iommu_devid > MAX_PCI_ID) { + istart = 0; + iend = MAX_PCI_ID; + n = amd_iommu_count_valid_dtes(istart, iend); + } else { + n = 1; + } if (amd_iommu_verbose) obuflen = n * 2048; else @@ -223,20 +294,29 @@ static ssize_t amd_iommu_debugfs_dte_read(struct file *filp, if (!obuf) return -ENOMEM; - for (i = istart ; i <= iend ; i++) - if ((amd_iommu_dev_table[i].data[0] ^ 0x3) - || amd_iommu_dev_table[i].data[1]) { - if (amd_iommu_verbose) { - oboff += OSCNPRINTF("Device %02x:%02x.%x\n", - PCI_BUS_NUM(i), - PCI_SLOT(i), - PCI_FUNC(i)); - amd_iommu_print_dte_verbose(i, &obuf, - &obuflen, &oboff); - } else { - oboff += PRINTDTE(i); + if (amd_iommu_devid > MAX_PCI_ID) { + for (i = istart ; i <= iend ; i++) + if ((amd_iommu_dev_table[i].data[0] ^ 0x3) + || amd_iommu_dev_table[i].data[1]) { + if (amd_iommu_verbose) { + oboff += OSCNPRINTF("Device %02x:%02x.%x\n", + PCI_BUS_NUM(i), + PCI_SLOT(i), + PCI_FUNC(i)); + amd_iommu_print_dte_verbose(i, &obuf, + &obuflen, + &oboff); + } else { + oboff += PRINTDTE(i); + } } - } + } else { + i = amd_iommu_devid; + if (amd_iommu_verbose) + amd_iommu_print_dte_verbose(i, &obuf, &obuflen, &oboff); + else + oboff += PRINTDTE(i); + } ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff); kfree(obuf); @@ -253,12 +333,17 @@ static const struct file_operations amd_iommu_debugfs_dte_ops = { static char readmetext[] = "devicetable Print active entries in the device table\n" +"devid Controls which device IDs are printed\n" "count Count of active devices\n" "verbose Provide additional descriptive text\n" "\n" " Dumping the Device Table\n" -"The device table is scanned for entries that appear to be active. The\n" -"default range is from 0 to 0xFFFF, and only active entries will be reported\n" +"The device table is scanned for entries that appear to be active.\n" +"The default (initial) range is from 0 to 0xFFFF, represented by a devid\n" +"value greater than 0xFFFF, and only active entries will be reported.\n" +"If devid is set to a specific value, only that device entry will be\n" +"displayed (active or not). devid may be specified as ##:##:#, a decimal\n" +"value, or a hex value.\n" "\n"; static ssize_t amd_iommu_debugfs_readme_read(struct file *filp, @@ -322,6 +407,12 @@ void amd_iommu_debugfs_setup(struct amd_iommu *iommu) if (!d_dte) goto err; + d_dte = debugfs_create_file("devid", 0400, + iommu->debugfs_instance, iommu, + &amd_iommu_debugfs_devid_ops); + if (!d_dte) + goto err; + d_dte = debugfs_create_file("README", 0400, iommu->debugfs_instance, iommu, &amd_iommu_debugfs_readme_ops);