mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org,
	Yinghai Lu <yhlu.kernel.send@gmail.com>,
	Yijing Wang <wangyijing@huawei.com>
Subject: Re: [PATCH v5 01/10] pci: export functions for msi/msix ctrl
Date: Thu, 2 Apr 2015 11:31:12 +0800	[thread overview]
Message-ID: <20150402033112.GD15412@fam-t430.nay.redhat.com> (raw)
In-Reply-To: <1427641227-7574-2-git-send-email-mst@redhat.com>

On Sun, 03/29 17:04, Michael S. Tsirkin wrote:
> move pci_msi_set_enable and pci_msix_clear_and_set_ctrl out of msi.c, so
> we can use them will be used which MSI isn't configured in kernel.

if

s/will be used which/when/

then

Reviewed-by: Fam Zheng <famz@redhat.com>
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/pci/pci.h | 21 +++++++++++++++++++++
>  drivers/pci/msi.c | 45 ++++++++++++---------------------------------
>  2 files changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4091f82..17f213d 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -146,6 +146,27 @@ static inline void pci_no_msi(void) { }
>  static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
>  #endif
>  
> +static inline void pci_msi_set_enable(struct pci_dev *dev, int enable)
> +{
> +	u16 control;
> +
> +	pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
> +	control &= ~PCI_MSI_FLAGS_ENABLE;
> +	if (enable)
> +		control |= PCI_MSI_FLAGS_ENABLE;
> +	pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
> +}
> +
> +static inline void pci_msix_clear_and_set_ctrl(struct pci_dev *dev, u16 clear, u16 set)
> +{
> +	u16 ctrl;
> +
> +	pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
> +	ctrl &= ~clear;
> +	ctrl |= set;
> +	pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl);
> +}
> +
>  void pci_realloc_get_opt(char *);
>  
>  static inline int pci_no_d1d2(struct pci_dev *dev)
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index c3e7dfc..9942f68 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -185,27 +185,6 @@ void __weak arch_restore_msi_irqs(struct pci_dev *dev)
>  	return default_restore_msi_irqs(dev);
>  }
>  
> -static void msi_set_enable(struct pci_dev *dev, int enable)
> -{
> -	u16 control;
> -
> -	pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
> -	control &= ~PCI_MSI_FLAGS_ENABLE;
> -	if (enable)
> -		control |= PCI_MSI_FLAGS_ENABLE;
> -	pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
> -}
> -
> -static void msix_clear_and_set_ctrl(struct pci_dev *dev, u16 clear, u16 set)
> -{
> -	u16 ctrl;
> -
> -	pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
> -	ctrl &= ~clear;
> -	ctrl |= set;
> -	pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl);
> -}
> -
>  static inline __attribute_const__ u32 msi_mask(unsigned x)
>  {
>  	/* Don't shift by >= width of type */
> @@ -452,7 +431,7 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
>  	entry = irq_get_msi_desc(dev->irq);
>  
>  	pci_intx_for_msi(dev, 0);
> -	msi_set_enable(dev, 0);
> +	pci_msi_set_enable(dev, 0);
>  	arch_restore_msi_irqs(dev);
>  
>  	pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
> @@ -473,14 +452,14 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
>  
>  	/* route the table */
>  	pci_intx_for_msi(dev, 0);
> -	msix_clear_and_set_ctrl(dev, 0,
> +	pci_msix_clear_and_set_ctrl(dev, 0,
>  				PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
>  
>  	arch_restore_msi_irqs(dev);
>  	list_for_each_entry(entry, &dev->msi_list, list)
>  		msix_mask_irq(entry, entry->masked);
>  
> -	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
> +	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
>  }
>  
>  void pci_restore_msi_state(struct pci_dev *dev)
> @@ -647,7 +626,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
>  	int ret;
>  	unsigned mask;
>  
> -	msi_set_enable(dev, 0);	/* Disable MSI during set up */
> +	pci_msi_set_enable(dev, 0);	/* Disable MSI during set up */
>  
>  	entry = msi_setup_entry(dev, nvec);
>  	if (!entry)
> @@ -683,7 +662,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
>  
>  	/* Set MSI enabled bits	 */
>  	pci_intx_for_msi(dev, 0);
> -	msi_set_enable(dev, 1);
> +	pci_msi_set_enable(dev, 1);
>  	dev->msi_enabled = 1;
>  
>  	dev->irq = entry->irq;
> @@ -775,7 +754,7 @@ static int msix_capability_init(struct pci_dev *dev,
>  	void __iomem *base;
>  
>  	/* Ensure MSI-X is disabled while it is set up */
> -	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
> +	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
>  
>  	pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control);
>  	/* Request & Map MSI-X table region */
> @@ -801,7 +780,7 @@ static int msix_capability_init(struct pci_dev *dev,
>  	 * MSI-X registers.  We need to mask all the vectors to prevent
>  	 * interrupts coming in before they're fully set up.
>  	 */
> -	msix_clear_and_set_ctrl(dev, 0,
> +	pci_msix_clear_and_set_ctrl(dev, 0,
>  				PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE);
>  
>  	msix_program_entries(dev, entries);
> @@ -814,7 +793,7 @@ static int msix_capability_init(struct pci_dev *dev,
>  	pci_intx_for_msi(dev, 0);
>  	dev->msix_enabled = 1;
>  
> -	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
> +	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
>  
>  	return 0;
>  
> @@ -919,7 +898,7 @@ void pci_msi_shutdown(struct pci_dev *dev)
>  	BUG_ON(list_empty(&dev->msi_list));
>  	desc = list_first_entry(&dev->msi_list, struct msi_desc, list);
>  
> -	msi_set_enable(dev, 0);
> +	pci_msi_set_enable(dev, 0);
>  	pci_intx_for_msi(dev, 1);
>  	dev->msi_enabled = 0;
>  
> @@ -1027,7 +1006,7 @@ void pci_msix_shutdown(struct pci_dev *dev)
>  		__pci_msix_desc_mask_irq(entry, 1);
>  	}
>  
> -	msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
> +	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
>  	pci_intx_for_msi(dev, 1);
>  	dev->msix_enabled = 0;
>  }
> @@ -1069,11 +1048,11 @@ void pci_msi_init_pci_dev(struct pci_dev *dev)
>  	 */
>  	dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
>  	if (dev->msi_cap)
> -		msi_set_enable(dev, 0);
> +		pci_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);
> +		pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
>  }
>  
>  /**
> -- 
> MST
> 

  reply	other threads:[~2015-04-02  3:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-29 15:03 [PATCH v5 00/10] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin
2015-03-29 15:04 ` [PATCH v5 01/10] pci: export functions for msi/msix ctrl Michael S. Tsirkin
2015-04-02  3:31   ` Fam Zheng [this message]
2015-03-29 15:04 ` [PATCH v5 02/10] pci: move pci_msi_init_pci_dev to probe.c Michael S. Tsirkin
2015-04-02  3:38   ` Fam Zheng
2015-04-02  5:45     ` Eric W. Biederman
2015-03-29 15:04 ` [PATCH v5 03/10] pci: drop some duplicate code Michael S. Tsirkin
2015-04-02  3:52   ` Fam Zheng
2015-03-29 15:04 ` [PATCH v5 04/10] pci: don't disable msi/msix at shutdown Michael S. Tsirkin
2015-04-02  3:54   ` Fam Zheng
2015-04-10 18:33   ` Bjorn Helgaas
2015-04-12  8:52     ` Michael S. Tsirkin
2015-03-29 15:04 ` [PATCH v5 05/10] pci: make msi/msix shutdown functions static Michael S. Tsirkin
2015-04-02  3:55   ` Fam Zheng
2015-03-29 15:04 ` [PATCH v5 06/10] virtio_pci: drop msi_off on probe Michael S. Tsirkin
2015-04-02  3:55   ` Fam Zheng
2015-03-29 15:04 ` [PATCH v5 07/10] ntb: drop pci_msi_off call " Michael S. Tsirkin
2015-03-29 15:04 ` [PATCH v5 08/10] mic: " Michael S. Tsirkin
2015-03-29 15:04 ` [PATCH v5 09/10] pci: drop pci_msi_off calls from quirks Michael S. Tsirkin
2015-03-29 15:04 ` [PATCH v5 10/10] pci: unexport pci_msi_off Michael S. Tsirkin
2015-04-08 22:16 ` [PATCH v5 00/10] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150402033112.GD15412@fam-t430.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=wangyijing@huawei.com \
    --cc=yhlu.kernel.send@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®