From: Leon Romanovsky <leonro@nvidia.com>
Remove the bus_off field from pci_p2pdma_map_state since it duplicates
information already available in the pgmap structure. The bus_offset
is only used in one location (pci_p2pdma_bus_addr_map) and is always
identical to pgmap->bus_offset.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/pci/p2pdma.c | 1 -
include/linux/pci-p2pdma.h | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index da5657a020074..274bb7bcc0bc5 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -1009,7 +1009,6 @@ void __pci_p2pdma_update_state(struct pci_p2pdma_map_state *state,
{
state->pgmap = page_pgmap(page);
state->map = pci_p2pdma_map_type(state->pgmap, dev);
- state->bus_off = to_p2p_pgmap(state->pgmap)->bus_offset;
}
/**
diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h
index 075c20b161d98..b502fc8b49bf9 100644
--- a/include/linux/pci-p2pdma.h
+++ b/include/linux/pci-p2pdma.h
@@ -146,7 +146,6 @@ enum pci_p2pdma_map_type {
struct pci_p2pdma_map_state {
struct dev_pagemap *pgmap;
enum pci_p2pdma_map_type map;
- u64 bus_off;
};
/* helper for pci_p2pdma_state(), do not use directly */
@@ -186,7 +185,7 @@ static inline dma_addr_t
pci_p2pdma_bus_addr_map(struct pci_p2pdma_map_state *state, phys_addr_t paddr)
{
WARN_ON_ONCE(state->map != PCI_P2PDMA_MAP_BUS_ADDR);
- return paddr + state->bus_off;
+ return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
}
#endif /* _LINUX_PCI_P2P_H */
--
2.50.1
On Mon, 4 Aug 2025 16:00:36 +0300
Leon Romanovsky <leon@kernel.org> wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> Remove the bus_off field from pci_p2pdma_map_state since it duplicates
> information already available in the pgmap structure. The bus_offset
> is only used in one location (pci_p2pdma_bus_addr_map) and is always
> identical to pgmap->bus_offset.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> drivers/pci/p2pdma.c | 1 -
> include/linux/pci-p2pdma.h | 3 +--
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index da5657a020074..274bb7bcc0bc5 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -1009,7 +1009,6 @@ void __pci_p2pdma_update_state(struct pci_p2pdma_map_state *state,
> {
> state->pgmap = page_pgmap(page);
> state->map = pci_p2pdma_map_type(state->pgmap, dev);
> - state->bus_off = to_p2p_pgmap(state->pgmap)->bus_offset;
> }
>
> /**
> diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h
> index 075c20b161d98..b502fc8b49bf9 100644
> --- a/include/linux/pci-p2pdma.h
> +++ b/include/linux/pci-p2pdma.h
> @@ -146,7 +146,6 @@ enum pci_p2pdma_map_type {
> struct pci_p2pdma_map_state {
> struct dev_pagemap *pgmap;
> enum pci_p2pdma_map_type map;
> - u64 bus_off;
> };
>
> /* helper for pci_p2pdma_state(), do not use directly */
> @@ -186,7 +185,7 @@ static inline dma_addr_t
> pci_p2pdma_bus_addr_map(struct pci_p2pdma_map_state *state, phys_addr_t paddr)
> {
> WARN_ON_ONCE(state->map != PCI_P2PDMA_MAP_BUS_ADDR);
> - return paddr + state->bus_off;
> + return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
> }
>
> #endif /* _LINUX_PCI_P2P_H */
Looks like you're relying on this bogus code getting resolved in the
next patch...
In file included from kernel/dma/direct.c:16:
./include/linux/pci-p2pdma.h: In function ‘pci_p2pdma_bus_addr_map’:
./include/linux/pci-p2pdma.h:188:24: error: implicit declaration of function ‘to_p2p_pgmap’ [-Wimplicit-function-declaration]
188 | return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
| ^~~~~~~~~~~~
./include/linux/pci-p2pdma.h:188:50: error: invalid type argument of ‘->’ (have ‘int’)
188 | return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
| ^~
./include/linux/pci-p2pdma.h:189:1: error: control reaches end of non-void function [-Werror=return-type]
189 | }
| ^
to_p2p_pgmap() is a static function and struct pci_p2pdma_pagemap
doesn't have a bus_offsetf member. Thanks,
Alex
On Wed, Aug 06, 2025 at 02:58:25PM -0600, Alex Williamson wrote:
> On Mon, 4 Aug 2025 16:00:36 +0300
> Leon Romanovsky <leon@kernel.org> wrote:
>
> > From: Leon Romanovsky <leonro@nvidia.com>
> >
> > Remove the bus_off field from pci_p2pdma_map_state since it duplicates
> > information already available in the pgmap structure. The bus_offset
> > is only used in one location (pci_p2pdma_bus_addr_map) and is always
> > identical to pgmap->bus_offset.
> >
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> > drivers/pci/p2pdma.c | 1 -
> > include/linux/pci-p2pdma.h | 3 +--
> > 2 files changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> > index da5657a020074..274bb7bcc0bc5 100644
> > --- a/drivers/pci/p2pdma.c
> > +++ b/drivers/pci/p2pdma.c
> > @@ -1009,7 +1009,6 @@ void __pci_p2pdma_update_state(struct pci_p2pdma_map_state *state,
> > {
> > state->pgmap = page_pgmap(page);
> > state->map = pci_p2pdma_map_type(state->pgmap, dev);
> > - state->bus_off = to_p2p_pgmap(state->pgmap)->bus_offset;
> > }
> >
> > /**
> > diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h
> > index 075c20b161d98..b502fc8b49bf9 100644
> > --- a/include/linux/pci-p2pdma.h
> > +++ b/include/linux/pci-p2pdma.h
> > @@ -146,7 +146,6 @@ enum pci_p2pdma_map_type {
> > struct pci_p2pdma_map_state {
> > struct dev_pagemap *pgmap;
> > enum pci_p2pdma_map_type map;
> > - u64 bus_off;
> > };
> >
> > /* helper for pci_p2pdma_state(), do not use directly */
> > @@ -186,7 +185,7 @@ static inline dma_addr_t
> > pci_p2pdma_bus_addr_map(struct pci_p2pdma_map_state *state, phys_addr_t paddr)
> > {
> > WARN_ON_ONCE(state->map != PCI_P2PDMA_MAP_BUS_ADDR);
> > - return paddr + state->bus_off;
> > + return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
> > }
> >
> > #endif /* _LINUX_PCI_P2P_H */
Sorry for long time to reply, I waited to see what is going on with DMA
phys_vec basic series and together with my summer vacation, it took a
while.
>
> Looks like you're relying on this bogus code getting resolved in the
> next patch...
>
> In file included from kernel/dma/direct.c:16:
> ./include/linux/pci-p2pdma.h: In function ‘pci_p2pdma_bus_addr_map’:
> ./include/linux/pci-p2pdma.h:188:24: error: implicit declaration of function ‘to_p2p_pgmap’ [-Wimplicit-function-declaration]
> 188 | return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
> | ^~~~~~~~~~~~
> ./include/linux/pci-p2pdma.h:188:50: error: invalid type argument of ‘->’ (have ‘int’)
> 188 | return paddr + to_p2p_pgmap(state->pgmap)->bus_offsetf;
> | ^~
> ./include/linux/pci-p2pdma.h:189:1: error: control reaches end of non-void function [-Werror=return-type]
> 189 | }
> | ^
>
> to_p2p_pgmap() is a static function and struct pci_p2pdma_pagemap
> doesn't have a bus_offsetf member. Thanks,
You are right, probably the best way to fix the error is simply squash
this change into the next patch.
Thanks
>
> Alex
>
© 2016 - 2026 Red Hat, Inc.