Re: [PATCH] MIPS: bcm63xx: move bcm63xx_gpio_init() to bcm63xx_register_devices().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 16, 2015 at 3:53 PM, Maxime Bizon <mbizon@xxxxxxxxxx> wrote:
>
> On Thu, 2015-03-12 at 17:00 +0100, Nicolas Schichan wrote:
>
>> When called from prom init code, bcm63xx_gpio_init() will fail as it
>> will call gpiochip_add() which relies on a working kmalloc() to alloc
>> the gpio_desc array and kmalloc is not useable yet at prom init time.
>>
>> Move bcm63xx_gpio_init() to bcm63xx_register_devices() (an
>> arch_initcall) where kmalloc works.
>
> no that patch is completely bogus:
>
> 1) bcm63xx_gpio_init() does more than registering the gpio_chip: look at
> bcm63xx_gpio_out_low_reg_init().
>
> We want at least the low lever helpers bcm_gpio_readl()/writel() to work
> early.

bcm_gpio_readl/bcm_gpio_writel() are completely unaffected by anything
done by bcm63xx_gpio_out_low_reg_init(), all they do is access the
gpio register space.

And all of the functions using the gpio_out_low_reg are static and
only accessible through the registered gpio chip, so there can't be
any rouge accesses before the chip is registered.

> 2) look at board_register_devices() in board_bcm963xx.c, it uses the
> gpio API, but is called during arch_initcall() (there was an attempt to
> move it later, but it has been reverted)
>
> so you cannot move that gpiochip registration later as-is, more
> refactoring and *testing* is required.

The only access done in board_register_devices() is the ephy-reset
gpio, and that is still done *after* moving bcm63xx_gpio_init() to
register_devices().

So I don't see how this breaks anything. But for the sake of the
argument, let's give it a spin:

root@OpenWrt:/# uname -a
Linux OpenWrt 4.0.0-rc1+ #383 SMP Mon Mar 16 16:46:49 CET 2015 mips GNU/Linux
root@OpenWrt:/# cat /sys/kernel/debug/gpio
GPIOs 0-39, bcm63xx-gpio:
 gpio-4   (power               ) out hi
 gpio-5   (stop                ) out lo
 gpio-15  (adsl-fail           ) out hi
 gpio-22  (ppp                 ) out hi
 gpio-23  (ppp-fail            ) out hi
 gpio-36  (ephy-reset          ) out hi

Everything seems to work fine.


Jonas





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux