From nobody Sat May 10 07:07:14 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1500761565675127.11236854338631; Sat, 22 Jul 2017 15:12:45 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1dZ2bQ-0007uj-Bk; Sun, 23 Jul 2017 00:10:24 +0200 Received: from mail-lf0-f68.google.com ([209.85.215.68]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1dZ2bF-0007sV-Vm for seabios@seabios.org; Sun, 23 Jul 2017 00:10:22 +0200 Received: by mail-lf0-f68.google.com with SMTP id b127so3054405lfb.2 for ; Sat, 22 Jul 2017 15:12:13 -0700 (PDT) Received: from localhost.localdomain (broadband-178-140-16-138.moscow.rt.ru. [178.140.16.138]) by smtp.gmail.com with ESMTPSA id s134sm1604053lfe.27.2017.07.22.15.12.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Jul 2017 15:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CmOZwW4vOVXjo1EUJyHCnxM0Fzt7UWfVLonZFjhFXqg=; b=aJjQ10xIoKi82nx50/XffaBRQbCLrnZiT42U+Ihu5ZUtvb9fM/YNfPtkVIG+vru7BR FREQjBpYadYRJc+E16/nbOSKborl6hNSFsQhYIvypZ/sv8/siFUjHYswKxUzysrQ2x2D AFZM9Umf0cqNAYuSAKNwALFbN+3ehp7QYZ8edTTBL45T25xWdc7tkGntW0cDSrwVLYqk 0VeXlnGaYhMJ8S5yaDI2EelcKHYC9AeNVmKGc1qyBqN0EsnpW2SvN9C+y8Cict3oMg3q bJEL98rnPE0mba9H2Rqbc5lGegNlxDmprhEk1oKQPOdNO7OP4NuFTQXRZ2+LnXQcC09O nOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CmOZwW4vOVXjo1EUJyHCnxM0Fzt7UWfVLonZFjhFXqg=; b=ATRd3ZS0RzMIw5ykrF4em8wq7Yb+9OjUGDJ2Tg6lvepUd04uE9qbrMtiqoAJMpdgiM AYy8sVuTZH5sZgusiCcfXEFa049xd32jnLIbgfwlnO9KlzuPpDaYLNUfYO6wpzkdul6E 5nEA0Zk2YSpzeOBE/Y2oOfKYbNMPnT4+E/0hBYx7kwhbWmF8iud2r+7tQ9X0GaaqzwT4 UmTe053IHHaFNZSlZI8vuPHcvstqAQOA0ZwlGLBxTz51zA4D04W61EVLzcZZfibmw3Jf +2Ah7aIaUkf6vQb14N/tXD2b1fIKpQge0BeYI6lvThrQPNpCQ8nJtvaLniMYppkuEkBa PU/A== X-Gm-Message-State: AIVw112KGRVRUt9yRNdThV8PqvLoR2/ZAHPft/g/dcWG6eO03/8MhoVC lrQfrBvZ5EIuSL13otk= X-Received: by 10.25.28.77 with SMTP id c74mr3258272lfc.32.1500761532066; Sat, 22 Jul 2017 15:12:12 -0700 (PDT) From: Aleksandr Bezzubikov To: seabios@seabios.org Date: Sun, 23 Jul 2017 01:11:47 +0300 Message-Id: <1500761510-1556-2-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500761510-1556-1-git-send-email-zuban32s@gmail.com> References: <1500761510-1556-1-git-send-email-zuban32s@gmail.com> X-Spam-Score: -3.5 (---) Subject: [SeaBIOS] [RFC PATCH v2 1/4] pci: refactor pci_find_capapibilty to get bdf as the first argument instead of the whole pci_device X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: konrad.wilk@oracle.com, mst@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com, marcel@redhat.com, lersek@redhat.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Refactor pci_find_capability function to get bdf instead of a whole pci_device* as the only necessary field for this function=20 is still bdf. It greatly helps when we have bdf but not pci_device. Signed-off-by: Aleksandr Bezzubikov Reviewed-by: Marcel Apfelbaum --- src/fw/pciinit.c | 4 ++-- src/hw/pcidevice.c | 12 ++++++------ src/hw/pcidevice.h | 2 +- src/hw/virtio-pci.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 08221e6..864954f 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -762,7 +762,7 @@ static int pci_bus_hotplug_support(struct pci_bus *bus,= u8 pcie_cap) return downstream_port && slot_implemented; } =20 - shpc_cap =3D pci_find_capability(bus->bus_dev, PCI_CAP_ID_SHPC, 0); + shpc_cap =3D pci_find_capability(bus->bus_dev->bdf, PCI_CAP_ID_SHPC, 0= ); return !!shpc_cap; } =20 @@ -844,7 +844,7 @@ static int pci_bios_check_devices(struct pci_bus *busse= s) */ parent =3D &busses[0]; int type; - u8 pcie_cap =3D pci_find_capability(s->bus_dev, PCI_CAP_ID_EXP, 0); + u8 pcie_cap =3D pci_find_capability(s->bus_dev->bdf, PCI_CAP_ID_EX= P, 0); int hotplug_support =3D pci_bus_hotplug_support(s, pcie_cap); for (type =3D 0; type < PCI_REGION_TYPE_COUNT; type++) { u64 align =3D (type =3D=3D PCI_REGION_TYPE_IO) ? diff --git a/src/hw/pcidevice.c b/src/hw/pcidevice.c index cfebf66..d01e27b 100644 --- a/src/hw/pcidevice.c +++ b/src/hw/pcidevice.c @@ -134,25 +134,25 @@ pci_find_init_device(const struct pci_device_id *ids,= void *arg) return NULL; } =20 -u8 pci_find_capability(struct pci_device *pci, u8 cap_id, u8 cap) +u8 pci_find_capability(u16 bdf, u8 cap_id, u8 cap) { int i; - u16 status =3D pci_config_readw(pci->bdf, PCI_STATUS); + u16 status =3D pci_config_readw(bdf, PCI_STATUS); =20 if (!(status & PCI_STATUS_CAP_LIST)) return 0; =20 if (cap =3D=3D 0) { /* find first */ - cap =3D pci_config_readb(pci->bdf, PCI_CAPABILITY_LIST); + cap =3D pci_config_readb(bdf, PCI_CAPABILITY_LIST); } else { /* find next */ - cap =3D pci_config_readb(pci->bdf, cap + PCI_CAP_LIST_NEXT); + cap =3D pci_config_readb(bdf, cap + PCI_CAP_LIST_NEXT); } for (i =3D 0; cap && i <=3D 0xff; i++) { - if (pci_config_readb(pci->bdf, cap + PCI_CAP_LIST_ID) =3D=3D cap_i= d) + if (pci_config_readb(bdf, cap + PCI_CAP_LIST_ID) =3D=3D cap_id) return cap; - cap =3D pci_config_readb(pci->bdf, cap + PCI_CAP_LIST_NEXT); + cap =3D pci_config_readb(bdf, cap + PCI_CAP_LIST_NEXT); } =20 return 0; diff --git a/src/hw/pcidevice.h b/src/hw/pcidevice.h index 354b549..adcc75a 100644 --- a/src/hw/pcidevice.h +++ b/src/hw/pcidevice.h @@ -69,7 +69,7 @@ int pci_init_device(const struct pci_device_id *ids , struct pci_device *pci, void *arg); struct pci_device *pci_find_init_device(const struct pci_device_id *ids , void *arg); -u8 pci_find_capability(struct pci_device *pci, u8 cap_id, u8 cap); +u8 pci_find_capability(u16 bdf, u8 cap_id, u8 cap); void pci_enable_busmaster(struct pci_device *pci); u16 pci_enable_iobar(struct pci_device *pci, u32 addr); void *pci_enable_membar(struct pci_device *pci, u32 addr); diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c index e5c2c33..4e33033 100644 --- a/src/hw/virtio-pci.c +++ b/src/hw/virtio-pci.c @@ -381,7 +381,7 @@ fail: =20 void vp_init_simple(struct vp_device *vp, struct pci_device *pci) { - u8 cap =3D pci_find_capability(pci, PCI_CAP_ID_VNDR, 0); + u8 cap =3D pci_find_capability(pci->bdf, PCI_CAP_ID_VNDR, 0); struct vp_cap *vp_cap; const char *mode; u32 offset, base, mul; @@ -479,7 +479,7 @@ void vp_init_simple(struct vp_device *vp, struct pci_de= vice *pci) vp_cap->cap, type, vp_cap->bar, addr, offset, mode); } =20 - cap =3D pci_find_capability(pci, PCI_CAP_ID_VNDR, cap); + cap =3D pci_find_capability(pci->bdf, PCI_CAP_ID_VNDR, cap); } =20 if (vp->common.cap && vp->notify.cap && vp->isr.cap && vp->device.cap)= { --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios