From nobody Mon Apr 29 12:54:45 2024 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 1500470791304488.68881554249197; Wed, 19 Jul 2017 06:26:31 -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 1dXosE-0004eY-OW; Wed, 19 Jul 2017 15:18:42 +0200 Received: from mail-lf0-f65.google.com ([209.85.215.65]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1dXos3-0004dQ-QV for seabios@seabios.org; Wed, 19 Jul 2017 15:18:38 +0200 Received: by mail-lf0-f65.google.com with SMTP id p11so4292622lfd.1 for ; Wed, 19 Jul 2017 06:20:26 -0700 (PDT) Received: from zuban32-isp.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.gmail.com with ESMTPSA id 62sm6826lfz.20.2017.07.19.06.20.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jul 2017 06:20:23 -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=hXT/RcM25hb7HQyY+MfGQuIQ/PhxWfwZ8gW2c/ejC6M=; b=r66H96KqepMsVEthzS6DK63a6c33w9LAcskuggKAmPBXGJ704wu3Dkv0g7TKu7XT9D tQLTyCNOUNDf7m4lP2OA6X15v0cdZ3v483vgC7OjJOuFKkEoyuQWzMrgLa578jkNXw1g h4CFzh/TaKKA5B6+vvDDDJRIqmU7hNE+MGhwdeMbBC92gf3wTk04JPWIunoqhZW5mxbk R+YzPUE+x4eJGImzuOfIm8xjPSc9KFZaL79DmXZh/5j2GVMV6oRByMdFtVHnU9iKqGuN Uo7ntWBP0fIXW0Eu0JZMiW0oP2x94UpBbyQtsW9ytrUADalxcDFMM29Px22vvm463Jdf quvg== 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=hXT/RcM25hb7HQyY+MfGQuIQ/PhxWfwZ8gW2c/ejC6M=; b=kjFtvZNLdPBY8v5Z6Q4dgNbAn1sYHOhikiNhrMiSg7nynbYZ97jUZnAnqIboQTeElQ V+q4XENLUvAbZh+PxL05CU6//k1Kc7WESB8zi6Ykf7QF8vx8lZThQc5EmkNEWzPGlsYH 2/6wVM18Q0KbZzAZuZineJENfmIYJSjeLBQDGPJIOj/jIt87Yn4Fruk0WEdg7GpK2d2w 5E6B6ssinCWHjlT1S3u9Cxut6aG8CUkRxZyPgFbRt0tr+vfQvpr3k5BgLwrCaSVkrY7n Wz9wvJAbNPOCytKDk8FiQdJ71eTYf/BT1jI5PzM4iY78MErL1JFS7VxXmMXKVBUehMsX WNaA== X-Gm-Message-State: AIVw1129M9TVFd0TIm74mMmQfnoTBZSfGzmzzGC4QpwPAxxbsGXeNAxa 6R0lTlHp03AsncUc X-Received: by 10.46.82.142 with SMTP id n14mr33086lje.0.1500470424481; Wed, 19 Jul 2017 06:20:24 -0700 (PDT) From: Aleksandr Bezzubikov To: seabios@seabios.org Date: Wed, 19 Jul 2017 16:20:13 +0300 Message-Id: <1500470414-7911-2-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500470414-7911-1-git-send-email-zuban32s@gmail.com> References: <1500470414-7911-1-git-send-email-zuban32s@gmail.com> X-Spam-Score: -3.0 (---) Subject: [SeaBIOS] [RFC PATCH 1/2] pci: add support for direct usage of bdf for capability lookup 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: marcel@redhat.com, qemu-devel@nongnu.org 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" Add a capability lookup function which gets bdf instead of pci_device as its first argument. It may be useful when we have bdf, but don't have the whole pci_device structure. Signed-off-by: Aleksandr Bezzubikov --- src/hw/pcidevice.c | 24 ++++++++++++++++++++++++ src/hw/pcidevice.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/hw/pcidevice.c b/src/hw/pcidevice.c index cfebf66..3fa240e 100644 --- a/src/hw/pcidevice.c +++ b/src/hw/pcidevice.c @@ -158,6 +158,30 @@ u8 pci_find_capability(struct pci_device *pci, u8 cap_= id, u8 cap) return 0; } =20 +u8 pci_find_capability_bdf(int bdf, u8 cap_id, u8 cap) +{ + int i; + u16 status =3D pci_config_readw(bdf, PCI_STATUS); + + if (!(status & PCI_STATUS_CAP_LIST)) + return 0; + + if (cap =3D=3D 0) { + /* find first */ + cap =3D pci_config_readb(bdf, PCI_CAPABILITY_LIST); + } else { + /* find 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(bdf, cap + PCI_CAP_LIST_ID) =3D=3D cap_id) + return cap; + cap =3D pci_config_readb(bdf, cap + PCI_CAP_LIST_NEXT); + } + + return 0; +} + // Enable PCI bus-mastering (ie, DMA) support on a pci device void pci_enable_busmaster(struct pci_device *pci) diff --git a/src/hw/pcidevice.h b/src/hw/pcidevice.h index 354b549..e4ed5cf 100644 --- a/src/hw/pcidevice.h +++ b/src/hw/pcidevice.h @@ -70,6 +70,7 @@ int pci_init_device(const struct pci_device_id *ids 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_bdf(int 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); --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Mon Apr 29 12:54:45 2024 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 1500470465960959.9639078650619; Wed, 19 Jul 2017 06:21:05 -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 1dXosL-0004gs-1O; Wed, 19 Jul 2017 15:18:49 +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 1dXos4-0004dS-Vq for seabios@seabios.org; Wed, 19 Jul 2017 15:18:44 +0200 Received: by mail-lf0-f68.google.com with SMTP id p11so4292650lfd.1 for ; Wed, 19 Jul 2017 06:20:27 -0700 (PDT) Received: from zuban32-isp.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.gmail.com with ESMTPSA id 62sm6826lfz.20.2017.07.19.06.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jul 2017 06:20:24 -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=m759tikvzbmSTciKP72VDICgSiqKngbEySkWB6wqQKE=; b=ri9euXakhi5fMLKyBik++GRo/e/i0b227mANF1tpDnQ5gRFiLuSDckF81BvnVqkUm5 qeg1HZu/SynSyMMhSZdMaE0FTC6QfmseLoeFrtV2SS321sqQt9a3+gzLX+dw5DczBJzc JRdFFaKH5yOEcBBGXvqBwiwJRnfPI0pFMROA1oox4YgriSNBRjwM/anNhGXnST6Wj/TJ H7ClyI0EPpmWv9vqzUaApTM8Z2tidtMz8aDHLw3XOzHqGPEcGY/zp2EtsRqWGpPmG1vM +rJAQ8Qar8I4CKDY3pzaqEh0hgMAKUILOtTWm/zUrMuGHtP08/sjwjjbWh4VJzgu+teA 6J/Q== 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=m759tikvzbmSTciKP72VDICgSiqKngbEySkWB6wqQKE=; b=kxu/jE10wuqLg+zhiZ93yi4EzLXSJGYELp7Q0nAuk6ANYCsNviXcP9z97JHTFxKnw9 FlCujAnckiD9JapBUAabFquMCcXiNJA4ysirVjk0YYYRoqv8mg7YBcF9Weroigqw3qEm W6thQEz9bYxwb88vVsa9evOuRVCpQnh9Wef5bvemOtfIhGYfIwsUseX9oe+GoX80MoMO V6NW5b0fXaV3wrzGXEB5NMGds4SJvCo3GCl0kh8tIrG1oXQBAf9yiZVvo3/olXvwRMIG GyoEg1jGD6fpeahGa5+qVD9xrZ/5ufoYJ6n3T3ngf2oUfQlmW3TQnCjtYOI0FVfeOQAu A9eQ== X-Gm-Message-State: AIVw112ZXtt/MAktWOksJAaudpH7UQhBHd4CwZ6cn0D4eYag8vbl20zh 2IRTN/5eBy6Ps0c6 X-Received: by 10.25.170.3 with SMTP id t3mr18480lfe.51.1500470425604; Wed, 19 Jul 2017 06:20:25 -0700 (PDT) From: Aleksandr Bezzubikov To: seabios@seabios.org Date: Wed, 19 Jul 2017 16:20:14 +0300 Message-Id: <1500470414-7911-3-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500470414-7911-1-git-send-email-zuban32s@gmail.com> References: <1500470414-7911-1-git-send-email-zuban32s@gmail.com> X-Spam-Score: -2.7 (--) Subject: [SeaBIOS] [RFC PATCH 2/2] pci: enable RedHat pci bridges to reserve more buses 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: marcel@redhat.com, qemu-devel@nongnu.org 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" In case of RedHat PCI bridges reserve additional buses, which number is pro= vided in a vendor-specific capability. Signed-off-by: Aleksandr Bezzubikov --- src/fw/pciinit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 08221e6..b6f3a01 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -578,9 +578,17 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus) pci_bios_init_bus_rec(secbus, pci_bus); =20 if (subbus !=3D *pci_bus) { + u16 vendor =3D pci_config_readw(bdf, PCI_VENDOR_ID); + u8 res_bus =3D 0; + if (vendor =3D=3D 0x1b36) { + u8 cap =3D pci_find_capability_bdf(bdf, PCI_CAP_ID_VNDR, 0= ); + if (cap) { + res_bus =3D pci_config_readb(bdf, cap + 16); + } + } dprintf(1, "PCI: subordinate bus =3D 0x%x -> 0x%x\n", - subbus, *pci_bus); - subbus =3D *pci_bus; + subbus, *pci_bus + res_bus); + subbus =3D *pci_bus + res_bus; } else { dprintf(1, "PCI: subordinate bus =3D 0x%x\n", subbus); } --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios