From patchwork Mon Dec 18 15:12:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 850109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eXjvLNXD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z0l2V2Cbmz9sDB for ; Tue, 19 Dec 2017 02:14:58 +1100 (AEDT) Received: from localhost ([::1]:46695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQx84-00068X-Af for incoming@patchwork.ozlabs.org; Mon, 18 Dec 2017 10:14:56 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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 = { }, }; -static int nvme_init(PCIDevice *pci_dev) +static void nvme_realize(PCIDevice *pci, Error **errp) { - NvmeCtrl *n = NVME(pci_dev); + NvmeCtrl *n = NVME(pci); NvmeIdCtrl *id = &n->id_ctrl; int i; @@ -931,30 +931,33 @@ static int nvme_init(PCIDevice *pci_dev) Error *local_err = NULL; if (!n->conf.blk) { - return -1; + error_setg(errp, "Block device missing"); + return; } bs_size = blk_getlength(n->conf.blk); if (bs_size < 0) { - return -1; + error_setg_errno(errp, -bs_size, "Could not get length of device"); + return; } 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; } - pci_conf = pci_dev->config; + pci_conf = pci->config; pci_conf[PCI_INTERRUPT_PIN] = 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); n->num_namespaces = 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; } -static void nvme_exit(PCIDevice *pci_dev) +static void nvme_exit(PCIDevice *pci) { - NvmeCtrl *n = NVME(pci_dev); + NvmeCtrl *n = NVME(pci); 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); } - msix_uninit_exclusive_bar(pci_dev); + msix_uninit_exclusive_bar(pci); } static Property nvme_props[] = { @@ -1081,7 +1083,7 @@ static void nvme_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc); - pc->init = nvme_init; + pc->realize = nvme_realize; pc->exit = nvme_exit; pc->class_id = PCI_CLASS_STORAGE_EXPRESS; pc->vendor_id = PCI_VENDOR_ID_INTEL; From patchwork Mon Dec 18 15:12:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 850124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XfAjHAhF"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z0l874B4zz9s82 for ; Tue, 19 Dec 2017 02:19:51 +1100 (AEDT) Received: from localhost ([::1]:46945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxCn-000215-Ee for incoming@patchwork.ozlabs.org; Mon, 18 Dec 2017 10:19:49 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost , =?utf-8?q?Herv=C3=A9_Poussinea?= =?utf-8?q?u?= 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 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_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé 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[] = { {0xa8, 4}, /* SNB: base of GTT stolen memory */ }; -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 = sizeof(path); + int rc, config_fd; /* Access real host bridge. */ - int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s", - 0, 0, 0, 0, "config"); - int ret = 0; - - if (rc >= size || rc < 0) { - return -ENODEV; - } + char *path = g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s", + 0, 0, 0, 0, "config"); config_fd = open(path, O_RDWR); if (config_fd < 0) { - return -ENODEV; + error_setg_errno(errp, errno, "Failed to open: %s", path); + goto out; } if (lseek(config_fd, pos, SEEK_SET) != pos) { - ret = -errno; - goto out; + error_setg_errno(errp, errno, "Failed to seek: %s", path); + goto out_close_fd; } do { rc = read(config_fd, (uint8_t *)val, len); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc != len) { - ret = -errno; + error_setg_errno(errp, errno, "Failed to read: %s", path); } -out: +out_close_fd: close(config_fd); - return ret; +out: + g_free(path); } -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev) +static void igd_pt_i440fx_realize(PCIDevice *pci_dev, Error **errp) { uint32_t val = 0; - int rc, i, num; + int i, num; int pos, len; + Error *local_err = NULL; num = ARRAY_SIZE(igd_host_bridge_infos); for (i = 0; i < num; i++) { pos = igd_host_bridge_infos[i].offset; len = igd_host_bridge_infos[i].len; - rc = 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; } static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data) @@ -865,7 +860,7 @@ static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->init = igd_pt_i440fx_initfn; + k->realize = igd_pt_i440fx_realize; dc->desc = "IGD Passthrough Host bridge"; } From patchwork Mon Dec 18 15:12:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 850117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GCbNlqRS"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z0l5Z3kLnz9s82 for ; Tue, 19 Dec 2017 02:17:37 +1100 (AEDT) Received: from localhost ([::1]:46782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxAc-0008Vy-Ff for incoming@patchwork.ozlabs.org; Mon, 18 Dec 2017 10:17: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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé 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, } } -static int xilinx_pcie_root_init(PCIDevice *dev) +static void xilinx_pcie_root_realize(PCIDevice *pci_dev, Error **errp) { - BusState *bus = qdev_get_parent_bus(DEVICE(dev)); + BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev)); XilinxPCIEHost *s = XILINX_PCIE_HOST(bus->parent); - 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); - pci_bridge_initfn(dev, TYPE_PCI_BUS); + pci_bridge_initfn(pci_dev, TYPE_PCI_BUS); - 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; } static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data) @@ -300,7 +298,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_BRIDGE_HOST; k->is_express = true; k->is_bridge = true; - k->init = xilinx_pcie_root_init; + k->realize = xilinx_pcie_root_realize; k->exit = pci_bridge_exitfn; dc->reset = pci_bridge_reset; k->config_read = xilinx_pcie_root_config_read; From patchwork Mon Dec 18 15:12:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 850119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UKxf2MBD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z0l5k5htgz9s82 for ; Tue, 19 Dec 2017 02:17:46 +1100 (AEDT) Received: from localhost ([::1]:46788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQxAm-0000BI-TO for incoming@patchwork.ozlabs.org; Mon, 18 Dec 2017 10:17:44 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" All PCI devices are now QOM'ified. Signed-off-by: Philippe Mathieu-Daudé 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; 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, Error **errp) } } -static void pci_default_realize(PCIDevice *dev, Error **errp) -{ - PCIDeviceClass *pc = 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 multifunction, 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 = DEVICE_CLASS(klass); - PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); k->realize = pci_qdev_realize; k->unrealize = pci_qdev_unrealize; k->bus_type = TYPE_PCI_BUS; k->props = pci_props; - pc->realize = pci_default_realize; } static void pci_device_class_base_init(ObjectClass *klass, void *data)