From: Jon Derrick <jonathan.derrick@intel.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>, <linux-pci@vger.kernel.org>,
Pawel Baldysiak <pawel.baldysiak@intel.com>,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>,
Keith Busch <keith.busch@intel.com>,
Dave Fugate <david.fugate@intel.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH 1/3] PCI: vmd: Add helpers to access device config space
Date: Wed, 16 Oct 2019 11:04:46 -0600 [thread overview]
Message-ID: <1571245488-3549-2-git-send-email-jonathan.derrick@intel.com> (raw)
In-Reply-To: <1571245488-3549-1-git-send-email-jonathan.derrick@intel.com>
This patch adds helpers to access child device config space. It uses the
fabric-view of the bus number, which requires the pci accessors to
translate out the starting bus number. This will allow internal code to
access child device config space without a struct pci_bus while minding
the accessing rules.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pci/controller/vmd.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index a35d3f3..959c7c7 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -440,12 +440,10 @@ static void vmd_setup_dma_ops(struct vmd_dev *vmd)
}
#undef ASSIGN_VMD_DMA_OPS
-static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
+static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, unsigned char busn,
unsigned int devfn, int reg, int len)
{
- char __iomem *addr = vmd->cfgbar +
- ((bus->number - vmd->busn_start) << 20) +
- (devfn << 12) + reg;
+ char __iomem *addr = vmd->cfgbar + (busn << 20) + (devfn << 12) + reg;
if ((addr - vmd->cfgbar) + len >=
resource_size(&vmd->dev->resource[VMD_CFGBAR]))
@@ -458,11 +456,10 @@ static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
* CPU may deadlock if config space is not serialized on some versions of this
* hardware, so all config space access is done under a spinlock.
*/
-static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
- int len, u32 *value)
+static int vmd_cfg_read(struct vmd_dev *vmd, unsigned char busn,
+ unsigned int devfn, int reg, int len, u32 *value)
{
- struct vmd_dev *vmd = vmd_from_bus(bus);
- char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+ char __iomem *addr = vmd_cfg_addr(vmd, busn, devfn, reg, len);
unsigned long flags;
int ret = 0;
@@ -488,16 +485,23 @@ static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
return ret;
}
+static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,
+ int len, u32 *value)
+{
+ struct vmd_dev *vmd = vmd_from_bus(bus);
+ return vmd_cfg_read(vmd, bus->number - vmd->busn_start, devfn,
+ reg, len, value);
+}
+
/*
* VMD h/w converts non-posted config writes to posted memory writes. The
* read-back in this function forces the completion so it returns only after
* the config space was written, as expected.
*/
-static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
- int len, u32 value)
+static int vmd_cfg_write(struct vmd_dev *vmd, unsigned char busn,
+ unsigned int devfn, int reg, int len, u32 value)
{
- struct vmd_dev *vmd = vmd_from_bus(bus);
- char __iomem *addr = vmd_cfg_addr(vmd, bus, devfn, reg, len);
+ char __iomem *addr = vmd_cfg_addr(vmd, busn, devfn, reg, len);
unsigned long flags;
int ret = 0;
@@ -526,6 +530,14 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
return ret;
}
+static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
+ int len, u32 value)
+{
+ struct vmd_dev *vmd = vmd_from_bus(bus);
+ return vmd_cfg_write(vmd, bus->number - vmd->busn_start, devfn,
+ reg, len, value);
+}
+
static struct pci_ops vmd_ops = {
.read = vmd_pci_read,
.write = vmd_pci_write,
--
1.8.3.1
next prev parent reply other threads:[~2019-10-16 23:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 17:04 [PATCH 0/3] Expose VMD BIOS domain info Jon Derrick
2019-10-16 17:04 ` Jon Derrick [this message]
2019-10-16 17:04 ` [PATCH 2/3] PCI: vmd: Expose VMD details from BIOS Jon Derrick
2019-10-31 11:37 ` Lorenzo Pieralisi
2019-11-01 13:16 ` Andrew Murray
2019-11-01 14:24 ` Derrick, Jonathan
2019-11-01 14:44 ` Andrew Murray
2019-11-01 21:53 ` Bjorn Helgaas
2019-11-01 22:16 ` Derrick, Jonathan
2019-11-04 18:07 ` Lorenzo Pieralisi
2019-11-05 10:12 ` Lorenzo Pieralisi
2019-11-05 21:32 ` Derrick, Jonathan
2019-11-05 22:22 ` Keith Busch
2019-11-05 22:38 ` Derrick, Jonathan
2019-11-05 22:45 ` Keith Busch
2020-01-27 10:38 ` Lorenzo Pieralisi
2020-01-27 23:48 ` Derrick, Jonathan
2019-10-16 17:04 ` [PATCH 3/3] PCI: vmd: Restore domain info during resets/unloads Jon Derrick
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=1571245488-3549-2-git-send-email-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=artur.paszkiewicz@intel.com \
--cc=david.fugate@intel.com \
--cc=helgaas@kernel.org \
--cc=keith.busch@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=pawel.baldysiak@intel.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;
as well as URLs for NNTP newsgroup(s).