Message ID | 20230515090848.833045-7-bhe@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: ioremap: Convert architectures to take GENERIC_IOREMAP way | expand |
On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > Several architectures has done checking if slab if available in > ioremap_prot(). In fact it should be done in generic ioremap_prot() > since on any architecutre, slab allocator must be available before > get_vm_area_caller() and vunmap() are used. > > Add the checking into generic_ioremap_prot(). > > Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> > Signed-off-by: Baoquan He <bhe@redhat.com> Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org> > --- > mm/ioremap.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/ioremap.c b/mm/ioremap.c > index 9f34a8f90b58..2fbe6b9bc50e 100644 > --- a/mm/ioremap.c > +++ b/mm/ioremap.c > @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, > phys_addr_t last_addr; > struct vm_struct *area; > > + /* An early platform driver might end up here */ > + if (!slab_is_available()) > + return NULL; > + > /* Disallow wrap-around or zero size */ > last_addr = phys_addr + size - 1; > if (!size || last_addr < phys_addr) > -- > 2.34.1 > >
On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > Several architectures has done checking if slab if available in > ioremap_prot(). In fact it should be done in generic ioremap_prot() > since on any architecutre, slab allocator must be available before > get_vm_area_caller() and vunmap() are used. > > Add the checking into generic_ioremap_prot(). Should we add a WARN_ON/WARN_ON_ONCE to aid debugging? Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On 2023/5/15 17:08, Baoquan He wrote: > Several architectures has done checking if slab if available in > ioremap_prot(). In fact it should be done in generic ioremap_prot() > since on any architecutre, slab allocator must be available before > get_vm_area_caller() and vunmap() are used. > > Add the checking into generic_ioremap_prot(). > > Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> > Signed-off-by: Baoquan He <bhe@redhat.com> > --- > mm/ioremap.c | 4 ++++ > 1 file changed, 4 insertions(+) > Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com>
On 05/16/23 at 11:30pm, Christoph Hellwig wrote: > On Mon, May 15, 2023 at 05:08:37PM +0800, Baoquan He wrote: > > Several architectures has done checking if slab if available in > > ioremap_prot(). In fact it should be done in generic ioremap_prot() > > since on any architecutre, slab allocator must be available before > > get_vm_area_caller() and vunmap() are used. > > > > Add the checking into generic_ioremap_prot(). > > Should we add a WARN_ON/WARN_ON_ONCE to aid debugging? Sounds like a great idea, will add WARN_ON_ONCE as below. Thanks. if (WARN_ON_ONCE(!slab_is_available())) return NULL;
diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (!slab_is_available()) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr)
Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Baoquan He <bhe@redhat.com> --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+)