From nobody Sat May 18 19:24:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167084634270798.24369265978123; Mon, 12 Dec 2022 03:59:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4hEQ-00064k-Pb; Mon, 12 Dec 2022 06:44:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEI-0005x8-8o; Mon, 12 Dec 2022 06:44:18 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEF-0003Lw-3I; Mon, 12 Dec 2022 06:44:18 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 51D175C00E2; Mon, 12 Dec 2022 06:44:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Dec 2022 06:44:14 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Dec 2022 06:44:12 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1670845454; x= 1670931854; bh=oa/gM116xDbWZ1Ao4T7XNAdlSC9fmaj8i8z7O8Wx7mk=; b=p O9WLyP7Bv49/Gl/kzuIKkC3mReZqG41/FrvV+9uN35GFykUXFXt/dpNOpzWi4Zg2 ZgDyzxyonMzh9MPyla9YEaD3WUQXu4VbpHG1fbHQqApCY1W87jXU2ggrsqqvc49q ccbL+Z/Pe9B9PdpO1Xp0kl41Vdf2Xb5v93IijMS+pZfAaRATdLVLY0KuWKnWQ3gK MykCQ9k49f50e150etyuwHHItUvoMPIaxh3iNneAf6rO9kCKGxbZOauNtcL2vnnV eHNz7/v+VmU7NHnrTINRLXF5FtbX0Kkp1FltIGMGOhk/OKXyurZ9ByWSXayj0oqI tfyxpaxVU5pz+MC7+Zc8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1670845454; x= 1670931854; bh=oa/gM116xDbWZ1Ao4T7XNAdlSC9fmaj8i8z7O8Wx7mk=; b=Q CXLMTxpsO4JClKy40RdaWJnactSwBh9AbQOWUUjtMXLfQMvGvctjrJ12U9+3/K7A r2cKHOyBSKEG/0uOFzW7YWcoVZWJ6Vsj8QZNeIezDcOxdc/JIZayUjvJUwozcU3F 3TlMPS4lI1KWMNcFPe5uXXH0Tdo8adAe8yE6SNht8U4RAYgJE61aM5ux0+dRONUQ nrke0Tt7gBlO1E5YsDLsEVrWsZXpsMxaUnX6WIqY+Odc6enoprObmeJTTQZd4otI FB0/A8IVghCBGZDPPbFYEfjjdZSVIxgll1zt9zw5aWnezxL2r1UzQ/swxurgvN59 eR4qTuqILufA4Z975fN0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjeeijeejvdeitdegheeiveeugffhgfejhfdvtdeludeftddvtdfhhfeileek ueelnecuffhomhgrihhnpehquggvvhdrihgunecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jinhao Fan , Guenter Roeck , Klaus Jensen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 1/4] hw/nvme: use QOM accessors Date: Mon, 12 Dec 2022 12:44:06 +0100 Message-Id: <20221212114409.34972-2-its@irrelevant.dk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212114409.34972-1-its@irrelevant.dk> References: <20221212114409.34972-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=openpgp-sha256; l=14730; i=k.jensen@samsung.com; h=from:subject; bh=UZobSTYj1I9QyUOqHFfLSvRkdW+crCTvRo9kkJ9fHBE=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGOXFAisP0zHgsW4rYZw2lBjYuITSYidcqpGQlfu Ji/3tZqTkokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJjlxQIAAoJEE3hrzFtTw3pOT wIAMDyWQQleRa5m/1Hl6kRzxLmu/a4pzY/VyUYBVt6SKz2qn29SSUl6NtRSwkaLcA0jBbHz/h548Z7 yPfowRzovF3jbOMJvVu+91HATc1e4jnamMesoss8a9BozC5bWeir5GYlYLENi1gwNM6K/5S2PpCHaN Bj0ciji2Si20/1lG8Cqh26s6DBGDJfqDml3yk9lGi37R0FXqzZOBbaNQ7IjaFdYCYIIiunENlrAjSV TL2KTF4yfAQ6JJt10KRi3r2KmbwC5Jbp4BW2NHCk3netND2iiVf413KxFyxTZr98/PPozaammjKC7D mX5Hr7I4xn58BOy5b/ufqKuhR0gjTTLtlLMa1+ X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1670846344695100003 From: Klaus Jensen Replace various ->parent_obj use with the equivalent QOM accessors. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 89 +++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index e54276dc1dc7..6b70c1e39831 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -449,7 +449,7 @@ static int nvme_addr_read(NvmeCtrl *n, hwaddr addr, voi= d *buf, int size) return 0; } =20 - return pci_dma_read(&n->parent_obj, addr, buf, size); + return pci_dma_read(PCI_DEVICE(n), addr, buf, size); } =20 static int nvme_addr_write(NvmeCtrl *n, hwaddr addr, const void *buf, int = size) @@ -469,7 +469,7 @@ static int nvme_addr_write(NvmeCtrl *n, hwaddr addr, co= nst void *buf, int size) return 0; } =20 - return pci_dma_write(&n->parent_obj, addr, buf, size); + return pci_dma_write(PCI_DEVICE(n), addr, buf, size); } =20 static bool nvme_nsid_valid(NvmeCtrl *n, uint32_t nsid) @@ -514,24 +514,27 @@ static uint8_t nvme_sq_empty(NvmeSQueue *sq) =20 static void nvme_irq_check(NvmeCtrl *n) { + PCIDevice *pci =3D PCI_DEVICE(n); uint32_t intms =3D ldl_le_p(&n->bar.intms); =20 - if (msix_enabled(&(n->parent_obj))) { + if (msix_enabled(pci)) { return; } if (~intms & n->irq_status) { - pci_irq_assert(&n->parent_obj); + pci_irq_assert(pci); } else { - pci_irq_deassert(&n->parent_obj); + pci_irq_deassert(pci); } } =20 static void nvme_irq_assert(NvmeCtrl *n, NvmeCQueue *cq) { + PCIDevice *pci =3D PCI_DEVICE(n); + if (cq->irq_enabled) { - if (msix_enabled(&(n->parent_obj))) { + if (msix_enabled(pci)) { trace_pci_nvme_irq_msix(cq->vector); - msix_notify(&(n->parent_obj), cq->vector); + msix_notify(pci, cq->vector); } else { trace_pci_nvme_irq_pin(); assert(cq->vector < 32); @@ -546,7 +549,7 @@ static void nvme_irq_assert(NvmeCtrl *n, NvmeCQueue *cq) static void nvme_irq_deassert(NvmeCtrl *n, NvmeCQueue *cq) { if (cq->irq_enabled) { - if (msix_enabled(&(n->parent_obj))) { + if (msix_enabled(PCI_DEVICE(n))) { return; } else { assert(cq->vector < 32); @@ -570,7 +573,7 @@ static void nvme_req_clear(NvmeRequest *req) static inline void nvme_sg_init(NvmeCtrl *n, NvmeSg *sg, bool dma) { if (dma) { - pci_dma_sglist_init(&sg->qsg, &n->parent_obj, 0); + pci_dma_sglist_init(&sg->qsg, PCI_DEVICE(n), 0); sg->flags =3D NVME_SG_DMA; } else { qemu_iovec_init(&sg->iov, 0); @@ -1333,7 +1336,7 @@ static inline void nvme_blk_write(BlockBackend *blk, = int64_t offset, =20 static void nvme_update_cq_head(NvmeCQueue *cq) { - pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &cq->head, + pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head, sizeof(cq->head)); trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head); } @@ -1363,7 +1366,7 @@ static void nvme_post_cqes(void *opaque) req->cqe.sq_id =3D cpu_to_le16(sq->sqid); req->cqe.sq_head =3D cpu_to_le16(sq->head); addr =3D cq->dma_addr + cq->tail * n->cqe_size; - ret =3D pci_dma_write(&n->parent_obj, addr, (void *)&req->cqe, + ret =3D pci_dma_write(PCI_DEVICE(n), addr, (void *)&req->cqe, sizeof(req->cqe)); if (ret) { trace_pci_nvme_err_addr_write(addr); @@ -4615,6 +4618,7 @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest= *req) =20 static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) { + PCIDevice *pci =3D PCI_DEVICE(n); uint16_t offset =3D (cq->cqid << 3) + (1 << 2); =20 n->cq[cq->cqid] =3D NULL; @@ -4625,8 +4629,8 @@ static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) event_notifier_set_handler(&cq->notifier, NULL); event_notifier_cleanup(&cq->notifier); } - if (msix_enabled(&n->parent_obj)) { - msix_vector_unuse(&n->parent_obj, cq->vector); + if (msix_enabled(pci)) { + msix_vector_unuse(pci, cq->vector); } if (cq->cqid) { g_free(cq); @@ -4664,8 +4668,10 @@ static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n= , uint64_t dma_addr, uint16_t cqid, uint16_t vector, uint16_t size, uint16_t irq_enabled) { - if (msix_enabled(&n->parent_obj)) { - msix_vector_use(&n->parent_obj, vector); + PCIDevice *pci =3D PCI_DEVICE(n); + + if (msix_enabled(pci)) { + msix_vector_use(pci, vector); } cq->ctrl =3D n; cq->cqid =3D cqid; @@ -4716,7 +4722,7 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeReque= st *req) trace_pci_nvme_err_invalid_create_cq_addr(prp1); return NVME_INVALID_PRP_OFFSET | NVME_DNR; } - if (unlikely(!msix_enabled(&n->parent_obj) && vector)) { + if (unlikely(!msix_enabled(PCI_DEVICE(n)) && vector)) { trace_pci_nvme_err_invalid_create_cq_vector(vector); return NVME_INVALID_IRQ_VECTOR | NVME_DNR; } @@ -5959,6 +5965,7 @@ static uint16_t nvme_assign_virt_res_to_sec(NvmeCtrl = *n, NvmeRequest *req, =20 static uint16_t nvme_virt_set_state(NvmeCtrl *n, uint16_t cntlid, bool onl= ine) { + PCIDevice *pci =3D PCI_DEVICE(n); NvmeCtrl *sn =3D NULL; NvmeSecCtrlEntry *sctrl; int vf_index; @@ -5968,9 +5975,9 @@ static uint16_t nvme_virt_set_state(NvmeCtrl *n, uint= 16_t cntlid, bool online) return NVME_INVALID_CTRL_ID | NVME_DNR; } =20 - if (!pci_is_vf(&n->parent_obj)) { + if (!pci_is_vf(pci)) { vf_index =3D le16_to_cpu(sctrl->vfn) - 1; - sn =3D NVME(pcie_sriov_get_vf_at_index(&n->parent_obj, vf_index)); + sn =3D NVME(pcie_sriov_get_vf_at_index(pci, vf_index)); } =20 if (online) { @@ -6028,6 +6035,7 @@ static uint16_t nvme_virt_mngmt(NvmeCtrl *n, NvmeRequ= est *req) =20 static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req) { + PCIDevice *pci =3D PCI_DEVICE(n); uint64_t dbs_addr =3D le64_to_cpu(req->cmd.dptr.prp1); uint64_t eis_addr =3D le64_to_cpu(req->cmd.dptr.prp2); int i; @@ -6054,8 +6062,7 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const = NvmeRequest *req) */ sq->db_addr =3D dbs_addr + (i << 3); sq->ei_addr =3D eis_addr + (i << 3); - pci_dma_write(&n->parent_obj, sq->db_addr, &sq->tail, - sizeof(sq->tail)); + pci_dma_write(pci, sq->db_addr, &sq->tail, sizeof(sq->tail)); =20 if (n->params.ioeventfd && sq->sqid !=3D 0) { if (!nvme_init_sq_ioeventfd(sq)) { @@ -6068,8 +6075,7 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const = NvmeRequest *req) /* CAP.DSTRD is 0, so offset of ith cq db_addr is (i<<3)+(1<<2= ) */ cq->db_addr =3D dbs_addr + (i << 3) + (1 << 2); cq->ei_addr =3D eis_addr + (i << 3) + (1 << 2); - pci_dma_write(&n->parent_obj, cq->db_addr, &cq->head, - sizeof(cq->head)); + pci_dma_write(pci, cq->db_addr, &cq->head, sizeof(cq->head)); =20 if (n->params.ioeventfd && cq->cqid !=3D 0) { if (!nvme_init_cq_ioeventfd(cq)) { @@ -6141,14 +6147,14 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeReq= uest *req) =20 static void nvme_update_sq_eventidx(const NvmeSQueue *sq) { - pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail, + pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &sq->tail, sizeof(sq->tail)); trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail); } =20 static void nvme_update_sq_tail(NvmeSQueue *sq) { - pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &sq->tail, + pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &sq->tail, sizeof(sq->tail)); trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail); } @@ -6216,7 +6222,7 @@ static void nvme_update_msixcap_ts(PCIDevice *pci_dev= , uint32_t table_size) =20 static void nvme_activate_virt_res(NvmeCtrl *n) { - PCIDevice *pci_dev =3D &n->parent_obj; + PCIDevice *pci_dev =3D PCI_DEVICE(n); NvmePriCtrlCap *cap =3D &n->pri_ctrl_cap; NvmeSecCtrlEntry *sctrl; =20 @@ -6239,7 +6245,7 @@ static void nvme_activate_virt_res(NvmeCtrl *n) =20 static void nvme_ctrl_reset(NvmeCtrl *n, NvmeResetType rst) { - PCIDevice *pci_dev =3D &n->parent_obj; + PCIDevice *pci_dev =3D PCI_DEVICE(n); NvmeSecCtrlEntry *sctrl; NvmeNamespace *ns; int i; @@ -6356,7 +6362,7 @@ static int nvme_start_ctrl(NvmeCtrl *n) uint32_t page_size =3D 1 << page_bits; NvmeSecCtrlEntry *sctrl =3D nvme_sctrl(n); =20 - if (pci_is_vf(&n->parent_obj) && !sctrl->scs) { + if (pci_is_vf(PCI_DEVICE(n)) && !sctrl->scs) { trace_pci_nvme_err_startfail_virt_state(le16_to_cpu(sctrl->nvi), le16_to_cpu(sctrl->nvq), sctrl->scs ? "ONLINE" : @@ -6471,6 +6477,7 @@ static void nvme_cmb_enable_regs(NvmeCtrl *n) static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data, unsigned size) { + PCIDevice *pci =3D PCI_DEVICE(n); uint64_t cap =3D ldq_le_p(&n->bar.cap); uint32_t cc =3D ldl_le_p(&n->bar.cc); uint32_t intms =3D ldl_le_p(&n->bar.intms); @@ -6494,7 +6501,7 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset= , uint64_t data, =20 switch (offset) { case NVME_REG_INTMS: - if (unlikely(msix_enabled(&(n->parent_obj)))) { + if (unlikely(msix_enabled(pci))) { NVME_GUEST_ERR(pci_nvme_ub_mmiowr_intmask_with_msix, "undefined access to interrupt mask set" " when MSI-X is enabled"); @@ -6507,7 +6514,7 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset= , uint64_t data, nvme_irq_check(n); break; case NVME_REG_INTMC: - if (unlikely(msix_enabled(&(n->parent_obj)))) { + if (unlikely(msix_enabled(pci))) { NVME_GUEST_ERR(pci_nvme_ub_mmiowr_intmask_with_msix, "undefined access to interrupt mask clr" " when MSI-X is enabled"); @@ -6732,7 +6739,7 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr a= ddr, unsigned size) return 0; } =20 - if (pci_is_vf(&n->parent_obj) && !nvme_sctrl(n)->scs && + if (pci_is_vf(PCI_DEVICE(n)) && !nvme_sctrl(n)->scs && addr !=3D NVME_REG_CSTS) { trace_pci_nvme_err_ignored_mmio_vf_offline(addr, size); return 0; @@ -6753,6 +6760,7 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr a= ddr, unsigned size) =20 static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val) { + PCIDevice *pci =3D PCI_DEVICE(n); uint32_t qid; =20 if (unlikely(addr & ((1 << 2) - 1))) { @@ -6820,8 +6828,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr,= int val) start_sqs =3D nvme_cq_full(cq) ? 1 : 0; cq->head =3D new_head; if (!qid && n->dbbuf_enabled) { - pci_dma_write(&n->parent_obj, cq->db_addr, &cq->head, - sizeof(cq->head)); + pci_dma_write(pci, cq->db_addr, &cq->head, sizeof(cq->head)); } if (start_sqs) { NvmeSQueue *sq; @@ -6894,8 +6901,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr,= int val) * including ones that run on Linux, are not updating Admin Qu= eues, * so we can't trust reading it for an appropriate sq tail. */ - pci_dma_write(&n->parent_obj, sq->db_addr, &sq->tail, - sizeof(sq->tail)); + pci_dma_write(pci, sq->db_addr, &sq->tail, sizeof(sq->tail)); } =20 qemu_bh_schedule(sq->bh); @@ -6909,7 +6915,7 @@ static void nvme_mmio_write(void *opaque, hwaddr addr= , uint64_t data, =20 trace_pci_nvme_mmio_write(addr, data, size); =20 - if (pci_is_vf(&n->parent_obj) && !nvme_sctrl(n)->scs && + if (pci_is_vf(PCI_DEVICE(n)) && !nvme_sctrl(n)->scs && addr !=3D NVME_REG_CSTS) { trace_pci_nvme_err_ignored_mmio_vf_offline(addr, size); return; @@ -7093,10 +7099,11 @@ static void nvme_init_state(NvmeCtrl *n) NvmePriCtrlCap *cap =3D &n->pri_ctrl_cap; NvmeSecCtrlList *list =3D &n->sec_ctrl_list; NvmeSecCtrlEntry *sctrl; + PCIDevice *pci =3D PCI_DEVICE(n); uint8_t max_vfs; int i; =20 - if (pci_is_vf(&n->parent_obj)) { + if (pci_is_vf(pci)) { sctrl =3D nvme_sctrl(n); max_vfs =3D 0; n->conf_ioqpairs =3D sctrl->nvq ? le16_to_cpu(sctrl->nvq) - 1 : 0; @@ -7125,7 +7132,7 @@ static void nvme_init_state(NvmeCtrl *n) cap->cntlid =3D cpu_to_le16(n->cntlid); cap->crt =3D NVME_CRT_VQ | NVME_CRT_VI; =20 - if (pci_is_vf(&n->parent_obj)) { + if (pci_is_vf(pci)) { cap->vqprt =3D cpu_to_le16(1 + n->conf_ioqpairs); } else { cap->vqprt =3D cpu_to_le16(1 + n->params.max_ioqpairs - @@ -7138,7 +7145,7 @@ static void nvme_init_state(NvmeCtrl *n) cap->vqfrt / MAX(max_vfs, 1); } =20 - if (pci_is_vf(&n->parent_obj)) { + if (pci_is_vf(pci)) { cap->viprt =3D cpu_to_le16(n->conf_msix_qsize); } else { cap->viprt =3D cpu_to_le16(n->params.msix_qsize - @@ -7445,7 +7452,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pc= i_dev) stl_le_p(&n->bar.vs, NVME_SPEC_VER); n->bar.intmc =3D n->bar.intms =3D 0; =20 - if (pci_is_vf(&n->parent_obj) && !sctrl->scs) { + if (pci_is_vf(pci_dev) && !sctrl->scs) { stl_le_p(&n->bar.csts, NVME_CSTS_FAILED); } } @@ -7483,6 +7490,7 @@ void nvme_attach_ns(NvmeCtrl *n, NvmeNamespace *ns) static void nvme_realize(PCIDevice *pci_dev, Error **errp) { NvmeCtrl *n =3D NVME(pci_dev); + DeviceState *dev =3D DEVICE(pci_dev); NvmeNamespace *ns; Error *local_err =3D NULL; NvmeCtrl *pn =3D NVME(pcie_sriov_get_pf(pci_dev)); @@ -7502,8 +7510,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **= errp) return; } =20 - qbus_init(&n->bus, sizeof(NvmeBus), TYPE_NVME_BUS, - &pci_dev->qdev, n->parent_obj.qdev.id); + qbus_init(&n->bus, sizeof(NvmeBus), TYPE_NVME_BUS, dev, dev->id); =20 if (nvme_init_subsys(n, errp)) { error_propagate(errp, local_err); --=20 2.38.1 From nobody Sat May 18 19:24:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167084645584120.5989201197458; Mon, 12 Dec 2022 04:00:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4hEQ-000642-Bh; Mon, 12 Dec 2022 06:44:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEJ-0005xY-9B; Mon, 12 Dec 2022 06:44:19 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEH-0003MD-JU; Mon, 12 Dec 2022 06:44:18 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id BFD375C013F; Mon, 12 Dec 2022 06:44:16 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 12 Dec 2022 06:44:16 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Dec 2022 06:44:14 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1670845456; x= 1670931856; bh=ywVj1WQrBqf/jjrsMoCRj00Qgrvf0S9EkuFWlVJfFoQ=; b=h zIER92NmbH/XQQMJKcWYKs37+PFxLMLhi4xmhWf/ci0ToabEfHON+kcStZXrjaBn TiJ6fvSthd9uyrzesbBEvQ+ipK0dbD0MTdVWVNykGBZuGRULz8C/htqPHBul06P9 LHHU/lKc0H1izwKx7hv2UobBRZ5SoxIGY9avkq+iuw8WFy0/MicbYv10Y/5PhD5O 7hBYpcc5668FV7RdoEPPOowjijO5XISsYJ1ApbsOgjaOfLA/nXq5ZhB1JLAj/YhM gRASrsv5jBkzE3c7mmdseBi9PtjPB1bENNMflgaSsnjw648G8sKWWNoxRStw8SBt jSKgk8QiFtYQUpRLwXEQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1670845456; x= 1670931856; bh=ywVj1WQrBqf/jjrsMoCRj00Qgrvf0S9EkuFWlVJfFoQ=; b=Y FpxJS+WlVunEGF1MWoiWpwIUAfyGdMy/wW+mG6XCMwMlrGU1hkBRUXym5o0ANUJb lyWuiedYIzddaZ7RjMci0g45pdTV0F/ExA9wvJZClkr1Lz1w6S/g36uLTq3Brkcf gioqw2oZQFE1/z4RaIcZgvDfR7GpAkX2VyBhJaZTb73PF8O/bXErfcx+SFJ/WEsC AtqyqpANcPIZOb93zKR0rT5BAMuZWrilvUQ7ZXMS39RlYP1jELGCmD9D+ghoKcDc 2m8Kvrkxc0wJvv4N3Zqg7Y6Dk4UnOpGth9b60pSMn0/6bsDlwi5/xq238O5Kf/7a qVTHtMPGE2Gj8yeeHaeLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepfeevtdeuteeuudffvefggfdtfedtueelfffhieegffekgeefjeefffetjeei hfdvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jinhao Fan , Guenter Roeck , Klaus Jensen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 2/4] hw/nvme: rename shadow doorbell related trace events Date: Mon, 12 Dec 2022 12:44:07 +0100 Message-Id: <20221212114409.34972-3-its@irrelevant.dk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212114409.34972-1-its@irrelevant.dk> References: <20221212114409.34972-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=openpgp-sha256; l=4099; i=k.jensen@samsung.com; h=from:subject; bh=N2PUz42ZQqJ+DBcFpFxR1tE5k9Erfcus0SAQB1SKFk0=; b=owJ4nJvAy8zAxej7cL1hrj/vS8bTakkMydNFOOSPLpALf7t9EmOwsPuLzYWZ7f7M/Yeb7PN/SuQf Dy9mndPJaMzCwMjFICumyBKkYbyq9NGdZ4vc0w7ADGJlApnCwMUpABOR5OBgWG6t1F3EpZ+99Hxe0I PKyskJkRM3/X2bl6t0Od/d9B6LVtwMvtXafjd57nIZf/186H7aJbu/tiG7LSfq80fK/lzwuGjnsy82 qotLQstnHrXs+VVarnR/Ak9n48+bXXaxVotb7OQ3ZZVdXh1kNevhNx6LDbu4oy2T06zXHBI3VoiPvP VrjUuhv8pFvdLynQfPRvaLPK8zmng52HaLgLjU/ONyDfMVQvoV+PcsrTbeJVqTfqeij1lPSVTriLHW S7nKIr1yoZc+T/6u4zC8vNTmztdXBV4CmxhZzpq3aDz6d/B+scTsgBeCBUcW/2H7rR9eIfcgJ/FiSc uWS7rKiUIiNT16kRofH7+e8OWSvgoASaCfSQ== X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1670846458368100003 From: Klaus Jensen Rename the trace events related to writing the event index and reading the doorbell value to make it more clear that the event is associated with an actual update (write or read respectively). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch --- hw/nvme/ctrl.c | 11 +++++++---- hw/nvme/trace-events | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 6b70c1e39831..cfab21b3436e 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1337,8 +1337,9 @@ static inline void nvme_blk_write(BlockBackend *blk, = int64_t offset, static void nvme_update_cq_head(NvmeCQueue *cq) { pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head, - sizeof(cq->head)); - trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head); + sizeof(cq->head)); + + trace_pci_nvme_update_cq_head(cq->cqid, cq->head); } =20 static void nvme_post_cqes(void *opaque) @@ -6147,16 +6148,18 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeReq= uest *req) =20 static void nvme_update_sq_eventidx(const NvmeSQueue *sq) { + trace_pci_nvme_update_sq_eventidx(sq->sqid, sq->tail); + pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &sq->tail, sizeof(sq->tail)); - trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail); } =20 static void nvme_update_sq_tail(NvmeSQueue *sq) { pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &sq->tail, sizeof(sq->tail)); - trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail); + + trace_pci_nvme_update_sq_tail(sq->sqid, sq->tail); } =20 static void nvme_process_sq(void *opaque) diff --git a/hw/nvme/trace-events b/hw/nvme/trace-events index fccb79f48973..b16f2260b4fd 100644 --- a/hw/nvme/trace-events +++ b/hw/nvme/trace-events @@ -84,8 +84,8 @@ pci_nvme_enqueue_event_noqueue(int queued) "queued %d" pci_nvme_enqueue_event_masked(uint8_t typ) "type 0x%"PRIx8"" pci_nvme_no_outstanding_aers(void) "ignoring event; no outstanding AERs" pci_nvme_enqueue_req_completion(uint16_t cid, uint16_t cqid, uint32_t dw0,= uint32_t dw1, uint16_t status) "cid %"PRIu16" cqid %"PRIu16" dw0 0x%"PRIx3= 2" dw1 0x%"PRIx32" status 0x%"PRIx16"" -pci_nvme_eventidx_cq(uint16_t cqid, uint16_t new_eventidx) "cqid %"PRIu16"= new_eventidx %"PRIu16"" -pci_nvme_eventidx_sq(uint16_t sqid, uint16_t new_eventidx) "sqid %"PRIu16"= new_eventidx %"PRIu16"" +pci_nvme_update_cq_eventidx(uint16_t cqid, uint16_t new_eventidx) "cqid %"= PRIu16" new_eventidx %"PRIu16"" +pci_nvme_update_sq_eventidx(uint16_t sqid, uint16_t new_eventidx) "sqid %"= PRIu16" new_eventidx %"PRIu16"" pci_nvme_mmio_read(uint64_t addr, unsigned size) "addr 0x%"PRIx64" size %d" pci_nvme_mmio_write(uint64_t addr, uint64_t data, unsigned size) "addr 0x%= "PRIx64" data 0x%"PRIx64" size %d" pci_nvme_mmio_doorbell_cq(uint16_t cqid, uint16_t new_head) "cqid %"PRIu16= " new_head %"PRIu16"" @@ -102,8 +102,8 @@ pci_nvme_mmio_start_success(void) "setting controller e= nable bit succeeded" pci_nvme_mmio_stopped(void) "cleared controller enable bit" pci_nvme_mmio_shutdown_set(void) "shutdown bit set" pci_nvme_mmio_shutdown_cleared(void) "shutdown bit cleared" -pci_nvme_shadow_doorbell_cq(uint16_t cqid, uint16_t new_shadow_doorbell) "= cqid %"PRIu16" new_shadow_doorbell %"PRIu16"" -pci_nvme_shadow_doorbell_sq(uint16_t sqid, uint16_t new_shadow_doorbell) "= sqid %"PRIu16" new_shadow_doorbell %"PRIu16"" +pci_nvme_update_cq_head(uint16_t cqid, uint16_t new_head) "cqid %"PRIu16" = new_head %"PRIu16"" +pci_nvme_update_sq_tail(uint16_t sqid, uint16_t new_tail) "sqid %"PRIu16" = new_tail %"PRIu16"" pci_nvme_open_zone(uint64_t slba, uint32_t zone_idx, int all) "open zone, = slba=3D%"PRIu64", idx=3D%"PRIu32", all=3D%"PRIi32"" pci_nvme_close_zone(uint64_t slba, uint32_t zone_idx, int all) "close zone= , slba=3D%"PRIu64", idx=3D%"PRIu32", all=3D%"PRIi32"" pci_nvme_finish_zone(uint64_t slba, uint32_t zone_idx, int all) "finish zo= ne, slba=3D%"PRIu64", idx=3D%"PRIu32", all=3D%"PRIi32"" --=20 2.38.1 From nobody Sat May 18 19:24:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670845817984930.750607023684; Mon, 12 Dec 2022 03:50:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4hEO-00061s-Oc; Mon, 12 Dec 2022 06:44:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEL-0005y3-Ke; Mon, 12 Dec 2022 06:44:22 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEK-0003MP-3R; Mon, 12 Dec 2022 06:44:21 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 03DE15C012A; Mon, 12 Dec 2022 06:44:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 12 Dec 2022 06:44:19 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Dec 2022 06:44:17 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1670845458; x= 1670931858; bh=MieW4e/zUymEmOAMJmAKy6sogL2DORGK0S7L8IsmVsI=; b=J 7TPBWCG3znR2jC3xcLiWn5vUxSXY1ZcUlScJZ1VuudEMX4+ytEBBXBujyb991z63 6k2jBO6WmTj7MWmfMG5FgDFRh0/jDFjsRBlr/gtRMbqpLFE5iNJI7MoyUcSfLJiG 6PA9xUC5F8W77p+UK2Q9u+oSyEY5RgvQy6/5puDVGwTJ21+KevHy9aQzdtvekrQB fNb8Tj6lhrkBezAuws5RBOcDSLoF57N9lfDoBjg8T/WGgXZS/dlAmdiQ8FdK74UA H00wzZZNGD0yJL2v8Tf4EGg5QvsGSFImzuuP4HOohU1TEdCV814kVRPKbHP24rTd 1QxHKJ+cce+gNifQdMlow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1670845458; x=1670931858; bh=MieW4e/zUymEm OAMJmAKy6sogL2DORGK0S7L8IsmVsI=; b=BNgJ0wNhz2iWkFL14Kqc8aSb9FiHd nr0tjI/Bcw1VGlgmP7dtgbhAqZX0i7y6qARDmv2BASLW85NMgXjSx1IfXzCc4ki0 BMpNK1k/uYRaVba8bwf+KtNJamZE0WvL8JyYtiTfw0huMY8v+I0+zZ6UhlrIcWz/ ZlwyqqBXZ4ZTWMQ5M5XWUxSrHjndHZ3mQIDQkXH//VBvPoVj/eTBt6ZfH7J0lrRA tWc7gU9/tM8jA+yEe/dH6oV2+KWR93jGZ1YBbvbHR6fg2pU9Ak0iPG6nakFx9Hdd bR5/W4gY0FvIhK2sXTeMPTLPh0eoR6dbQ5r6h8GEd9Wc+s27gycQsuBag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedujedu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jinhao Fan , Guenter Roeck , Klaus Jensen , qemu-stable@nongnu.org Subject: [PATCH v4 3/4] hw/nvme: fix missing endian conversions for doorbell buffers Date: Mon, 12 Dec 2022 12:44:08 +0100 Message-Id: <20221212114409.34972-4-its@irrelevant.dk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212114409.34972-1-its@irrelevant.dk> References: <20221212114409.34972-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1771; i=k.jensen@samsung.com; h=from:subject; bh=UGO0tQzSAcPY/fhLFF5RrdpYwEmDgTGctLdgH52GF3w=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGOXFAhDdQL0UIhd++XvDT7Hai2DArn13926Z1XT thIWoLi14IkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJjlxQIAAoJEE3hrzFtTw3pG9 QH+wRlxyLCZUbGqKbngR3lf7RZKEPnkEdLO3A/U0BOdHmc2voVJncBMFd4StzQim+Q+KysOIR6BxHk szyrh9N7238q7+ylaYP+eYLNKz/3wKMs7RYtDf8xqduZeKgbPa2ths3a+8qggy2nRUIxeWte4G6sDW XtDTQG/NupkERvl/XqSTlbMHK2kisHs6Cg74sw73A7u7OufpqWNuWJiPKM1AnbkGXtnqgtjzASd/EP DF1QPcV2kAlUjGtKHM493cbIUWmoJH8+iiSH92f3MZNVo2Gn6uCZthhW1AoliTv6Norneg0mZw9Usy oV5/it5rIgKm929X78r52LMsm3hLMuK6wD/Ksn X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1670845819484100003 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen The eventidx and doorbell value are not handling endianness correctly. Fix this. Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support") Cc: qemu-stable@nongnu.org Reported-by: Guenter Roeck Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/nvme/ctrl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index cfab21b3436e..bb505131f5f9 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1336,8 +1336,11 @@ static inline void nvme_blk_write(BlockBackend *blk,= int64_t offset, =20 static void nvme_update_cq_head(NvmeCQueue *cq) { - pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head, - sizeof(cq->head)); + uint32_t v; + + pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &v, sizeof(v)); + + cq->head =3D le32_to_cpu(v); =20 trace_pci_nvme_update_cq_head(cq->cqid, cq->head); } @@ -6148,16 +6151,20 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeReq= uest *req) =20 static void nvme_update_sq_eventidx(const NvmeSQueue *sq) { + uint32_t v =3D cpu_to_le32(sq->tail); + trace_pci_nvme_update_sq_eventidx(sq->sqid, sq->tail); =20 - pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &sq->tail, - sizeof(sq->tail)); + pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &v, sizeof(v)); } =20 static void nvme_update_sq_tail(NvmeSQueue *sq) { - pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &sq->tail, - sizeof(sq->tail)); + uint32_t v; + + pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &v, sizeof(v)); + + sq->tail =3D le32_to_cpu(v); =20 trace_pci_nvme_update_sq_tail(sq->sqid, sq->tail); } --=20 2.38.1 From nobody Sat May 18 19:24:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670846276463403.18934616711545; Mon, 12 Dec 2022 03:57:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4hES-00065h-AP; Mon, 12 Dec 2022 06:44:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEN-0005zl-VD; Mon, 12 Dec 2022 06:44:23 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4hEM-0003Ml-D6; Mon, 12 Dec 2022 06:44:23 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 128125C0151; Mon, 12 Dec 2022 06:44:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Dec 2022 06:44:21 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Dec 2022 06:44:19 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1670845461; x= 1670931861; bh=vZ+OOsnZYJL8GkKEt4CioC1k5V+A7SG820NOYkn+cXE=; b=U 14bREhcVi6EtRbfAQW4+7TQ28+TFq/nADAUj6470Fy+aggfWqa5HmeO5Q4K7jO7b nG9UURV0IScRg/7MtoP/IQFjpx5CgLgBeLgp/pYosXE2DKZOtFX02SGJsAyjq8Tj rKSk1YLdVQwtw1dNBTZfd+ZuD82PP9Imea8ikjf4HMr6iN3KHrORIDPCGq1HHlAC CUxp/6dAM9k/kYBrlNejCACFwaQ2T3E/ikQeq1fyuwAVD91laL7TFxd4VDLxrcou MZv2+YMf5JaMTExLhxXTwVqi1r6vXLQLcLLgLu+JcVsa7LYnC1XzvrchBCLgrRYC VNnoZLApSXhjmTenEcUZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1670845461; x=1670931861; bh=vZ+OOsnZYJL8G kKEt4CioC1k5V+A7SG820NOYkn+cXE=; b=upg01wsIGAzAUSSK+jLA+bykhog5q w2mjsmbMHfouQIXin6013T70lrTyo3w4nHxnBd2KR3C24htK4uph60DwD2PYaARd Ahk30iGRTQcj9v7kZ3+LoIqSUSNrv36SOrZxILvEHLHZP/WodY8bChHbA2YjdXdY XZUGD/90XQXMDgCcIEP819WRwrGLBGYW4Ryy8lIikzX+ZHEA63BHqM+ncJsSzxuj cZZ82mNKaXWnkG0RUvUoyqKA0fbQjZHvDhO4Fd892OgUFgFmivtNeJY5CFbuQrtZ lOoNKqOAodZzegXCIH1IMlmVqELv1iQO4/xhijNwDmWG8mXejRJ4M/Jhg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedujedu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jinhao Fan , Guenter Roeck , Klaus Jensen , qemu-stable@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v4 4/4] hw/nvme: fix missing cq eventidx update Date: Mon, 12 Dec 2022 12:44:09 +0100 Message-Id: <20221212114409.34972-5-its@irrelevant.dk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212114409.34972-1-its@irrelevant.dk> References: <20221212114409.34972-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1368; i=k.jensen@samsung.com; h=from:subject; bh=aoxzJKx0O6Lh8Uwyoz0I0J6X3ZQ9AYZS1frBhrJxaH8=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGOXFAn4JT/RXbSN0djv0q7720auhySmj6ZktG2k oNtrDeicEYkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJjlxQJAAoJEE3hrzFtTw3pR2 gH/3Hip0LUeBk37fBjirn7KRFbkooCOW3s23ATqkwvHonUmHsCdVwtNcixh1xRgmVKFHmn5dweCIU9 P4VjtQawawuIGvoH0tecvf73b9TvJGqHXI+ef5Ij6w8Y3OpoiHj8EtBBBIlM1q3KNN8XUTH+CYZhS+ ML+tuvEW8g7A7lNO0iqYmI7rOY86XIcgo7SbFKDOjSkdQhqbsYPZb+wZrKhEtoMP8ycX+okfjrPly3 8xXgcmJYQPfgtuWTHkxLeADSCz9TxNRsZ09WJ2uXLIOxZZ7QdIfR+W/Pd6WF5+71zqJJ2HVQ2dC1Xq /I5u4xlAEZnWVGRVg6Jb4BSRoL78LJRdJlFa3C X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1670846278295100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Prior to reading the shadow doorbell cq head, we have to update the eventidx. Otherwise, we risk that the driver will skip an mmio doorbell write. This happens on riscv64, as reported by Guenter. Adding the missing update to the cq eventidx fixes the issue. Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support") Cc: qemu-stable@nongnu.org Cc: qemu-riscv@nongnu.org Reported-by: Guenter Roeck Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch --- hw/nvme/ctrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index bb505131f5f9..3df29ea68b2f 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1334,6 +1334,15 @@ static inline void nvme_blk_write(BlockBackend *blk,= int64_t offset, } } =20 +static void nvme_update_cq_eventidx(const NvmeCQueue *cq) +{ + uint32_t v =3D cpu_to_le32(cq->head); + + trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head); + + pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &v, sizeof(v)); +} + static void nvme_update_cq_head(NvmeCQueue *cq) { uint32_t v; @@ -1358,6 +1367,7 @@ static void nvme_post_cqes(void *opaque) hwaddr addr; =20 if (n->dbbuf_enabled) { + nvme_update_cq_eventidx(cq); nvme_update_cq_head(cq); } =20 --=20 2.38.1