* [PATCH] nvme: Use pci_iomap instead of ioremap
[not found] <CGME20220121143539eucas1p20202376f83b0b499143c18b1434ff000@eucas1p2.samsung.com>
@ 2022-01-21 14:35 ` Pankaj Raghav
2022-01-26 16:33 ` Christoph Hellwig
0 siblings, 1 reply; 9+ messages in thread
From: Pankaj Raghav @ 2022-01-21 14:35 UTC (permalink / raw)
To: Keith Busch, Christoph Hellwig; +Cc: Pankaj Raghav, linux-nvme, Pankaj Raghav
Use the better checked pci_iomap instead of ioremap.
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
drivers/nvme/host/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index d8585df2c2fd..6c8aad9ff7db 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1800,7 +1800,7 @@ static int nvme_remap_bar(struct nvme_dev *dev, unsigned long size)
return -ENOMEM;
if (dev->bar)
iounmap(dev->bar);
- dev->bar = ioremap(pci_resource_start(pdev, 0), size);
+ dev->bar = pci_iomap(pdev, 0, size);
if (!dev->bar) {
dev->bar_mapped_size = 0;
return -ENOMEM;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-21 14:35 ` [PATCH] nvme: Use pci_iomap instead of ioremap Pankaj Raghav
@ 2022-01-26 16:33 ` Christoph Hellwig
2022-01-26 17:22 ` Keith Busch
2022-01-27 13:05 ` Pankaj Raghav
0 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-26 16:33 UTC (permalink / raw)
To: Pankaj Raghav; +Cc: Keith Busch, Christoph Hellwig, Pankaj Raghav, linux-nvme
pci_iomap goes with the ioread/iowrite accessors which we absolutely
do not want in nvme.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-26 16:33 ` Christoph Hellwig
@ 2022-01-26 17:22 ` Keith Busch
2022-01-26 17:26 ` Christoph Hellwig
2022-01-27 13:16 ` Pankaj Raghav
2022-01-27 13:05 ` Pankaj Raghav
1 sibling, 2 replies; 9+ messages in thread
From: Keith Busch @ 2022-01-26 17:22 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Pankaj Raghav, Pankaj Raghav, linux-nvme
On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
> pci_iomap goes with the ioread/iowrite accessors which we absolutely
> do not want in nvme.
It looks like the action pci_iomap() uses is based on the
pci_resource_flags(), and should call the same "ioremap()" function we
currently use.
The one problem I see with this, though, is that pci_iomap() will
automatically clamp the mapped length to the resource's length, which
may be shorter than the potential doorbell registers that the driver
thinks it's getting.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-26 17:22 ` Keith Busch
@ 2022-01-26 17:26 ` Christoph Hellwig
2022-01-27 13:16 ` Pankaj Raghav
1 sibling, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-26 17:26 UTC (permalink / raw)
To: Keith Busch; +Cc: Christoph Hellwig, Pankaj Raghav, Pankaj Raghav, linux-nvme
On Wed, Jan 26, 2022 at 09:22:04AM -0800, Keith Busch wrote:
> On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
> > pci_iomap goes with the ioread/iowrite accessors which we absolutely
> > do not want in nvme.
>
> It looks like the action pci_iomap() uses is based on the
> pci_resource_flags(), and should call the same "ioremap()" function we
> currently use.
Yes. But the rule is: use ioremap when you use read*/write*, and use
pci_iomap when using ioread/iowrite. But they should never be mixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-26 16:33 ` Christoph Hellwig
2022-01-26 17:22 ` Keith Busch
@ 2022-01-27 13:05 ` Pankaj Raghav
2022-01-27 14:45 ` Christoph Hellwig
1 sibling, 1 reply; 9+ messages in thread
From: Pankaj Raghav @ 2022-01-27 13:05 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Pankaj Raghav, Keith Busch, linux-nvme
On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
> pci_iomap goes with the ioread/iowrite accessors which we absolutely
> do not want in nvme.
Is it because of ioread/iowrite has a conditional check everytime we do
a read/write with IO_COND? Or is there any other reason?
--
Pankaj
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-26 17:22 ` Keith Busch
2022-01-26 17:26 ` Christoph Hellwig
@ 2022-01-27 13:16 ` Pankaj Raghav
1 sibling, 0 replies; 9+ messages in thread
From: Pankaj Raghav @ 2022-01-27 13:16 UTC (permalink / raw)
To: Keith Busch, Christoph Hellwig; +Cc: Pankaj Raghav, linux-nvme
On 2022-01-26 22:52, Keith Busch wrote:
> On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
> The one problem I see with this, though, is that pci_iomap() will
> automatically clamp the mapped length to the resource's length, which
> may be shorter than the potential doorbell registers that the driver
> thinks it's getting.
The current implementation disallow the size to be greater than
the pci_resource_len(pdev, 0).
if (size > pci_resource_len(pdev, 0))
return -ENOMEM;
So, clamping shouldn't be an issue when we use pci_iomap.
--
Regards,
Pankaj
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-27 13:05 ` Pankaj Raghav
@ 2022-01-27 14:45 ` Christoph Hellwig
2022-01-27 15:56 ` Pankaj Raghav
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-27 14:45 UTC (permalink / raw)
To: Pankaj Raghav; +Cc: Christoph Hellwig, Pankaj Raghav, Keith Busch, linux-nvme
On Thu, Jan 27, 2022 at 06:35:41PM +0530, Pankaj Raghav wrote:
> On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
> > pci_iomap goes with the ioread/iowrite accessors which we absolutely
> > do not want in nvme.
> Is it because of ioread/iowrite has a conditional check everytime we do
> a read/write with IO_COND? Or is there any other reason?
Yes, ioread* and iowrite* are more expensive. And nvme doesn't support
port I/O anyway so there is no point.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-27 14:45 ` Christoph Hellwig
@ 2022-01-27 15:56 ` Pankaj Raghav
2022-01-27 16:01 ` Christoph Hellwig
0 siblings, 1 reply; 9+ messages in thread
From: Pankaj Raghav @ 2022-01-27 15:56 UTC (permalink / raw)
To: Christoph Hellwig, Pankaj Raghav; +Cc: Keith Busch, linux-nvme
On 2022-01-27 20:15, Christoph Hellwig wrote:
> On Thu, Jan 27, 2022 at 06:35:41PM +0530, Pankaj Raghav wrote:
>> On Wed, Jan 26, 2022 at 05:33:06PM +0100, Christoph Hellwig wrote:
>>> pci_iomap goes with the ioread/iowrite accessors which we absolutely
>>> do not want in nvme.
>> Is it because of ioread/iowrite has a conditional check everytime we do
>> a read/write with IO_COND? Or is there any other reason?
>
> Yes, ioread* and iowrite* are more expensive. And nvme doesn't support
> port I/O anyway so there is no point.
Ok.
`ioremap` has a comment to prefer pci_iomap if the area we are trying
to map is a PCI BAR. Does it makes sense then to have a comment in
the nvme pci driver as to why ioremap is preferred over pci_iomap?
--
Regards,
Pankaj
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] nvme: Use pci_iomap instead of ioremap
2022-01-27 15:56 ` Pankaj Raghav
@ 2022-01-27 16:01 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2022-01-27 16:01 UTC (permalink / raw)
To: Pankaj Raghav; +Cc: Christoph Hellwig, Pankaj Raghav, Keith Busch, linux-nvme
On Thu, Jan 27, 2022 at 09:26:28PM +0530, Pankaj Raghav wrote:
> `ioremap` has a comment to prefer pci_iomap if the area we are trying
> to map is a PCI BAR. Does it makes sense then to have a comment in
> the nvme pci driver as to why ioremap is preferred over pci_iomap?
I don't think that comment is correct. pci_iomap is not a replacement
for ioremap, but an interface that helps drivers that need to
transparently deal with MMIO and Port I/O - something that is mostly
of historic interest these days.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-27 16:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20220121143539eucas1p20202376f83b0b499143c18b1434ff000@eucas1p2.samsung.com>
2022-01-21 14:35 ` [PATCH] nvme: Use pci_iomap instead of ioremap Pankaj Raghav
2022-01-26 16:33 ` Christoph Hellwig
2022-01-26 17:22 ` Keith Busch
2022-01-26 17:26 ` Christoph Hellwig
2022-01-27 13:16 ` Pankaj Raghav
2022-01-27 13:05 ` Pankaj Raghav
2022-01-27 14:45 ` Christoph Hellwig
2022-01-27 15:56 ` Pankaj Raghav
2022-01-27 16:01 ` Christoph Hellwig
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.