Messages in this thread | | | From | Christophe Leroy <> | Subject | Re: [PATCH v2 07/11] openrisc: mm: Convert to GENERIC_IOREMAP | Date | Tue, 30 Aug 2022 06:05:12 +0000 |
| |
Hi Christoph,
Le 21/08/2022 à 09:03, Christoph Hellwig a écrit : >> + if (unlikely(!mem_init_done)) { >> if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) >> + return IOMEM_ERR_PTR(ret); >> v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); >> fixmaps_used += (size >> PAGE_SHIFT); >> >> + if (ioremap_page_range(v, v + size, p, __pgprot(*prot_val))) { >> fixmaps_used -= (size >> PAGE_SHIFT); >> + return IOMEM_ERR_PTR(ret); >> + } >> + >> + return (void __iomem *)(offset + (char *)v); >> } > > This code needs to go away, and all very early boot uses of ioremap > need to switch to use early_ioremap insted. >
early_ioremap() is not that easy to use. I don't know in this particular openrisc context, but in powerpc we have many places that use ioremap() very early.
Three years ago we implemented EARLY_IOREMAP, commit d538aadc2718 ("powerpc/ioremap: warn on early use of ioremap()") added a warning to identify all places using ioremap() early with the target being to get rid of early usage of ioremap. But it turned that using early_ioremap() is not that easy.
The problem with early_ioremap() is that it installs ephemeral mappings that must be freed before the end of init. Most early uses of ioremap() in powerpc are to install mappings that will last for life.
If we could have something that works like memblock_alloc() and allows to keep the allocation forever, then it would be a lot easier to use early_ioremap() and we could get rid of the early handling of ioremap() in powerpc.
Christophe | |