From patchwork Mon Jan 12 07:06:27 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: 5608461 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5EF71C058D for ; Mon, 12 Jan 2015 07:09:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77AD42063A for ; Mon, 12 Jan 2015 07:09:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06DEC2039E for ; Mon, 12 Jan 2015 07:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751993AbbALHJ2 (ORCPT ); Mon, 12 Jan 2015 02:09:28 -0500 Received: from g4t3427.houston.hp.com ([15.201.208.55]:57888 "EHLO g4t3427.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbbALHJZ (ORCPT ); Mon, 12 Jan 2015 02:09:25 -0500 Received: from g4t3433.houston.hp.com (g4t3433.houston.hp.com [16.210.25.219]) by g4t3427.houston.hp.com (Postfix) with ESMTP id A0E9C6C; Mon, 12 Jan 2015 07:09:24 +0000 (UTC) Received: from piepie.asiapacific.hpqcorp.net (piepie.asiapacific.hpqcorp.net [16.187.245.10]) by g4t3433.houston.hp.com (Postfix) with ESMTP id 99542D6; Mon, 12 Jan 2015 07:09:19 +0000 (UTC) From: "Li, Zhen-Hua" To: , , , , , Cc: , , , , , , , , , , , , , , , Subject: [PATCH v8 09/10] iommu/vt-d: Copy functions for irte Date: Mon, 12 Jan 2015 15:06:27 +0800 Message-Id: <1421046388-27925-10-git-send-email-zhen-hual@hp.com> X-Mailer: git-send-email 2.0.0-rc0 In-Reply-To: <1421046388-27925-1-git-send-email-zhen-hual@hp.com> References: <1421046388-27925-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 | 62 +++++++++++++++++++++++++++++++++++++ include/linux/intel-iommu.h | 4 +++ 2 files changed, 66 insertions(+) diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index a55b207..d37fd62 100644 --- a/drivers/iommu/intel_irq_remapping.c +++ b/drivers/iommu/intel_irq_remapping.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,11 @@ #include "irq_remapping.h" +#ifdef CONFIG_CRASH_DUMP +static int __iommu_load_old_irte(struct intel_iommu *iommu); +static int __iommu_update_old_irte(struct intel_iommu *iommu, int index); +#endif /* CONFIG_CRASH_DUMP */ + struct ioapic_scope { struct intel_iommu *iommu; unsigned int id; @@ -1296,3 +1302,59 @@ int dmar_ir_hotplug(struct dmar_drhd_unit *dmaru, bool insert) return ret; } + +#ifdef CONFIG_CRASH_DUMP + +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; +} +#endif /* CONFIG_CRASH_DUMP */ diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 8e29b97..76c6ea5 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h @@ -290,6 +290,10 @@ struct q_inval { struct ir_table { struct irte *base; unsigned long *bitmap; +#ifdef CONFIG_CRASH_DUMP + void __iomem *base_old_virt; + unsigned long base_old_phys; +#endif }; #endif