All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v2 09/12] pci: switch pci_conf_write8 to use pci_sbdf_t
Date: Thu, 6 Jun 2019 11:01:43 +0200	[thread overview]
Message-ID: <20190606090146.77381-10-roger.pau@citrix.com> (raw)
In-Reply-To: <20190606090146.77381-1-roger.pau@citrix.com>

This reduces the number of parameters of the function to two, and
simplifies some of the calling sites.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
---
 xen/arch/x86/cpu/amd.c       |  2 +-
 xen/arch/x86/x86_64/pci.c    | 21 ++++++++-------------
 xen/drivers/acpi/reboot.c    |  6 +++---
 xen/drivers/char/ehci-dbgp.c |  8 +++++---
 xen/drivers/vpci/vpci.c      |  8 +++-----
 xen/include/xen/pci.h        |  4 +---
 6 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index c461a3f3c9..e0530e7265 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -426,7 +426,7 @@ static void disable_c1_ramping(void)
 		if (pmm7 == 0xFF)
 			break;
 		pmm7 &= 0xFC; /* clear pmm7[1:0] */
-		pci_conf_write8(0, 0, 0x18 + node, 0x3, 0x87, pmm7);
+		pci_conf_write8(PCI_SBDF(0, 0, 0x18 + node, 3), 0x87, pmm7);
 		printk ("AMD: Disabling C1 Clock Ramping Node #%x\n", node);
 	}
 }
diff --git a/xen/arch/x86/x86_64/pci.c b/xen/arch/x86/x86_64/pci.c
index b8b82a6fe7..eaa67b04f2 100644
--- a/xen/arch/x86/x86_64/pci.c
+++ b/xen/arch/x86/x86_64/pci.c
@@ -50,23 +50,18 @@ uint32_t pci_conf_read32(pci_sbdf_t sbdf, unsigned int reg)
     return pci_conf_read(PCI_CONF_ADDRESS(sbdf, reg), 0, 4);
 }
 
-#undef PCI_CONF_ADDRESS
-#define PCI_CONF_ADDRESS(bus, dev, func, reg) \
-    (0x80000000 | (bus << 16) | (dev << 11) | (func << 8) | (reg & ~3))
-
-void pci_conf_write8(
-    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
-    unsigned int reg, uint8_t data)
+void pci_conf_write8(pci_sbdf_t sbdf, unsigned int reg, uint8_t data)
 {
-    if ( seg || reg > 255 )
-        pci_mmcfg_write(seg, bus, PCI_DEVFN(dev, func), reg, 1, data);
+    if ( sbdf.seg || reg > 255 )
+        pci_mmcfg_write(sbdf.seg, sbdf.bus, sbdf.devfn, reg, 1, data);
     else
-    {
-        BUG_ON((bus > 255) || (dev > 31) || (func > 7));
-        pci_conf_write(PCI_CONF_ADDRESS(bus, dev, func, reg), reg & 3, 1, data);
-    }
+        pci_conf_write(PCI_CONF_ADDRESS(sbdf, reg), reg & 3, 1, data);
 }
 
+#undef PCI_CONF_ADDRESS
+#define PCI_CONF_ADDRESS(bus, dev, func, reg) \
+    (0x80000000 | (bus << 16) | (dev << 11) | (func << 8) | (reg & ~3))
+
 void pci_conf_write16(
     unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
     unsigned int reg, uint16_t data)
diff --git a/xen/drivers/acpi/reboot.c b/xen/drivers/acpi/reboot.c
index 72d06fd8e5..04dac4fe7d 100644
--- a/xen/drivers/acpi/reboot.c
+++ b/xen/drivers/acpi/reboot.c
@@ -23,9 +23,9 @@ void acpi_reboot(void)
 	case ACPI_ADR_SPACE_PCI_CONFIG:
 		printk("Resetting with ACPI PCI RESET_REG.\n");
 		/* Write the value that resets us. */
-		pci_conf_write8(0, 0,
-				(rr->address >> 32) & 31,
-				(rr->address >> 16) & 7,
+		pci_conf_write8(PCI_SBDF(0, 0,
+					 (rr->address >> 32) & 31,
+					 (rr->address >> 16) & 7),
 				(rr->address & 255),
 				reset_value);
 		break;
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 9b9025fb33..010fc3c5bc 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1048,7 +1048,8 @@ static void ehci_dbgp_bios_handoff(struct ehci_dbgp *dbgp, u32 hcc_params)
     if ( (cap & 0xff) == 1 && (cap & EHCI_USBLEGSUP_BIOS) )
     {
         dbgp_printk("dbgp: BIOS handoff\n");
-        pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func, offset + 3, 1);
+        pci_conf_write8(PCI_SBDF(0, dbgp->bus, dbgp->slot, dbgp->func),
+                        offset + 3, 1);
     }
 
     /* if boot firmware now owns EHCI, spin till it hands it over. */
