From patchwork Mon May 11 09:52:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Zhen-Hua" X-Patchwork-Id: 6375401 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 91DD79F1C2 for ; Mon, 11 May 2015 09:56:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C030720225 for ; Mon, 11 May 2015 09:56:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3B7C201ED for ; Mon, 11 May 2015 09:56:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753496AbbEKJyv (ORCPT ); Mon, 11 May 2015 05:54:51 -0400 Received: from g2t2354.austin.hp.com ([15.217.128.53]:48484 "EHLO g2t2354.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753458AbbEKJyu (ORCPT ); Mon, 11 May 2015 05:54:50 -0400 Received: from g2t2360.austin.hp.com (g2t2360.austin.hp.com [16.197.8.247]) by g2t2354.austin.hp.com (Postfix) with ESMTP id A41BCD2; Mon, 11 May 2015 09:54:49 +0000 (UTC) Received: from piepie.asiapacific.hpqcorp.net (piepie.asiapacific.hpqcorp.net [16.187.246.216]) by g2t2360.austin.hp.com (Postfix) with ESMTP id 3DF8C71; Mon, 11 May 2015 09:54:44 +0000 (UTC) From: "Li, Zhen-Hua" To: , , , , , Cc: , , , , , , , , , , , , , , , Subject: [PATCH v11 09/10] iommu/vt-d: Copy functions for irte Date: Mon, 11 May 2015 17:52:53 +0800 Message-Id: <1431337974-545-10-git-send-email-zhen-hual@hp.com> X-Mailer: git-send-email 2.0.0-rc0 In-Reply-To: <1431337974-545-1-git-send-email-zhen-hual@hp.com> References: <1431337974-545-1-git-send-email-zhen-hual@hp.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Functions to copy the irte data from the old kernel into the kdump kernel. Signed-off-by: Li, Zhen-Hua --- drivers/iommu/intel_irq_remapping.c | 68 +++++++++++++++++++++++++++++++++++++ include/linux/intel-iommu.h | 4 +++ 2 files changed, 72 insertions(+) diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index 5709ae9..c2a4406 100644 --- a/drivers/iommu/intel_irq_remapping.c +++ b/drivers/iommu/intel_irq_remapping.c @@ -17,6 +17,10 @@ #include "irq_remapping.h" +static int __iommu_load_old_irte(struct intel_iommu *iommu); +static int __iommu_update_old_irte(struct intel_iommu *iommu, int index); +static void iommu_check_pre_ir_status(struct intel_iommu *iommu); + struct ioapic_scope { struct intel_iommu *iommu; unsigned int id; @@ -1299,3 +1303,67 @@ int dmar_ir_hotplug(struct dmar_drhd_unit *dmaru, bool insert) return ret; } + +static int __iommu_load_old_irte(struct intel_iommu *iommu) +{ + if ((!iommu) + || (!iommu->ir_table) + || (!iommu->ir_table->base) + || (!iommu->ir_table->base_old_phys) + || (!iommu->ir_table->base_old_virt)) + return -1; + + memcpy(iommu->ir_table->base, + iommu->ir_table->base_old_virt, + INTR_REMAP_TABLE_ENTRIES*sizeof(struct irte)); + + __iommu_flush_cache(iommu, iommu->ir_table->base, + INTR_REMAP_TABLE_ENTRIES*sizeof(struct irte)); + + return 0; +} + +static int __iommu_update_old_irte(struct intel_iommu *iommu, int index) +{ + int start; + unsigned long size; + void __iomem *to; + void *from; + + if ((!iommu) + || (!iommu->ir_table) + || (!iommu->ir_table->base) + || (!iommu->ir_table->base_old_phys) + || (!iommu->ir_table->base_old_virt)) + return -1; + + if (index < -1 || index >= INTR_REMAP_TABLE_ENTRIES) + return -1; + + if (index == -1) { + start = 0; + size = INTR_REMAP_TABLE_ENTRIES * sizeof(struct irte); + } else { + start = index * sizeof(struct irte); + size = sizeof(struct irte); + } + + to = iommu->ir_table->base_old_virt; + from = iommu->ir_table->base; + memcpy(to + start, from + start, size); + + __iommu_flush_cache(iommu, to + start, size); + + return 0; +} + +static void iommu_check_pre_ir_status(struct intel_iommu *iommu) +{ + u32 sts; + + sts = readl(iommu->reg + DMAR_GSTS_REG); + if (sts & DMA_GSTS_IRES) { + pr_info("IR is enabled prior to OS.\n"); + iommu->pre_enabled_ir = 1; + } +} diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 90e122e..d7a0b5d 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h @@ -301,6 +301,8 @@ struct q_inval { struct ir_table { struct irte *base; unsigned long *bitmap; + void __iomem *base_old_virt; + unsigned long base_old_phys; }; #endif @@ -342,6 +344,8 @@ struct intel_iommu { /* whether translation is enabled prior to OS*/ u8 pre_enabled_trans; + /* whether interrupt remapping is enabled prior to OS*/ + u8 pre_enabled_ir; void __iomem *root_entry_old_virt; /* mapped from old root entry */ unsigned long root_entry_old_phys; /* root entry in old kernel */