From patchwork Thu Aug 18 19:42:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 74206 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp72638qga; Thu, 18 Aug 2016 18:25:55 -0700 (PDT) X-Received: by 10.98.56.207 with SMTP id f198mr9383413pfa.83.1471569955656; Thu, 18 Aug 2016 18:25:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si2130437pfw.47.2016.08.18.18.25.54; Thu, 18 Aug 2016 18:25:55 -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 S1755131AbcHSBZi (ORCPT + 27 others); Thu, 18 Aug 2016 21:25:38 -0400 Received: from mail-sn1nam01on0088.outbound.protection.outlook.com ([104.47.32.88]:30848 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755044AbcHSBRb (ORCPT ); Thu, 18 Aug 2016 21:17:31 -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=SMqeeGZMdVUBXS1pETl1910l2S94IZDL9Lv67R+UQnM=; b=MMuyfX8Va2jeiIeBtFRza2XzOuneMsxak6XYvw1h1u4wOeIY4CrDmfUQioSQVtUVFax96yRpIiVkr+ZzMd9Z/+2sBfytzCfx+GVC3ZwqZEWkeM54Qsfpd0zM3SUOdU94zZrrvh2DLnxaccURv88nHhGcJoZLK6GLtsXBjor+SF4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from localhost.localdomain (114.109.128.54) by MWHPR12MB1453.namprd12.prod.outlook.com (10.172.55.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Thu, 18 Aug 2016 19:43:34 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v6 03/12] iommu/amd: Introduce interrupt remapping ops structure Date: Thu, 18 Aug 2016 14:42:35 -0500 Message-ID: <1471549364-6672-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471549364-6672-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1471549364-6672-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: KL1PR0201CA0016.apcprd02.prod.outlook.com (10.167.53.154) To MWHPR12MB1453.namprd12.prod.outlook.com (10.172.55.22) X-MS-Office365-Filtering-Correlation-Id: 39e231f6-a0b0-4940-73df-08d3c79ff239 X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 2:tIPWkzJh1UMw9j4zBDsn+wqp38B0tkynN7eS/unfsbIUJ+TBtFJQEbetyYKDLPSF3Yp9fSSc+70LX/JKIpHET0l4bj0fN05OOBJ7E9KZfHac4JN4R7S5qBhyfgdI1Bl7xjTbTxyJTHUyCrG77FLWEzdcU3ugSU6y1CLztSQg8bFAZSXL3AIpJsGXmYFXrzeX; 3:ednob6o19AGd1EFjzBv7JQAl83TF+GhA4XZ7/M7pXcRPliJvMAA0+1Dmnq9AYjGQ2ZIjBf6LeT7v9aXPHDfN+ZwobFLDH10YR7QX4IUlksl/LEC9UR/wv6jbTFV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Od2tnRkuZrnww8VJAUWIazOzi8YaOXcuGB7qrHV+07DZr7np2XoTrV+qDgkdjkVRJbeyU5w=; 20:Jdjh+oH46y6OJo2LSoLhVfGXs8OpkisqdL4adDMS0dOmUA3jKyS1z/C7ENgSB5QgAYxrqD/uTHe2t4q3IBgP6BIuMTSl8Gsgh6jKdjPJGcgIpCv9Z1BOkev1c50SDDT0Cl0tddrUtWPKw9juCkakwOn2XruewNs2bN1QB3AiQXbd8r4DOZQEFlTo/UbSs7FvmjaOPKWMS0ec5JuTBrWftFfifB69BkRRO1EbSxytXab43kIOzixRQp8PnWqibOCT8ELv6IV3jmAd72F7JOLavPUFSgbiWL3WQGjmFtu5uhNcU6Va4pNjThulvwzYY350ESsMtmPg/5HuQjAZ83TwV+2pSqF53Ctrv+MnVIiTNm2Y8QsR75csIF7iLadM30XV7zYZkhXg6y4+qN2XGxl+igmLXmQjKWHV+5CZp1yKx2HRIXwjMztqOwGEFmaugtab7JdLScDUTftGsRt0hJ3fmsgFI6kH5RkUsSBeRHog0B3HMTr35X+AY/Gzp8EaLIUv X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:MWHPR12MB1453; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1453; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 4:q0ksYW2clY90fqyPisHku98MBO7QaTgT3ep0jmD4UfDoB3DotIO+BTLfPSnKJEx3InWrHJwmItbV2TWUVvI78Puzvmw6ZyS4GEmBMPF9M3yHTwdMTR3rVQMklV4VD+nRVOUDWvhY2OV1j5TFYpMoDiVaBAzTkcuXepNVeoaKdlXFIjg67YZIuo800cSwyihB8whiUInSmBJh0CAR9bG9H1psDL20BJcD+Sy5+hfhCiCHsJr0C/UEzATW41M3FYJypqeJbXHZBEec90RV8kYmjNIOckhZ55L2hSr80mHr8/TOj+3KWi1BwNpq58lGq62QagcE0Lal4WLB11lZ/XI67zIyNXnaTSPzIVNZq2s3C7PxmNHJHklYaIvi4JAaakiC+lZp7J8gfOLn8E8hhW/BBK8YQa+o5qSmGN5h9P0hkPeE4PCi76A1MdxP7UTiLDc/ X-Forefront-PRVS: 0038DE95A2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(86362001)(42186005)(50226002)(19580395003)(586003)(68736007)(92566002)(3846002)(6116002)(189998001)(105586002)(8676002)(81156014)(81166006)(5003940100001)(47776003)(5001770100001)(2950100001)(97736004)(48376002)(77096005)(50986999)(50466002)(106356001)(36756003)(2201001)(305945005)(19580405001)(76176999)(7846002)(7736002)(4326007)(2906002)(66066001)(229853001)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1453; 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; MWHPR12MB1453; 23:qX4DkmNZOrU15ZbWnoNYeXwTN+TFa7PRtgo2GfPaa?= =?us-ascii?Q?5B//948wvjhopTs2lh9+Qu0wRSSDIAjuxjcvHPbLPh3rZvbSpQy774joeD3V?= =?us-ascii?Q?ywgRF/WtIAJc91P+Ojq+HBtsNzmLL3ddgOVUuxjn55WMbKqNaFh+3auVRe1G?= =?us-ascii?Q?VtuEEDoOjzSpgwaX5nkVsGjWqF/6e4IXjtWlnIHYxVK3LPWAABAXapCrm1nx?= =?us-ascii?Q?IYNosdFGgxjctSBTpptQhDIXtIgyWoBiHApVR8Ueqhdrufk7RgadxvYqS+yD?= =?us-ascii?Q?uGoCNRPfeX0KCBlzRQad47umlEcqhTMg65HJspeT2wlai37ZfeDDDCStYCwk?= =?us-ascii?Q?L2LhLfkDjaSuXvTlQQAU5SRpcT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D8VwSrPp3ahAI6n8aS4Wqm/E+DXle+rZZHrVnyzSBb8lUk7S6DLui7bZdojYWHyMXe2iyJCWH7ihfVZcF00AD5226DXRgZundrqDFEN8ECBWI5NLndTFKDvb/0te7tTpxAxuYOwG9RBl/EkEe/tdRxkyWbq4QELkL9IXzvN43FIoYsqR97UHER+KSRKbk/g==; 5:Nbl4QyReAt0prWGStQ3axLQv8xIjcpOK/l0Szuy9x6xnaakb+D9oFAwK9siEC01Fp7a8Nr8YNMQ76cEOZsJbgpaXBZb4lfmyMhkiBpmFIDg95f0pjz6ni0P42HMB7pFF2t6S895BlDajWTWAJAMaVQ==; 24:eVP3Q1xusKmYwjs1Q2yPWhvSwh+xS19PWYSwzrP5ODflQLKaYFVCj8Cx8k62JIXcBNPNmOO7TS42Y3LSWMSIF1X2c7034YinnGQk/LYzTyc=; 7:JCxO2PEF/bKkhOCyElZu4P4rqEmdDyUl60zbr3Akofc/ObuR3UY6NK4D88bqr7HzHpBkWuGAP5SO0jC3LIaa3ZNPCIYMCgtOy3u6E0lE4Twuc9ihBxAAnqvxv9TYX0Gl+8NK18KyBXkgC+sSaWiQtQWc3nwzC3QLIZJFSNfMceUVzpyR/McjPBusYJlm9lSyRnGhYcfyPqYg1daa2IVsIav3Mms/VJtPD/uEnmurN08RAZTRGN7iuH1FVVUggQIy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 20:3I9DW1b0cEtDCji+scA141Kv1cea0p5NwM0sITIxOimUE1TrPJxNl3Iq/ORtm8Iep3l4h9fQgN+NzvoicYGItlWGWhxgpa7wzxa5e2AxabEpwarEHUVgCAsPP+Jn4iz4jPd60LfRjt1ika4vMB3B+Z8wgro/nAifsAvUvRPvgNhKHd3ScqQApLbD4Sj/+k1j7kBpdllT1mpZfO7pd5DEdxRsILb1VBLOWe3Jrq5HQhIoVKOHhL6njbarV8ennqhZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2016 19:43:34.2190 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1453 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, IOMMU support two interrupt remapping table entry formats, 32-bit (legacy) and 128-bit (GA). The spec also implies that it might support additional modes/formats in the future. So, this patch introduces the new struct amd_irte_ops, which allows the same code to work with different irte formats by providing hooks for various operations on an interrupt remapping table entry. Suggested-by: Joerg Roedel Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu.c | 193 ++++++++++++++++++++++++++++++++++++++-- drivers/iommu/amd_iommu_types.h | 20 +++++ 2 files changed, 208 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index ac2962f..139ea8b 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -3826,11 +3826,13 @@ out: return index; } -static int modify_irte(u16 devid, int index, union irte irte) +static int modify_irte_ga(u16 devid, int index, struct irte_ga *irte) { struct irq_remap_table *table; struct amd_iommu *iommu; unsigned long flags; + struct irte_ga *entry; + struct irte_ga tmp; iommu = amd_iommu_rlookup_table[devid]; if (iommu == NULL) @@ -3841,7 +3843,40 @@ static int modify_irte(u16 devid, int index, union irte irte) return -ENOMEM; spin_lock_irqsave(&table->lock, flags); - table->table[index] = irte.val; + + entry = (struct irte_ga *)table->table; + entry = &entry[index]; + memcpy(&tmp, entry, sizeof(struct irte_ga)); + entry->lo.fields_remap.valid = 0; + entry->hi.val = irte->hi.val; + entry->hi.fields.ga_root_ptr = tmp.hi.fields.ga_root_ptr; + entry->lo.val = irte->lo.val; + entry->lo.fields_remap.valid = 1; + + spin_unlock_irqrestore(&table->lock, flags); + + iommu_flush_irt(iommu, devid); + iommu_completion_wait(iommu); + + return 0; +} + +static int modify_irte(u16 devid, int index, union irte *irte) +{ + struct irq_remap_table *table; + struct amd_iommu *iommu; + unsigned long flags; + + iommu = amd_iommu_rlookup_table[devid]; + if (iommu == NULL) + return -EINVAL; + + table = get_irq_table(devid, false); + if (!table) + return -ENOMEM; + + spin_lock_irqsave(&table->lock, flags); + table->table[index] = irte->val; spin_unlock_irqrestore(&table->lock, flags); iommu_flush_irt(iommu, devid); @@ -3872,6 +3907,134 @@ static void free_irte(u16 devid, int index) iommu_completion_wait(iommu); } +static void irte_prepare(void *entry, + u32 delivery_mode, u32 dest_mode, + u8 vector, u32 dest_apicid) +{ + union irte *irte = (union irte *) entry; + + irte->val = 0; + irte->fields.vector = vector; + irte->fields.int_type = delivery_mode; + irte->fields.destination = dest_apicid; + irte->fields.dm = dest_mode; + irte->fields.valid = 1; +} + +static void irte_ga_prepare(void *entry, + u32 delivery_mode, u32 dest_mode, + u8 vector, u32 dest_apicid) +{ + struct irte_ga *irte = (struct irte_ga *) entry; + + irte->lo.val = 0; + irte->hi.val = 0; + irte->lo.fields_remap.guest_mode = 0; + irte->lo.fields_remap.int_type = delivery_mode; + irte->lo.fields_remap.dm = dest_mode; + irte->hi.fields.vector = vector; + irte->lo.fields_remap.destination = dest_apicid; + irte->lo.fields_remap.valid = 1; +} + +static void irte_activate(void *entry, u16 devid, u16 index) +{ + union irte *irte = (union irte *) entry; + + irte->fields.valid = 1; + modify_irte(devid, index, irte); +} + +static void irte_ga_activate(void *entry, u16 devid, u16 index) +{ + struct irte_ga *irte = (struct irte_ga *) entry; + + irte->lo.fields_remap.valid = 1; + modify_irte_ga(devid, index, irte); +} + +static void irte_deactivate(void *entry, u16 devid, u16 index) +{ + union irte *irte = (union irte *) entry; + + irte->fields.valid = 0; + modify_irte(devid, index, irte); +} + +static void irte_ga_deactivate(void *entry, u16 devid, u16 index) +{ + struct irte_ga *irte = (struct irte_ga *) entry; + + irte->lo.fields_remap.valid = 0; + modify_irte_ga(devid, index, irte); +} + +static void irte_set_affinity(void *entry, u16 devid, u16 index, + u8 vector, u32 dest_apicid) +{ + union irte *irte = (union irte *) entry; + + irte->fields.vector = vector; + irte->fields.destination = dest_apicid; + modify_irte(devid, index, irte); +} + +static void irte_ga_set_affinity(void *entry, u16 devid, u16 index, + u8 vector, u32 dest_apicid) +{ + struct irte_ga *irte = (struct irte_ga *) entry; + + irte->hi.fields.vector = vector; + irte->lo.fields_remap.destination = dest_apicid; + irte->lo.fields_remap.guest_mode = 0; + modify_irte_ga(devid, index, irte); +} + +static void irte_set_allocated(struct irq_remap_table *table, int index) +{ + table->table[index] = IRTE_ALLOCATED; +} + +static void irte_ga_set_allocated(struct irq_remap_table *table, int index) +{ + struct irte_ga *ptr = (struct irte_ga *)table->table; + struct irte_ga *irte = &ptr[index]; + + memset(&irte->lo.val, 0, sizeof(u64)); + memset(&irte->hi.val, 0, sizeof(u64)); + irte->hi.fields.vector = 0xff; +} + +static bool irte_is_allocated(struct irq_remap_table *table, int index) +{ + union irte *ptr = (union irte *)table->table; + union irte *irte = &ptr[index]; + + return irte->val != 0; +} + +static bool irte_ga_is_allocated(struct irq_remap_table *table, int index) +{ + struct irte_ga *ptr = (struct irte_ga *)table->table; + struct irte_ga *irte = &ptr[index]; + + return irte->hi.fields.vector != 0; +} + +static void irte_clear_allocated(struct irq_remap_table *table, int index) +{ + table->table[index] = 0; +} + +static void irte_ga_clear_allocated(struct irq_remap_table *table, int index) +{ + struct irte_ga *ptr = (struct irte_ga *)table->table; + struct irte_ga *irte = &ptr[index]; + + memset(&irte->lo.val, 0, sizeof(u64)); + memset(&irte->hi.val, 0, sizeof(u64)); +} + static int get_devid(struct irq_alloc_info *info) { int devid = -1; @@ -3999,6 +4162,26 @@ static void irq_remapping_prepare_irte(struct amd_ir_data *data, } } +struct amd_irte_ops irte_32_ops = { + .prepare = irte_prepare, + .activate = irte_activate, + .deactivate = irte_deactivate, + .set_affinity = irte_set_affinity, + .set_allocated = irte_set_allocated, + .is_allocated = irte_is_allocated, + .clear_allocated = irte_clear_allocated, +}; + +struct amd_irte_ops irte_128_ops = { + .prepare = irte_ga_prepare, + .activate = irte_ga_activate, + .deactivate = irte_ga_deactivate, + .set_affinity = irte_ga_set_affinity, + .set_allocated = irte_ga_set_allocated, + .is_allocated = irte_ga_is_allocated, + .clear_allocated = irte_ga_clear_allocated, +}; + static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { @@ -4104,7 +4287,7 @@ static void irq_remapping_activate(struct irq_domain *domain, struct amd_ir_data *data = irq_data->chip_data; struct irq_2_irte *irte_info = &data->irq_2_irte; - modify_irte(irte_info->devid, irte_info->index, data->irte_entry); + modify_irte(irte_info->devid, irte_info->index, &data->irte_entry); } static void irq_remapping_deactivate(struct irq_domain *domain, @@ -4115,7 +4298,7 @@ static void irq_remapping_deactivate(struct irq_domain *domain, union irte entry; entry.val = 0; - modify_irte(irte_info->devid, irte_info->index, data->irte_entry); + modify_irte(irte_info->devid, irte_info->index, &data->irte_entry); } static struct irq_domain_ops amd_ir_domain_ops = { @@ -4144,7 +4327,7 @@ static int amd_ir_set_affinity(struct irq_data *data, */ ir_data->irte_entry.fields.vector = cfg->vector; ir_data->irte_entry.fields.destination = cfg->dest_apicid; - modify_irte(irte_info->devid, irte_info->index, ir_data->irte_entry); + modify_irte(irte_info->devid, irte_info->index, &ir_data->irte_entry); /* * After this point, all the interrupts will start arriving diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index c37c5c4..d57c56d 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -410,6 +410,7 @@ struct amd_iommu_fault { struct iommu_domain; struct irq_domain; +struct amd_irte_ops; /* * This structure contains generic data for IOMMU protection domains @@ -534,6 +535,8 @@ struct amd_iommu { #ifdef CONFIG_IRQ_REMAP struct irq_domain *ir_domain; struct irq_domain *msi_domain; + + struct amd_irte_ops *irte_ops; #endif }; @@ -780,6 +783,23 @@ struct amd_ir_data { struct irq_2_irte irq_2_irte; union irte irte_entry; struct msi_msg msi_entry; + void *entry; /* Pointer to union irte or struct irte_ga */ +}; + +struct amd_irte_ops { + void (*prepare)(void *, u32, u32, u8, u32); + void (*activate)(void *, u16, u16); + void (*deactivate)(void *, u16, u16); + void (*set_affinity)(void *, u16, u16, u8, u32); + void *(*get)(struct irq_remap_table *, int); + void (*set_allocated)(struct irq_remap_table *, int); + bool (*is_allocated)(struct irq_remap_table *, int); + void (*clear_allocated)(struct irq_remap_table *, int); }; +#ifdef CONFIG_IRQ_REMAP +extern struct amd_irte_ops irte_32_ops; +extern struct amd_irte_ops irte_128_ops; +#endif + #endif /* _ASM_X86_AMD_IOMMU_TYPES_H */