From nobody Sun May 11 22:04:27 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 150263943117327.06582115070023; Sun, 13 Aug 2017 08:50: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 1dgv76-0002Tu-8o; Sun, 13 Aug 2017 17:47:40 +0200 Received: from mail-lf0-f66.google.com ([209.85.215.66]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1dgv6q-0002R5-Fz for seabios@seabios.org; Sun, 13 Aug 2017 17:47:38 +0200 Received: by mail-lf0-f66.google.com with SMTP id 65so5163685lfa.0 for ; Sun, 13 Aug 2017 08:49:59 -0700 (PDT) Received: from localhost.localdomain (broadband-109-173-19-108.moscow.rt.ru. [109.173.19.108]) by smtp.gmail.com with ESMTPSA id 15sm833283ljw.35.2017.08.13.08.49.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Aug 2017 08:49:57 -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=sHwIyV0k/SGQEiG30gug2O/n6Hud1ZcXoaBTyQR5XgE=; b=E/+P5V8LcrS0rQBXjPksw7si9MKS8snxAvEoCZU4u7zX7mp/jK/kALbpHPBHN5N4Yy bIGRjtxOFZw2W4iNlCjJNhlETEZgsTV1ctmyoW5YsRwGu7L8aGzQWuJoJ9ycF5yDJwe7 ZiHsnJ+JgWfxPQH6omTIdfGCa7JoyiWcNopQScqNsPykSyD+7PbfbvJDP3IeEQHkwiOG oKyK8KjLACmqYfFWrQilDuGhlgRQU4VpRxJLARqXTG3WYrIn1irRnHLjqpt+h/WghGGT 90LnpS8UNx5ZvAFdFYUJTYB49ATI/j8UsM8lj4rEyA90yHDzUDRvi788y0kj0K9+iOEo xhQw== 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=sHwIyV0k/SGQEiG30gug2O/n6Hud1ZcXoaBTyQR5XgE=; b=mNQNLFosCfVlY3pW3BRSVmLvO6r1TVmNhVlO3I47UGRaWvgw1GAxirvMWU88BCHQky v6OqHH4Ue9xNdZp8g1A8GR90LghKkj7PPKahytK/L7TK/MXIZkbYtrdSJh5vmYxKmjm4 htGbfutVihleYf5Yz6/MjY+g6E5l+rEgrB1NQFjjpMDDCrQMEEGSAeeipPmoVCOee9on Q/NG9iwj28tL9CCBQddGkn+CsjYLQ+7b2CDj1gCAWcyb2AQRoo/zlb961zsQ7dS7y/He TJFmOETpfFRIQFo1pku2B60LyeiM4xmk/5u2qzIznkDRXMU5AzYsik2id/motkhZ0+/8 WQ3g== X-Gm-Message-State: AHYfb5hXicd+Xp2pTzSvrGNDKC+4rVgDtr632PaZikQasC0amTW6iEeX bEcAB4G1Puv2fOOS X-Received: by 10.25.151.18 with SMTP id z18mr7757646lfd.101.1502639398459; Sun, 13 Aug 2017 08:49:58 -0700 (PDT) From: Aleksandr Bezzubikov To: qemu-devel@nongnu.org Date: Sun, 13 Aug 2017 18:49:47 +0300 Message-Id: <1502639388-12580-4-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502639388-12580-1-git-send-email-zuban32s@gmail.com> References: <1502639388-12580-1-git-send-email-zuban32s@gmail.com> X-Spam-Score: -2.6 (--) Subject: [SeaBIOS] [PATCH v6 3/4] hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port 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, seabios@seabios.org, lersek@redhat.com, mst@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" To enable hotplugging of a newly created pcie-pci-bridge, we need to tell firmware (e.g. SeaBIOS) to reserve additional buses or IO/MEM/PREF space for pcie-root-port. Additional bus reservation allows us to hotplug pcie-pci-bridge into this r= oot port. The number of buses and IO/MEM/PREF space to reserve are provided to the de= vice via a corresponding property, and to the firmware via new PCI capability. The properties' default values are -1 to keep default behavior unchanged. Signed-off-by: Aleksandr Bezzubikov Reviewed-by: Marcel Apfelbaum --- hw/pci-bridge/gen_pcie_root_port.c | 36 ++++++++++++++++++++++++++++++++++= ++ include/hw/pci/pcie_port.h | 1 + 2 files changed, 37 insertions(+) diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_ro= ot_port.c index cb694d6..bd65479 100644 --- a/hw/pci-bridge/gen_pcie_root_port.c +++ b/hw/pci-bridge/gen_pcie_root_port.c @@ -16,6 +16,8 @@ #include "hw/pci/pcie_port.h" =20 #define TYPE_GEN_PCIE_ROOT_PORT "pcie-root-port" +#define GEN_PCIE_ROOT_PORT(obj) \ + OBJECT_CHECK(GenPCIERootPort, (obj), TYPE_GEN_PCIE_ROOT_PORT) =20 #define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100 #define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1 @@ -26,6 +28,13 @@ typedef struct GenPCIERootPort { /*< public >*/ =20 bool migrate_msix; + + /* additional resources to reserve on firmware init */ + uint32_t bus_reserve; + uint64_t io_reserve; + uint32_t mem_reserve; + uint32_t pref32_reserve; + uint64_t pref64_reserve; } GenPCIERootPort; =20 static uint8_t gen_rp_aer_vector(const PCIDevice *d) @@ -60,6 +69,24 @@ static bool gen_rp_test_migrate_msix(void *opaque, int v= ersion_id) return rp->migrate_msix; } =20 +static void gen_rp_realize(DeviceState *dev, Error **errp) +{ + PCIDevice *d =3D PCI_DEVICE(dev); + GenPCIERootPort *grp =3D GEN_PCIE_ROOT_PORT(d); + PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(d); + + rpc->parent_realize(dev, errp); + + int rc =3D pci_bridge_qemu_reserve_cap_init(d, 0, grp->bus_reserve, + grp->io_reserve, grp->mem_reserve, grp->pref32_reserve, + grp->pref64_reserve, errp); + + if (rc < 0) { + rpc->parent_class.exit(d); + return; + } +} + static const VMStateDescription vmstate_rp_dev =3D { .name =3D "pcie-root-port", .version_id =3D 1, @@ -78,6 +105,11 @@ static const VMStateDescription vmstate_rp_dev =3D { =20 static Property gen_rp_props[] =3D { DEFINE_PROP_BOOL("x-migrate-msix", GenPCIERootPort, migrate_msix, true= ), + DEFINE_PROP_UINT32("bus-reserve", GenPCIERootPort, bus_reserve, -1), + DEFINE_PROP_UINT64("io-reserve", GenPCIERootPort, io_reserve, -1), + DEFINE_PROP_UINT32("mem-reserve", GenPCIERootPort, mem_reserve, -1), + DEFINE_PROP_UINT32("pref32-reserve", GenPCIERootPort, pref32_reserve, = -1), + DEFINE_PROP_UINT64("pref64-reserve", GenPCIERootPort, pref64_reserve, = -1), DEFINE_PROP_END_OF_LIST() }; =20 @@ -92,6 +124,10 @@ static void gen_rp_dev_class_init(ObjectClass *klass, v= oid *data) dc->desc =3D "PCI Express Root Port"; dc->vmsd =3D &vmstate_rp_dev; dc->props =3D gen_rp_props; + + rpc->parent_realize =3D dc->realize; + dc->realize =3D gen_rp_realize; + rpc->aer_vector =3D gen_rp_aer_vector; rpc->interrupts_init =3D gen_rp_interrupts_init; rpc->interrupts_uninit =3D gen_rp_interrupts_uninit; diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h index 1333266..0736014 100644 --- a/include/hw/pci/pcie_port.h +++ b/include/hw/pci/pcie_port.h @@ -65,6 +65,7 @@ void pcie_chassis_del_slot(PCIESlot *s); =20 typedef struct PCIERootPortClass { PCIDeviceClass parent_class; + DeviceRealize parent_realize; =20 uint8_t (*aer_vector)(const PCIDevice *dev); int (*interrupts_init)(PCIDevice *dev, Error **errp); --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios