From: Bob Pearson <rpearsonhpe@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 2/2] RDMA/rxe: Pass a pointer to virt_to_page()
Date: Wed, 29 Mar 2023 15:14:05 -0500 [thread overview]
Message-ID: <ed178af5-841f-2615-3b51-8f8bcf656e46@gmail.com> (raw)
In-Reply-To: <20230329142341.863175-2-linus.walleij@linaro.org>
On 3/29/23 09:23, Linus Walleij wrote:
> Like the other calls in this function virt_to_page() expects
> a pointer, not an integer.
>
> However since many architectures implement virt_to_pfn() as
> a macro, this function becomes polymorphic and accepts both a
> (unsigned long) and a (void *).
>
> Fix this up with an explicit cast.
>
> Then we need a second cast to (uintptr_t). This is because
> the kernel robot builds this driver also for the PARISC,
> yielding the following build error on PARISC when casting
> (void *) to virt_to_page():
>
> drivers/infiniband/sw/rxe/rxe_mr.c: In function 'rxe_set_page':
>>> drivers/infiniband/sw/rxe/rxe_mr.c:216:42: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 216 | struct page *page = virt_to_page((void *)(iova & mr->page_mask));
> | ^
> include/asm-generic/memory_model.h:18:46: note: in definition of macro '__pfn_to_page'
> 18 | #define __pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET))
> | ^~~
> arch/parisc/include/asm/page.h:179:45: note: in expansion of macro '__pa'
> 179 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
> | ^~~~
> drivers/infiniband/sw/rxe/rxe_mr.c:216:29: note: in expansion of macro 'virt_to_page'
> 216 | struct page *page = virt_to_page((void *)(iova & mr->page_mask));
> | ^~~~~~~~~~~~
>
> First: I think this happens because iova is u64 by design and
> (void *) on PARISC is sometimes 32 bit.
>
> Second: compilation of the SW RXE driver on PARISC is made possible
> because it fulfills depends on INFINIBAND_VIRT_DMA since that is just
> def_bool !HIGHMEM and PARISC does not have HIGHMEM.
>
> By first casting iova to (uintptr_t) it is turned into a u32 on PARISC
> or any other 32bit system and u64 on any 64BIT system.
>
> Link: https://lore.kernel.org/linux-rdma/202303242000.HmTaa6yB-lkp@intel.com/
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Fix up confusion between virtual and physical addresses found
> by Jason in a separate patch.
> - Fix up compilation on PARISC by additional cast.
> I don't know if this is the right solution, perhaps RDMA should
> rather depend on 64BIT if the subsystem is only for 64BIT
> systems?
> ---
> drivers/infiniband/sw/rxe/rxe_mr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
> index 8e8250652f9d..a5efb0575956 100644
> --- a/drivers/infiniband/sw/rxe/rxe_mr.c
> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
> @@ -213,7 +213,7 @@ int rxe_mr_init_fast(int max_pages, struct rxe_mr *mr)
> static int rxe_set_page(struct ib_mr *ibmr, u64 iova)
> {
> struct rxe_mr *mr = to_rmr(ibmr);
> - struct page *page = virt_to_page(iova & mr->page_mask);
> + struct page *page = virt_to_page((void *)(uintptr_t)(iova & mr->page_mask));
> bool persistent = !!(mr->access & IB_ACCESS_FLUSH_PERSISTENT);
> int err;
>
Linus, Thanks for these. AFAIK these are just fine. I am not aware of any interest in 32 bit
support for the rxe driver. My testing has been limited to IA64 architectures but I would be interested
in going further with emulated hardware.
Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
next prev parent reply other threads:[~2023-03-29 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 14:23 [PATCH v2 1/2] RDMA/rxe: Treat physical addresses right Linus Walleij
2023-03-29 14:23 ` [PATCH v2 2/2] RDMA/rxe: Pass a pointer to virt_to_page() Linus Walleij
2023-03-29 20:14 ` Bob Pearson [this message]
2023-04-02 13:51 ` [PATCH v2 1/2] RDMA/rxe: Treat physical addresses right Zhu Yanjun
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=ed178af5-841f-2615-3b51-8f8bcf656e46@gmail.com \
--to=rpearsonhpe@gmail.com \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linus.walleij@linaro.org \
--cc=linux-rdma@vger.kernel.org \
/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 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).