From patchwork Mon Jul 25 09:32:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 72689 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1048069qga; Mon, 25 Jul 2016 02:33:47 -0700 (PDT) X-Received: by 10.98.50.2 with SMTP id y2mr27893774pfy.138.1469439227255; Mon, 25 Jul 2016 02:33:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mu1si26395721pab.286.2016.07.25.02.33.46; Mon, 25 Jul 2016 02:33:47 -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 S1752936AbcGYJd0 (ORCPT + 29 others); Mon, 25 Jul 2016 05:33:26 -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 S1752323AbcGYJdA (ORCPT ); Mon, 25 Jul 2016 05:33:00 -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=LEsw7Io4sjX0MhNRKz8A+pl3yA0F3CC21wT2LNDtk5k=; b=OW2a9iQTCg4e29l+1claMGJ4X758vRsK/43pl2VIqNysbm2+6gJF+8Vwmzm7fHh5cc/d1ezgNLINpnDr30LwmKUOyXKDNWu6wBMMlQ5wDFjKcBKCILe1DNH1GOkGVgtDNDT3CL2eyNJETiyIcx8VKL15Z3w/Mvpf6s8zGkzBrZ0= 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:46 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART2 PATCH v5 03/12] iommu/amd: Introduce interrupt remapping ops structure Date: Mon, 25 Jul 2016 04:32:02 -0500 Message-ID: <1469439131-11308-4-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: 7c1b4d6a-16e1-465c-5b46-08d3b46ea805 X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 2:Mty7xwT/fgC5oTnU3GP6MXgjKMbUE7R8iTCgusujrcZfR8BSfqrHLiGi6popJiWYMp7bXtK6TyzGrTlXW9j7SAB7tWkKqgZNdB90cEXpUPOrhsegxSVHaR5m+HvpyCZSayz8Ll66euBNE2t9UEP0JwWSqDAe5huraTEmAC+uicdjkt9XPXSktDMvRftoYWNC; 3:Seie1TJIxubuj1QWUo2o/qFfLA+ONsNWi7ujvIqtAXQ/i9GUj/2tcla7pCtLlRyOaBxZeXCQ8YwTJUi/ycJYr/wofxc7XvdKhyQRlmvpioueabYpMO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q7xdQqTAPNG1nFtUDUaQe3HnHfyqjRQnoqHiPccuHfW+tap3/PZH0KoQhgzKyb/ah45zIQy9A9rq4ppaN/xbd3PhoBRN5hk2esEsdTNzKa5epVUkN1IxHmIDUVkxFtEjpCnSd3wV5zjFF5CeGEoiLFdSg/LbRHabqYQ7ED9/+Mj1AAPNozsrR3KVMrJ435DMh; 4:fcsqQ7fLVeKMYg9moCznEro+6zdQ6oVaNaYL76xaxhTKjWm5RyE6QN8godPWFsApS5OXM7zPYFlP6fvWyWrAl888T/2F+dVVJWU5MfNu203dK3+mEJ97Bh45Mylmj6i7iI7JRKf0yrrZNJPusPR5/r4tVp3t6vOUEAB2VC9vnaRfPCnKrtZnb2dkB1Zmj8emBfWe5J1mDE7PLo0+Cgmlb2X7NXNOeZr4lTp1OZl03ZprmCYEE0jBYYlUm1ZykPNw+sLJv7qTxkqWNP9Pvdu/VGPwV9UsQalh6ll25rDQXuj2EpH2iHAaPMh8HQ6DPMGqX0f5YCVnzYGEyjQ4RxTAQeFZJML+i63Mn45bjrmhhcEnBleShlxtJeFeNGcJVTBrI0JWBSNlw7fAxCiw1nadFDRVToKbRsvEFkShBFylc7s8PxDha80Zu2q1ubUiIPjo 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)(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:O+x2uTWuUzsK9TEzyMd9PQHWQtArDxsgd7UIXS6yE?= =?us-ascii?Q?jHloCcTJuV6rj6McE0m94XHG9TpOUJWcgZC5o9csDwB+bpKcWtDO3FbWKsvn?= =?us-ascii?Q?QRShu3TyKSZ1bvo60yq1dSi1N9bbYjTsSgsdS1rSiygAAHsuHeiJZJxxj/Xq?= =?us-ascii?Q?la0q/X2hUV7yDEs71NGu9xFMUC9oWPkC2J+TjJzFQZz16/ZSFIzoM66yBISD?= =?us-ascii?Q?C2rRqaezyvrtMxnNDD6bmAmHpMP/G704xJ2R7jKpIF9j9kJ7Ku+LZl9rZqzG?= =?us-ascii?Q?2jSMgeMPNAfU84RvjYMDPehQCdjJCWlJ2u6cpJVa9yPGj6+UaM5doAG6L9wu?= =?us-ascii?Q?ooVwKBF+nv/7jSiJU23rtqxbzI7VIGunP4NaLum2iHoDwEGM1acfTYTedEt7?= =?us-ascii?Q?hydwIVZ+reiSOPiChlt/dcoPjkbsj+MY7qFrIWHMP/502bqHUzWklOTiRi6h?= =?us-ascii?Q?U8tyKKGP/Qs+8SlWWRN5UyOLiRUSRwzE/cVqzLpYOTdRCIxlkOhaiBVjTB1Q?= =?us-ascii?Q?3cRjC0/uUFRdnrMZ8lSryI3i+f2YnMtPICddFYt7uJwZAFXhmeUY876pKNdM?= =?us-ascii?Q?PUySelK5l55tlJy51p98rzwx0mAaSUH+6u63a/ca60vbYwKyQUfskg+mzgIi?= =?us-ascii?Q?9mBCAXFazH7Yn/A6TXI5K7JZYIo8BIikq79yWPmxHtE1gOnafDXMaX4rUEGU?= =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QAFOaUIE6K9N5Ft9N7mvdTg1v6C9R8PfA27LtJDAQJ7OLT5yIYSAKJlZsfZsCTuMvpiXPvg=; 7:W5pqXOEGBVp67gIawD2ORvdhXSRt6QMKwiQjGzvsNOJEk8zM3gX9HmwqIDyUulpKdUtv2mQGSyqRkhftU+6Zzq4gMv2nOek8MAN6iSAAhCi2pl/dEVfWVtSAC3sK8kAsP6RIaUPrfl4hpVxcYr4q7TvYj6xJ7op8VCkQ4AJ86kdPQJnUiZtcuyB9ujFtUXWK2B3fNe2/Zggr3BQJCdqoyBmfldN+5OOgZsNI0HgkcedUmqZMNE2djUvr/gmL9vAr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 20:5Y9ogjElUjjWzbVd8fscCgj6uahxNwULYN+aKkuStxy4IDx77jdLSmG9c4+xBPgTIN/lENyn3tH/PKg0v5iExECwiI33Y0/XbJuSYDnfJGbgUJ2cfYhE/BY5IFL/eEr+sZ0VDjR3pbeSGVoWPl3ydATB6vxII917md2jyf+bp9AL6evKrHQR7FTTrLoO1YRuyA0QR6YaKhiAZ5I1zdmnNejDO1nGygrMIfP6GOJAgwcwmIz6UOQYZNoUduIvODWZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2016 09:32:46.4289 (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 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 d9227a9..2a3819a 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 }; @@ -776,12 +779,29 @@ struct irq_2_irte { u16 index; /* Index into IRTE table*/ }; +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); +}; + struct amd_ir_data { struct irq_2_irte irq_2_irte; union irte irte_entry; + void *entry; /* Pointer to union irte or struct irte_ga */ union { struct msi_msg msi_entry; }; }; +#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 */