From patchwork Thu Aug 22 21:03:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 2848403 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 38985BF546 for ; Thu, 22 Aug 2013 21:03:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 954C2202AC for ; Thu, 22 Aug 2013 21:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2309F2020F for ; Thu, 22 Aug 2013 21:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753204Ab3HVVDI (ORCPT ); Thu, 22 Aug 2013 17:03:08 -0400 Received: from mail-ob0-f181.google.com ([209.85.214.181]:33396 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752489Ab3HVVDH (ORCPT ); Thu, 22 Aug 2013 17:03:07 -0400 Received: by mail-ob0-f181.google.com with SMTP id dn14so813664obc.40 for ; Thu, 22 Aug 2013 14:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=m2rSP0/Vtb4ZeWdWUsfinHhFVnzsddgTYsORdG2gZSA=; b=L3hdMollO1dqMIW0bNM7DbkhQl3r7b2e49FC9ZEKmYYOH2hg45WRfejiIWt7qZp2e5 pDfgRqOpontgCFo6zxMjmZzByiOitks86NEAje/VIYfkge3pDbms7yh9URajQ0X1ntiP eGwOrE7kxr820WUZetIRTjkJbyO9ayQO17qFn5LQTN+RFncpsa00/kqy7B/CRXXWGvBO PgbXV+NqdxkmNrywNWls7ytcBLdtV9uDeQw/4FwGKKLufTNuFtYm2IjmV2nhFkm+Jkz/ 0wObFbP0yL6L/ce47SjKiKS9jIMzXeGimyajcEYRxMlQqGXmz5COgMqCAd9VGV/+FOOO fajw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=m2rSP0/Vtb4ZeWdWUsfinHhFVnzsddgTYsORdG2gZSA=; b=Pb0nfmHS2SP7SaHBCFhE5uv0UNJmrV28AX0mAwY3cKZIVKGc3Jedcc8oqUExyCKOgd OOnGLQly/1FT2iL4AxRszSI3mYiCDWM1iDsrnXEGkWj2UfjHPuruTeMxU3gwNR82/zGp QuhuPQtgti+5Taul+gq0NwKj+fyDEpOpJ6c4dGhehafxvaHYe64CIrZwhxL0OZmo3i4W kJYxwNywVWL+gH4AfiGdePNkoEwwuddalYhCv87xCAH5N+NmQM2zGBjyGZgLtrA0jya1 qehZ/kCh27QLX+ThSBH/6CUFhh/p8/9n1nnwBL3YmfeO9hmJrfBPHnKaVh1I0tVHHace GlyQ== X-Gm-Message-State: ALoCoQmvpu07c+Kp6r0yDr1JyNFtpr6YLDQDiItd8pE6s9VQWqPHSB3R3KLEXyTDFs2H+ZnOH2pecwCK0GbEDvB1TNsf+7the4TcfAg8TN5Iq/OiCv1tDFAujPOZsmjh1kNT30SgHMFYl/NmcXBn5hrdL25J9lFgzyx8mwk76SmIuyGoE5zvPgrd5S4qohywSDD8eF9GXZ2EpCnUVdz1UM96bbSzih0LOg== X-Received: by 10.50.13.8 with SMTP id d8mr1480035igc.46.1377205385689; Thu, 22 Aug 2013 14:03:05 -0700 (PDT) Received: from google.com ([172.29.122.86]) by mx.google.com with ESMTPSA id ka5sm21609975igb.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 22 Aug 2013 14:03:04 -0700 (PDT) Date: Thu, 22 Aug 2013 15:03:01 -0600 From: Bjorn Helgaas To: Yijing Wang Cc: linux-pci@vger.kernel.org, Hanjun Guo , jiang.liu@huawei.com, ebiederm@xmission.com Subject: Re: [PATCH] PCI: use msi/x_set_enable() to simplify pci_msi_off() Message-ID: <20130822210301.GA1626@google.com> References: <1375962969-34824-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1375962969-34824-1-git-send-email-wangyijing@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 [+cc Eric] On Thu, Aug 08, 2013 at 07:56:09PM +0800, Yijing Wang wrote: > Move pci_msi_off() to driver/pci/msi.c and use msi_set_enable() > and msix_set_enable() to simplify pci_msi_off() function code. I was about to apply this, but there are callers that use pci_msi_off() even when CONFIG_PCI_MSI=n, so I don't think we can do this. I think I'll apply the attached patch instead. > Signed-off-by: Yijing Wang > --- > drivers/pci/msi.c | 17 +++++++++++++++++ > drivers/pci/pci.c | 28 ---------------------------- > 2 files changed, 17 insertions(+), 28 deletions(-) > > diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c > index aca7578..080d14f 100644 > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -1002,6 +1002,23 @@ void pci_disable_msix(struct pci_dev *dev) > EXPORT_SYMBOL(pci_disable_msix); > > /** > + * pci_msi_off - disables any msi or msix capabilities > + * @dev: the PCI device to operate on > + * > + * If you want to use msi see pci_enable_msi and friends. > + * This is a lower level primitive that allows us to disable > + * msi operation at the device level. > + */ > +void pci_msi_off(struct pci_dev *dev) > +{ > + if (dev->msi_cap) > + msi_set_enable(dev, 0); > + if (dev->msix_cap) > + msix_set_enable(dev, 0); > +} > +EXPORT_SYMBOL_GPL(pci_msi_off); > + > +/** > * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state > * @dev: pointer to the pci_dev data structure of MSI(X) device function > * > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index e37fea6..6975f2a 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -3058,34 +3058,6 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev) > } > EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx); > > -/** > - * pci_msi_off - disables any msi or msix capabilities > - * @dev: the PCI device to operate on > - * > - * If you want to use msi see pci_enable_msi and friends. > - * This is a lower level primitive that allows us to disable > - * msi operation at the device level. > - */ > -void pci_msi_off(struct pci_dev *dev) > -{ > - int pos; > - u16 control; > - > - pos = pci_find_capability(dev, PCI_CAP_ID_MSI); > - if (pos) { > - pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); > - control &= ~PCI_MSI_FLAGS_ENABLE; > - pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); > - } > - pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); > - if (pos) { > - pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); > - control &= ~PCI_MSIX_FLAGS_ENABLE; > - pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); > - } > -} > -EXPORT_SYMBOL_GPL(pci_msi_off); > - > int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size) > { > return dma_set_max_seg_size(&dev->dev, size); > -- > 1.7.1 PCI: Add comment about needing pci_msi_off() even when CONFIG_PCI_MSI=n From: Bjorn Helgaas Per f5f2b13129 ("msi: sanely support hardware level msi disabling"), we want pci_msi_off() to work even if MSI support is not compiled into the kernel, and there are existing callers that use it when CONFIG_PCI_MSI=n. This adds a comment to that effect. No functional change. Signed-off-by: Bjorn Helgaas --- drivers/pci/pci.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 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/pci.c b/drivers/pci/pci.c index 69dcd32..42e5f86 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3059,18 +3059,23 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev) EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx); /** - * pci_msi_off - disables any msi or msix capabilities + * pci_msi_off - disables any MSI or MSI-X capabilities * @dev: the PCI device to operate on * - * If you want to use msi see pci_enable_msi and friends. - * This is a lower level primitive that allows us to disable - * msi operation at the device level. + * If you want to use MSI, see pci_enable_msi() and friends. + * This is a lower-level primitive that allows us to disable + * MSI operation at the device level. */ void pci_msi_off(struct pci_dev *dev) { int pos; u16 control; + /* + * This looks like it could go in msi.c, but we need it even when + * CONFIG_PCI_MSI=n. For the same reason, we can't use + * dev->msi_cap or dev->msix_cap here. + */ pos = pci_find_capability(dev, PCI_CAP_ID_MSI); if (pos) { pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control);