From: Josh Cartwright <joshc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Geert Uytterhoeven
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>,
Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH] of: Turn of_match_node into a static inline when CONFIG_OF isn't set
Date: Tue, 11 Feb 2014 15:55:19 -0600 [thread overview]
Message-ID: <20140211215519.GJ841@joshc.qualcomm.com> (raw)
In-Reply-To: <CAL_JsqKnsr-9nSjCGvroC0nDK36vQUnwMWj=cPjvUbRymmHFOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Tue, Feb 11, 2014 at 03:30:33PM -0600, Rob Herring wrote:
> On Tue, Feb 11, 2014 at 12:29 PM, Geert Uytterhoeven
> <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> wrote:
> > On Tue, Feb 11, 2014 at 7:08 PM, Josh Cartwright <joshc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
> >> It sure would be convenient if platform_device had a 'const struct
> >> of_device_id *of_id_entry' member similar to the existing struct
> >> platform_device_id one, that was set up during platform device matching.
> >> Most platform_driver users of of_match_node() would simply go away.
> >
> > Can't the entry be shared for both platform_device_id and of_device_id?
> > Only one of them can be valid at the same time, right?
> >
[..]
>
> I believe this is the reason drivers have to call of_match_device:
>
> commit b1608d69cb804e414d0887140ba08a9398e4e638
> Author: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Date: Wed May 18 11:19:24 2011 -0600
>
> drivercore: revert addition of of_match to struct device
>
> Commit b826291c, "drivercore/dt: add a match table pointer to struct
> device" added an of_match pointer to struct device to cache the
> of_match_table entry discovered at driver match time. This was unsafe
> because matching is not an atomic operation with probing a driver. If
> two or more drivers are attempted to be matched to a driver at the
> same time, then the cached matching entry pointer could get
> overwritten.
>
> This patch reverts the of_match cache pointer and reworks all users to
> call of_match_device() directly instead.
>
> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Interesting, thanks for the history! I'm wondering if this same problem
exists for the existing platform_device_id cached pointer as well.
Okay, so maybe caching a pointer in the device isn't the best option,
what if we considered extending the platform_driver callbacks to include
a set of per-method (?) probe callbacks which do provide a handle to
matched identifiers.
In the case of a totally contrived platform_driver supporting ACPI, OF,
and !OF configurations, it might look something like:
static const struct of_device_id acme_of_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(of, acme_of_table);
static int acme_probe_of(struct platform_device *pdev,
const struct of_device_id *id)
{
/* ... */
return 0;
}
static const struct acpi_device_id acme_acpi_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(acpi, acme_acpi_table);
static int acme_probe_acpi(struct platform_device *pdev,
const struct acpi_device_id *id)
{
/* ... */
return 0;
}
static const struct platform_device_id acme_platform_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(platform, acme_platform_table);
static int acme_probe_acpi(struct platform_device *pdev,
const struct platform_device_id *id)
{
/* ... */
return 0;
}
static int acme_probe_name(struct platform_device *pdev)
{
/* ... */
return 0;
}
static struct platform_driver acme_driver = {
.probe_of = acme_probe_of,
.probe_acpi = acme_probe_acpi,
.probe_platform = acme_probe_platform,
.probe_name = acme_probe_name,
.remove = acme_remove,
.driver = {
.name = "acme",
.of_match_table = of_match_ptr(acme_of_table),
.acpi_match_table = ACPI_PTR(acme_acpi_table),
},
};
module_platform_driver(acme_driver);
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Josh Cartwright <joshc@codeaurora.org>
To: Rob Herring <robherring2@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH] of: Turn of_match_node into a static inline when CONFIG_OF isn't set
Date: Tue, 11 Feb 2014 15:55:19 -0600 [thread overview]
Message-ID: <20140211215519.GJ841@joshc.qualcomm.com> (raw)
In-Reply-To: <CAL_JsqKnsr-9nSjCGvroC0nDK36vQUnwMWj=cPjvUbRymmHFOQ@mail.gmail.com>
On Tue, Feb 11, 2014 at 03:30:33PM -0600, Rob Herring wrote:
> On Tue, Feb 11, 2014 at 12:29 PM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Tue, Feb 11, 2014 at 7:08 PM, Josh Cartwright <joshc@codeaurora.org> wrote:
> >> It sure would be convenient if platform_device had a 'const struct
> >> of_device_id *of_id_entry' member similar to the existing struct
> >> platform_device_id one, that was set up during platform device matching.
> >> Most platform_driver users of of_match_node() would simply go away.
> >
> > Can't the entry be shared for both platform_device_id and of_device_id?
> > Only one of them can be valid at the same time, right?
> >
[..]
>
> I believe this is the reason drivers have to call of_match_device:
>
> commit b1608d69cb804e414d0887140ba08a9398e4e638
> Author: Grant Likely <grant.likely@secretlab.ca>
> Date: Wed May 18 11:19:24 2011 -0600
>
> drivercore: revert addition of of_match to struct device
>
> Commit b826291c, "drivercore/dt: add a match table pointer to struct
> device" added an of_match pointer to struct device to cache the
> of_match_table entry discovered at driver match time. This was unsafe
> because matching is not an atomic operation with probing a driver. If
> two or more drivers are attempted to be matched to a driver at the
> same time, then the cached matching entry pointer could get
> overwritten.
>
> This patch reverts the of_match cache pointer and reworks all users to
> call of_match_device() directly instead.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Interesting, thanks for the history! I'm wondering if this same problem
exists for the existing platform_device_id cached pointer as well.
Okay, so maybe caching a pointer in the device isn't the best option,
what if we considered extending the platform_driver callbacks to include
a set of per-method (?) probe callbacks which do provide a handle to
matched identifiers.
In the case of a totally contrived platform_driver supporting ACPI, OF,
and !OF configurations, it might look something like:
static const struct of_device_id acme_of_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(of, acme_of_table);
static int acme_probe_of(struct platform_device *pdev,
const struct of_device_id *id)
{
/* ... */
return 0;
}
static const struct acpi_device_id acme_acpi_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(acpi, acme_acpi_table);
static int acme_probe_acpi(struct platform_device *pdev,
const struct acpi_device_id *id)
{
/* ... */
return 0;
}
static const struct platform_device_id acme_platform_table[] = {
/* ... */
{ },
};
MODULE_DEVICE_TABLE(platform, acme_platform_table);
static int acme_probe_acpi(struct platform_device *pdev,
const struct platform_device_id *id)
{
/* ... */
return 0;
}
static int acme_probe_name(struct platform_device *pdev)
{
/* ... */
return 0;
}
static struct platform_driver acme_driver = {
.probe_of = acme_probe_of,
.probe_acpi = acme_probe_acpi,
.probe_platform = acme_probe_platform,
.probe_name = acme_probe_name,
.remove = acme_remove,
.driver = {
.name = "acme",
.of_match_table = of_match_ptr(acme_of_table),
.acpi_match_table = ACPI_PTR(acme_acpi_table),
},
};
module_platform_driver(acme_driver);
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2014-02-11 21:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1392122211-11422-1-git-send-email-laurent.pinchart@ ideasonboard.com>
2014-02-11 12:36 ` [PATCH] of: Turn of_match_node into a static inline when CONFIG_OF isn't set Laurent Pinchart
[not found] ` <1392122211-11422-1-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2014-02-11 14:41 ` Josh Cartwright
2014-02-11 14:41 ` Josh Cartwright
2014-02-11 14:55 ` Laurent Pinchart
2014-02-11 16:48 ` Josh Cartwright
[not found] ` <20140211164825.GC841-OP5zVEFNDbfdOxZ39nK119BPR1lH4CV8@public.gmane.org>
2014-02-11 17:20 ` Laurent Pinchart
2014-02-11 17:20 ` Laurent Pinchart
2014-02-11 18:08 ` Josh Cartwright
[not found] ` <20140211180845.GG841-OP5zVEFNDbfdOxZ39nK119BPR1lH4CV8@public.gmane.org>
2014-02-11 18:29 ` Geert Uytterhoeven
2014-02-11 18:29 ` Geert Uytterhoeven
2014-02-11 20:06 ` Arnd Bergmann
2014-02-12 21:54 ` Geert Uytterhoeven
[not found] ` <CAMuHMdVOkUMxEkUK70Y=Y126XmqgKMpyqmGRG5us7vZPhP8WNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-13 1:01 ` Josh Cartwright
2014-02-13 1:01 ` Josh Cartwright
[not found] ` <CAMuHMdVkPLe5986hYPApoQr7oJSb6U2P71=nP+9mtvtaskdHXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-11 21:30 ` Rob Herring
2014-02-11 21:30 ` Rob Herring
[not found] ` <CAL_JsqKnsr-9nSjCGvroC0nDK36vQUnwMWj=cPjvUbRymmHFOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-11 21:55 ` Josh Cartwright [this message]
2014-02-11 21:55 ` Josh Cartwright
[not found] ` <20140211215519.GJ841-OP5zVEFNDbfdOxZ39nK119BPR1lH4CV8@public.gmane.org>
2014-02-11 23:14 ` Rob Herring
2014-02-11 23:14 ` Rob Herring
[not found] ` <CAL_JsqJdbBuv0TgN7Okrxa4MmEon6a74hv458VFS=8RpcyX5tw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-12 2:15 ` Josh Cartwright
2014-02-12 2:15 ` Josh Cartwright
2014-02-11 19:17 ` Laurent Pinchart
2014-02-17 18:19 ` Grant Likely
2014-02-17 18:19 ` Grant Likely
2014-02-17 18:18 ` Grant Likely
[not found] ` <20140217181829.B5F80C40372-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-02-17 19:50 ` Laurent Pinchart
2014-02-17 19:50 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140211215519.GJ841@joshc.qualcomm.com \
--to=joshc-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.