From patchwork Fri Mar 7 19:39:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3794341 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 806FFBF540 for ; Fri, 7 Mar 2014 19:39:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E8B52034B for ; Fri, 7 Mar 2014 19:39:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1758A20265 for ; Fri, 7 Mar 2014 19:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbaCGTjt (ORCPT ); Fri, 7 Mar 2014 14:39:49 -0500 Received: from mail-ie0-f177.google.com ([209.85.223.177]:55135 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbaCGTjt (ORCPT ); Fri, 7 Mar 2014 14:39:49 -0500 Received: by mail-ie0-f177.google.com with SMTP id rl12so4802238iec.36 for ; Fri, 07 Mar 2014 11:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=pBz9H5/OJM8zHxP70ms5sJs1xWQXAEgtAXxcwGI0PHA=; b=tUKoARWBdScYUhMLClXvNRJB8Jkua3CCmJiuz60Y/KoaGjgy62PwdXSNhPrGazQLZL 4Kd3Zuxtiya7OQv7shQ1IaTj8W5NrF37bMeuCrSBPElLNiMqRePs5uvd+1HzJuvQIGXU DoZX6WmMwCO838L88XR1p6C55LdS2KPa9uRHgPO48WrrUBphiEiCzyDwNhyluWtHPIu7 yXdgLGGFf7QscW2p2MIK7hW7BZgB0fUWdAIE5hH7+r4tgMVqMEi07rgn3pbKcB8eChDp 5rKgn1DoBd5zeU1S9PpG2u+NjvTecUGwJsrZyRmhLkjKUZhhMh9e4aZDAJxAgN7eJs7q nwfw== MIME-Version: 1.0 X-Received: by 10.50.4.74 with SMTP id i10mr4654826igi.43.1394221188354; Fri, 07 Mar 2014 11:39:48 -0800 (PST) Received: by 10.64.168.72 with HTTP; Fri, 7 Mar 2014 11:39:48 -0800 (PST) In-Reply-To: References: Date: Fri, 7 Mar 2014 11:39:48 -0800 X-Google-Sender-Auth: xy9MTxTpmgTukB7lIzSxSARcKn0 Message-ID: Subject: Re: [Bug] PCI: Enable INTx if BIOS left them disabled - triggers during rescan From: Yinghai Lu To: Bjorn Helgaas Cc: Andreas Noever , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , Rajat Jain 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,T_TVD_MIME_EPI, 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 Fri, Mar 7, 2014 at 8:45 AM, Bjorn Helgaas wrote: > > I opened a bugzilla report at https://bugzilla.kernel.org/show_bug.cgi?id=71691 > > It seems like clearing DisINTx has some effect on MSI. I don't see > anything in the spec that would suggest this (I'm looking at the PCIe > r3.0 spec, sec 7.5.1.1). > > Can somebody point out a connection between DisINTx and MSI? If not, > maybe we'll need some sort of quirk to deal with this. I had different impression: if you disable INTx in some chipset, MSI will not work anymore. so we have static void pci_intx_for_msi(struct pci_dev *dev, int enable) { if (!(dev->dev_flags & PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG)) pci_intx(dev, enable); } and have quirks for ati and broadcom chip to set that FLAG. regarding the regression: i would suggest move out do_pci_enable_intx() from re-enable path. if (err < 0 && err != -EIO) @@ -1204,14 +1215,6 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars) return err; pci_fixup_device(pci_fixup_enable, dev); - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - if (pin) { - pci_read_config_word(dev, PCI_COMMAND, &cmd); - if (cmd & PCI_COMMAND_INTX_DISABLE) - pci_write_config_word(dev, PCI_COMMAND, - cmd & ~PCI_COMMAND_INTX_DISABLE); - } - return 0; } @@ -1287,6 +1290,8 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) err = do_pci_enable_device(dev, bars); if (err < 0) atomic_dec(&dev->enable_cnt); + else + do_pci_enable_intx(dev); return err; } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 5a24cb3..92718c9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1190,11 +1190,22 @@ int __weak pcibios_enable_device(struct pci_dev *dev, int bars) return pci_enable_resources(dev, bars); } +static void do_pci_enable_intx(struct pci_dev *dev) +{ + u8 pin; + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + if (pin) { + pci_read_config_word(dev, PCI_COMMAND, &cmd); + if (cmd & PCI_COMMAND_INTX_DISABLE) + pci_write_config_word(dev, PCI_COMMAND, + cmd & ~PCI_COMMAND_INTX_DISABLE); + } +} + static int do_pci_enable_device(struct pci_dev *dev, int bars) { int err; u16 cmd; - u8 pin; err = pci_set_power_state(dev, PCI_D0); if (err < 0 && err != -EIO) @@ -1204,14 +1215,6 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars) return err; pci_fixup_device(pci_fixup_enable, dev); - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - if (pin) { - pci_read_config_word(dev, PCI_COMMAND, &cmd); - if (cmd & PCI_COMMAND_INTX_DISABLE) - pci_write_config_word(dev, PCI_COMMAND, - cmd & ~PCI_COMMAND_INTX_DISABLE); - } - return 0; } @@ -1287,6 +1290,8 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) err = do_pci_enable_device(dev, bars); if (err < 0) atomic_dec(&dev->enable_cnt); + else + do_pci_enable_intx(dev); return err; }