From patchwork Mon Mar 23 19:22:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 6074911 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 80732BF90F for ; Mon, 23 Mar 2015 19:22:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 927252035C for ; Mon, 23 Mar 2015 19:22:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D2452037A for ; Mon, 23 Mar 2015 19:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753253AbbCWTWo (ORCPT ); Mon, 23 Mar 2015 15:22:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54762 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753249AbbCWTWo (ORCPT ); Mon, 23 Mar 2015 15:22:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 216AB3D3340; Mon, 23 Mar 2015 19:22:44 +0000 (UTC) Received: from redhat.com (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t2NJMegk032731; Mon, 23 Mar 2015 15:22:41 -0400 Date: Mon, 23 Mar 2015 20:22:39 +0100 From: "Michael S. Tsirkin" To: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-pci@vger.kernel.org, Fam Zheng , Yinghai Lu , Ulrich Obergfell , Rusty Russell Subject: Re: [PATCH v2 1/4] pci: disable msi/msix at probe time Message-ID: <20150323201237-mutt-send-email-mst@redhat.com> References: <1426786724-22241-1-git-send-email-mst@redhat.com> <1426786724-22241-2-git-send-email-mst@redhat.com> <20150323185006.GT26935@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150323185006.GT26935@google.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 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 On Mon, Mar 23, 2015 at 01:50:06PM -0500, Bjorn Helgaas wrote: > Hi Michael, > > On Thu, Mar 19, 2015 at 07:57:52PM +0100, Michael S. Tsirkin wrote: > > commit d52877c7b1afb8c37ebe17e2005040b79cb618b0 > > pci/irq: let pci_device_shutdown to call pci_msi_shutdown v2 > > > > attempted to address the problem of kexec getting > > started after linux enabled msi/msix for a device, > > and drivers being confused by msi being enabled, > > by disabling msi at shutdown. > > > > But arguably, it's better to disable msi/msix when kexec > > starts - for example, kexec might run after a crash (kdump) > > and shutdown callbacks are not always invoked in that case. > > > > Cc: Yinghai Lu > > Cc: Ulrich Obergfell > > Cc: Fam Zheng > > Cc: Rusty Russell > > Signed-off-by: Michael S. Tsirkin > > --- > > drivers/pci/pci-driver.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > > index 3cb2210..2ebd2a8 100644 > > --- a/drivers/pci/pci-driver.c > > +++ b/drivers/pci/pci-driver.c > > @@ -305,6 +305,12 @@ static long local_pci_probe(void *_ddi) > > */ > > pm_runtime_get_sync(dev); > > pci_dev->driver = pci_drv; > > + /* > > + * When using kexec, msi might be left enabled by the previous kernel, > > + * this breaks things as some drivers assume msi/msi-x is off at boot. > > + * Fix this by forcing msi off at startup. > > + */ > > + pci_msi_off(pci_dev); > > I think this makes sense, but I have a few questions. This is a device > initialization thing, so it seems like a better fit for the enumeration > path, e.g,. pci_msi_init_pci_dev(), than for the driver binding path. > > But when CONFIG_PCI_MSI=y, pci_msi_init_pci_dev() already does basically > the same thing, so we shouldn't need this change unless CONFIG_PCI_MSI is > not set in the kdump kernel. > > If this is a problem just with kexeced kernels that don't have > CONFIG_PCI_MSI=y, I think I would prefer to fix this by moving > pci_msi_init_pci_dev() outside the #ifdef so it works regardless of > CONFIG_PCI_MSI. That would also be nice because we could clean up the > duplication between pci_msi_off() and pci_msi_init_pci_dev(). It would > also make the starting machine state less dependent on the new kernel, > which seems like a good thing. What you say above makes sense. OK so the simplest fix is something like below then. Fixes the duplication and kexec for CONFIG_PCI_MSI=n. Acceptable? Pls let me know, if yes I'll test and resubmit properly. > Are there any bugzillas we could reference here? I'll check this point. Maybe not - the real bugfix is patch 2/4, this was just found by reading code, but it's a dependency to make sure 2/4 does not introduce regressions. --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 0e037af..2ab59d4 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1062,18 +1062,8 @@ EXPORT_SYMBOL(pci_msi_enabled); void pci_msi_init_pci_dev(struct pci_dev *dev) { INIT_LIST_HEAD(&dev->msi_list); - - /* Disable the msi hardware to avoid screaming interrupts - * during boot. This is the power on reset default so - * usually this should be a noop. - */ dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI); - if (dev->msi_cap) - msi_set_enable(dev, 0); - dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX); - if (dev->msix_cap) - msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0); } /** diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 8d2f400..c455501 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1485,6 +1485,12 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) static void pci_init_capabilities(struct pci_dev *dev) { + /* Disable the msi hardware to avoid screaming interrupts + * during boot. This is the power on reset default so + * usually this should be a noop. + */ + pci_msi_off(dev); + /* MSI/MSI-X list */ pci_msi_init_pci_dev(dev);