From patchwork Fri Apr 1 13:05:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Wan X-Patchwork-Id: 64823 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp538611lbc; Thu, 31 Mar 2016 22:29:09 -0700 (PDT) X-Received: by 10.67.30.163 with SMTP id kf3mr27948198pad.45.1459488549327; Thu, 31 Mar 2016 22:29:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qe4si3466868pab.195.2016.03.31.22.29.09; Thu, 31 Mar 2016 22:29:09 -0700 (PDT) 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; 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 S1758111AbcDAF2r (ORCPT + 29 others); Fri, 1 Apr 2016 01:28:47 -0400 Received: from mail-bl2on0090.outbound.protection.outlook.com ([65.55.169.90]:61120 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754831AbcDAF2o (ORCPT ); Fri, 1 Apr 2016 01:28:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MDpG6sxzJzfZ9x0X5/ky6cDOlndJ0gHm/P7++CJNfpo=; b=oWFK0Gu9VJGYyomK4ZCt3D6c6Owe5sXTUoc+De85WFGpNlnggkr3AV8sOblF/Fq+qrI9xoaR9pPjdk/lrIxoqUgC0ZiTV4dVyNiCq+Bj5E1DGxNgbHRiAawdP7WCAm9ZqkIepMx7BtY6R6e+lCPstZMf1d5XUPiRt4e2Sx4MJZo= Received: from CY1PR12CA0056.namprd12.prod.outlook.com (10.163.230.24) by CY1PR12MB0856.namprd12.prod.outlook.com (10.164.70.14) with Microsoft SMTP Server (TLS) id 15.1.447.15; Fri, 1 Apr 2016 05:28:40 +0000 Received: from CO1NAM03FT035.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by CY1PR12CA0056.outlook.office365.com (2a01:111:e400:c42b::24) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Fri, 1 Apr 2016 05:28:40 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by CO1NAM03FT035.mail.protection.outlook.com (10.152.80.179) with Microsoft SMTP Server id 15.1.453.6 via Frontend Transport; Fri, 1 Apr 2016 05:28:38 +0000 X-WSS-ID: 0O4XWJK-08-O1X-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 22AFED16048; Fri, 1 Apr 2016 01:28:32 -0400 (EDT) Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 1 Apr 2016 00:29:02 -0500 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 1 Apr 2016 01:28:35 -0400 Received: from viwan-emmc.amd.com (10.237.75.161) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.266.1; Fri, 1 Apr 2016 13:28:30 +0800 From: Wan Zongshun To: Joerg Roedel , CC: Suravee Suthikulpanit , Borislav Petkov , Ray Huang , , , , Wan Zongshun Subject: [PATCH V3 3/9] iommu/amd: Use the most comprehensive IVHD type that the driver can support Date: Fri, 1 Apr 2016 09:05:59 -0400 Message-ID: <1459515965-2865-4-git-send-email-vincent.wan@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan@amd.com> References: <1459515965-2865-1-git-send-email-vincent.wan@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(189002)(199003)(33646002)(81166005)(189998001)(101416001)(11100500001)(50986999)(76176999)(105586002)(106466001)(2906002)(4326007)(50226001)(5003940100001)(86362001)(47776003)(50466002)(2950100001)(36756003)(5003600100002)(5001770100001)(586003)(92566002)(19580395003)(48376002)(229853001)(19580405001)(53416004)(77096005)(5008740100001)(87936001)(1096002)(1220700001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0856; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-MS-Office365-Filtering-Correlation-Id: 88b6a147-3bf3-4e6f-a998-08d359ee7b3e X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0856; 2:KgprlWK9567+hDjQMfHrGIT+ybpn+k657q+U+JuwNKy5jtFOJbFY+1vungIZ/9L/PXECd74jMsz+o9MzN4dmxVFpOtMVDVO7XaYmjiS/63Dhk9LnckGkACsGo6ci6Nj7hE1Uyvx2Q2Q7h0WcDF1yI80/2TUaYk7jYsiD58K87Ie34Pzatdr5iadIbqNA7NL6; 3:s0qkSUMaHF2HQ7zjKB1es+zn5MPaO/bUY9kLFivS5kIR/1rA2HNgHLYB5Fy51Ht3L8Q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nA2PleGmZPDF6zbZONCglDZsoK46aS6AQkPsuP9RD4x3A781comEEs6eOZQwwi544qArlpixkwVaky846iRID8hCtdEBfg5Ko4ScYXFYXqCb1L/Zk+XYVnyeRsU1BbarnTvS0GgQnuWa3AUx/rlEHdntSy7VaYPGdFjpyRUXui6Y/a75p9vCUcBuUC/E6Dj3QaTAKMsBe9SZZuZNUTriftxg5344+edx+UxPIdSwOAji1U2f23Jf4aY5+tUhbwYA4iTQf9jScCYn9OYQhCUe8zcIzQOL59r/qD5db0Cvq/ykV/30RwNHyGCHmAYONc0Y4Tjr/04eRMuf/JphupqSEjMdBhu5svoQjwn2zzHTUJzUYQU/LgRKmRaaJxlx45gq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13018025)(8121501046)(13017025)(13015025)(13024025)(13023025)(10201501046)(3002001); SRVR:CY1PR12MB0856; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0856; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0856; 4:unJRyDuViJoIBgttt6zgLWshGdWl9w7x9ofmAryzZfG0YGwC6cMAc5a5Dbif0a85i7ogMGcBgt8UglyUpRygyIeB7P156QVhzCajWIO1RdzMZh7q5WleBaDaihktrMUAnfgSDTBAE/nDqxvzi6XStA7m6N9ivGtOVfFD15Ul8nuYnB7czQM87Q+50VV0N1726AZtxwWkfAFSfczsccNaJnUMW1hR1NNIZ0TQq/hZg2nSBMTcp0K7egIVJQNFlgxG+YbexoVYkAJnTn5XgXQAiZX1Nn0PqrgUVq5dB1TSCc0REuUzi/XZuMYs/cQ54JrOFftXWNp4bZunEwoouoFBnanh6LzltyfPsPHt47n+CAMOAaYACzDyfpAsKiZd4VfIR9UqanQOz79ZWwTLaF0fjLPzVCuihFlWl1Cop2koIgdUkVAh5JejBAXok27VtQD4egpvnnm9G9JGkDmAoXcjCw== X-Forefront-PRV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us-ascii?Q?zb1ylh/E0ZTCo3aZUg6iwms//0sYIke/wHmbX1WhWa+cJkDQ145W5TPTx+Ud?= =?us-ascii?Q?2iFwj7Qe/SvxWVCxBj9NMxO7qyL5eI3wQ5B/pn8+dQYIuimHQrUkKWLUGnej?= =?us-ascii?Q?zlQXADTC9PHFY4pj8Cp03PzVQzTUrBpoWZLlOyX4/D8vbNeVKz7q37d86Kr3?= =?us-ascii?Q?OrNIc73V/D9kew9zIzFsG86?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0856; 5:jNRs5z31afQD+vUGtPJXjSHU22Msa54H+rTpyw4YBS0QH2GQAr7gANxK5kPYSZB8STK0ln6Dq0lnkGYwHrxSKXn4cDkGjzTQWBpyAvX1N05P4EIC6C6ofPME9ZlvBbE/oA/vntqBKa6r+uHgvcBsBA==; 24:L8OQrFlFRQpLBMJcumhMPoTeT/XkY5LTzRK1sgv5uDJ+HDqCCGeqI1UBv3I0zdAKxRbVbxv2EODi1yJChEpJXLr6fWkDJi2JTKLS4WB8DtA=; 20:PWRem2l2E+q1OjUrfgpv4Uq13mTobpbbKkZNKLwjMi0FRjHVYjSj+eBYJgCWtQvvktX1QgIvRzZ9sZg9ddioXwJY/wvcSr+sr2MgBpOha25UoIQrkFlGu8KjAlZiMUMB75xvXcw7ZEbA8PHzQYWUdmBXdgjwpwavjk82CPTwursxy62kkI93BXFL6YtfLUo/IDLnlJN4RKqaFAbhQYhe+tgev3AZvcCDBVo+RPdtoMO6iBuaE7HrkWvQqH1HQW5P SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2016 05:28:38.6351 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0856 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit The IVRS in more recent AMD system usually contains multiple IVHD block types (e.g. 0x10, 0x11, and 0x40) for each IOMMU. The newer IVHD types provide more information (e.g. new features specified in the IOMMU spec), while maintain compatibility with the older IVHD type. Having multiple IVHD type allows older IOMMU drivers to still function (e.g. using the older IVHD type 0x10) while the newer IOMMU driver can use the newer IVHD types (e.g. 0x11 and 0x40). Therefore, the IOMMU driver should only make use of the newest IVHD type that it can support. This patch adds new logic to determine the highest level of IVHD type it can support, and use it throughout the to initialize the driver. This requires adding another pass to the IVRS parsing to determine appropriate IVHD type (see function get_highest_supported_ivhd_type()) before parsing the contents. [Vincent: fix the build error of IVHD_DEV_ACPI_HID flag not found] Signed-off-by: Wan Zongshun Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 107 ++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 29 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 22e078b..8f49612 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -44,7 +44,7 @@ */ #define IVRS_HEADER_LENGTH 48 -#define ACPI_IVHD_TYPE 0x10 +#define ACPI_IVHD_TYPE_MAX_SUPPORTED 0x40 #define ACPI_IVMD_TYPE_ALL 0x20 #define ACPI_IVMD_TYPE 0x21 #define ACPI_IVMD_TYPE_RANGE 0x22 @@ -58,6 +58,7 @@ #define IVHD_DEV_EXT_SELECT 0x46 #define IVHD_DEV_EXT_SELECT_RANGE 0x47 #define IVHD_DEV_SPECIAL 0x48 +#define IVHD_DEV_ACPI_HID 0xf0 #define IVHD_SPECIAL_IOAPIC 1 #define IVHD_SPECIAL_HPET 2 @@ -137,6 +138,7 @@ bool amd_iommu_irq_remap __read_mostly; static bool amd_iommu_detected; static bool __initdata amd_iommu_disabled; +static int amd_iommu_target_ivhd_type; u16 amd_iommu_last_bdf; /* largest PCI device id we have to handle */ @@ -428,7 +430,15 @@ static inline u32 get_ivhd_header_size(struct ivhd_header *h) */ static inline int ivhd_entry_length(u8 *ivhd) { - return 0x04 << (*ivhd >> 6); + u32 type = ((struct ivhd_entry *)ivhd)->type; + + if (type < 0x80) { + return 0x04 << (*ivhd >> 6); + } else if (type == IVHD_DEV_ACPI_HID) { + /* For ACPI_HID, offset 21 is uid len */ + return *((u8 *)ivhd + 21) + 22; + } + return 0; } /* @@ -475,6 +485,22 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h) return 0; } +static int __init check_ivrs_checksum(struct acpi_table_header *table) +{ + int i; + u8 checksum = 0, *p = (u8 *)table; + + for (i = 0; i < table->length; ++i) + checksum += p[i]; + if (checksum != 0) { + /* ACPI table corrupt */ + pr_err(FW_BUG "AMD-Vi: IVRS invalid checksum\n"); + return -ENODEV; + } + + return 0; +} + /* * Iterate over all IVHD entries in the ACPI table and find the highest device * id which we need to handle. This is the first of three functions which parse @@ -482,31 +508,19 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h) */ static int __init find_last_devid_acpi(struct acpi_table_header *table) { - int i; - u8 checksum = 0, *p = (u8 *)table, *end = (u8 *)table; + u8 *p = (u8 *)table, *end = (u8 *)table; struct ivhd_header *h; - /* - * Validate checksum here so we don't need to do it when - * we actually parse the table - */ - for (i = 0; i < table->length; ++i) - checksum += p[i]; - if (checksum != 0) - /* ACPI table corrupt */ - return -ENODEV; - p += IVRS_HEADER_LENGTH; end += table->length; while (p < end) { h = (struct ivhd_header *)p; - switch (h->type) { - case ACPI_IVHD_TYPE: - find_last_devid_from_ivhd(h); - break; - default: - break; + if (h->type == amd_iommu_target_ivhd_type) { + int ret = find_last_devid_from_ivhd(h); + + if (ret) + return ret; } p += h->length; } @@ -1164,6 +1178,32 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) return 0; } +/** + * get_highest_supported_ivhd_type - Look up the appropriate IVHD type + * @ivrs Pointer to the IVRS header + * + * This function search through all IVDB of the maximum supported IVHD + */ +static u8 get_highest_supported_ivhd_type(struct acpi_table_header *ivrs) +{ + u8 *base = (u8 *)ivrs; + struct ivhd_header *ivhd = (struct ivhd_header *) + (base + IVRS_HEADER_LENGTH); + u8 last_type = ivhd->type; + u16 devid = ivhd->devid; + + while (((u8 *)ivhd - base < ivrs->length) && + (ivhd->type <= ACPI_IVHD_TYPE_MAX_SUPPORTED)) { + u8 *p = (u8 *) ivhd; + + if (ivhd->devid == devid) + last_type = ivhd->type; + ivhd = (struct ivhd_header *)(p + ivhd->length); + } + + return last_type; +} + /* * Iterates over all IOMMU entries in the ACPI table, allocates the * IOMMU structure and initializes it with init_iommu_one() @@ -1180,8 +1220,7 @@ static int __init init_iommu_all(struct acpi_table_header *table) while (p < end) { h = (struct ivhd_header *)p; - switch (*p) { - case ACPI_IVHD_TYPE: + if (*p == amd_iommu_target_ivhd_type) { DUMP_printk("device: %02x:%02x.%01x cap: %04x " "seg: %d flags: %01x info %04x\n", @@ -1198,9 +1237,6 @@ static int __init init_iommu_all(struct acpi_table_header *table) ret = init_iommu_one(iommu, h); if (ret) return ret; - break; - default: - break; } p += h->length; @@ -1865,18 +1901,20 @@ static void __init free_dma_resources(void) * remapping setup code. * * This function basically parses the ACPI table for AMD IOMMU (IVRS) - * three times: + * four times: * - * 1 pass) Find the highest PCI device id the driver has to handle. + * 1 pass) Discover the most comprehensive IVHD type to use. + * + * 2 pass) Find the highest PCI device id the driver has to handle. * Upon this information the size of the data structures is * determined that needs to be allocated. * - * 2 pass) Initialize the data structures just allocated with the + * 3 pass) Initialize the data structures just allocated with the * information in the ACPI table about available AMD IOMMUs * in the system. It also maps the PCI devices in the * system to specific IOMMUs * - * 3 pass) After the basic data structures are allocated and + * 4 pass) After the basic data structures are allocated and * initialized we update them with information about memory * remapping requirements parsed out of the ACPI table in * this last pass. @@ -1904,6 +1942,17 @@ static int __init early_amd_iommu_init(void) } /* + * Validate checksum here so we don't need to do it when + * we actually parse the table + */ + ret = check_ivrs_checksum(ivrs_base); + if (ret) + return ret; + + amd_iommu_target_ivhd_type = get_highest_supported_ivhd_type(ivrs_base); + DUMP_printk("Using IVHD type %#x\n", amd_iommu_target_ivhd_type); + + /* * First parse ACPI tables to find the largest Bus/Dev/Func * we need to handle. Upon this information the shared data * structures for the IOMMUs in the system will be allocated