From nobody Mon Feb 9 07:55:49 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1563545336; cv=none; d=zoho.com; s=zohoarc; b=NbATNeSjZDi4SF0IUIvP7zZLXKHXq0gjgqItJCvdXeL+GHW9jqq3QU/59VYbYDkrcSgUnpG28mmMzd7xyQc6OIYJuPssHvNo+TNyh/Ne9eiZ0418f1bcH4AEj8NaUH6NNQ7lezbYXz15b2xnwoBRiHo+2lZoRccKt0V9N1A6W54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563545336; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=McqU/TEisjMam+WE/kQljt2tBfkAjct0qkZnARqqiHQ=; b=m81IWVNvB9PuLC5vm7czXPUwklA8+ip0+ZMqfSxxl2E2tYXfciCoa+XlatZssmyYaVAKYFz5CehK/QFfQNWWrWFx44RORkgbS8idRkiCgWKLSTORd+FDuzUztEZMBozD7LK3fTaLqS67+ktyuu2oDwh1KllMC31zQwQFvh1t2Rc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1563545336423441.9652069148025; Fri, 19 Jul 2019 07:08:56 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hoTY3-00071F-Ve; Fri, 19 Jul 2019 14:07:47 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hoTY2-000709-Nn for xen-devel@lists.xenproject.org; Fri, 19 Jul 2019 14:07:46 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 94b0d2b8-aa2e-11e9-8980-bc764e045a96; Fri, 19 Jul 2019 14:07:45 +0000 (UTC) X-Inumbo-ID: 94b0d2b8-aa2e-11e9-8980-bc764e045a96 Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: SArjAQm2scj5/fNtMF0U1KBH1bRCp/MED2arw0ZWVqR3DBZ5oaniP8n1hIeS5LiQLe/GwaDi7d AahvhbF6MJCR48l2wdy56Dsm7PYzaX+8DM/VdMh8qQdtFfd7iP5FZQY06uvLJf/22rzMWpSJfD 15Xb4aHk176+I/uyxWuMGxb5BtCWVibw0b4czx81tXALgXZRRi2qiqkKWHTNdwPAhOxGRPKZWE +bG2FcKi1BbFdNLAQ21TcV1Nqd5NlDaj+68qYrVQi9Bvv1xm8SIo97FW1vLpwqQuHgau5IDYwV qZY= X-SBRS: 2.7 X-MesageID: 3294257 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,282,1559534400"; d="scan'208";a="3294257" From: Roger Pau Monne To: Date: Fri, 19 Jul 2019 16:07:22 +0200 Message-ID: <20190719140724.69596-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190719140724.69596-1-roger.pau@citrix.com> References: <20190719140724.69596-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 4/6] pci: switch pci_conf_write8 to use pci_sbdf_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This reduces the number of parameters of the function to two, and simplifies some of the calling sites. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan --- Changes since v3: - Drop pointless AND-ing by constants. - Remove insertion of stray newline. --- xen/arch/x86/cpu/amd.c | 2 +- xen/arch/x86/x86_64/pci.c | 21 ++++++++------------- xen/drivers/acpi/reboot.c | 5 ++--- xen/drivers/char/ehci-dbgp.c | 8 +++++--- xen/drivers/vpci/vpci.c | 8 +++----- xen/include/xen/pci.h | 4 +--- 6 files changed, 20 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c index 8a40373ddf..f66de362cb 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 =3D=3D 0xFF) break; pmm7 &=3D 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); } =20 -#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 fun= c, - 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); } =20 +#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 fun= c, unsigned int reg, uint16_t data) diff --git a/xen/drivers/acpi/reboot.c b/xen/drivers/acpi/reboot.c index 72d06fd8e5..f6345be874 100644 --- a/xen/drivers/acpi/reboot.c +++ b/xen/drivers/acpi/reboot.c @@ -23,9 +23,8 @@ 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, + rr->address >> 16), (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) =3D=3D 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); } =20 /* 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); } =20 /* 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); } =20 diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 2106255863..b141e57883 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.fn, reg, - data); + pci_conf_write8(sbdf, reg, data); pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, 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.fn, reg, data); - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 2, - data >> 16); + pci_conf_write8(sbdf, reg + 2, data >> 16); } break; =20 @@ -282,7 +280,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int= reg, unsigned int size, break; =20 case 1: - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); + pci_conf_write8(sbdf, reg, data); break; =20 default: diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 6885408687..144cfb2e62 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 fun= c, - 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 fun= c, unsigned int reg, uint16_t data); --=20 2.20.1 (Apple Git-117) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel