lkml.org 
[lkml]   [2012]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver core: fix possible missing of device probe
On Fri, Sep 28, 2012 at 08:52:43AM +0800, Ming Lei wrote:
> Inside bus_add_driver(), one device might be added into
> the bus or probed which is triggered by deferred probe
> just after completing of driver_attach() and before
> 'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)',
> so the device won't be probed by this driver.
>
> This patch moves the below line
>
> 'klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers)'
>
> before driver_attach() inside bus_add_driver().
>
> So fixes the problem since the below way can guarantee that
> no probe(dev) may be lost.
>
> CPU0 CPU1
> driver_register
> ...
> write(bus->driver_list)
> smp_mb()
> read(bus->device_list)
> ...
> device_add
> /* bus_add_device */
> write(bus->device_list)
> smp_mb()
> /* bus_probe_device*/
> read(bus->driver_list)
>
> And the smp_mb() has been implicit by UNLOCK+LOCK
> of 'klist' according to 'VARIETIES OF MEMORY BARRIER' part
> of Documentation/memory-barriers.txt.
>
> Reported-and-Tested-by: Russell King <linux@arm.linux.org.uk>

Please use rmk+kernel@arm.linux.org.uk here, thanks.


\
 
 \ /
  Last update: 2012-09-28 11:41    [W:0.066 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site