From nobody Tue Oct 28 12:15:18 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513610176932277.748717384368; Mon, 18 Dec 2017 07:16:16 -0800 (PST) Received: from localhost ([::1]:46742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx9E-0007Mk-P2 for importer@patchew.org; Mon, 18 Dec 2017 10:16:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx75-0005dE-Hr for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQx6A-0000mK-Pz for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:13:55 -0500 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:44828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQx69-0000l8-Qj; Mon, 18 Dec 2017 10:12:57 -0500 Received: by mail-qt0-x244.google.com with SMTP id m59so20312802qte.11; Mon, 18 Dec 2017 07:12:57 -0800 (PST) Received: from x1.local ([138.117.48.211]) by smtp.gmail.com with ESMTPSA id y16sm8334022qta.48.2017.12.18.07.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 07:12:56 -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=XVqz6/DEj/tyQp5Lf+oHLUovkmNFkVFks5E1qhgQrM0=; b=eXjvLNXDv06HcJCxWM6bEHJxvrQRJVrZKJWL30RHNi7Quy8n3Q5DbWj/qnpluJgK5D /nba17rzgDoSPDlzOR1kRwPs2S1NjUHvYCvCYRetAReWrZC7IDDEb4DhZIvOfanmmUJ1 wV4CFZnL8hwE/TCqPM0+hqIuVYMbL5Zdcrnx/FSCFOWbJQv3hT8xbLouHASUVZfiUYq7 djqOBKxHIuzboLqeOlfqcEqu4eIRs9uOcJ8DVOG7ipCiTCsonxvrg0krRi2LKdUo1ItN bVPwzJ351ilzz2kkwjzkCJhvrOh6Cg6EHTKdoC3BXKSy0BHemPOVii6oDqGGSooA8BP7 zbQA== 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=XVqz6/DEj/tyQp5Lf+oHLUovkmNFkVFks5E1qhgQrM0=; b=db82vrVIXvPyQGWhAnBG8ZmM2zgweZKl7b81/DEavz0Qxij2vGD0Of2zUAdPl85jql 5wKwjGg2muSoNix9nQLPoCr+c2zeWCXmInwl7dnJBIfZH2MZR/nFA8cVgBH5zV4XpGwP hpxhfAt/lFyDCHC6jWZbd2Os4LdmMKqSKcsfMPfIxuHD8iSHHxqmvB57/gxm20c86aqx uHhAGWhWAq+1/zswtp8/Ud+cL/41Kcq3RTMaJJoL2f7njvra3MK4GW6bXXQ5r2Bhb8ib lzTLLU1wvbj2GnmSvc0BXSR+gty72x2nvQTRr7LpEH7/y+Zp3VqLbsmLOnd1JEYtI9Gz kXPw== X-Gm-Message-State: AKGB3mIZ73dy+Q+E0UaZlElP9OBaiu1R9HItdnJFms1kc3X9DW1RVKH1 sOeB53+SUFJchHqaFlB3y34= X-Google-Smtp-Source: ACJfBoshXE7c+ZvYeSNH5c7O7YMV20ZNcbMw8PnOu+/67/GvhnR6vRgRWa32GFlMaQOasVgHJh8kGA== X-Received: by 10.237.37.227 with SMTP id y32mr200072qtc.251.1513609976700; Mon, 18 Dec 2017 07:12:56 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost , Keith Busch Date: Mon, 18 Dec 2017 12:12:41 -0300 Message-Id: <20171218151244.9975-2-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171218151244.9975-1-f4bug@amsat.org> References: <20171218151244.9975-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:c0d::244 Subject: [Qemu-devel] [PATCH v2 1/4] hw/block/nvme: QOM'ify PCI NVME 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: Kevin Wolf , Max Reitz , =?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/block/nvme.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 441e21ed1f..9c5f898da0 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -920,9 +920,9 @@ static const MemoryRegionOps nvme_cmb_ops =3D { }, }; =20 -static int nvme_init(PCIDevice *pci_dev) +static void nvme_realize(PCIDevice *pci, Error **errp) { - NvmeCtrl *n =3D NVME(pci_dev); + NvmeCtrl *n =3D NVME(pci); NvmeIdCtrl *id =3D &n->id_ctrl; =20 int i; @@ -931,30 +931,33 @@ static int nvme_init(PCIDevice *pci_dev) Error *local_err =3D NULL; =20 if (!n->conf.blk) { - return -1; + error_setg(errp, "Block device missing"); + return; } =20 bs_size =3D blk_getlength(n->conf.blk); if (bs_size < 0) { - return -1; + error_setg_errno(errp, -bs_size, "Could not get length of device"); + return; } =20 blkconf_serial(&n->conf, &n->serial); if (!n->serial) { - return -1; + error_setg(errp, "Could not get device serial number"); + return; } blkconf_blocksizes(&n->conf); blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), false, &local_err); if (local_err) { - error_report_err(local_err); - return -1; + error_propagate(errp, local_err); + return; } =20 - pci_conf =3D pci_dev->config; + pci_conf =3D pci->config; pci_conf[PCI_INTERRUPT_PIN] =3D 1; - pci_config_set_prog_interface(pci_dev->config, 0x2); - pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); + pci_config_set_prog_interface(pci->config, 0x2); + pci_config_set_class(pci->config, PCI_CLASS_STORAGE_EXPRESS); pcie_endpoint_cap_init(&n->parent_obj, 0x80); =20 n->num_namespaces =3D 1; @@ -1046,12 +1049,11 @@ static int nvme_init(PCIDevice *pci_dev) cpu_to_le64(n->ns_size >> id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds); } - return 0; } =20 -static void nvme_exit(PCIDevice *pci_dev) +static void nvme_exit(PCIDevice *pci) { - NvmeCtrl *n =3D NVME(pci_dev); + NvmeCtrl *n =3D NVME(pci); =20 nvme_clear_ctrl(n); g_free(n->namespaces); @@ -1061,7 +1063,7 @@ static void nvme_exit(PCIDevice *pci_dev) memory_region_unref(&n->ctrl_mem); } =20 - msix_uninit_exclusive_bar(pci_dev); + msix_uninit_exclusive_bar(pci); } =20 static Property nvme_props[] =3D { @@ -1081,7 +1083,7 @@ static void nvme_class_init(ObjectClass *oc, void *da= ta) DeviceClass *dc =3D DEVICE_CLASS(oc); PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(oc); =20 - pc->init =3D nvme_init; + pc->realize =3D nvme_realize; pc->exit =3D nvme_exit; pc->class_id =3D PCI_CLASS_STORAGE_EXPRESS; pc->vendor_id =3D PCI_VENDOR_ID_INTEL; --=20 2.15.1 From nobody Tue Oct 28 12:15:18 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1513610444856542.5538438445377; Mon, 18 Dec 2017 07:20:44 -0800 (PST) Received: from localhost ([::1]:47130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxDR-0002tN-Gi for importer@patchew.org; Mon, 18 Dec 2017 10:20:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx7L-000636-GX for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQx6F-0000qf-SI for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:11 -0500 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:44992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQx6E-0000p4-Nk; Mon, 18 Dec 2017 10:13:02 -0500 Received: by mail-qk0-x241.google.com with SMTP id h19so18705825qkj.11; Mon, 18 Dec 2017 07:13:02 -0800 (PST) Received: from x1.local ([138.117.48.211]) by smtp.gmail.com with ESMTPSA id y16sm8334022qta.48.2017.12.18.07.12.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 07:12:59 -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=XfLMLU+zTf2G+aDo7DUTmQjMimPvFT8MfZttUxwvOO4=; b=XfAjHAhFg+mqGxcQdpAkM1a0wyw4jgGJECaKWba6jTXK3pYqk22XUc9LQxcyhSWZv9 h/zLpXMXwuH3/mQvLMWlZWu0ysceN6WekJ6whINrihfshk+xr1GJS+3YfVWFbPJmz0gR Js84UfUK+GIKhCiPhhlhFjKekh6lhEy4C4Paey9R3YhOKLssCRqUwNi1Sr84wnjZ4S+k T8iWwjGqOLKfmb84/ug1xnob5Dp+2nJlLge4Pz82Yn7GH7lr+GStf0ilZojGSYEhDJFW 7rA7xcA2ehDe7Z2MLuc+HWFXTpmX2IAJ0oJo3eQaHFUmNQgDsNepognp+GMmHZkEhB0M 27ig== 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=XfLMLU+zTf2G+aDo7DUTmQjMimPvFT8MfZttUxwvOO4=; b=T96myE2phaZZm0c+GiKKEzwr8S4VLuYiCbm7A4DIz56+e7vZ5VdIdHilOjkLG8AcEa a3FebpDlrQfMV0AwsAkv5DbR3iPOkUtbrmOJZrHlu3wJZ5sii8reLPJhl6CU2lYxWyKi QKr4RgLlDqT+GzToZMOUkRlXfb0gizjvBgpDp19339lxL5Xclo6TE0rwLih8qtR9zKTO JOMtlZXEqG/dU7V6mxGeCZ+kODAl7+WlN/07H8Vz8arUcOJ5a0rXa/a0r5QWSSA2JJTd ZR2loTbE68k7iYPjRIa8MQAHMXoWSOy/QwHE53H3xbTiI/rAqQ+CGlyOSNYrQmqSzDQK /Yuw== X-Gm-Message-State: AKGB3mLEEsV5a/EjwwFUmcyePMHrjiYkUpV+QLrZzf8twmJwtv8rmnKJ 2FrUGKJPCuAP476jhm0Z9GI= X-Google-Smtp-Source: ACJfBovVmfHrlZRDrrycyFgjJo2tQlhUvtE4uG0AYyGoqq0Ekvg/5nLhS3vaWIgwX9IWM8qP0vU6PA== X-Received: by 10.55.200.90 with SMTP id c87mr86173qkj.132.1513609979884; Mon, 18 Dec 2017 07:12:59 -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: Mon, 18 Dec 2017 12:12:42 -0300 Message-Id: <20171218151244.9975-3-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171218151244.9975-1-f4bug@amsat.org> References: <20171218151244.9975-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::241 Subject: [Qemu-devel] [PATCH v2 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_6 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marcel Apfelbaum --- v2: use g_strdup_printf(), use 'pci_dev' variable. hw/pci-host/piix.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index a684a7cca9..bb6560f815 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -804,60 +804,55 @@ 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; - ssize_t size =3D sizeof(path); + int rc, config_fd; /* 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; - - if (rc >=3D size || rc < 0) { - return -ENODEV; - } + char *path =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%d= /%s", + 0, 0, 0, 0, "config"); =20 config_fd =3D open(path, O_RDWR); if (config_fd < 0) { - return -ENODEV; + error_setg_errno(errp, errno, "Failed to open: %s", path); + goto out; } =20 if (lseek(config_fd, pos, SEEK_SET) !=3D pos) { - ret =3D -errno; - goto out; + error_setg_errno(errp, errno, "Failed to seek: %s", path); + goto out_close_fd; } =20 do { 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: +out_close_fd: close(config_fd); - return ret; +out: + g_free(path); } =20 -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev) +static void igd_pt_i440fx_realize(PCIDevice *pci_dev, 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); } - - return 0; } =20 static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *da= ta) @@ -865,7 +860,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 From nobody Tue Oct 28 12:15:18 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 1513610337236356.34270733039455; Mon, 18 Dec 2017 07:18:57 -0800 (PST) Received: from localhost ([::1]:46894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxBa-0001BU-Gq for importer@patchew.org; Mon, 18 Dec 2017 10:18:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx78-0005iO-SM for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQx6L-0000uB-F7 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:13:58 -0500 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:44829) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQx6I-0000rs-JJ for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:13:06 -0500 Received: by mail-qt0-x244.google.com with SMTP id m59so20313304qte.11 for ; Mon, 18 Dec 2017 07:13:06 -0800 (PST) Received: from x1.local ([138.117.48.211]) by smtp.gmail.com with ESMTPSA id y16sm8334022qta.48.2017.12.18.07.13.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 07:13:03 -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=+9CtsjJf29VTuJjLsm8q2e6OaaWCYHxbC/p69P61uuw=; b=GCbNlqRSs30QNvGXM68fOe4yxzn8rsL1EfSqyYKKDYsJMi52EYXKfbrr1oKE1QKbXP MM/rKLULeOqRHZvV+Ar94fk0XNzvB29BPK3Pn9I29jTbikibwpXe5nFSkAcbDny8ZY98 iibAEFa4usRXCYpkjPhudEOMfCKKZquiSC8Fxh+KZcAGSq2JsT5ytDQsddlDSucCHLjs yBzxrroYxKjpwli9LE1rdUIPYaycGVog9Xfr0gDK8iyDTQdomNFb47maeNxdjOslrCsM DFXscNJK/hjl9coDVxeZARb9gv95+Itu4Kzcbi62puXCqEj6CZMqBuCwHij2hFcGaaE+ v9Hw== 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=+9CtsjJf29VTuJjLsm8q2e6OaaWCYHxbC/p69P61uuw=; b=FuMSRibSIg+aTuKEKyaVIxLWEATTEqX02e8K9Kj0aj+y4DiKyZddVrKd/hhQys35wa CzxiMP0KM7SzXKsAljTUtaJ6X6qkZH+9G1F79vmKgo16j/rjfUeJENZOKvxQ+jHEISjV IOz5KxlV+prmVWuRFLsFxk4Gnfpx9s2MKVH8xo9ZQCk8oRJRDKGTVDhhgWGe1uQ+QxWO BmvIFUIYdgkCC6/I5hz0VtNd2KTYAfTCpFN46WAJT8hwXRDXe8Z/zhqTHXlEtqa3ktJf hQeH+2qkdQf8GzOCPcOOYUjWgk68tBpGbEdV6hRTI9Egxe5bEGARLKAxaUpsDfDki0gu 6Ohg== X-Gm-Message-State: AKGB3mIjtkRFcc5H7Qr8iLUDYv7s7lAOx+z8rCtVJE2jVn91Hm70tTut suk1K5O/Ew9zd2I4WYIworA= X-Google-Smtp-Source: ACJfBouhmiYzi3vnsQgsyjm6eDSEYz0odxajt031atFea79hTruwTU0zmcASBN7afWfNfucwPTsQ7A== X-Received: by 10.200.63.43 with SMTP id c40mr241834qtk.338.1513609984261; Mon, 18 Dec 2017 07:13:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost , Paul Burton , Yongbok Kim , "Edgar E . Iglesias" , Alistair Francis Date: Mon, 18 Dec 2017 12:12:43 -0300 Message-Id: <20171218151244.9975-4-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171218151244.9975-1-f4bug@amsat.org> References: <20171218151244.9975-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:c0d::244 Subject: [Qemu-devel] [PATCH v2 3/4] hw/pci-host/xilinx: QOM'ify the AXI-PCIe 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: James Hogan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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 Reviewed-by: Marcel Apfelbaum --- v2: use 'pci_dev' variable, replaced hw_error() -> error_setg() hw/pci-host/xilinx-pcie.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index 7659253090..681fdf486a 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -267,24 +267,22 @@ static void xilinx_pcie_root_config_write(PCIDevice *= d, uint32_t address, } } =20 -static int xilinx_pcie_root_init(PCIDevice *dev) +static void xilinx_pcie_root_realize(PCIDevice *pci_dev, Error **errp) { - BusState *bus =3D qdev_get_parent_bus(DEVICE(dev)); + BusState *bus =3D qdev_get_parent_bus(DEVICE(pci_dev)); XilinxPCIEHost *s =3D XILINX_PCIE_HOST(bus->parent); =20 - pci_set_word(dev->config + PCI_COMMAND, + pci_set_word(pci_dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - pci_set_word(dev->config + PCI_MEMORY_BASE, s->mmio_base >> 16); - pci_set_word(dev->config + PCI_MEMORY_LIMIT, + pci_set_word(pci_dev->config + PCI_MEMORY_BASE, s->mmio_base >> 16); + pci_set_word(pci_dev->config + PCI_MEMORY_LIMIT, ((s->mmio_base + s->mmio_size - 1) >> 16) & 0xfff0); =20 - pci_bridge_initfn(dev, TYPE_PCI_BUS); + pci_bridge_initfn(pci_dev, TYPE_PCI_BUS); =20 - if (pcie_endpoint_cap_v1_init(dev, 0x80) < 0) { - hw_error("Failed to initialize PCIe capability"); + if (pcie_endpoint_cap_v1_init(pci_dev, 0x80) < 0) { + error_setg(errp, "Failed to initialize PCIe capability"); } - - return 0; } =20 static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data) @@ -300,7 +298,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *kl= ass, void *data) k->class_id =3D PCI_CLASS_BRIDGE_HOST; k->is_express =3D true; k->is_bridge =3D true; - k->init =3D xilinx_pcie_root_init; + k->realize =3D xilinx_pcie_root_realize; k->exit =3D pci_bridge_exitfn; dc->reset =3D pci_bridge_reset; k->config_read =3D xilinx_pcie_root_config_read; --=20 2.15.1 From nobody Tue Oct 28 12:15:18 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1513610335915882.7951723093917; Mon, 18 Dec 2017 07:18:55 -0800 (PST) Received: from localhost ([::1]:46902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxBg-0001Gs-P5 for importer@patchew.org; Mon, 18 Dec 2017 10:18:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx7G-0005zB-V5 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQx6Q-0000xn-Vy for qemu-devel@nongnu.org; Mon, 18 Dec 2017 10:14:06 -0500 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:42287) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQx6M-0000wA-J0; Mon, 18 Dec 2017 10:13:10 -0500 Received: by mail-qt0-x244.google.com with SMTP id g9so20369985qth.9; Mon, 18 Dec 2017 07:13:10 -0800 (PST) Received: from x1.local ([138.117.48.211]) by smtp.gmail.com with ESMTPSA id y16sm8334022qta.48.2017.12.18.07.13.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 07:13:07 -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=58UWNiTsKb2DS8wj3MUUc1bomt4VCJOBOOmfdstU4wM=; b=UKxf2MBDGvLGvCEbtBX5vIR7dL+chOSn5StKbn4/ekOfdTZe/UCDBRoKoY4pHAc/2V 5TVmjAKPJjm3FH4fSjBxT2KBqHEAR/Dhryy5uz9PAH0fLZwgFuID7DGjGhDQJ8Yk2VSl CMvvLAy9izDXqu4WxLez3dpW69IEKyOQSUQdDatf8BC9U/eXEUb5b56CnoWebtC4+Azd M2lMoBu15dS8O2pkehXJzJhQ38nYeTxOlPAGGl1jVkJaOMWd8EHx5040rKOQJsMXo7NE Ymk6GbHYPjP7Y0FE+5evdQnz5TqtC5LcPYx31KglGh+Ba9Ixll62SfPtQprIM5jTmnTl 0+0w== 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=58UWNiTsKb2DS8wj3MUUc1bomt4VCJOBOOmfdstU4wM=; b=RKQmHR40cKL1bI5q91uHwzb0MtplF5a7sZmHDajxiSATq9CnS8A+/vsvFC36KZBYvk O1r/52lVNU65dlgsOA+S9+yDJA5Au05mI3ukvQzAFydRq/97Z0uKPn3yp3fsblHePzqC ZpfSsd2Fj0AH8ou94nUddpPs4NswoTykj1dcZqNfQRbQLVNVxoakQmtgLnmeMo3/pTBm akj8u5hnA7p+XDIBrRIy+sphzxq5aTaLbZu4X55UPBaMNzRb7tgNdPO82xyBzpyBlwfQ bw4woa4u/0BF0W06gjivoMdkk3b2VJY6xfTu2s4RCNzjf+5Ep6VwRuLylCadgxam+JD/ zYYg== X-Gm-Message-State: AKGB3mI02/japG+R4xqUp7yRagQmfkOMGlpNvxGvEDf6GeDSix/i5X4D IuAZ1zJK8YRIvBu+NBwue78= X-Google-Smtp-Source: ACJfBotNwfJhfUjAhY//ekkhy5vTO7mDASLVTMhNkPwG2v/CAMoIRy3gIciByptrzd+Nreb0Udtlkg== X-Received: by 10.200.3.23 with SMTP id q23mr227555qtg.229.1513609987724; Mon, 18 Dec 2017 07:13:07 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost Date: Mon, 18 Dec 2017 12:12:44 -0300 Message-Id: <20171218151244.9975-5-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171218151244.9975-1-f4bug@amsat.org> References: <20171218151244.9975-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:c0d::244 Subject: [Qemu-devel] [PATCH v2 4/4] hw/pci: remove obsolete PCIDevice->init() 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_6 Z_629925259 SPT_0 All PCI devices are now QOM'ified. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marcel Apfelbaum --- v2: added Marcel's R-b include/hw/pci/pci.h | 1 - hw/pci/pci.c | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8d02a0a383..0f1ed64c2f 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -217,7 +217,6 @@ typedef struct PCIDeviceClass { DeviceClass parent_class; =20 void (*realize)(PCIDevice *dev, Error **errp); - int (*init)(PCIDevice *dev);/* TODO convert to realize() and remove */ PCIUnregisterFunc *exit; PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b2d139bd9a..cd25ab6f6b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2054,18 +2054,6 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) } } =20 -static void pci_default_realize(PCIDevice *dev, Error **errp) -{ - PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); - - if (pc->init) { - if (pc->init(dev) < 0) { - error_setg(errp, "Device initialization failed"); - return; - } - } -} - PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunc= tion, const char *name) { @@ -2538,13 +2526,11 @@ MemoryRegion *pci_address_space_io(PCIDevice *dev) static void pci_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D pci_qdev_realize; k->unrealize =3D pci_qdev_unrealize; k->bus_type =3D TYPE_PCI_BUS; k->props =3D pci_props; - pc->realize =3D pci_default_realize; } =20 static void pci_device_class_base_init(ObjectClass *klass, void *data) --=20 2.15.1