From patchwork Wed Jul 8 07:41:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 6741461 Return-Path: X-Original-To: patchwork-dmaengine@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 B572BC05AC for ; Wed, 8 Jul 2015 07:47:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E097E20782 for ; Wed, 8 Jul 2015 07:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F24D22078A for ; Wed, 8 Jul 2015 07:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933580AbbGHHmg (ORCPT ); Wed, 8 Jul 2015 03:42:36 -0400 Received: from mga09.intel.com ([134.134.136.24]:32804 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933169AbbGHHj6 (ORCPT ); Wed, 8 Jul 2015 03:39:58 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 08 Jul 2015 00:39:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,430,1432623600"; d="scan'208";a="724882904" Received: from gerry-dev.bj.intel.com ([10.238.158.61]) by orsmga001.jf.intel.com with ESMTP; 08 Jul 2015 00:39:55 -0700 From: Jiang Liu To: Vinod Koul , Dave Jiang , Dan Williams , Jiang Liu , Jarkko Nikula Cc: David Woodhouse , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: [Patch V2] ioatdma: Ignore IOAT devices under hotplug-capable PCI host bridge Date: Wed, 8 Jul 2015 15:41:42 +0800 Message-Id: <1436341305-19936-1-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The dmaengine core assumes that async DMA devices will only be removed when they not used anymore, or it assumes dma_async_device_unregister() will only be called by dma driver exit routines. But this assumption is not true for the IOAT driver, which calls dma_async_device_unregister() from ioat_remove(). So current IOAT driver doesn't support device hot-removal because it may cause system crash to hot-remove an inuse IOAT device. To support CPU socket hot-removal, all PCI devices, including IOAT devices embedded in the socket, will be hot-removed. The idea solution is to enhance the dmaengine core and IOAT driver to support hot-removal, but that's too hard. This patch implements a hack to disable IOAT devices under hotplug-capable CPU socket so it won't break socket hot-removal. Signed-off-by: Jiang Liu --- Hi Vinod, This is a resend of v1, no actual changes except the email title. Dan and Dave have no objection to this approach, though they haven't explicitly acked the patch:) Thanks! Gerry --- drivers/dma/ioat/pci.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/dma/ioat/pci.c b/drivers/dma/ioat/pci.c index 76f0dc688a19..3b8c9b03f4b3 100644 --- a/drivers/dma/ioat/pci.c +++ b/drivers/dma/ioat/pci.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "dma.h" #include "dma_v2.h" #include "registers.h" @@ -148,6 +149,34 @@ alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase) return d; } +/* + * The dmaengine core assumes that async DMA devices will only be removed + * when they not used anymore, or it assumes dma_async_device_unregister() + * will only be called by dma driver exit routines. But this assumption is + * not true for the IOAT driver, which calls dma_async_device_unregister() + * from ioat_remove(). So current IOAT driver doesn't support device + * hot-removal because it may cause system crash to hot-remove inuse IOAT + * devices. + * + * This is a hack to disable IOAT devices under ejectable PCI host bridge + * so it won't break PCI host bridge hot-removal. + */ +static bool ioat_pci_has_ejectable_acpi_ancestor(struct pci_dev *pdev) +{ +#ifdef CONFIG_ACPI + struct pci_bus *bus = pdev->bus; + struct acpi_device *adev; + + while (bus->parent) + bus = bus->parent; + for (adev = ACPI_COMPANION(bus->bridge); adev; adev = adev->parent) + if (adev->flags.ejectable) + return true; +#endif + + return false; +} + static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { void __iomem * const *iomap; @@ -155,6 +184,11 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct ioatdma_device *device; int err; + if (ioat_pci_has_ejectable_acpi_ancestor(pdev)) { + dev_dbg(&pdev->dev, "ignore ejectable IOAT device.\n"); + return -ENODEV; + } + err = pcim_enable_device(pdev); if (err) return err;