From patchwork Mon Jun 13 22:06:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 69947 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1759165qgf; Mon, 13 Jun 2016 15:22:42 -0700 (PDT) X-Received: by 10.98.104.68 with SMTP id d65mr24244483pfc.34.1465856561983; Mon, 13 Jun 2016 15:22:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v76si34436908pfa.20.2016.06.13.15.22.41; Mon, 13 Jun 2016 15:22:41 -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 S1423053AbcFMWWU (ORCPT + 30 others); Mon, 13 Jun 2016 18:22:20 -0400 Received: from mail-bn1on0062.outbound.protection.outlook.com ([157.56.110.62]:8544 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1161372AbcFMWWP (ORCPT ); Mon, 13 Jun 2016 18:22:15 -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=+wNzvPXQ90iVX69Nb0qRYf0kTDigq6kWjHhtUxPHKUY=; b=zN2am5escTLdQ7BinIlSPfcf9/UhXLax1ng5uchQAMSbYTTots5KcznpnYspA0bHrqvJSFJeSdbIx/OtPTUogHzSGLEjIHnDM+uDy4S1Nuau2aijMjPNqgi448lINgXHQhTFUIKqpeXjpjWJdk/RC6sNlsE/dl1Sq6YH5y/Mp4Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 22:07:03 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 RFC v2 04/10] iommu/amd: Adding GALOG interrupt handler Date: Mon, 13 Jun 2016 17:06:44 -0500 Message-ID: <1465855611-10092-5-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465855611-10092-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1465855611-10092-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR0701CA0005.namprd07.prod.outlook.com (10.162.96.15) To BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) X-MS-Office365-Filtering-Correlation-Id: 69a181c4-941d-4fce-4778-08d393d70d42 X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 2:WdV3UhfaBWmolwtI+Bz0/Cqe1bGVI0Z6BPb/Z74ZSxX4/7RcSC2WP0/ihMoS5siYNynDp0f4h+BU3T7vDTQmwle8EXYd+St8WZ+Vk3kGtk5zuLCggnSWDSVIfR1UrvrAvKGlzpJ0Zfwq51Ti4Ka7Po4bn7AIvTPmIF6snKWGlqF/6nhmjMKtFMkuOCNmqzsr; 3:O7+c+Caw9Wo3d0j9uBWyRkLViA9waknraXhInZWoToFLDuWMsdDzJeFZNrlHkMD7QZX4A1JBP5JISm9e9V15iaRomAzZ1qpCEdatSUZ8DaQuZAeKjPzWc6REblZQzBvO X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR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08SwOR83eDgIwjYsm7uWKNAN6ngR8UmjFD49sBLtZTx71AAVuF2zhG7ork2IBHdzziJZd3USX4CfkGCFqm66oycb8jdOpOhzJmSv89KGGmgQ/R3YpqYkTu3dZQBq/vbi65bL5lLKYvqDyNa/P3xNO4Y/ez3CS/Slc68zW1AO4o/4aCpg7E1Qaogw3W+TSSDO5nHKyrvuxMwpVOKhIao6qGoTw8/1roWGAGVVwz++N0f9G7tWpar8sxz6T0SNS0uNvroH/P0V3aJzBN7RlhzSC426nh68XnJsO3S; 4:NIIcEdaejkglS6WYs/eiUOpdnhW92uqq55fdDazOzpZxybN1CW9YNB46NxGN81AjO/5LSxMv528Z0pO0c5q+4NzQeAHl/sy3cPfdX2h1Xn9tULGtWE/UAWi37usJF5YcNvRVhTvFSyiYFJhFugXFfYoE9nYbHdhTK35Pq8UhdJANYlqR6A4eNP/jkItWmSvs/J/FYfNpOwxKPksvK4CS0LqEUD4lBJ0WxqtCqcBHNF72nV9pKPgMMiKdx/JkcJcP0dZl/udz2so+YJ8aLovgiABWFL+0aZ7yEWtbr5dDHROMwWzU+TCrcrKQ0P1hXUX1lYOc/ED3qv3/n91GSfo4sRX96zuyRHlLtFNkhtmPPyH+RIGVPGJXjc+PiF6DWQzfJwX5o/pZY8iUvJvI5y6+4JIayaBb5zr8i86hb5SEUjJNhtOYdpjSvqTmMjVeAwnu 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)(3002001)(10201501046)(6055026); SRVR:BLUPR12MB0434; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0434; X-Forefront-PRVS: 0972DEC1D9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(53416004)(50226002)(5008740100001)(50466002)(36756003)(19580405001)(19580395003)(106356001)(189998001)(68736007)(105586002)(42186005)(2906002)(586003)(5001770100001)(101416001)(50986999)(4326007)(8676002)(81156014)(2950100001)(3846002)(6116002)(76176999)(77096005)(81166006)(97736004)(5003940100001)(5004730100002)(47776003)(86362001)(575784001)(48376002)(92566002)(229853001)(33646002)(2201001)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0434; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0434; 23:mbmmwDWayyDc1RZldAkMsOmlU5PO6ilObnTT5ZlIc?= =?us-ascii?Q?2FuQ5Muia/gGS8pRlgHABvYUmjXDLTzDJLN2jTEZA/Q+okTh5uLOyducZD69?= =?us-ascii?Q?wfvODcaLsrwB1JPfwTVkDCZ2Km3Q07Jv3Jy9KN1by2STrfhSSufIrb9n/ByH?= =?us-ascii?Q?x8pk6EBwXbjpBwfcxDSRlPNwBLGXnMlvcf+L1In1oOBrOVDC3Ed4YYp5aVki?= =?us-ascii?Q?pf7IJlXpCIWaIFGhLmzO0SVuHZ4e/iC/aPRNfUujOjZ1mFHlQjkE0qamkfvZ?= =?us-ascii?Q?7FKiHkMBQv8wdtKJ/6qT1WRYLjFD4GumAOz5DNtUgZj2lpzpw2RHSQVaju4n?= =?us-ascii?Q?KncP88yLnyU07YZ0j1P3ZsxjzOysP6EeWxuu45BEQUawJncfUowFUFBVR9lg?= =?us-ascii?Q?n0BfYQ/UEe7CWeCNBmY3EfhgNLBJjLKhVvCiq6KmeEA3aM5Tr72QCPdnuyJ2?= =?us-ascii?Q?EFWYPNPxu+KUQRHkILIVVKeVZ/uraH2qh9Y3mBwUzia8jNi+TYJgADTNxyQa?= =?us-ascii?Q?D9N7A8wNFsC/6H0rxqe0Me66z4K/WkBB+YqyjHso0PmOfXFqYGZ/OKJhqa0d?= =?us-ascii?Q?+QN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fd6wdAPDvEIvlwlB81xbrmw+Im1EIPzcQM3qpJXT0GPnVvQLo0b0ZpFWEaxnGWmWUwfv3+U2s6TH44TYd2My9H3dBI8Cin2LWEJQ6BwBrzdrnuMYyTGsgCw==; 24:q9iLPifn3G5JN2FNARfQRBu94yRqg6ymzTyDa4WNkQCCs1TlWppAg5qfcvBOnPY4BzVNTLPOlpYUDXzZILFesHHORGbxNG6pITZlU+m/nE0=; 7:RCWlnMlwcQvKz+jxyj10qqK4V7MvO7qqDl31GhC3xTQWsxpHDk3L8KeU4bpPtama8XN+T5R4SqpfkH+Usj8q6tDmBDWae+30u1vwX09HjrEN1h/opZ1nZkePKKFlyEQiVi5DU9AIdpgLCAeelTB48g1zVYhSQ34uXRDfBTFxhnffOXdy56AIZxCDTcq4DJ7JbBKK237gqQ5v+kKTHfzwkg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 20:F0ygC0ASptoXdr+F9t/Zb+eIhP7tnYERnOpWyAf9XfGtcTLXah1juDEmILuDSp8Y77dCx3eJJ+jpwvgWL92kQoocYKKu5Rrc+j62oswcdjg0EB7DIBflKBgD9HrvSXJq4BoB7DuU+/4GGgXZTO9KRahR40rtSUDmHkwNv+bOJd7s6l0Td4IVcLnNwE4KFgK0YmMIWYGKpzAEp+yzs7VswgeP7kKliQhvKL08fLzYRWoOClHjIB6S8A1MvWIWDBAw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2016 22:07:03.4070 (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 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 | 108 +++++++++++++++++++++++++++++++++------- drivers/iommu/amd_iommu_init.c | 4 ++ drivers/iommu/amd_iommu_types.h | 27 ++++++++++ include/linux/amd-iommu.h | 10 ++++ 4 files changed, 132 insertions(+), 17 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 7dac927..ae339c5 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -741,14 +741,97 @@ static void iommu_poll_ppr_log(struct amd_iommu *iommu) } } +static int (*iommu_ga_log_notifier)(int, int, int); + +int amd_iommu_register_ga_log_notifier(int (*notifier)(int, int, int)) +{ + iommu_ga_log_notifier = notifier; + + return 0; +} +EXPORT_SYMBOL(amd_iommu_register_ga_log_notifier); + +static void iommu_handle_ga_guest_nr_entry(struct amd_iommu *iommu, + u16 devid, u32 ga_tag) +{ + struct amd_ir_data *ir_data; + unsigned long flags; + int vec = 0; + + if (!iommu_ga_log_notifier) + return; + + spin_lock_irqsave(&iommu->ga_hash_lock, flags); + hash_for_each_possible(iommu->ga_hash, ir_data, hnode, ga_tag) { + vec = ir_data->irte_ga_entry.hi.fields.vector; + break; + } + spin_unlock_irqrestore(&iommu->ga_hash_lock, flags); + + if (vec) { + pr_debug("AMD-Vi: %s: devid=%#x, ga_tag=%#x\n", + __func__, devid, ga_tag); + + if (iommu_ga_log_notifier(GATAG_TO_AVICTAG(ga_tag), + GATAG_TO_VCPUID(ga_tag), vec) != 0) + pr_err("AMD-Vi: GA log notifier failed.\n"); + } +} + +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 entry; + + raw = (u64 *)(iommu->ga_log + head); + cnt++; + + /* Avoid memcpy function-call overhead */ + 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(entry)) { + case GA_GUEST_NR: + iommu_handle_ga_guest_nr_entry(iommu, + GA_DEVID(entry), + GA_TAG(entry)); + 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); + } +} + +#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 +844,11 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) iommu_poll_ppr_log(iommu); } + if (status & MMIO_STATUS_GALOG_INT_MASK) { + pr_devel("AMD-Vi: Processing IOMMU GA Log\n"); + iommu_poll_ga_log(iommu); + } + /* * Hardware bug: ERBT1312 * When re-enabling interrupt (by writing 1 @@ -3693,20 +3781,6 @@ EXPORT_SYMBOL(amd_iommu_device_info); * *****************************************************************************/ -struct irq_2_irte { - u16 devid; /* Device ID for IRTE table */ - u16 index; /* Index into IRTE table*/ -}; - -struct amd_ir_data { - struct irq_2_irte irq_2_irte; - union irte irte_entry; - struct irte_ga irte_ga_entry; - union { - struct msi_msg msi_entry; - }; -}; - static struct irq_chip amd_ir_chip; #define DTE_IRQ_PHYS_ADDR_MASK (((1ULL << 45)-1) << 6) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index a6e23cc..60b0394 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -1577,6 +1577,10 @@ static int iommu_init_pci(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->ga_hash); + spin_lock_init(&iommu->ga_hash_lock); + } ret = iommu_init_ga_log(iommu); if (ret) diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index af0b9d5..390e7b2 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -22,10 +22,12 @@ #include #include +#include #include #include #include #include +#include /* * Maximum number of IOMMUs supported @@ -119,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_AVICTAG(x) ((x >> 8) & 0xFF) +#define GATAG_TO_VCPUID(x) (x & 0xFF) + /* event logging constants */ #define EVENT_ENTRY_SIZE 0x10 #define EVENT_TYPE_SHIFT 28 @@ -556,6 +566,8 @@ struct amd_iommu { struct irq_domain *ir_domain; struct irq_domain *msi_domain; #endif + DECLARE_HASHTABLE(ga_hash, AMD_IOMMU_GA_HASH_BITS); + spinlock_t ga_hash_lock; }; #define ACPIHID_UID_LEN 256 @@ -792,4 +804,19 @@ struct irte_ga { union irte_ga_hi hi; }; +struct irq_2_irte { + u16 devid; /* Device ID for IRTE table */ + u16 index; /* Index into IRTE table*/ +}; + +struct amd_ir_data { + struct hlist_node hnode; + struct irq_2_irte irq_2_irte; + union irte irte_entry; + struct irte_ga irte_ga_entry; + union { + struct msi_msg msi_entry; + }; +}; + #endif /* _ASM_X86_AMD_IOMMU_TYPES_H */ diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index 2b08e79..36648fe 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -169,10 +169,20 @@ 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); +/* IOMMU AVIC Function */ +extern int +amd_iommu_register_ga_log_notifier(int (*notifier)(int, int, int)); + #else static inline int amd_iommu_detect(void) { return -ENODEV; } +static inline int +amd_iommu_register_ga_log_notifier(int (*notifier)(int, int, int)) +{ + return 0; +} + #endif #endif /* _ASM_X86_AMD_IOMMU_H */