[External] Re: [PATCH] riscv: introduce the ioremap_prot() function

yunhui cui cuiyunhui at bytedance.com
Sun Mar 23 18:34:13 PDT 2025


Hi Christoph,

On Thu, Mar 20, 2025 at 11:41 PM Christoph Hellwig <hch at infradead.org> wrote:
>
> > +{
> > +     phys_addr_t addr = PFN_PHYS(pfn);
> > +
> > +     /* avoid false positives for bogus PFNs, see comment in pfn_valid() */
> > +     if (PHYS_PFN(addr) != pfn)
> > +             return 0;
> > +
> > +     return memblock_is_map_memory(addr);
> > +}
> > +EXPORT_SYMBOL(pfn_is_map_memory);
>
> This should not be exported or even exposed.  Please just open code it
> in the only caller.
>
> > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
> > +                        pgprot_t pgprot)
> > +{
> > +     /* Don't allow RAM to be mapped. */
> > +     if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr))))
> > +             return NULL;
>
> Or just use pfn_valid as that's what we usually use for that check.
> Or am I missing something specific here?
>
> It would also be nice to just life this to common code.

Thank you for your suggestion. I was planning to do just that. If
possible, I'll make the update in version 2.

Thanks,
Yunhui



More information about the linux-riscv mailing list