linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>,
	clsoto@us.ibm.com, benh@kernel.crashing.org,
	linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	mpe@ellerman.id.au
Subject: Re: [PATCH v4 5/7] PCI: Remove pci_resource_bar() and pci_iov_resource_bar()
Date: Tue, 29 Nov 2016 16:02:05 +1100	[thread overview]
Message-ID: <20161129050205.GA23115@gwshan> (raw)
In-Reply-To: <20161129041542.21453.14468.stgit@bhelgaas-glaptop.roam.corp.google.com>

On Mon, Nov 28, 2016 at 10:15:42PM -0600, Bjorn Helgaas wrote:
>pci_std_update_resource() only deals with standard BARs, so we don't have
>to worry about the complications of VF BARs in an SR-IOV capability.
>
>Compute the BAR address inline and remove pci_resource_bar().  That makes
>pci_iov_resource_bar() unused, so remove that as well.
>
>Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

>---
> drivers/pci/iov.c       |   18 ------------------
> drivers/pci/pci.c       |   30 ------------------------------
> drivers/pci/pci.h       |    6 ------
> drivers/pci/setup-res.c |   13 +++++++------
> 4 files changed, 7 insertions(+), 60 deletions(-)
>
>diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>index a800ba2..c9c84ba 100644
>--- a/drivers/pci/iov.c
>+++ b/drivers/pci/iov.c
>@@ -554,24 +554,6 @@ void pci_iov_release(struct pci_dev *dev)
> }
>
> /**
>- * pci_iov_resource_bar - get position of the SR-IOV BAR
>- * @dev: the PCI device
>- * @resno: the resource number
>- *
>- * Returns position of the BAR encapsulated in the SR-IOV capability.
>- */
>-int pci_iov_resource_bar(struct pci_dev *dev, int resno)
>-{
>-	if (resno < PCI_IOV_RESOURCES || resno > PCI_IOV_RESOURCE_END)
>-		return 0;
>-
>-	BUG_ON(!dev->is_physfn);
>-
>-	return dev->sriov->pos + PCI_SRIOV_BAR +
>-		4 * (resno - PCI_IOV_RESOURCES);
>-}
>-
>-/**
>  * pci_iov_update_resource - update a VF BAR
>  * @dev: the PCI device
>  * @resno: the resource number
>diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>index 631eac2..ec3f16d 100644
>--- a/drivers/pci/pci.c
>+++ b/drivers/pci/pci.c
>@@ -4827,36 +4827,6 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
> }
> EXPORT_SYMBOL(pci_select_bars);
>
>-/**
>- * pci_resource_bar - get position of the BAR associated with a resource
>- * @dev: the PCI device
>- * @resno: the resource number
>- * @type: the BAR type to be filled in
>- *
>- * Returns BAR position in config space, or 0 if the BAR is invalid.
>- */
>-int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
>-{
>-	int reg;
>-
>-	if (resno < PCI_ROM_RESOURCE) {
>-		*type = pci_bar_unknown;
>-		return PCI_BASE_ADDRESS_0 + 4 * resno;
>-	} else if (resno == PCI_ROM_RESOURCE) {
>-		*type = pci_bar_mem32;
>-		return dev->rom_base_reg;
>-	} else if (resno < PCI_BRIDGE_RESOURCES) {
>-		/* device specific resource */
>-		*type = pci_bar_unknown;
>-		reg = pci_iov_resource_bar(dev, resno);
>-		if (reg)
>-			return reg;
>-	}
>-
>-	dev_err(&dev->dev, "BAR %d: invalid resource\n", resno);
>-	return 0;
>-}
>-
> /* Some architectures require additional programming to enable VGA */
> static arch_set_vga_state_t arch_set_vga_state;
>
>diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>index 5bfcb92..a5d37f6 100644
>--- a/drivers/pci/pci.h
>+++ b/drivers/pci/pci.h
>@@ -245,7 +245,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl,
> int pci_setup_device(struct pci_dev *dev);
> int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
> 		    struct resource *res, unsigned int reg);
>-int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type);
> void pci_configure_ari(struct pci_dev *dev);
> void __pci_bus_size_bridges(struct pci_bus *bus,
> 			struct list_head *realloc_head);
>@@ -289,7 +288,6 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
> #ifdef CONFIG_PCI_IOV
> int pci_iov_init(struct pci_dev *dev);
> void pci_iov_release(struct pci_dev *dev);
>-int pci_iov_resource_bar(struct pci_dev *dev, int resno);
> void pci_iov_update_resource(struct pci_dev *dev, int resno);
> resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
> void pci_restore_iov_state(struct pci_dev *dev);
>@@ -304,10 +302,6 @@ static inline void pci_iov_release(struct pci_dev *dev)
>
> {
> }
>-static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno)
>-{
>-	return 0;
>-}
> static inline void pci_restore_iov_state(struct pci_dev *dev)
> {
> }
>diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
>index ee0be34..09bdff7 100644
>--- a/drivers/pci/setup-res.c
>+++ b/drivers/pci/setup-res.c
>@@ -32,7 +32,6 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
> 	u16 cmd;
> 	u32 new, check, mask;
> 	int reg;
>-	enum pci_bar_type type;
> 	struct resource *res = dev->resource + resno;
>
> 	/* Per SR-IOV spec 3.4.1.11, VF BARs are RO zero */
>@@ -65,14 +64,16 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
> 	else
> 		mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
>
>-	reg = pci_resource_bar(dev, resno, &type);
>-	if (!reg)
>-		return;
>-	if (type != pci_bar_unknown) {
>+	if (resno < PCI_ROM_RESOURCE) {
>+		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
>+	} else if (resno == PCI_ROM_RESOURCE) {
> 		if (!(res->flags & IORESOURCE_ROM_ENABLE))
> 			return;
>+
>+		reg = dev->rom_base_reg;
> 		new |= PCI_ROM_ADDRESS_ENABLE;
>-	}
>+	} else
>+		return;
>
> 	/*
> 	 * We can't update a 64-bit BAR atomically, so when possible,
>

  reply	other threads:[~2016-11-29  5:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  4:13 [PATCH v4 0/7] Disable VF's memory space on updating IOV BARs Bjorn Helgaas
2016-11-29  4:14 ` [PATCH v4 1/7] PCI: Do any VF BAR updates before enabling the BARs Bjorn Helgaas
2016-11-29  4:14 ` [PATCH v4 2/7] PCI: Ignore BAR updates on virtual functions Bjorn Helgaas
2016-11-29  4:45   ` Gavin Shan
2016-11-29  4:15 ` [PATCH v4 3/7] PCI: Separate VF BAR updates from standard BAR updates Bjorn Helgaas
2016-11-29  4:55   ` Gavin Shan
2016-11-29 14:48     ` Bjorn Helgaas
2016-11-29 23:20       ` Gavin Shan
2016-11-30  0:06         ` Bjorn Helgaas
2016-11-30 23:02           ` Gavin Shan
2016-11-30 23:45             ` Bjorn Helgaas
2016-12-01  0:00               ` Gavin Shan
2016-11-29  4:15 ` [PATCH v4 4/7] PCI: Don't update VF BARs while VF memory space is enabled Bjorn Helgaas
2016-11-29  4:57   ` Gavin Shan
2016-11-30 17:56   ` David Laight
2016-11-30 18:52     ` Bjorn Helgaas
2016-11-29  4:15 ` [PATCH v4 5/7] PCI: Remove pci_resource_bar() and pci_iov_resource_bar() Bjorn Helgaas
2016-11-29  5:02   ` Gavin Shan [this message]
2016-11-29  4:16 ` [PATCH v4 6/7] PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE Bjorn Helgaas
2016-11-29  5:03   ` Gavin Shan
2016-11-29  4:16 ` [PATCH v4 7/7] PCI: Add comments about ROM BAR updating Bjorn Helgaas
2016-11-29  5:05   ` Gavin Shan
2016-12-01 22:21 ` [PATCH v4 0/7] Disable VF's memory space on updating IOV BARs Bjorn Helgaas

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=20161129050205.GA23115@gwshan \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=clsoto@us.ibm.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /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;
as well as URLs for NNTP newsgroup(s).