@@ -1066,11 +1067,12 @@ static void ehci_dbgp_bios_handoff(struct ehci_dbgp *dbgp, u32 hcc_params)
         /* well, possibly buggy BIOS... try to shut it down,
          * and hope nothing goes too wrong */
         dbgp_printk("dbgp: BIOS handoff failed: %08x\n", cap);
-        pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func, offset + 2, 0);
+        pci_conf_write8(PCI_SBDF(0, dbgp->bus, dbgp->slot, dbgp->func),
+                        offset + 2, 0);
     }
 
     /* just in case, always disable EHCI SMIs */
-    pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func,
+    pci_conf_write8(PCI_SBDF(0, dbgp->bus, dbgp->slot, dbgp->func),
                     offset + EHCI_USBLEGCTLSTS, 0);
 }
 
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 9969b85b4f..b9aaa11142 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -263,8 +263,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
          */
         if ( reg & 1 )
         {
-            pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg,
-                            data);
+            pci_conf_write8(sbdf, reg, data);
             pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 1,
                              data >> 8);
         }
@@ -272,8 +271,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         {
             pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg,
                              data);
-            pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 2,
-                            data >> 16);
+            pci_conf_write8(sbdf, reg + 2, data >> 16);
         }
         break;
 
@@ -282,7 +280,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         break;
 
     case 1:
-        pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data);
+        pci_conf_write8(sbdf, reg, data);
         break;
 
     default:
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index 78a3985f0f..fdea7b307d 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -175,9 +175,7 @@ void pci_check_disable_device(u16 seg, u8 bus, u8 devfn);
 uint8_t pci_conf_read8(pci_sbdf_t sbdf, unsigned int reg);
 uint16_t pci_conf_read16(pci_sbdf_t sbdf, unsigned int reg);
 uint32_t pci_conf_read32(pci_sbdf_t sbdf, unsigned int reg);
-void pci_conf_write8(
-    unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
-    unsigned int reg, uint8_t data);
+void pci_conf_write8(pci_sbdf_t sbdf, unsigned int reg, uint8_t data);
 void pci_conf_write16(
     unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func,
     unsigned int reg, uint16_t data);
-- 
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-06-06  9:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06  9:01 [Xen-devel] [PATCH v2 00/12] pci: expand usage of pci_sbdf_t Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 01/12] pci: introduce a devfn field to pci_sbdf_t Roger Pau Monne
2019-06-06  9:50   ` Paul Durrant
2019-06-06 10:09     ` Jan Beulich
2019-06-06 10:13       ` Roger Pau Monné
2019-06-06 10:22         ` Jan Beulich
2019-06-06 10:28           ` Roger Pau Monné
2019-06-06 10:11     ` Roger Pau Monné
2019-06-06 12:34   ` Jan Beulich
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 02/12] pci: introduce a pci_sbdf_t field to pci_dev Roger Pau Monne
2019-06-06  9:52   ` Paul Durrant
2019-06-06 12:37   ` Jan Beulich
2019-06-06 14:54     ` Roger Pau Monné
2019-06-06 15:03       ` Jan Beulich
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 03/12] pci: make PCI_SBDF return a pci_sbdf_t Roger Pau Monne
2019-06-06 11:11   ` Paul Durrant
2019-06-06 11:19     ` Paul Durrant
2019-06-06 11:31       ` Jan Beulich
2019-06-06 11:37         ` Paul Durrant
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 04/12] pci: make PCI_SBDF2 " Roger Pau Monne
2019-06-06 11:22   ` Paul Durrant
2019-06-06 16:27     ` Roger Pau Monné
2019-06-06 16:28       ` Paul Durrant
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 05/12] pci: make PCI_SBDF3 " Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 06/12] pci: switch pci_conf_read8 to use pci_sbdf_t Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 07/12] pci: switch pci_conf_read16 " Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 08/12] pci: switch pci_conf_read32 " Roger Pau Monne
2019-06-06  9:01 ` Roger Pau Monne [this message]
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 10/12] pci: switch pci_conf_write16 " Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 11/12] pci: switch pci_conf_write32 " Roger Pau Monne
2019-06-06  9:01 ` [Xen-devel] [PATCH v2 12/12] print: introduce a format specifier for pci_sbdf_t Roger Pau Monne

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=20190606090146.77381-10-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.