From nobody Sat May 10 07:05: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 1501284920875181.42351655390848; Fri, 28 Jul 2017 16:35:20 -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 1dbEkd-0006FR-1p; Sat, 29 Jul 2017 01:32:59 +0200 Received: from mail-lf0-f67.google.com ([209.85.215.67]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1dbEkL-00069k-2t for seabios@seabios.org; Sat, 29 Jul 2017 01:32:56 +0200 Received: by mail-lf0-f67.google.com with SMTP id x16so10946717lfb.4 for ; Fri, 28 Jul 2017 16:34:50 -0700 (PDT) Received: from localhost.localdomain (broadband-95-84-133-8.moscow.rt.ru. [95.84.133.8]) by smtp.gmail.com with ESMTPSA id s133sm2579116lfs.4.2017.07.28.16.34.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Jul 2017 16:34:48 -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=hZyvRCjiiIf2F6dVBk5hTdB46qGz36P2+wsR3JrZudA=; b=tRrYGXrtUQ7nrWvMmmDbIRyN4Nj2hCY9XgGRSYVq9VRAoVypidsiUlpO4km0crC4Zv puG0B9zMGy2TPd4ndYATunJ2+VdKOqCB9rr356zIurhi+T5UYdZNd7T4/VHxt+L3lRsC 3lzNwVU/3A+gl1/echOCgV8kcVYlgiKkYYds3weazGp/la9/YGRKGGUtYyhB6VCwQpAm 20yi4Mi5sw2HbddpE99tdWB8EjzorrVdpDiPWIvL6HQz/ZDz6R2J3vPFTtfgBwgvwkwx 5kbnlyMW95ElDgtVa6tXedlHaFNvqPramJvdsIM4XwtQFXiFKWidZMyNooM1oLAA1ZlY 7RTw== 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=hZyvRCjiiIf2F6dVBk5hTdB46qGz36P2+wsR3JrZudA=; b=ez8rTpKVqU5BT6K2kOlEsrmtUnYDF+Z27/i2Hv4DOUr2CBskBuTHqhSCIaaDlkTf+L E95I9NEUtO5I3YhPQ1HIIKxWMd18P8heHt9vNWi869nCvN+h3+5nzR1pbWujLOWEVgNN Zu9QpQlhQ95YGgmfilGYls3b87fdOaJcOEavKPFDBbnklCYN3UFuNItRa05OeciW2MRg +b2vPktNoBWQMhCJ9nc0l4jUaoKFyzDAHRe8VJmj5cxMAcpel5FhveM69ULcJg5CazRM Z/ApMeEwc5pIG2tJdNbBUJFL+YQL2rqsF8MXGmmZeppXuKpa6pw1t/6ZS7ruKBt0FAjH vaGw== X-Gm-Message-State: AIVw112CsibKGZ79ByxFVDRFP4dqIKGOCf49EzL1H0qnIt6XZIMXRfis Gl6eE8j6Ttly18k7 X-Received: by 10.46.92.137 with SMTP id q131mr3379209ljb.102.1501284889112; Fri, 28 Jul 2017 16:34:49 -0700 (PDT) From: Aleksandr Bezzubikov To: seabios@seabios.org Date: Sat, 29 Jul 2017 02:34:32 +0300 Message-Id: <1501284872-2078-4-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501284872-2078-1-git-send-email-zuban32s@gmail.com> References: <1501284872-2078-1-git-send-email-zuban32s@gmail.com> X-Spam-Score: -6.4 (------) Subject: [SeaBIOS] [PATCH v3 3/3] pci: enable RedHat PCI bridges to reserve additional buses on PCI init 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: 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" In case of Red Hat Generic PCIE Root Port reserve additional buses, which number is provided in a vendor-specific capability. Signed-off-by: Aleksandr Bezzubikov --- src/fw/pciinit.c | 37 +++++++++++++++++++++++++++++++++++-- src/hw/pci_ids.h | 3 +++ src/types.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 864954f..a302a85 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -15,6 +15,7 @@ #include "hw/pcidevice.h" // pci_probe_devices #include "hw/pci_ids.h" // PCI_VENDOR_ID_INTEL #include "hw/pci_regs.h" // PCI_COMMAND +#include "fw/dev-pci.h" // qemu_pci_cap #include "list.h" // struct hlist_node #include "malloc.h" // free #include "output.h" // dprintf @@ -578,9 +579,41 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus) pci_bios_init_bus_rec(secbus, pci_bus); =20 if (subbus !=3D *pci_bus) { + u8 res_bus =3D 0; + if (pci_config_readw(bdf, PCI_VENDOR_ID) =3D=3D PCI_VENDOR_ID_= REDHAT && + pci_config_readw(bdf, PCI_DEVICE_ID) =3D=3D + PCI_DEVICE_ID_REDHAT_ROOT_PORT) { + u8 cap; + do { + cap =3D pci_find_capability(bdf, PCI_CAP_ID_VNDR, 0); + } while (cap && + pci_config_readb(bdf, cap + PCI_CAP_VNDR_SPEC_TYP= E) !=3D + REDHAT_CAP_TYPE_QEMU); + if (cap) { + u8 cap_len =3D pci_config_readb(bdf, cap + PCI_CAP_FLA= GS); + if (cap_len !=3D QEMU_PCI_CAP_SIZE) { + dprintf(1, "PCI: QEMU cap length %d is invalid\n", + cap_len); + } else { + res_bus =3D pci_config_readb(bdf, + cap + QEMU_PCI_CAP_BUS_= RES); + if ((u8)(res_bus + secbus) < secbus || + (u8)(res_bus + secbus) < res_bus) { + dprintf(1, "PCI: bus_reserve value %d is inval= id\n", + res_bus); + res_bus =3D 0; + } else { + dprintf(1, "PCI: QEMU cap is found, value =3D = %u\n", + res_bus); + } + } + } + res_bus =3D MAX(*pci_bus, secbus + res_bus); + } dprintf(1, "PCI: subordinate bus =3D 0x%x -> 0x%x\n", - subbus, *pci_bus); - subbus =3D *pci_bus; + subbus, res_bus); + subbus =3D res_bus; + *pci_bus =3D res_bus; } else { dprintf(1, "PCI: subordinate bus =3D 0x%x\n", subbus); } diff --git a/src/hw/pci_ids.h b/src/hw/pci_ids.h index 4ac73b4..38fa2ca 100644 --- a/src/hw/pci_ids.h +++ b/src/hw/pci_ids.h @@ -2263,6 +2263,9 @@ #define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600 #define PCI_DEVICE_ID_KORENIX_JETCARDF1 0x16ff =20 +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_ROOT_PORT 0x000C + #define PCI_VENDOR_ID_TEKRAM 0x1de1 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 =20 diff --git a/src/types.h b/src/types.h index 19d9f6c..75d9108 100644 --- a/src/types.h +++ b/src/types.h @@ -122,6 +122,8 @@ extern void __force_link_error__only_in_16bit(void) __n= oreturn; typeof(divisor) __divisor =3D divisor; \ (((x) + ((__divisor) / 2)) / (__divisor)); \ }) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) #define ALIGN_DOWN(x,a) ((x) & ~((typeof(x))(a)-1)) --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios