From patchwork Mon Jul 25 09:32:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 72692 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1048341qga; Mon, 25 Jul 2016 02:34:23 -0700 (PDT) X-Received: by 10.98.47.132 with SMTP id v126mr28109171pfv.152.1469439262759; Mon, 25 Jul 2016 02:34:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z88si32773471pff.218.2016.07.25.02.34.22; Mon, 25 Jul 2016 02:34:22 -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 S1753083AbcGYJeA (ORCPT + 29 others); Mon, 25 Jul 2016 05:34:00 -0400 Received: from mail-sn1nam01on0076.outbound.protection.outlook.com ([104.47.32.76]:16256 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752913AbcGYJdX (ORCPT ); Mon, 25 Jul 2016 05:33:23 -0400 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=iOEgJ7FWkjZ6go8citTuD76JKWR+eH2sok27Yt3hOuA=; b=SKg0gETFTrZ0vnSIw4px7B7ywh1t5B/+7SP1L1gxLeD1zjde7Udb8ipOgoOxgCw1hyijfnhcGio3DMe/N+xzBKWfR6kGfnwH0meHTtacT7NTMwQGaNH6VD9aziNlglTxyFCkSLTYao8ujjikYP+/t8QZqlu0BFv6FMkIEzszkZI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from localhost.localdomain (114.109.128.54) by BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Mon, 25 Jul 2016 09:32:58 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v5 05/12] iommu/amd: Detect and initialize guest vAPIC log Date: Mon, 25 Jul 2016 04:32:04 -0500 Message-ID: <1469439131-11308-6-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469439131-11308-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1469439131-11308-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SG2PR06CA0066.apcprd06.prod.outlook.com (10.167.73.162) To BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) X-MS-Office365-Filtering-Correlation-Id: 319e687f-352d-4617-08cc-08d3b46eabf4 X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 2:bDLY/T/Hycxxbf+hAJQMgeetIa4fGINwuvWl1QX/R5EH06bjkSSIRcBrXhelOxVk1ytrIAeKn8XXZi/63IL6+46b2SB2JP6Q3zVyEkvLlmYqMDyB9h79vGrdEtRHHRDK5DMhC4KItHMyL8WY/RfYjJ7E95jLAGZjo0+DI3MIIxF8+1PhUvI5euVcwpZA8fKi; 3:0QMXZxBA7zC+uzC/DZAE+HDVxDNIwm+ZyrhMTioZI6VnRQ6DEkzXlfSnm2kPULZrN+Fh6Qw/qaTp6+Wx/WdZCt2CxHQYuwFbpsCv35wSGoFhGfF4e4LfZ9MfI3iZUkz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7VlXnnW0AmnDq1b4by4KdKie+qayTGnZHRViKCJmERC3/vy8MAxWh7AzKYQDnIKekAkVSbO/eQ4MqCl2LpCqBPwQ3D7IuNEegGY0sFe65YjOFhMMVb/a+CgRa/8iHg+GPr7auYynQjTozAz3WAqm0h8Gx8Lt9cxiPCsrM7JWLR7UCxwOOMHddbIj; 4:qHX4DcmYcEnkhO645TE3tjZwX70oj0Sj2cC4j+QzgUtcgncbhky0oy1ZdJYwOQ9gHW6fw8M1OjgPDhDBhVWuxgDUGKKMDOE6qtpQc6WkeyPWu6xzaJPUH4Z6Y6ftsMTxsfJunnfAsCw1NNcKNu2hfpxkZ8o3/4/b/vL7Exj5MP3igqr9XKB0XYTKY1uuhxe/UUFig1VVWf4jNsxuAhSnPIwO9kHObZ+O1x7uDbreSW6lLnaEHnffsOwsPrc3ZTTVDRzVXxrQ7WBr2ExOP1Vms6fqnsIjhQ1pAYNnntWwHt2T/Ao+miO3eBonKUUJHDNfD92w1vxDvSkIISe8ihOVXny1zKOPaWTlIdwfSqLklMZL2jib4V3Vpt71JloSVR2R+4MogDij2yX21rJJ6HGhM3zhX2uFsxtwj44PFwbUaW8cVKRTm/yOS/rFz7qsT1w0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BLUPR12MB0434; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0434; X-Forefront-PRVS: 0014E2CF50 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(77096005)(229853001)(50986999)(76176999)(586003)(48376002)(105586002)(19580405001)(81156014)(81166006)(8676002)(97736004)(4326007)(42186005)(5001770100001)(189998001)(2906002)(50226002)(19580395003)(50466002)(7846002)(66066001)(5003940100001)(68736007)(92566002)(86362001)(575784001)(101416001)(7736002)(305945005)(3846002)(6116002)(2950100001)(106356001)(47776003)(36756003)(33646002)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0434; H:localhost.localdomain; 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: =?us-ascii?Q?1; BLUPR12MB0434; 23:SKrazeOjHrDrVXjdFqXZIMYsE1+33R4J2bCbWTbZl?= =?us-ascii?Q?bG2RMq1aJyw3snhRRhsLcsc5y0dPL0ERaJEVl9rORot1z/8O/IbN2mMYrWh9?= =?us-ascii?Q?fkEIoa4vwgDSveglzjomVizmtncTaiYdQ9mC6lJQYjuDTqlhQo4wwmfvsTWe?= =?us-ascii?Q?/oWMfOspr0jIhLoMOh/IuEyLFScaavkastwF++q6juDv+B3AO5fHvPjSGDro?= =?us-ascii?Q?t9tKckAjebTihkrjFw3C1BhIWGJ/PtwkH7wK/GwuKv6nScz4NK4HsFkxE/2I?= =?us-ascii?Q?Rwb30/UMzxFh8NaMv+Qy/sVa06TUlGx6mb1TMx5vB0xev+4SQGNc8s6mgUab?= =?us-ascii?Q?wSByc2Cm4hccuLGEUXyCpVkSuX/LRwn33+kvWluTr5IyqrlCv5lkszU3HtFK?= =?us-ascii?Q?u/d46vsurqC/bIrFbuJLTmHjIXzlZSDN6SxU3mepkOxvKMEvRNunG1pZAuD5?= =?us-ascii?Q?0MmEWFaJd7d3VEDtRxJia6qzrqFl+odpAJZlw5jIM50IOu7Wucnjb5z5zgj/?= =?us-ascii?Q?7Chbe9E1XPN5de0FfnDOUSUFFF5oUUmHiPXmUy0KRx/kIBQYLL7XCvgSrtP5?= =?us-ascii?Q?UBTEskFf9HlgfedTEVNFUiJbdUv61qXq82OigYzsPfJb+kIIEoKkReOGHzmC?= =?us-ascii?Q?bWCrgI98gl1pbiiA2ijtAywBav+k+qJlNbxrbH5aQ/uVmeP96owzDsVkD6WD?= =?us-ascii?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24:+rpO90szEK4+fQD054xtB1KcyokUFEZFffSO4SW21oagKShDkK1FMCzT153/L7VuomzxoplpqTo47SEL70qPa6icg5WCq/P+r9JmGvQwPZc=; 7:4pb8C2a58wnxqh9OTB7Jvx65AaPUdURPtdaVl1/z0ae3vVl1jKkGsZYnuzCs64x5iGljIxVZjc8QfBEHmqk9yo3JUhPin7wSCFSNycyL1RdCfSfS3FbB2Tp+7guuaAp5bujYFg2fPXfK9xFZ3Weq105hE1tjXyuzKJ3gtoE6llbum7BxajZZDwFpxCOmvdJNvC/0e5yL87ErMzGDRO3eHHG0ocC51tOmOUPQ6wGosLYIDG4IR14UXhcSv5NiFN17 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 20:WmUlRsf64khUw12OfYAuzuqEW2LHJuDKGA+x3H4IObOnr1aEOR5FpMuMmt4yd2epSbyfq/DDASsfi03oha00is5QFr35tb6R/1aVMeUUGBwUrEkzsoJg74ycEaIOst36I2ly4qR2eEjrlCGAfsi7Hok8RYdYAGWk5C7+lPSydBupZZ44nwep7LkWyTuY2Ixn5kgF/8vbdKHqMENsqZtOlrPJrv+ytWNPNq/f1TA9yQKVJO/KE7iNt8LoT9czqxS1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2016 09:32:58.5177 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0434 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit This patch adds support to detect and initialize IOMMU Guest vAPIC log (GALOG). By default, it also enable GALog interrupt to notify IOMMU driver when GA Log entry is created. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 112 +++++++++++++++++++++++++++++++++++++--- drivers/iommu/amd_iommu_types.h | 28 ++++++++++ 2 files changed, 133 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 6635cdf..c32d0b3 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -84,6 +84,7 @@ #define ACPI_DEVFLAG_LINT1 0x80 #define ACPI_DEVFLAG_ATSDIS 0x10000000 +#define LOOP_TIMEOUT 100000 /* * ACPI table definitions * @@ -388,6 +389,10 @@ static void iommu_disable(struct amd_iommu *iommu) iommu_feature_disable(iommu, CONTROL_EVT_INT_EN); iommu_feature_disable(iommu, CONTROL_EVT_LOG_EN); + /* Disable IOMMU GA_LOG */ + iommu_feature_disable(iommu, CONTROL_GALOG_EN); + iommu_feature_disable(iommu, CONTROL_GAINT_EN); + /* Disable IOMMU hardware itself */ iommu_feature_disable(iommu, CONTROL_IOMMU_EN); } @@ -673,6 +678,99 @@ static void __init free_ppr_log(struct amd_iommu *iommu) free_pages((unsigned long)iommu->ppr_log, get_order(PPR_LOG_SIZE)); } +static void free_ga_log(struct amd_iommu *iommu) +{ +#ifdef CONFIG_IRQ_REMAP + if (iommu->ga_log) + free_pages((unsigned long)iommu->ga_log, + get_order(GA_LOG_SIZE)); + if (iommu->ga_log_tail) + free_pages((unsigned long)iommu->ga_log_tail, + get_order(8)); +#endif +} + +static int iommu_ga_log_enable(struct amd_iommu *iommu) +{ +#ifdef CONFIG_IRQ_REMAP + u32 status, i; + + if (!iommu->ga_log) + return -EINVAL; + + status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); + + /* Check if already running */ + if (status & (MMIO_STATUS_GALOG_RUN_MASK)) + return 0; + + iommu_feature_enable(iommu, CONTROL_GAINT_EN); + iommu_feature_enable(iommu, CONTROL_GALOG_EN); + + for (i = 0; i < LOOP_TIMEOUT; ++i) { + status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); + if (status & (MMIO_STATUS_GALOG_RUN_MASK)) + break; + } + + if (i >= LOOP_TIMEOUT) + return -EINVAL; +#endif /* CONFIG_IRQ_REMAP */ + return 0; +} + +#ifdef CONFIG_IRQ_REMAP +static int iommu_init_ga_log(struct amd_iommu *iommu) +{ + u64 entry; + + if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) + return 0; + + iommu->ga_log = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + get_order(GA_LOG_SIZE)); + if (!iommu->ga_log) + goto err_out; + + iommu->ga_log_tail = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + get_order(8)); + if (!iommu->ga_log_tail) + goto err_out; + + entry = (u64)virt_to_phys(iommu->ga_log) | GA_LOG_SIZE_512; + memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_BASE_OFFSET, + &entry, sizeof(entry)); + entry = ((u64)virt_to_phys(iommu->ga_log) & 0xFFFFFFFFFFFFFULL) & ~7ULL; + memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_TAIL_OFFSET, + &entry, sizeof(entry)); + writel(0x00, iommu->mmio_base + MMIO_GA_HEAD_OFFSET); + writel(0x00, iommu->mmio_base + MMIO_GA_TAIL_OFFSET); + + return 0; +err_out: + free_ga_log(iommu); + return -EINVAL; +} +#endif /* CONFIG_IRQ_REMAP */ + +static int iommu_init_ga(struct amd_iommu *iommu) +{ + int ret = 0; + +#ifdef CONFIG_IRQ_REMAP + /* Note: We have already checked GASup from IVRS table. + * Now, we need to make sure that GAMSup is set. + */ + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) && + !iommu_feature(iommu, FEATURE_GAM_VAPIC)) + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA; + + ret = iommu_init_ga_log(iommu); +#endif /* CONFIG_IRQ_REMAP */ + + return ret; +} + static void iommu_enable_gt(struct amd_iommu *iommu) { if (!iommu_feature(iommu, FEATURE_GT)) @@ -1146,6 +1244,7 @@ static void __init free_iommu_one(struct amd_iommu *iommu) free_command_buffer(iommu); free_event_buffer(iommu); free_ppr_log(iommu); + free_ga_log(iommu); iommu_unmap_mmio_space(iommu); } @@ -1438,6 +1537,7 @@ static int iommu_init_pci(struct amd_iommu *iommu) { int cap_ptr = iommu->cap_ptr; u32 range, misc, low, high; + int ret; iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid), iommu->devid & 0xff); @@ -1494,13 +1594,9 @@ static int iommu_init_pci(struct amd_iommu *iommu) if (iommu_feature(iommu, FEATURE_PPR) && alloc_ppr_log(iommu)) return -ENOMEM; - /* Note: We have already checked GASup from IVRS table. - * Now, we need to make sure that GAMSup is set. - */ - if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) && - !iommu_feature(iommu, FEATURE_GAM_VAPIC)) - amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA; - + ret = iommu_init_ga(iommu); + if (ret) + return ret; if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE)) amd_iommu_np_cache = true; @@ -1657,6 +1753,8 @@ enable_faults: if (iommu->ppr_log != NULL) iommu_feature_enable(iommu, CONTROL_PPFINT_EN); + iommu_ga_log_enable(iommu); + return 0; } diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 4fad61a..947c74a 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -70,6 +70,8 @@ #define MMIO_EXCL_LIMIT_OFFSET 0x0028 #define MMIO_EXT_FEATURES 0x0030 #define MMIO_PPR_LOG_OFFSET 0x0038 +#define MMIO_GA_LOG_BASE_OFFSET 0x00e0 +#define MMIO_GA_LOG_TAIL_OFFSET 0x00e8 #define MMIO_CMD_HEAD_OFFSET 0x2000 #define MMIO_CMD_TAIL_OFFSET 0x2008 #define MMIO_EVT_HEAD_OFFSET 0x2010 @@ -77,6 +79,8 @@ #define MMIO_STATUS_OFFSET 0x2020 #define MMIO_PPR_HEAD_OFFSET 0x2030 #define MMIO_PPR_TAIL_OFFSET 0x2038 +#define MMIO_GA_HEAD_OFFSET 0x2040 +#define MMIO_GA_TAIL_OFFSET 0x2048 #define MMIO_CNTR_CONF_OFFSET 0x4000 #define MMIO_CNTR_REG_OFFSET 0x40000 #define MMIO_REG_END_OFFSET 0x80000 @@ -112,6 +116,9 @@ #define MMIO_STATUS_EVT_INT_MASK (1 << 1) #define MMIO_STATUS_COM_WAIT_INT_MASK (1 << 2) #define MMIO_STATUS_PPR_INT_MASK (1 << 6) +#define MMIO_STATUS_GALOG_RUN_MASK (1 << 8) +#define MMIO_STATUS_GALOG_OVERFLOW_MASK (1 << 9) +#define MMIO_STATUS_GALOG_INT_MASK (1 << 10) /* event logging constants */ #define EVENT_ENTRY_SIZE 0x10 @@ -150,6 +157,8 @@ #define CONTROL_GT_EN 0x10ULL #define CONTROL_GA_EN 0x11ULL #define CONTROL_GAM_EN 0x19ULL +#define CONTROL_GALOG_EN 0x1CULL +#define CONTROL_GAINT_EN 0x1DULL #define CTRL_INV_TO_MASK (7 << CONTROL_INV_TIMEOUT) #define CTRL_INV_TO_NONE 0 @@ -228,6 +237,19 @@ #define PPR_REQ_FAULT 0x01 +/* Constants for GA Log handling */ +#define GA_LOG_ENTRIES 512 +#define GA_LOG_SIZE_SHIFT 56 +#define GA_LOG_SIZE_512 (0x8ULL << GA_LOG_SIZE_SHIFT) +#define GA_ENTRY_SIZE 8 +#define GA_LOG_SIZE (GA_ENTRY_SIZE * GA_LOG_ENTRIES) + +#define GA_TAG(x) (u32)(x & 0xffffffffULL) +#define GA_DEVID(x) (u16)(((x) >> 32) & 0xffffULL) +#define GA_REQ_TYPE(x) (((x) >> 60) & 0xfULL) + +#define GA_GUEST_NR 0x1 + #define PAGE_MODE_NONE 0x00 #define PAGE_MODE_1_LEVEL 0x01 #define PAGE_MODE_2_LEVEL 0x02 @@ -502,6 +524,12 @@ struct amd_iommu { /* Base of the PPR log, if present */ u8 *ppr_log; + /* Base of the GA log, if present */ + u8 *ga_log; + + /* Tail of the GA log, if present */ + u8 *ga_log_tail; + /* true if interrupts for this IOMMU are already enabled */ bool int_enabled;