All of lore.kernel.org
 help / color / mirror / Atom feed
From: Torsten Duwe <duwe@lst.de>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: "Bin Meng" <bmeng.cn@gmail.com>,
	"Andrew Goodbody" <andrew.goodbody@linaro.org>,
	"Peter Robinson" <pbrobinson@gmail.com>,
	"Matthias Brugger" <mbrugger@suse.com>,
	"Tom Rini" <trini@konsulko.com>,
	"Andrea della Porta" <andrea.porta@suse.com>,
	"Simon Glass" <sjg@chromium.org>, "Jan Čermák" <sairon@sairon.cz>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 2/3] nvme: Fix missing address translation for PCIe inbound access
Date: Tue, 12 May 2026 11:30:17 +0200	[thread overview]
Message-ID: <20260512113017.6d91e06c@neoN1> (raw)
In-Reply-To: <0fd48f59-1309-45ff-ab21-8b037449ea86@linaro.org>

On Mon, 11 May 2026 16:50:48 +0200
Neil Armstrong <neil.armstrong@linaro.org> wrote:

> On 5/8/26 17:42, Torsten Duwe wrote:
[...]
> > +#define DEV_ADDR(a)		dev_phys_to_bus(dev->udev, (a))
> 
> This doesn't look very clean, I would do something closer to linux by precalculating
> the DMA addresses after allocation like:
> ====================><================================
> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> index 2b14437f69c..1ce06402a90 100644
> --- a/drivers/nvme/nvme.c
> +++ b/drivers/nvme/nvme.c
> @@ -241,6 +241,7 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev,
>   	nvmeq->sq_cmds = (void *)memalign(4096, NVME_SQ_SIZE(depth));
>   	if (!nvmeq->sq_cmds)
>   		goto free_queue;
> +	nvmeq->sq_dma_addr = dev_phys_to_bus(dev->udev, nvmeq->sq_cmds);
>   	memset((void *)nvmeq->sq_cmds, 0, NVME_SQ_SIZE(depth));
> 
>   	nvmeq->dev = dev;
> @@ -393,7 +394,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
>   	dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
> 
>   	writel(aqa, &dev->bar->aqa);
> -	nvme_writeq((ulong)nvmeq->sq_cmds, &dev->bar->asq);
> +	nvme_writeq((ulong)nvmeq->sq_dma_addr, &dev->bar->asq);
>   	nvme_writeq((ulong)nvmeq->cqes, &dev->bar->acq);
> 
>   	result = nvme_enable_ctrl(dev);

Hm, time / space tradeoff. I don't really have a strong preference
regarding this, I'd worry most about U-Boot code size (for which this
doesn't make much of a difference). However, I was under the impression
that during regular NVMe business a lot of those buffers and addresses
get allocated and the translations are required often. That's probably
only true once a full-blown operating system is running.

I'll check the allocations and assignments. Any other opinions?

	Torsten

  reply	other threads:[~2026-05-12  9:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 15:41 [PATCH 0/3] Fix NVMe, not only on Raspberry Pi 5 Torsten Duwe
2026-05-08 15:42 ` [PATCH 1/3] core: Skip parent device nodes without a DT reference when looking for dma-ranges Torsten Duwe
2026-05-08 18:47   ` Simon Glass
2026-05-08 19:42     ` Torsten Duwe
2026-05-08 19:56       ` Peter Robinson
2026-05-08 23:36         ` Simon Glass
2026-05-09 15:29   ` Peter Robinson
2026-05-08 15:42 ` [PATCH 2/3] nvme: Fix missing address translation for PCIe inbound access Torsten Duwe
2026-05-09 15:28   ` Peter Robinson
2026-05-11 14:50   ` Neil Armstrong
2026-05-12  9:30     ` Torsten Duwe [this message]
2026-05-12  9:34       ` Neil Armstrong
2026-05-08 15:42 ` [PATCH 3/3] configs: enable NVMe Torsten Duwe
2026-05-08 18:00   ` Peter Robinson
2026-05-09 15:27     ` Peter Robinson
2026-05-09 15:31 ` [PATCH 0/3] Fix NVMe, not only on Raspberry Pi 5 Peter Robinson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260512113017.6d91e06c@neoN1 \
    --to=duwe@lst.de \
    --cc=andrea.porta@suse.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=mbrugger@suse.com \
    --cc=neil.armstrong@linaro.org \
    --cc=pbrobinson@gmail.com \
    --cc=sairon@sairon.cz \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.