Re: [PATCH] include/asm-generic/io.h: add 'UML' case just like 'no-MMU'

From: Chen Gang
Date: Sun Jun 30 2013 - 23:45:30 EST


On 07/01/2013 09:40 AM, Chen Gang wrote:
> On 06/26/2013 06:22 PM, Chen Gang wrote:
>> > On 06/26/2013 06:17 PM, Richard Weinberger wrote:
>>> >> Am 26.06.2013 12:01, schrieb Chen Gang:
>>>>> >>>> On 06/26/2013 05:48 PM, Geert Uytterhoeven wrote:
>>>>>>> >>>>>> On Wed, Jun 26, 2013 at 11:38 AM, Richard Weinberger <richard@xxxxxx> wrote:
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> Since the API itself already contents the meaning: "return NULL means
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> the arch has no related io memory",
>>>>>>> >>>>>> No, NULL means it could not map the I/O memory.
>>>>>>> >>>>>>
>>>>> >>>>
>>>>> >>>> "it could not map the I/O memory" includes "has no related io memory".
>>>>> >>>> So it is enough for our case.
>>>>> >>>>
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> Why not define a generic dummy one in "include/asm-generic/io.h" instead
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> of "HAS_IOMEM" (which has already spread many various places, and also,
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> most of new drivers have to know about it).
>>>>>>>>>>>>>>> >>>>>>>>>>>>>>
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> e.g: in "include/asm-generic/io.h", if "CONFIG_HAS_IOMEM=n", define a
>>>>>>>>>>>>>>> >>>>>>>>>>>>>> dummy ioremap() which return NULL ... (also need consider more details).
>>>>>>>>>>> >>>>>>>>>>
>>>>>>>>>>> >>>>>>>>>> Because we don't even want to build these drivers and not make them fail while
>>>>>>>>>>> >>>>>>>>>> executing io memory related functions.
>>>>>>> >>>>>> Indeed, it doesn't make sense to build drivers that cannot work.
>>>>>>> >>>>>> And they may fail in a very bad way.
>>>>> >>>>
>>>>> >>>> That is our 'platform' guys feeling, not the 'module' guys, as
>>>>> >>>> 'platform' guys, it is better to provide the choice to 'module' guys,
>>>>> >>>> and let them decide by themselves, not forced by us.
>>> >> FYI, this is my last reply to this thread.
>>> >>
>>> >> As Geert and I said, drivers which need io memory have to depend on HAS_IOMEM=y.
>>> >> If an arch does not have io memory these drivers cannot work and therefore we don't
>>> >> want them built.
>> >
> Hmm, if the modules select 'COMPILE_TEST', it is better to let asm-generic
> support this features (at least, not forbid it)
>
> So how about the diff below ? ;-)
>
> ---------------------------diff begin-----------------------------------
>
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index d5afe96..ede3775 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -303,13 +303,17 @@ static inline void *phys_to_virt(unsigned long address)
> /*
> * Change "struct page" to physical address.
> *
> - * This implementation is for the no-MMU case only... if you have an MMU
> - * you'll need to provide your own definitions.
> + * This for the no-MMU, or no-IOMEM but still try to COMPILE_TEST cases.
> + * if you have an MMU and IOMEM, you'll need to provide your own definitions.
> */
> -#ifndef CONFIG_MMU
> +#if !defined(CONFIG_MMU) || \
> + (!defined(CONFIG_HAS_IOMEM) && defined(COMPILE_TEST))

Need use 'CONFIG_COMPILE_TEST' instead of 'COMPILE_TEST'.

> static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
> {
> +#if !defined(CONFIG_MMU)
> return (void __iomem*) (unsigned long)offset;
> +#else
> + return NULL;
> }
>
> #define __ioremap(offset, size, flags) ioremap(offset, size)
> @@ -325,7 +329,7 @@ static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
> static inline void iounmap(void __iomem *addr)
> {
> }
> -#endif /* CONFIG_MMU */
> +#endif /* !MMU || (!HAS_IOMEM && COMPILE_TEST) */
>
> #ifdef CONFIG_HAS_IOPORT
> #ifndef CONFIG_GENERIC_IOMAP
>
> ---------------------------diff end-------------------------------------
>
>> > It is really the time for stopping discussion, and thank you all for
>> > spending your time resources on this discussion.
>> >
>> > Next, I will send related patch for it (also cc to you all).
>> >
>> >
>> > Thanks.
>> >
>
> -- Chen Gang
>


--
Chen Gang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/