From patchwork Tue Aug 23 18:52: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: 74512 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2246535qga; Tue, 23 Aug 2016 11:56:16 -0700 (PDT) X-Received: by 10.98.200.29 with SMTP id z29mr55569838pff.143.1471978576257; Tue, 23 Aug 2016 11:56:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 191si5078781pfz.229.2016.08.23.11.56.15; Tue, 23 Aug 2016 11:56:16 -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 S1754670AbcHWS4N (ORCPT + 27 others); Tue, 23 Aug 2016 14:56:13 -0400 Received: from mail-co1nam03on0073.outbound.protection.outlook.com ([104.47.40.73]:37280 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754046AbcHWS4L (ORCPT ); Tue, 23 Aug 2016 14:56:11 -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=bkFYXkV435gJs4RfC1x8WjyekMSBcWguTnyu1ntmRjo=; b=UuTre7TgSGT/muj63xXSELAJWg/efAseMF5dqqJycxqb2srPSMXaywKVwbmInAuFp2ABDMtwanc7B+tHpWx8OklBbwgC5C58fotoEkLIu86ZwIGperx9nvtER3d/xwzUnCw3tUxoekG1xWeREHNTq1ZZxagmnb94qKNFcIV6MTs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from localhost.localdomain (114.109.128.54) by DM5PR12MB1452.namprd12.prod.outlook.com (10.172.38.141) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Tue, 23 Aug 2016 18:53:19 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v7 04/12] iommu/amd: Add support for multiple IRTE formats Date: Tue, 23 Aug 2016 13:52:35 -0500 Message-ID: <1471978363-13756-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471978363-13756-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1471978363-13756-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: KL1PR02CA0053.apcprd02.prod.outlook.com (10.167.54.21) To DM5PR12MB1452.namprd12.prod.outlook.com (10.172.38.141) X-MS-Office365-Filtering-Correlation-Id: c6ddf558-f33a-4f37-47fd-08d3cb86c18c X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1452; 2:sZ0S0RwJItsDhWC/GPsiH0mLp0fTVnnK7wPTpVwLXA9qp6efC/dabsRL+UFGuSnNnPtZ3q766DMuWMbT/Nb5YEvsdb9KN5VDiC1h5btdN5L1Mos2SMv1SK3+pflo+IcjagPKwjzhoKM6CJZlhXsVYJY4P0J9Kpa9Xr6HlV3RxBUds91nAGCDCsjBmxOeiCOf; 3:Klc3Q46UDvbF5HXXI2SuoHOw/wBAc6BTyA+kgeOH/vWOq5LNxLtubjvGzEsXOVVojQYEkJ6QcEC/So1wsknvS8ZbHswH8Ll8xFzPqB+cXsfFhO2qhL2J07eS1LnOW6jp X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR12MB1452; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1452; 25:gcYn8I5noyzLMzL1PIcpKbMf15t8HGhHnERE9tx171R5X8JMIgR2crLzzOW26qi8fIA+O5clK5Hl9dVsNO5fLTAa0ithwPsG5rg6B44kuxdpeWDlE7ZcC72z/2M9IEPZf4p01H6/QpDdwdtSyNmGFCdC/YeLyAPoMMgcMx10gl00F48fPFRNpx2atG+pTsMXDQ6w/B6euMrlrt8NEFhmmEGLHtzooYoup+KYCnk+nei8ONuhyacK9SXR201d3/rG/yBD4RAikUSxLlbxkvhVyz5uVmp3+4ozjeVWt7HmteZsVvPOrXrXr9NBCTB17OFvlE7YBS4+oyG4vCzw5GNa3fNpKE6y1eDXbqhZx08nMvDVtHHKK0qsajLIqrhCFxuHiBwrwF8RZFK/RGhz6FlJW66OnfZcmohbV4ZZDuRrxCvOVV9b6At7u9TYfz9aEgXyZCZatXGnUyv2Z7TnRKSTuHqY7LgUML8d7rxSx+X0/eNoQY7pDy8lfAang9eiflsigMDx3pR5bDha5eEEwaphaGlAG16pT2OfslOZC3vVq1W+vYivHmngq3GlnD56g/lygZRlFqVlhhF7pMCMTasS1BcQkYZB7QdsrUr6P9z4a0OMcaIqSouf/s0D8LJNqM8g3+oH+kAafu9XLCaCF4wereMhlOg5KN0rJchC+qIc13BbB1cItWpsV23hsIZXFeeEbJdIc16q2DPWlfAGHbaDf8k1w997HgMn7hwOxpzhoT8= X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1452; 31:zPwKJn8vp1/RZ7vy9gCDdLUcFqGbtVhyhYbgdWRdhCJIdPgpgrFNIWf/S1ItM/Add3DM0C1fU/EgLbLcPje83N6ZHhK/5iEXRls5NlxKzxIZPapYB+QMuSXkxwgayK6wP76tnM1Qnsrjf1qfvUb+13s0wYsG24/NEGUYlGphVrh2GEzkwJyok8PdGC2Nu0x3hI0NvxZzSUrLZ6whbzasfQsmg+1w/BIvnSsBIZi1Nzw=; 20:YfbEb2artxeNgefjSQ/7pboNpW3bLfn3FFhSTG6PaoSCJzJ4y61vhG/Z1oIlmqnvh2LcNpaqhRk2ID8yMsSWcy2cENsmR/aAn3pJWwV+TKG5yEcheWeGmQVeNUJFgbYGIcUhLKuMUeM8uUShDpDPBiEt22VXNq1EjmqoIDBMQoHdkMY+87fXEHCkKjWtMnpcpXKZdMkHj00UiP9tGPqP99VSMfwAwIYpH/Aug4mNinWB74s2PDp237TSs15yMyAznXORgg/XcfMkbMHW8GJjs2qrY60vZ7x+5jXjcK7TI2RNMsGXjngX+0MN0ncSEatZoIffX36sZbbSva0TLw0poLAnvRYLRaoaW5gyuvIh8yIA3JBOu6euh6zB3PzV+npT1QHXYHbhVKQcF9KDrDcmf2w1STgCUS5pXpIQWp3eEjn5BKK5zOIa4+Q8B05xqxlVV14t94Gzh4Jcy6klBhADZrt0Mr2gCqHl/3oVdolqdBJpfhpbt96J0R3pX6CbR5dk 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)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:DM5PR12MB1452; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1452; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1452; 4:5RChixAnElM7HdtzGDFvop8ffZmFBAHr9ZWaTqhldorVHgZdysbsT/Bjl047i3DMPQUYT+Rkzdh5W81dc+7nWnJPXZ+7r8ZLT3WvbMYKf8DKsBQ3GpteICuPy/zz9Oh85KmxwoEUfbwcvJFUgpu48edfc/GkBIcT7slihn9eVxqIBmsSkg7Ddbov0jHW3YXLrk3ZC83I8fSbvVaJ+dIOgqsZKhhdR5qVrTXN+Zh2qCR+2H6MVDkEZsj96UOPw7ZuW+AnnDTmPFNZxccbaVbsYeFUzazbCNr5+KF7y13Kiyx0Q20rTbiEe0CHKyE8Tk11rIIexkd2TgQYBCbjZc55O5lmQh+dS9+ZFBeuo75rnPaMrSB7+aCwdK2as+QA57htYfgU8lEu7SuQiK7TajLj7TNyHN/B2OutNR2PIJjWWAYXZ+BJHNwzJOGaS2GfvbJM X-Forefront-PRVS: 004395A01C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(42186005)(76176999)(101416001)(48376002)(50466002)(77096005)(5660300001)(92566002)(105586002)(5003940100001)(36756003)(86362001)(106356001)(66066001)(50986999)(5001770100001)(19580395003)(19580405001)(50226002)(97736004)(189998001)(229853001)(3846002)(2950100001)(47776003)(8676002)(7736002)(6116002)(586003)(81156014)(68736007)(4326007)(2201001)(81166006)(305945005)(7846002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1452; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM5PR12MB1452; 23:jZ7AyysIhzSD68bjZIASpizXrrC8Zf+DaNFReODAj?= =?us-ascii?Q?M2lyrfRTsXfLbIaLrxuGM4SLDx/VyjI91SodoPIjO/OllNT+R5hyCSfa34jx?= =?us-ascii?Q?FsNXhF+2Yfa/kxsdQ6+ZKmD0z5+tnkZhvFKqERHVBT/JltvzI8GVM0uDz5rb?= =?us-ascii?Q?wb6hfYm1iJ25er1XtGyoX0II4xgx7VM7BmWYqpHTKTpXmyTlqE6SM2nuAoPV?= =?us-ascii?Q?ZkrrEPjACsL9689qyoGVrhvW0fKyO9lzBoPIQIWtHtnRbW6kZYbLCjNofkU4?= =?us-ascii?Q?7e0lII/iXC3689tHPG9WHeQR/7QYIqj07UKWefZVVZQeXQaqJogC1srFVkKE?= =?us-ascii?Q?1NCoIedtcasVens78HCwcaRTcJ2VlD0PrJm8BWaii5IHDdYzpPCo9xgiF1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0WMRD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2016 18:53:19.3599 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1452 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit This patch enables support for the new 128-bit IOMMU IRTE format, which can be used for both legacy and vapic interrupt remapping modes. It replaces the existing operations on IRTE, which can only support the older 32-bit IRTE format, with calls to the new struct amd_irt_ops. It also provides helper functions for setting up, accessing, and updating interrupt remapping table entries in different mode. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu.c | 72 +++++++++++++++++++++++++++-------------- drivers/iommu/amd_iommu_init.c | 2 ++ drivers/iommu/amd_iommu_types.h | 1 - 3 files changed, 50 insertions(+), 25 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 5260b42..52e1e4a 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -3714,8 +3714,6 @@ static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table) amd_iommu_dev_table[devid].data[2] = dte; } -#define IRTE_ALLOCATED (~1U) - static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic) { struct irq_remap_table *table = NULL; @@ -3761,13 +3759,18 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic) goto out; } - memset(table->table, 0, MAX_IRQS_PER_TABLE * sizeof(u32)); + if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir)) + memset(table->table, 0, + MAX_IRQS_PER_TABLE * sizeof(u32)); + else + memset(table->table, 0, + (MAX_IRQS_PER_TABLE * (sizeof(u64) * 2))); if (ioapic) { int i; for (i = 0; i < 32; ++i) - table->table[i] = IRTE_ALLOCATED; + iommu->irte_ops->set_allocated(table, i); } irq_lookup_table[devid] = table; @@ -3793,6 +3796,10 @@ static int alloc_irq_index(u16 devid, int count) struct irq_remap_table *table; unsigned long flags; int index, c; + struct amd_iommu *iommu = amd_iommu_rlookup_table[devid]; + + if (!iommu) + return -ENODEV; table = get_irq_table(devid, false); if (!table) @@ -3804,14 +3811,14 @@ static int alloc_irq_index(u16 devid, int count) for (c = 0, index = table->min_index; index < MAX_IRQS_PER_TABLE; ++index) { - if (table->table[index] == 0) + if (!iommu->irte_ops->is_allocated(table, index)) c += 1; else c = 0; if (c == count) { for (; c != 0; --c) - table->table[index - c + 1] = IRTE_ALLOCATED; + iommu->irte_ops->set_allocated(table, index - c + 1); index -= count - 1; goto out; @@ -3897,7 +3904,7 @@ static void free_irte(u16 devid, int index) return; spin_lock_irqsave(&table->lock, flags); - table->table[index] = 0; + iommu->irte_ops->clear_allocated(table, index); spin_unlock_irqrestore(&table->lock, flags); iommu_flush_irt(iommu, devid); @@ -3987,6 +3994,7 @@ static void irte_ga_set_affinity(void *entry, u16 devid, u16 index, modify_irte_ga(devid, index, irte); } +#define IRTE_ALLOCATED (~1U) static void irte_set_allocated(struct irq_remap_table *table, int index) { table->table[index] = IRTE_ALLOCATED; @@ -4116,19 +4124,17 @@ static void irq_remapping_prepare_irte(struct amd_ir_data *data, { struct irq_2_irte *irte_info = &data->irq_2_irte; struct msi_msg *msg = &data->msi_entry; - union irte *irte = &data->irte_entry; struct IO_APIC_route_entry *entry; + struct amd_iommu *iommu = amd_iommu_rlookup_table[devid]; + + if (!iommu) + return; data->irq_2_irte.devid = devid; data->irq_2_irte.index = index + sub_handle; - - /* Setup IRTE for IOMMU */ - irte->val = 0; - irte->fields.vector = irq_cfg->vector; - irte->fields.int_type = apic->irq_delivery_mode; - irte->fields.destination = irq_cfg->dest_apicid; - irte->fields.dm = apic->irq_dest_mode; - irte->fields.valid = 1; + iommu->irte_ops->prepare(data->entry, apic->irq_delivery_mode, + apic->irq_dest_mode, irq_cfg->vector, + irq_cfg->dest_apicid); switch (info->type) { case X86_IRQ_ALLOC_TYPE_IOAPIC: @@ -4184,7 +4190,7 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, { struct irq_alloc_info *info = arg; struct irq_data *irq_data; - struct amd_ir_data *data; + struct amd_ir_data *data = NULL; struct irq_cfg *cfg; int i, ret, devid; int index = -1; @@ -4236,6 +4242,16 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq, if (!data) goto out_free_data; + if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir)) + data->entry = kzalloc(sizeof(union irte), GFP_KERNEL); + else + data->entry = kzalloc(sizeof(struct irte_ga), + GFP_KERNEL); + if (!data->entry) { + kfree(data); + goto out_free_data; + } + irq_data->hwirq = (devid << 16) + i; irq_data->chip_data = data; irq_data->chip = &amd_ir_chip; @@ -4272,6 +4288,7 @@ static void irq_remapping_free(struct irq_domain *domain, unsigned int virq, data = irq_data->chip_data; irte_info = &data->irq_2_irte; free_irte(irte_info->devid, irte_info->index); + kfree(data->entry); kfree(data); } } @@ -4283,8 +4300,11 @@ 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; + struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid]; - modify_irte(irte_info->devid, irte_info->index, &data->irte_entry); + if (iommu) + iommu->irte_ops->activate(data->entry, irte_info->devid, + irte_info->index); } static void irq_remapping_deactivate(struct irq_domain *domain, @@ -4292,10 +4312,11 @@ static void irq_remapping_deactivate(struct irq_domain *domain, { struct amd_ir_data *data = irq_data->chip_data; struct irq_2_irte *irte_info = &data->irq_2_irte; - union irte entry; + struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid]; - entry.val = 0; - modify_irte(irte_info->devid, irte_info->index, &data->irte_entry); + if (iommu) + iommu->irte_ops->deactivate(data->entry, irte_info->devid, + irte_info->index); } static struct irq_domain_ops amd_ir_domain_ops = { @@ -4312,8 +4333,12 @@ static int amd_ir_set_affinity(struct irq_data *data, struct irq_2_irte *irte_info = &ir_data->irq_2_irte; struct irq_cfg *cfg = irqd_cfg(data); struct irq_data *parent = data->parent_data; + struct amd_iommu *iommu = amd_iommu_rlookup_table[irte_info->devid]; int ret; + if (!iommu) + return -ENODEV; + ret = parent->chip->irq_set_affinity(parent, mask, force); if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE) return ret; @@ -4322,9 +4347,8 @@ static int amd_ir_set_affinity(struct irq_data *data, * Atomically updates the IRTE with the new destination, vector * and flushes the interrupt entry cache. */ - 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); + iommu->irte_ops->set_affinity(ir_data->entry, irte_info->devid, + irte_info->index, cfg->vector, cfg->dest_apicid); /* * After this point, all the interrupts will start arriving diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index c3afd86..c17febb 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -1893,8 +1893,10 @@ static void iommu_enable_ga(struct amd_iommu *iommu) /* Fall through */ case AMD_IOMMU_GUEST_IR_LEGACY_GA: iommu_feature_enable(iommu, CONTROL_GA_EN); + iommu->irte_ops = &irte_128_ops; break; default: + iommu->irte_ops = &irte_32_ops; break; } #endif diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index d57c56d..a591747 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -781,7 +781,6 @@ struct irq_2_irte { 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 */ };