From patchwork Wed Jul 13 13:20:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 71931 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1048136qga; Wed, 13 Jul 2016 07:59:23 -0700 (PDT) X-Received: by 10.98.89.210 with SMTP id k79mr4228714pfj.152.1468421963877; Wed, 13 Jul 2016 07:59:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5si4486334pfb.258.2016.07.13.07.59.22; Wed, 13 Jul 2016 07:59:23 -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 S1753073AbcGMO4H (ORCPT + 30 others); Wed, 13 Jul 2016 10:56:07 -0400 Received: from mail-sn1nam02on0088.outbound.protection.outlook.com ([104.47.36.88]:27456 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751684AbcGMOzs (ORCPT ); Wed, 13 Jul 2016 10:55:48 -0400 X-Greylist: delayed 3646 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Jul 2016 10:55:47 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=VX11y4oFukQ0U9Z7oo+MrwMo/70Oml26k6hmz8B0anA=; b=Py6enhmGcMOB/N8urzL4HNzaf3TrExuv5oPiN+18VRE4gWUEH0xFtCP6GPEquWcME0ro153HQX1Qdb76Eibmilttsh9PDniOJQKcDlgmUHzHEMfk2mBFy/Evh00bUJ4WX+71NW7JQtQ2MAFHPxR37w5+4YL+RNJ6vBf4lbSCR0c= 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:12 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART2 PATCH v4 03/11] iommu/amd: Introduce interrupt remapping ops structure Date: Wed, 13 Jul 2016 08:20:24 -0500 Message-ID: <1468416032-7692-4-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: 5d63635b-6e55-4a26-663d-08d3ab209470 X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:/6kclb3g+z79MT1eVq2sC8oVJfDgtZuXqv/k8BwRSsfOb7Pp1BzqjBCvrNPT0f1Gl/zee9vHPxNSAHYFk8DGYrPCEdKtc48IRJ1e/C1hGRstW5ZKD3Y1GBMGhIprPn96R9tXF+jZ+SYXdpINzPUOXWipOuwfm2R8+Ool9FEuVJvQpOyfYRIJiOec0/0xDkR1; 3:Q0hcp5BqpJvI5wel7pbSO4OQ8B8xBGk6qw2ejyeXjcgwMXFR7RGc2fjs9He6jGsNQD/A2pDPV294iMPUwHUuw8qXjKha3Z8EvJ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cp3ambLgOUtPRovX69baA9+GfK7C4OMLPPLjFQsq5tVnrtf+GDUNxyvOt4io7iucpP4zTzR3mNcT97onudThgwsZHFNWugZui1oDw6D7dOgFKOEwbsBj7qgaUAeKGlv/QU/cg0aP4S2/HDLBrBHNw3/zfyaG13GlXntnaTxSns3WREqittxSTPtS2tzC1JZIK36cdTtVZZZNwip4rysBS1oLDJu; 4:TQ1aObACLCC8bE/TWGadUY+XFkZ60Ea3sRnKEd+XpF4c50+mi4miuYbYhcxTejmjOgFm5M6pFAyxVT+OatG1uQvVnWhBfC6k19sVprFSL70BVB6Da2W7I6Oos9kyA+1VmxEOZJ6zCUsmw7dWYmYtNzPOiPWtx7/mIWkXZmmJOae6og/xIhkVrah+vm77rtsatAmHGGZ3FI/4y8TM1mqvkI6+nR4ufurfDaEhlMr8gIY34oFAlOYNhWDCA/2DPXffF1sl9TOZZBs6IhNl7vaMd5ndVmoHRipaPLtth4OLhlLihVC5nxkdx1saf8WaMuzF6P+6CQlBtFUuePjhh3WmaIKAYSMkfmt+nqMg/fUP2MGor1cgoZ91IvA/cU//FzW1wbDgnBIkxnKYI7W1HLYrY1mItl5EOjgR2s4WL5tzYqg= 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-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:oNBKDINBiSN37PBQzBfE+KuutmDNDx0Rg/g1hbEYv?= =?us-ascii?Q?sKTuo6QnMJeU8yDgyadyozLegKlzqCTtt7DlXnYz5jcNnfz0RIQbLd/mNDsk?= =?us-ascii?Q?gCUkyTeGv+yAsIokeThNKHNgiN3dWrluuV9XrjBTPKXhKVIbKR3BQvMHWU7p?= =?us-ascii?Q?T+FfurBCx6e5M/p/RcAL9wwpCqyVjSnoVPuHK8MQvu7+XiAWQZ3GzIbqF0lb?= =?us-ascii?Q?W6ph8vhlto7nsCVyj5AY7liLGqVrV6S+63f/5TCTRefBnADPkxM3PmbNXbag?= =?us-ascii?Q?zaXfJKlz5tGDHEyCk8th3SW2xRh2U6lLEgEWKWAJIDHpEC3fmGZRE/n/g4qt?= =?us-ascii?Q?uRZ81TtAKRCZ7DoUuINLhr90Hn+EtaUTmbAJnkCtdGokG+O0+BQO8TIgP5+G?= =?us-ascii?Q?6y61ZN0aF3gGApINYvp/CRDCxZFwqpmd1MaYlGiKI7OR8ItE+yA8E47yCk8K?= =?us-ascii?Q?111HrAQwhGrQDbmbVz74DQsyQ/EkzNuPHilgZyPZqrbyoqiF8za0hEm08RQL?= =?us-ascii?Q?ClXhOeAys8/Aj2krKgKzXqAaiSa6UlYngZzp6efF9dp+7Um9t73LQH43BYqh?= =?us-ascii?Q?PTBbmC2Z5CnUxEyvfgN7LQ/LXWl7LRoRKSY1PJIq4qKZ0A/b6ngDlOAbwAHN?= =?us-ascii?Q?bQPLdTeDSUOr58d38hB9fnoQmHvIENFj9zZA2woJMC/dlvSgPqNecwhqqtJe?= =?us-ascii?Q?N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ixxoCUKiChWkEsfUS7PKX6nQc/i2LYlN5q8iTqSsQ7dDt9uA/15hmPOgf0uj3oZFlGKA=; 7:AaKIR4h1k9NQt91h8iaYnuOTi7hzzwocDaBFgZbn7wDWB9QkNIrbRseHnJGUc/X5rrHhS8OVwe1SeA1POZMfGbYP+i8So+gfLtyKE74k1p2aeMLZSlKdS4H9mSrmErSsA1mK/rWOKUNBSfS8NWaB43inilV41eSJbOpfL3wNSlTMWy3Pd3BlwI5ZEw5mLMlmcaHEhmMxE3W56WBitN1gaxuKT5g/dMEBtw5jUfkmi/fQkRTLMab6Es/hGphEOiIC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 20:uLqrqJcrVg+XF/EiM56GRmrvJBO1bK4rRFP5wfDuF+Go7BXfDdduTAU0gZZHOjeQ0mQnnISlQHp9AwUoSy04hZc0EqtzEOozMnltKk4GjTMXqkLzQfFLvJoYQPmKTeY1fVmRytkpiLwrOkf8oiavgTCjWGJ/1OiDDVm2GgawRTkO/xbZ0d7+3zgjjumltPVOKvhe4PUw7eg1B/eG7/W5LeeSxX6CYjmy4vyQXxkwRNMrPkcymQsXHIOYDKLAwtPo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2016 13:21:12.9519 (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 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..cc59fc5 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; 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 */