* [PULL 0/1] hw/nvme fixes
@ 2023-07-30 19:29 Klaus Jensen
2023-07-30 19:29 ` [PULL 1/1] hw/nvme: use stl/ldl pci dma api Klaus Jensen
2023-07-31 16:26 ` [PULL 0/1] hw/nvme fixes Richard Henderson
0 siblings, 2 replies; 3+ messages in thread
From: Klaus Jensen @ 2023-07-30 19:29 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Keith Busch, Philippe Mathieu-Daudé, qemu-block,
Stefan Hajnoczi, Klaus Jensen, Kevin Wolf, Hanna Reitz, Fam Zheng,
Klaus Jensen
From: Klaus Jensen <k.jensen@samsung.com>
Hi,
This should also fix coverity cid 1518067 and 1518066.
The following changes since commit ccb86f079a9e4d94918086a9df18c1844347aff8:
Merge tag 'pull-nbd-2023-07-28' of https://repo.or.cz/qemu/ericb into staging (2023-07-28 09:56:57 -0700)
are available in the Git repository at:
https://gitlab.com/birkelund/qemu.git tags/nvme-next-pull-request
for you to fetch changes up to c1e244b6552efdff5612a33c6630aaf95964eaf5:
hw/nvme: use stl/ldl pci dma api (2023-07-30 20:09:54 +0200)
----------------------------------------------------------------
hw/nvme fixes
- use the stl/ldl pci dma api
-----BEGIN PGP SIGNATURE-----
iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmTGuc8ACgkQTeGvMW1P
Dek41wgAwqgRmtUhmmaQJJpF5Pya3J7n3Zkbp+cULdnSp/su7W7yIUTcTzdbr34d
9LbNHmWerXYinlIxG08ZWw2lq0TwApKj+8gv/wf8H7dG86/pBYfoQvOlkNx2QKyR
vtRNlILCEbJpbSfY3LbFNvRGOkArr6HkzT4hZprUIfCvRg58u5oIxEx/ZYa+m3WU
ED0y/46e7HbVbmbwJKrn4EK3k0zGdFyeINRZ5TB5DML3lCTX6eaZTLUXGIb7LLcK
Xyv6/TCkPTggDszTam24kx0A7DhC+3f2C8DsJg7H8jnWb1F+oq/2EJam/0HU22Uk
n348MrWOusuF7kbHMCP9h28gYT3aWw==
=KjVO
-----END PGP SIGNATURE-----
----------------------------------------------------------------
Klaus Jensen (1):
hw/nvme: use stl/ldl pci dma api
hw/nvme/ctrl.c | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PULL 1/1] hw/nvme: use stl/ldl pci dma api
2023-07-30 19:29 [PULL 0/1] hw/nvme fixes Klaus Jensen
@ 2023-07-30 19:29 ` Klaus Jensen
2023-07-31 16:26 ` [PULL 0/1] hw/nvme fixes Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Klaus Jensen @ 2023-07-30 19:29 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
Cc: Keith Busch, Philippe Mathieu-Daudé, qemu-block,
Stefan Hajnoczi, Klaus Jensen, Kevin Wolf, Hanna Reitz, Fam Zheng,
Klaus Jensen, Cédric Le Goater, Thomas Huth
From: Klaus Jensen <k.jensen@samsung.com>
Use the stl/ldl pci dma api for writing/reading doorbells. This removes
the explicit endian conversions.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index dadc2dc7da10..f2e5a2fa737b 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1468,20 +1468,16 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
{
- uint32_t v = 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));
+ stl_le_pci_dma(PCI_DEVICE(cq->ctrl), cq->ei_addr, cq->head,
+ MEMTXATTRS_UNSPECIFIED);
}
static void nvme_update_cq_head(NvmeCQueue *cq)
{
- uint32_t v;
-
- pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &v, sizeof(v));
-
- cq->head = le32_to_cpu(v);
+ ldl_le_pci_dma(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head,
+ MEMTXATTRS_UNSPECIFIED);
trace_pci_nvme_update_cq_head(cq->cqid, cq->head);
}
@@ -6801,7 +6797,6 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
PCIDevice *pci = PCI_DEVICE(n);
uint64_t dbs_addr = le64_to_cpu(req->cmd.dptr.prp1);
uint64_t eis_addr = le64_to_cpu(req->cmd.dptr.prp2);
- uint32_t v;
int i;
/* Address should be page aligned */
@@ -6819,8 +6814,6 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
NvmeCQueue *cq = n->cq[i];
if (sq) {
- v = cpu_to_le32(sq->tail);
-
/*
* CAP.DSTRD is 0, so offset of ith sq db_addr is (i<<3)
* nvme_process_db() uses this hard-coded way to calculate
@@ -6828,7 +6821,7 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
*/
sq->db_addr = dbs_addr + (i << 3);
sq->ei_addr = eis_addr + (i << 3);
- pci_dma_write(pci, sq->db_addr, &v, sizeof(sq->tail));
+ stl_le_pci_dma(pci, sq->db_addr, sq->tail, MEMTXATTRS_UNSPECIFIED);
if (n->params.ioeventfd && sq->sqid != 0) {
if (!nvme_init_sq_ioeventfd(sq)) {
@@ -6838,12 +6831,10 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
}
if (cq) {
- v = cpu_to_le32(cq->head);
-
/* CAP.DSTRD is 0, so offset of ith cq db_addr is (i<<3)+(1<<2) */
cq->db_addr = dbs_addr + (i << 3) + (1 << 2);
cq->ei_addr = eis_addr + (i << 3) + (1 << 2);
- pci_dma_write(pci, cq->db_addr, &v, sizeof(cq->head));
+ stl_le_pci_dma(pci, cq->db_addr, cq->head, MEMTXATTRS_UNSPECIFIED);
if (n->params.ioeventfd && cq->cqid != 0) {
if (!nvme_init_cq_ioeventfd(cq)) {
@@ -6974,20 +6965,16 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
{
- uint32_t v = cpu_to_le32(sq->tail);
-
trace_pci_nvme_update_sq_eventidx(sq->sqid, sq->tail);
- pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &v, sizeof(v));
+ stl_le_pci_dma(PCI_DEVICE(sq->ctrl), sq->ei_addr, sq->tail,
+ MEMTXATTRS_UNSPECIFIED);
}
static void nvme_update_sq_tail(NvmeSQueue *sq)
{
- uint32_t v;
-
- pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &v, sizeof(v));
-
- sq->tail = le32_to_cpu(v);
+ ldl_le_pci_dma(PCI_DEVICE(sq->ctrl), sq->db_addr, &sq->tail,
+ MEMTXATTRS_UNSPECIFIED);
trace_pci_nvme_update_sq_tail(sq->sqid, sq->tail);
}
@@ -7592,7 +7579,7 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size)
static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
{
PCIDevice *pci = PCI_DEVICE(n);
- uint32_t qid, v;
+ uint32_t qid;
if (unlikely(addr & ((1 << 2) - 1))) {
NVME_GUEST_ERR(pci_nvme_ub_db_wr_misaligned,
@@ -7659,8 +7646,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
start_sqs = nvme_cq_full(cq) ? 1 : 0;
cq->head = new_head;
if (!qid && n->dbbuf_enabled) {
- v = cpu_to_le32(cq->head);
- pci_dma_write(pci, cq->db_addr, &v, sizeof(cq->head));
+ stl_le_pci_dma(pci, cq->db_addr, cq->head, MEMTXATTRS_UNSPECIFIED);
}
if (start_sqs) {
NvmeSQueue *sq;
@@ -7720,8 +7706,6 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
sq->tail = new_tail;
if (!qid && n->dbbuf_enabled) {
- v = cpu_to_le32(sq->tail);
-
/*
* The spec states "the host shall also update the controller's
* corresponding doorbell property to match the value of that entry
@@ -7735,7 +7719,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
* including ones that run on Linux, are not updating Admin Queues,
* so we can't trust reading it for an appropriate sq tail.
*/
- pci_dma_write(pci, sq->db_addr, &v, sizeof(sq->tail));
+ stl_le_pci_dma(pci, sq->db_addr, sq->tail, MEMTXATTRS_UNSPECIFIED);
}
qemu_bh_schedule(sq->bh);
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PULL 0/1] hw/nvme fixes
2023-07-30 19:29 [PULL 0/1] hw/nvme fixes Klaus Jensen
2023-07-30 19:29 ` [PULL 1/1] hw/nvme: use stl/ldl pci dma api Klaus Jensen
@ 2023-07-31 16:26 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2023-07-31 16:26 UTC (permalink / raw)
To: Klaus Jensen, Peter Maydell, qemu-devel
Cc: Keith Busch, Philippe Mathieu-Daudé, qemu-block,
Stefan Hajnoczi, Kevin Wolf, Hanna Reitz, Fam Zheng, Klaus Jensen
On 7/30/23 12:29, Klaus Jensen wrote:
> From: Klaus Jensen<k.jensen@samsung.com>
>
> Hi,
>
> This should also fix coverity cid 1518067 and 1518066.
>
> The following changes since commit ccb86f079a9e4d94918086a9df18c1844347aff8:
>
> Merge tag 'pull-nbd-2023-07-28' ofhttps://repo.or.cz/qemu/ericb into staging (2023-07-28 09:56:57 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/birkelund/qemu.git tags/nvme-next-pull-request
>
> for you to fetch changes up to c1e244b6552efdff5612a33c6630aaf95964eaf5:
>
> hw/nvme: use stl/ldl pci dma api (2023-07-30 20:09:54 +0200)
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-31 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-30 19:29 [PULL 0/1] hw/nvme fixes Klaus Jensen
2023-07-30 19:29 ` [PULL 1/1] hw/nvme: use stl/ldl pci dma api Klaus Jensen
2023-07-31 16:26 ` [PULL 0/1] hw/nvme fixes Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).