From patchwork Wed Jul 13 13:20:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 71957 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1148379qga; Wed, 13 Jul 2016 11:43:38 -0700 (PDT) X-Received: by 10.98.95.5 with SMTP id t5mr5847688pfb.103.1468435418868; Wed, 13 Jul 2016 11:43:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si5040281pfr.240.2016.07.13.11.43.38; Wed, 13 Jul 2016 11:43:38 -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 S1753071AbcGMR7G (ORCPT + 30 others); Wed, 13 Jul 2016 13:59:06 -0400 Received: from mail-co1nam03on0046.outbound.protection.outlook.com ([104.47.40.46]:30848 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751455AbcGMR6y (ORCPT ); Wed, 13 Jul 2016 13:58:54 -0400 X-Greylist: delayed 11062 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Jul 2016 13:58:54 EDT 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=6e/chG7R1KN7DUpXXDamqmhlWhx7zrY8/R20BFK0E5w=; b=Fip30uX8aGUN1GeY22lEgWgJbEYlfWaX8dN12K8GeM8TK4MnjkTcGi1sLYFFl/pU2RDvdurVlmntQ5nhhOgg+0hI6y6s3xUVdgkvZv0F1hlTbqSDxjzyI1XDNzE4ux2Tpq3zs+lK2GderUZmvcz3lsEkZSYLdr2sCgB7fp7i9aQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from localhost.localdomain (114.109.128.54) by SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) with Microsoft SMTP Server (TLS) id 15.1.534.14; Wed, 13 Jul 2016 13:21:27 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v4 06/11] iommu/amd: Adding GALOG interrupt handler Date: Wed, 13 Jul 2016 08:20:27 -0500 Message-ID: <1468416032-7692-7-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468416032-7692-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1468416032-7692-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SIXPR04CA0024.apcprd04.prod.outlook.com (10.162.171.14) To SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) X-MS-Office365-Filtering-Correlation-Id: 5b357e69-43c8-4e7d-32d9-08d3ab2099bf X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:AJtDvzd2sBF+6f35W+zY1Y/DbsGrScZCrKA6UTbLXxI7zy8hK6ibPdFU3Rr7Y7auNAR59ftM4o5n8FHIvK/lBeFjKaMTBYN8B9xpBgaRAMjSm6ksax/IpvMHMLSBLLUsyUGkSmXME7Ejpj8Mvst2m9ElysWcKXs1Dlkc4yi560Pm/UtvkgpouezbnbIORDzl; 3:Ql6K1eRm+NwC0ugHW+edRRjrwOYlqthPdBBfsDihLetBDeiMUs3xWYuRxcqZlwsw+ZCacEuaSjXjYfHIPE6KRzCbhRPSlwlI8/W6dBJB71mH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mtZvBBlr53fbsUWg4aWKpuSfdT0eTE2aE0FDkkxbasHAUQ0ogvF9RIwL9MRurL9PtYSdzAqDB4eLNJGjk5Q==; 20:1YQmXZVgyxep3gojc3/4LbEa1w2wv16IJfnKTuqyKIk29VHugk/mIeezLefYDuI0yHaQOk0AwSvkLmaq9PPih/uMq7wKfiv69ZkmQGMy8h3FZBcfY3C8nq4uMrEqE1kpJ5ajL031iocBgnMd9CD7w+f7kfzGvCcRJn8Xgmur9DGHBAvsqd8mQMAwQ5o0qukO9I3Qjpngu6rwZp8a7eHOGYxN7DafV2VBFeSzGNmr7jSPUPvXg1hVMsSWD+SwKqILHU1rTB7FGwq4xKbTtjelvKo5AOZHVhnGk3GQp3s5xf+SZu+iXegiCU/xVufJAyuoR/8dIvQxlTI3XUfDdDVBZO2/xthmMyCCn1rdQ4lLxiB7CnFHNQ6MtisjA0/nRuX7CCuRfTwDOFCII5xVWGYA2K1FEyxGUsplIciOFVvpLR0ZGsTS6UecjhzDMwSMuN/sMAV3BIFqWu1RKKGJxcrNCp/qgFeNp1nqUyS/ISssDdALio7NeHzStRznzgx63dhd X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR12MB0445; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0445; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 4:0JJeB/WjtWoEHBKugAR+vO0QvkH1NrCh2fypkqLPKDoUF1qYsZVpOy42OdZHR/Y3auPg1ZkmPk6NhhcGr5NDkkJS03C8rxM1pxyAVBVC7fDQAO4nxiX0D5aceFpRnMx7GVfDFc+nzNVTQGvpNX8Ia1nPwbGDAil7xgP1pzJlq9KTLyIb66x0vIGBx8WqD3Z40YJZQMBuWz5Ez5V76swec4VeWYocYkvXxgr8SKdUq9m1bxOf9O+KcvWl+qBF9mRB7OEvFs3AQrKiilyykA6xcgApKiyC8qz4qZ/Ai63lKY7ad0W8QrMV1rx3LE/uGAoBBtEtPlf/GGXfgrrnsTlPSjQJUYxQHT3Acnun5waf/cIJ1W/4npK5BCma6yPZhR1Xs3xeiDiSWZDf/zt+Mk/Y7jawP0Xk/OZqibIsspSA6Ko= X-Forefront-PRVS: 000227DA0C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(229853001)(101416001)(77096005)(8676002)(6116002)(2950100001)(42186005)(586003)(81156014)(81166006)(2201001)(3846002)(50986999)(4326007)(76176999)(50466002)(36756003)(5003940100001)(68736007)(105586002)(305945005)(47776003)(66066001)(86362001)(7846002)(50226002)(2906002)(48376002)(92566002)(106356001)(19580405001)(7736002)(33646002)(97736004)(189998001)(5001770100001)(19580395003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0445; 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; SN1PR12MB0445; 23:gmDlvtwdL/idJvDmHe/KuPTh8i7H797XEQ38WvrDp?= =?us-ascii?Q?O6K7WvPuizhmjLi2WnL28iNQFJf0/pnBRAmIjhb7b+IbNTyo9tghHR32/m22?= =?us-ascii?Q?1wEW+4I9FXExXvhTOe+o9fzDrh4n3Y9bIyn2jkqgtO1NjtAY716PSrGHy2ph?= =?us-ascii?Q?BAB0eSVEfsT9OyEnTlcBU8aGA9OwURUNoXbv0kD/5EKNUkQ+fZb78vIwly43?= =?us-ascii?Q?5N8U07nQ3NIjGhW1WiTzfHYZCQRTTvXcK8ZOSr30RMHiBQCJRjeG1vwJAOah?= =?us-ascii?Q?emdHzC3RmvFpCLfxo3Jz3TUJRz9JOsZpt0+UIrJI1F9auMYCgVQPTjcxocRZ?= =?us-ascii?Q?PS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TrW5rQVyN7g0CJyy5IT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2016 13:21:27.0926 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 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 AMD IOMMU guest virtual APIC log (GALOG) handler. When IOMMU hardware receives an interrupt targeting a blocking vcpu, it creates an entry in the GALOG, and generates an interrupt to notify the AMD IOMMU driver. At this point, the driver processes the log entry, and notify the SVM driver via the registered iommu_ga_log_notifier function. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu.c | 80 +++++++++++++++++++++++++++++++++++++++-- drivers/iommu/amd_iommu_init.c | 5 +++ drivers/iommu/amd_iommu_types.h | 20 +++++++++++ include/linux/amd-iommu.h | 20 +++++++++-- 4 files changed, 119 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index abfb2b7..fe9b005 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -741,14 +741,81 @@ static void iommu_poll_ppr_log(struct amd_iommu *iommu) } } +#ifdef CONFIG_IRQ_REMAP +static int (*iommu_ga_log_notifier)(int, int); + +int amd_iommu_register_ga_log_notifier(int (*notifier)(int, int)) +{ + iommu_ga_log_notifier = notifier; + + return 0; +} +EXPORT_SYMBOL(amd_iommu_register_ga_log_notifier); + +static void iommu_poll_ga_log(struct amd_iommu *iommu) +{ + u32 head, tail, cnt = 0; + + if (iommu->ga_log == NULL) + return; + + head = readl(iommu->mmio_base + MMIO_GA_HEAD_OFFSET); + tail = readl(iommu->mmio_base + MMIO_GA_TAIL_OFFSET); + + while (head != tail) { + volatile u64 *raw; + u64 log_entry; + + raw = (u64 *)(iommu->ga_log + head); + cnt++; + + /* Avoid memcpy function-call overhead */ + log_entry = *raw; + + /* Update head pointer of hardware ring-buffer */ + head = (head + GA_ENTRY_SIZE) % GA_LOG_SIZE; + writel(head, iommu->mmio_base + MMIO_GA_HEAD_OFFSET); + + /* Handle GA entry */ + switch (GA_REQ_TYPE(log_entry)) { + case GA_GUEST_NR: { + u32 ga_tag = GA_TAG(log_entry); + + if (!iommu_ga_log_notifier) + break; + + pr_debug("AMD-Vi: %s: devid=%#x, ga_tag=%#x\n", + __func__, GA_DEVID(log_entry), ga_tag); + + if (iommu_ga_log_notifier(GATAG_TO_VMID(ga_tag), + GATAG_TO_VCPUID(ga_tag)) != 0) + pr_err("AMD-Vi: GA log notifier failed.\n"); + break; + } + default: + break; + } + + /* Refresh ring-buffer information */ + head = readl(iommu->mmio_base + MMIO_GA_HEAD_OFFSET); + tail = readl(iommu->mmio_base + MMIO_GA_TAIL_OFFSET); + } +} +#endif /* CONFIG_IRQ_REMAP */ + +#define AMD_IOMMU_INT_MASK \ + (MMIO_STATUS_EVT_INT_MASK | \ + MMIO_STATUS_PPR_INT_MASK | \ + MMIO_STATUS_GALOG_INT_MASK) + irqreturn_t amd_iommu_int_thread(int irq, void *data) { struct amd_iommu *iommu = (struct amd_iommu *) data; u32 status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); - while (status & (MMIO_STATUS_EVT_INT_MASK | MMIO_STATUS_PPR_INT_MASK)) { - /* Enable EVT and PPR interrupts again */ - writel((MMIO_STATUS_EVT_INT_MASK | MMIO_STATUS_PPR_INT_MASK), + while (status & AMD_IOMMU_INT_MASK) { + /* Enable EVT and PPR and GA interrupts again */ + writel(AMD_IOMMU_INT_MASK, iommu->mmio_base + MMIO_STATUS_OFFSET); if (status & MMIO_STATUS_EVT_INT_MASK) { @@ -761,6 +828,13 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) iommu_poll_ppr_log(iommu); } +#ifdef CONFIG_IRQ_REMAP + if (status & MMIO_STATUS_GALOG_INT_MASK) { + pr_devel("AMD-Vi: Processing IOMMU GA Log\n"); + iommu_poll_ga_log(iommu); + } +#endif + /* * Hardware bug: ERBT1312 * When re-enabling interrupt (by writing 1 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 44483a7..6fab883 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -765,6 +765,11 @@ static int iommu_init_ga(struct amd_iommu *iommu) !iommu_feature(iommu, FEATURE_GAM_VAPIC)) amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA; + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) { + hash_init(iommu->gatag_ir_hash); + spin_lock_init(&iommu->gatag_ir_hash_lock); + } + ret = iommu_init_ga_log(iommu); #endif /* CONFIG_IRQ_REMAP */ diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index d72ab15..2ed353b 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -27,6 +27,7 @@ #include #include #include +#include /* * Maximum number of IOMMUs supported @@ -120,6 +121,14 @@ #define MMIO_STATUS_GALOG_OVERFLOW_MASK (1 << 9) #define MMIO_STATUS_GALOG_INT_MASK (1 << 10) +#define AMD_IOMMU_GA_HASH_BITS 16 +#define AMD_IOMMU_GA_HASH_MASK ((1U << AMD_IOMMU_GA_HASH_BITS) - 1) +#define AMD_IOMMU_GATAG(x, y) \ + ((((x & 0xFF) << 8) | (y & 0xFF)) & AMD_IOMMU_GA_HASH_MASK) + +#define GATAG_TO_VMID(x) ((x >> 8) & 0xFF) +#define GATAG_TO_VCPUID(x) (x & 0xFF) + /* event logging constants */ #define EVENT_ENTRY_SIZE 0x10 #define EVENT_TYPE_SHIFT 28 @@ -565,6 +574,16 @@ struct amd_iommu { struct irq_domain *msi_domain; struct amd_irte_ops *irte_ops; + + /* + * Hash table for mapping ga_tag to struct amd_ir_data + * which contains interrupt remapping information + * (e.g. cached irte and reference to the entry in the + * table). This is used to avoid IRTE scaning when we need to + * update IRTEs when vCPU is scheduled to a particular CPU. + */ + DECLARE_HASHTABLE(gatag_ir_hash, AMD_IOMMU_GA_HASH_BITS); + spinlock_t gatag_ir_hash_lock; #endif }; @@ -819,6 +838,7 @@ struct amd_irte_ops { }; struct amd_ir_data { + struct hlist_node hnode; struct irq_2_irte irq_2_irte; void *entry; union { diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index 2b08e79..940fdd8 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -168,11 +168,25 @@ typedef void (*amd_iommu_invalidate_ctx)(struct pci_dev *pdev, int pasid); extern int amd_iommu_set_invalidate_ctx_cb(struct pci_dev *pdev, amd_iommu_invalidate_ctx cb); - -#else +#else /* CONFIG_AMD_IOMMU */ static inline int amd_iommu_detect(void) { return -ENODEV; } -#endif +#endif /* CONFIG_AMD_IOMMU */ + +#if defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) + +/* IOMMU AVIC Function */ +extern int amd_iommu_register_ga_log_notifier(int (*notifier)(int, int)); + +#else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ + +static inline int +amd_iommu_register_ga_log_notifier(int (*notifier)(int, int)) +{ + return 0; +} + +#endif /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ #endif /* _ASM_X86_AMD_IOMMU_H */