From nobody Tue Oct 28 23:11:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513543914638850.4163269586135; Sun, 17 Dec 2017 12:51:54 -0800 (PST) Received: from localhost ([::1]:55450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQfuY-0002lb-FH for importer@patchew.org; Sun, 17 Dec 2017 15:51:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQfsK-0001HN-HS for qemu-devel@nongnu.org; Sun, 17 Dec 2017 15:49:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQfsJ-0005cR-HT for qemu-devel@nongnu.org; Sun, 17 Dec 2017 15:49:32 -0500 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:38391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQfsJ-0005cC-C9; Sun, 17 Dec 2017 15:49:31 -0500 Received: by mail-qk0-x242.google.com with SMTP id z203so16162822qkb.5; Sun, 17 Dec 2017 12:49:31 -0800 (PST) Received: from x1.local ([181.91.222.165]) by smtp.gmail.com with ESMTPSA id b186sm7296778qka.19.2017.12.17.12.49.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 12:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MKUomvPn9cyvbRzAUY14krEkmJhcLtCcuk7xUtIQsTQ=; b=EBt1N1GkmzSihZAgfoml3u8tQagUBFf3gNYUY50mll1DvIjpi8wnBicGOewJRI71+B eMYoIRBJeALnfAUXPCWtsyprGNddb+1oftSthZw6hTKExxWe6POw2uErfemoE6H2fm7a sCwig1RW7gbvU1fHgL2rY3BBLJxcz8XXOctTQMpEsiv2glS1pZ1daXuQf/ggSpzjRVcH 9rZLDgoyEqHb1rq3n4FII1lRxdiJXysR7/W3J5bgEVRZ56pE16pQpQ6NMNL+AXG5cQaw b+g5Q88WsNtxKmuqtBgaV/DhCoMu6ndr26O03Brtz1SR2od3OxnN13MNI+OUZYzs2k2Y p3hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MKUomvPn9cyvbRzAUY14krEkmJhcLtCcuk7xUtIQsTQ=; b=PXJKevVIWi7zBYe0v041/O/3FnM7rR5kp+x30x0Py9LHPc7rMafrsdXTGvu34+FM4+ /d1khVu2NSgtBS/+Qnst64xuzcRBJPx2Z6clc2vxRt6rtZF6XpLGCTZUCn0BeBkdg7PA XWSDCCQXQFd3huI0NsalQrG6XPNqrqzztxxEbAh/tAT0LYeoJbr6Th2tKo12fwCYQS/d RRCZs8Xabb52YEhM6b0v4bEUqMAsKE9gIbv3APSfC/vNPsQ2ICDNxPwUaMZgPMtG8Ktg PuySF6HpPTROAsrd096mU37g/M2uR17ZahA1NgW/kjsyfuCe2V2QuF9ApDb9y5Y2FDv0 ZsFA== X-Gm-Message-State: AKGB3mISeG7Zsxb30xaUNnCUbwUwP0ndqP2NdJrmZT1cY/T1fUrRMqu5 Xwc4GFkcl+se/Wd5bdltrIs= X-Google-Smtp-Source: ACJfBov4WbAztyWj+oD9dE8vm02avO7S6SsDpRkfUSQQgSR3HhQXV2L4R+MtYl2PpYzBeMEr12aEew== X-Received: by 10.55.101.9 with SMTP id z9mr31531993qkb.206.1513543770714; Sun, 17 Dec 2017 12:49:30 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 17 Dec 2017 17:49:10 -0300 Message-Id: <20171217204912.12420-3-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171217204912.12420-1-f4bug@amsat.org> References: <20171217204912.12420-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH 2/4] hw/pci-host/piix: QOM'ify the IGD Passthrough host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci-host/piix.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index a684a7cca9..0153f32a32 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -804,7 +804,7 @@ static const IGDHostInfo igd_host_bridge_infos[] =3D { {0xa8, 4}, /* SNB: base of GTT stolen memory */ }; =20 -static int host_pci_config_read(int pos, int len, uint32_t *val) +static void host_pci_config_read(int pos, int len, uint32_t *val, Error **= errp) { char path[PATH_MAX]; int config_fd; @@ -812,19 +812,19 @@ static int host_pci_config_read(int pos, int len, uin= t32_t *val) /* Access real host bridge. */ int rc =3D snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%= d/%s", 0, 0, 0, 0, "config"); - int ret =3D 0; =20 if (rc >=3D size || rc < 0) { - return -ENODEV; + error_setg(&error_abort, "Invalid PCI device"); } =20 config_fd =3D open(path, O_RDWR); if (config_fd < 0) { - return -ENODEV; + error_setg_errno(errp, errno, "Failed to open: %s", path); + return; } =20 if (lseek(config_fd, pos, SEEK_SET) !=3D pos) { - ret =3D -errno; + error_setg_errno(errp, errno, "Failed to seek: %s", path); goto out; } =20 @@ -832,32 +832,31 @@ static int host_pci_config_read(int pos, int len, uin= t32_t *val) rc =3D read(config_fd, (uint8_t *)val, len); } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); if (rc !=3D len) { - ret =3D -errno; + error_setg_errno(errp, errno, "Failed to read: %s", path); } =20 out: close(config_fd); - return ret; } =20 -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev) +static void igd_pt_i440fx_realize(PCIDevice *pci, Error **errp) { uint32_t val =3D 0; - int rc, i, num; + int i, num; int pos, len; + Error *local_err =3D NULL; =20 num =3D ARRAY_SIZE(igd_host_bridge_infos); for (i =3D 0; i < num; i++) { pos =3D igd_host_bridge_infos[i].offset; len =3D igd_host_bridge_infos[i].len; - rc =3D host_pci_config_read(pos, len, &val); - if (rc) { - return -ENODEV; + host_pci_config_read(pos, len, &val, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; } - pci_default_write_config(pci_dev, pos, val, len); + pci_default_write_config(pci, pos, val, len); } - - return 0; } =20 static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *da= ta) @@ -865,7 +864,7 @@ static void igd_passthrough_i440fx_class_init(ObjectCla= ss *klass, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 - k->init =3D igd_pt_i440fx_initfn; + k->realize =3D igd_pt_i440fx_realize; dc->desc =3D "IGD Passthrough Host bridge"; } =20 --=20 2.15.1