lkml.org 
[lkml]   [2022]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] ARM: Add sanity check for dev->periphid in amba_probe()
On Tue, Aug 30, 2022 at 3:36 AM Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
>
> On Tue, Aug 30, 2022 at 06:31:14PM +0800, Leizhen (ThunderTown) wrote:
> > On 2022/8/30 18:07, Russell King (Oracle) wrote:
> > > For an amba driver, drv->bus will always be pointing at amba_bustype.
> > > That always has a "match" operation. Therefore, the default of '1'
> > > above will *never* be used for an AMBA driver.
> > >
> > > If drv->bus does not point at amba_bustype, then amba_probe() will
> > > not be called for "drv".
> > >
> > > Therefore, amba_match() must always be called before amba_probe().
> >
> > Oh, I was careless. I think it's drv->match. But the processing flow
> > will continue to go to "dev->bus->probe".
> >
> > __driver_attach():
> > ret = driver_match_device(drv, dev);
> > if (ret == 0) {
> > /* no match */
> > return 0;
> > } else if (ret == -EPROBE_DEFER) { <------no return in this branch
> > dev_dbg(dev, "Device match requests probe deferral\n");
> > dev->can_match = true;
> > driver_deferred_probe_add(dev);
> > } else if (ret < 0) {
> > dev_dbg(dev, "Bus failed to match device: %d\n", ret);
> > return ret;
> > } /* ret > 0 means positive match */
> >
> > ... ...
> > driver_probe_device(drv, dev);
> > ......
> > dev->bus->probe
>
> And that makes no sense, is an already known issue, and there is a patch
> to fix it:
>
> https://lore.kernel.org/all/20220817184026.3468620-1-isaacmanjarres@google.com/

Russell,

Thanks for discussing this further and pointing out the other fix. I
assumed Leizhen was talking about an instance of
device_driver_attach() which allows probe to be called without match.
Thankfully that function is used only by some specific
frameworks/buses types. I did a cursory check and I don't see any
intersection with we amba.

-Saravana
P.S: I hate that function exists, as it just throws a wrench in the
whole driver core design and adds corner cases to a lot of generic
driver core design.

\
 
 \ /
  Last update: 2022-08-30 19:55    [W:0.054 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site