Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1278404 > unrolled thread
| Started by | martin.wilck@ts.fujitsu.com |
|---|---|
| First post | 2015-11-26 20:20 +0100 |
| Last post | 2015-11-30 14:10 +0100 |
| Articles | 20 on this page of 23 — 7 participants |
Back to article view | Back to linux.kernel
[PATCH] base/platform: fix panic when probe function is NULL martin.wilck@ts.fujitsu.com - 2015-11-26 20:20 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2015-11-26 21:40 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL "Wilck, Martin" <martin.wilck@ts.fujitsu.com> - 2015-11-27 08:40 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-28 17:50 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-28 17:50 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2015-11-29 00:00 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-30 14:00 +0100
Re: [PATCH] base/platform: fix panic when probe function is NULL Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-27 11:20 +0100
Re: [PATCH] base/platform: fix panic when probe function is NULL "Wilck, Martin" <martin.wilck@ts.fujitsu.com> - 2015-11-30 08:50 +0100
[PATCH v2] base/platform: return success when probe function is NULL martin.wilck@ts.fujitsu.com - 2015-11-30 13:00 +0100
Re: [PATCH v2] base/platform: return success when probe function is NULL Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-12-01 21:40 +0100
Re: [PATCH] base/platform: fix panic when probe function is NULL "Wilck, Martin" <martin.wilck@ts.fujitsu.com> - 2015-12-01 11:50 +0100
Re: [PATCH] base/platform: fix panic when probe function is NULL Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-12-01 14:30 +0100
Re: [PATCH] base/platform: fix panic when probe function is NULL "Wilck, Martin" <martin.wilck@ts.fujitsu.com> - 2015-12-01 16:20 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2015-12-01 18:30 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Peter Huewe <peterhuewe@gmx.de> - 2015-12-01 19:40 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2015-12-01 19:50 +0100
Aw: Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL "Peter Huewe" <PeterHuewe@gmx.de> - 2015-12-01 20:00 +0100
Re: Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2015-12-01 20:10 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-28 17:40 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2015-11-29 11:00 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-30 14:00 +0100
Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-11-30 14:10 +0100
Page 1 of 2 [1] 2 Next page →
| From | martin.wilck@ts.fujitsu.com |
|---|---|
| Date | 2015-11-26 20:20 +0100 |
| Subject | [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzaff-Tv-9@gated-at.bofh.it> |
From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
Since b8b2c7d845d5, platform_drv_probe() is called for all platform
devices. If drv->probe is NULL, and dev_pm_domain_attach() fails,
platform_drv_probe() will return the error code from dev_pm_domain_attach().
This causes real_probe() to enter the "probe_failed" path and set
dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume
success if both dev->bus->probe and drv->probe are missing.
This may cause a panic later. For example, inserting the tpm_tis
driver with parameter "force=1" (i.e. registering tpm_tis as a platform
driver) will panic in tpmm_chip_alloc() because dev->driver is NULL:
chip->cdev.owner = chip->pdev->driver->owner;
This patch fixes this by returning success in platform_drv_probe() if
"just" dev_pm_domain_attach() had failed. This restores the semantics
of platform_device_register_XXX() if the associated platform driver has
no "probe" function.
Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain
callbacks are called unconditionally")
Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
---
drivers/base/platform.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1dd6d3b..c994e76 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -513,10 +513,14 @@ static int platform_drv_probe(struct device *_dev)
return ret;
ret = dev_pm_domain_attach(_dev, true);
- if (ret != -EPROBE_DEFER && drv->probe) {
- ret = drv->probe(dev);
- if (ret)
- dev_pm_domain_detach(_dev, true);
+ if (ret != -EPROBE_DEFER) {
+ if (drv->probe) {
+ ret = drv->probe(dev);
+ if (ret)
+ dev_pm_domain_detach(_dev, true);
+ } else
+ /* don't fail if just dev_pm_domain_attach failed */
+ ret = 0;
}
if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2015-11-26 21:40 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzbuG-1By-9@gated-at.bofh.it> |
| In reply to | #1278404 |
On Thu, Nov 26, 2015 at 08:01:34PM +0100, martin.wilck@ts.fujitsu.com wrote: > From: Martin Wilck <Martin.Wilck@ts.fujitsu.com> > > Since b8b2c7d845d5, platform_drv_probe() is called for all platform > devices. If drv->probe is NULL, and dev_pm_domain_attach() fails, > platform_drv_probe() will return the error code from dev_pm_domain_attach(). > > This causes real_probe() to enter the "probe_failed" path and set > dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume > success if both dev->bus->probe and drv->probe are missing. > > This may cause a panic later. For example, inserting the tpm_tis > driver with parameter "force=1" (i.e. registering tpm_tis as a platform > driver) will panic in tpmm_chip_alloc() because dev->driver is NULL: > > chip->cdev.owner = chip->pdev->driver->owner; Is this happening because tpm_tis is not creating the platform device properly? ie it just calls platform_device_register_simple and then force initializes it via tpm_tis_init, which expects to be called from a probe function with an attached driver. Instead we should setup a proper platform device with the default IO range for x86 and let the driver core call tpm_tis_init via tis_drv.probe. Would changing things in this way fix the problem you've observed? I have some patches to do this that are part of my OF enablement series, but I can make something simpler that would deal with this fairly quickly if you can test. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wilck, Martin" <martin.wilck@ts.fujitsu.com> |
|---|---|
| Date | 2015-11-27 08:40 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzlNo-8gf-21@gated-at.bofh.it> |
| In reply to | #1278430 |
T24gRG8sIDIwMTUtMTEtMjYgYXQgMTM6Mz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cml2ZXItPnByb2Jl ID09IE5VTEwsIHNvIHRoYXQKY2FzZSBzaG91bGQgYmUgaGFuZGxlZCBncmFjZWZ1bGx5LiBPdGhl cndpc2UsIGZhaWx1cmUgc2hvdWxkIG9jY3VyCmVhcmxpZXIsIGUuZy4gd2hlbiBwbGF0Zm9ybV9k cml2ZXJfcmVnaXN0ZXIoKSBpcyBjYWxsZWQgd2l0aCAKcGxhdGZvcm1fZHJpdmVyLT5wcm9iZSA9 PSBOVUxMLiB0cG1fdGlzIG1heSBub3QgYmUgdGhlIG9ubHkgZHJpdmVyIHRoYXQKdXNlcyBwbGF0 Zm9ybV9kZXZpY2VfcmVnaXN0ZXJfc2ltcGxlKCkgaW4gdGhpcyB3YXkuCgo+IEkgaGF2ZSBzb21l IHBhdGNoZXMgdG8gZG8gdGhpcyB0aGF0IGFyZSBwYXJ0IG9mIG15IE9GIGVuYWJsZW1lbnQKPiBz ZXJpZXMsIGJ1dCBJIGNhbiBtYWtlIHNvbWV0aGluZyBzaW1wbGVyIHRoYXQgd291bGQgZGVhbCB3 aXRoIHRoaXMKPiBmYWlybHkgcXVpY2tseSBpZiB5b3UgY2FuIHRlc3QuCgpMZXQncyBmaXJzdCB3 YWl0IHdoYXQgdGhlIHBsYXRmb3JtIGd1eXMgc2F5LgoKTWFydGluCgo= -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2015-11-28 17:50 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzQRc-2PH-5@gated-at.bofh.it> |
| In reply to | #1278430 |
On Sat, Nov 28, 2015 at 06:40:03PM +0200, Jarkko Sakkinen wrote: > On Thu, Nov 26, 2015 at 01:30:31PM -0700, Jason Gunthorpe wrote: > > On Thu, Nov 26, 2015 at 08:01:34PM +0100, martin.wilck@ts.fujitsu.com wrote: > > > From: Martin Wilck <Martin.Wilck@ts.fujitsu.com> > > > > > > Since b8b2c7d845d5, platform_drv_probe() is called for all platform > > > devices. If drv->probe is NULL, and dev_pm_domain_attach() fails, > > > platform_drv_probe() will return the error code from dev_pm_domain_attach(). > > > > > > This causes real_probe() to enter the "probe_failed" path and set > > > dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume > > > success if both dev->bus->probe and drv->probe are missing. > > > > > > This may cause a panic later. For example, inserting the tpm_tis > > > driver with parameter "force=1" (i.e. registering tpm_tis as a platform > > > driver) will panic in tpmm_chip_alloc() because dev->driver is NULL: > > > > > > chip->cdev.owner = chip->pdev->driver->owner; > > > > Is this happening because tpm_tis is not creating the platform device > > properly? ie it just calls platform_device_register_simple and then > > force initializes it via tpm_tis_init, which expects to be called from > > a probe function with an attached driver. > > Agreed. We should have a probe callback. > > > Instead we should setup a proper platform device with the default > > IO range for x86 and let the driver core call tpm_tis_init via > > tis_drv.probe. > > > > Would changing things in this way fix the problem you've observed? > > > > I have some patches to do this that are part of my OF enablement > > series, but I can make something simpler that would deal with this > > fairly quickly if you can test. > > Does the patch set that you sent include the fix or not? I haven't yet > reviewed them properly. Another question: does you patch series include an alternative fix for the probe bug or should I just pick Martins fix? As I sad previously I was seriously lost with the race but now I understand what you and Martin were saying (and feel utterly stupid + ashamed!). Now I'm just thinking, which fix I should pick. Anyway, I'll try to go through your code ASAP. /Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2015-11-28 17:50 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzQRc-2PH-7@gated-at.bofh.it> |
| In reply to | #1278430 |
On Thu, Nov 26, 2015 at 01:30:31PM -0700, Jason Gunthorpe wrote: > On Thu, Nov 26, 2015 at 08:01:34PM +0100, martin.wilck@ts.fujitsu.com wrote: > > From: Martin Wilck <Martin.Wilck@ts.fujitsu.com> > > > > Since b8b2c7d845d5, platform_drv_probe() is called for all platform > > devices. If drv->probe is NULL, and dev_pm_domain_attach() fails, > > platform_drv_probe() will return the error code from dev_pm_domain_attach(). > > > > This causes real_probe() to enter the "probe_failed" path and set > > dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume > > success if both dev->bus->probe and drv->probe are missing. > > > > This may cause a panic later. For example, inserting the tpm_tis > > driver with parameter "force=1" (i.e. registering tpm_tis as a platform > > driver) will panic in tpmm_chip_alloc() because dev->driver is NULL: > > > > chip->cdev.owner = chip->pdev->driver->owner; > > Is this happening because tpm_tis is not creating the platform device > properly? ie it just calls platform_device_register_simple and then > force initializes it via tpm_tis_init, which expects to be called from > a probe function with an attached driver. Agreed. We should have a probe callback. > Instead we should setup a proper platform device with the default > IO range for x86 and let the driver core call tpm_tis_init via > tis_drv.probe. > > Would changing things in this way fix the problem you've observed? > > I have some patches to do this that are part of my OF enablement > series, but I can make something simpler that would deal with this > fairly quickly if you can test. Does the patch set that you sent include the fix or not? I haven't yet reviewed them properly. > Jason /Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2015-11-29 00:00 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzWDg-6xS-15@gated-at.bofh.it> |
| In reply to | #1279177 |
On Sat, Nov 28, 2015 at 06:40:03PM +0200, Jarkko Sakkinen wrote: > > I have some patches to do this that are part of my OF enablement > > series, but I can make something simpler that would deal with this > > fairly quickly if you can test. > > Does the patch set that you sent include the fix or not? I haven't yet > reviewed them properly. No fixing probe is another task. I can send some patches for that when we are done with the IRQ stuff. That is something we should fix no matter what.. BTW, please test my IRQ series, I forgot to mention I was unable to test it properly here... Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2015-11-30 14:00 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAwdI-3Lg-15@gated-at.bofh.it> |
| In reply to | #1279243 |
On Sat, Nov 28, 2015 at 03:52:51PM -0700, Jason Gunthorpe wrote: > On Sat, Nov 28, 2015 at 06:40:03PM +0200, Jarkko Sakkinen wrote: > > > I have some patches to do this that are part of my OF enablement > > > series, but I can make something simpler that would deal with this > > > fairly quickly if you can test. > > > > Does the patch set that you sent include the fix or not? I haven't yet > > reviewed them properly. > > No fixing probe is another task. I can send some patches for that when > we are done with the IRQ stuff. That is something we should fix no > matter what.. > > BTW, please test my IRQ series, I forgot to mention I was unable to > test it properly here... Got you. I need to at least test insmod/rmod (maybe couple of times in a cycle). Do you see any other code paths that could easily break because of your patches? > Jason /Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
|---|---|
| Date | 2015-11-27 11:20 +0100 |
| Message-ID | <qzoie-1vq-13@gated-at.bofh.it> |
| In reply to | #1278404 |
Hello Martin,
On Thu, Nov 26, 2015 at 08:01:34PM +0100, martin.wilck@ts.fujitsu.com wrote:
> From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
>
> Since b8b2c7d845d5, platform_drv_probe() is called for all platform
> devices. If drv->probe is NULL, and dev_pm_domain_attach() fails,
> platform_drv_probe() will return the error code from dev_pm_domain_attach().
Correct, this is an unintended change of behaviour introduced in
b8b2c7d845d5.
> This causes real_probe() to enter the "probe_failed" path and set
> dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume
> success if both dev->bus->probe and drv->probe are missing.
>
> This may cause a panic later. For example, inserting the tpm_tis
> driver with parameter "force=1" (i.e. registering tpm_tis as a platform
> driver) will panic in tpmm_chip_alloc() because dev->driver is NULL:
>
> chip->cdev.owner = chip->pdev->driver->owner;
This sounds like a separate issue though. Looking at init_tis there is:
rc = platform_driver_register(&tis_drv);
if (rc < 0)
return rc;
pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
if (IS_ERR(pdev)) {
rc = PTR_ERR(pdev);
goto err_dev;
}
rc = tpm_tis_init(&pdev->dev, &tis_default_info, NULL);
tpm_tis_init calls tpmm_chip_alloc which barfs when pdev (i.e. the return value
of platform_device_register_simple above) isn't bound. It is not allowed
to assume that the device is bound after the above function calls.
So I'd say drop the paragraph about tpm_tis and the change is fine.
> This patch fixes this by returning success in platform_drv_probe() if
> "just" dev_pm_domain_attach() had failed. This restores the semantics
> of platform_device_register_XXX() if the associated platform driver has
> no "probe" function.
>
> Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain
> callbacks are called unconditionally")
>
I think line breaks in the Fixes: line are frowned on. Also usually
there is no empty line between Fixes: and S-o-b:.
> Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
> ---
> drivers/base/platform.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 1dd6d3b..c994e76 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -513,10 +513,14 @@ static int platform_drv_probe(struct device *_dev)
> return ret;
>
> ret = dev_pm_domain_attach(_dev, true);
> - if (ret != -EPROBE_DEFER && drv->probe) {
> - ret = drv->probe(dev);
> - if (ret)
> - dev_pm_domain_detach(_dev, true);
> + if (ret != -EPROBE_DEFER) {
> + if (drv->probe) {
> + ret = drv->probe(dev);
> + if (ret)
> + dev_pm_domain_detach(_dev, true);
> + } else
> + /* don't fail if just dev_pm_domain_attach failed */
> + ret = 0;
An else that has a } should also have a {, according to
checkpatch and Documentation/CodingStyle. You can write it
alternatively as:
if (ret != -EPROBE_DEFER) {
if (drv->probe)
ret = drv->probe(dev);
else
ret = 0;
if (ret)
dev_pm_domain_detach(_dev, true);
}
.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wilck, Martin" <martin.wilck@ts.fujitsu.com> |
|---|---|
| Date | 2015-11-30 08:50 +0100 |
| Message-ID | <qArnI-Ea-9@gated-at.bofh.it> |
| In reply to | #1278700 |
SGVsbG8gVXdlLAoKdGhhbmtzIGZvciB5b3VyIHJldmlldy4KCj4gVGhpcyBtYXkgY2F1c2UgYSBw YW5pYyBsYXRlci4gRm9yIGV4YW1wbGUsIGluc2VydGluZyB0aGUgdHBtX3Rpcwo+ID4gZHJpdmVy IHdpdGggcGFyYW1ldGVyICJmb3JjZT0xIiAoaS5lLiByZWdpc3RlcmluZyB0cG1fdGlzIGFzIGEg cGxhdGZvcm0KPiA+IGRyaXZlcikgd2lsbCBwYW5pYyBpbiB0cG1tX2NoaXBfYWxsb2MoKSBiZWNh dXNlIGRldi0+ZHJpdmVyIGlzIE5VTEw6Cj4gPiAKPiA+ICAgICAgY2hpcC0+Y2Rldi5vd25lciA9 IGNoaXAtPnBkZXYtP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uIFlvdSBjYW4gd3JpdGUgaXQKPiBhbHRlcm5hdGl2ZWx5 IGFzOgo+IAo+IAlpZiAocmV0ICE9IC1FUFJPQkVfREVGRVIpIHsKPiAJCWlmIChkcnYtPnByb2Jl KQo+IAkJCXJldCA9IGRydi0+cHJvYmUoZGV2KTsKPiAJCWVsc2UKPiAJCQlyZXQgPSAwOwo+IAo+ IAkJaWYgKHJldCkKPiAJCQlkZXZfcG1fZG9tYWluX2RldGFjaChfZGV2LCB0cnVlKTsKPiAJfQo+ IAo+IC4KPiAKPiBCZXN0IHJlZ2FyZHMKPiBVd2UKPiAK -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | martin.wilck@ts.fujitsu.com |
|---|---|
| Date | 2015-11-30 13:00 +0100 |
| Subject | [PATCH v2] base/platform: return success when probe function is NULL |
| Message-ID | <qAvhE-38r-19@gated-at.bofh.it> |
| In reply to | #1278700 |
From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
Since b8b2c7d845d5, platform_drv_probe() is called for all platform
devices. If drv->probe is NULL, and dev_pm_domain_attach() fails,
platform_drv_probe() will return the error code from dev_pm_domain_attach().
This causes real_probe() to enter the "probe_failed" path and set
dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume
success if both dev->bus->probe and drv->probe were missing. As a result,
a device and driver could be "bound" together just by matching their names;
this doesn't work any more after b8b2c7d845d5.
This may cause problems later for certain usage of platform_driver_register()
and platform_device_register_simple(). I observed a panic while loading
the tpm_tis driver with parameter "force=1" (i.e. registering tpm_tis as
a platform driver), because tpm_tis_init's assumption that the device
returned by platform_device_register_simple() was bound didn't hold any more
(tpmm_chip_alloc() dereferences chip->pdev->driver, causing panic).
This patch restores the previous (4.3.0 and earlier) behavior of
platform_drv_probe() in the case when the associated platform driver has
no "probe" function.
v2: fixed style issues, rephrased commit message.
Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain callbacks are called unconditionally")
Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
---
drivers/base/platform.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1dd6d3b..176b59f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -513,10 +513,15 @@ static int platform_drv_probe(struct device *_dev)
return ret;
ret = dev_pm_domain_attach(_dev, true);
- if (ret != -EPROBE_DEFER && drv->probe) {
- ret = drv->probe(dev);
- if (ret)
- dev_pm_domain_detach(_dev, true);
+ if (ret != -EPROBE_DEFER) {
+ if (drv->probe) {
+ ret = drv->probe(dev);
+ if (ret)
+ dev_pm_domain_detach(_dev, true);
+ } else {
+ /* don't fail if just dev_pm_domain_attach failed */
+ ret = 0;
+ }
}
if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
|---|---|
| Date | 2015-12-01 21:40 +0100 |
| Subject | Re: [PATCH v2] base/platform: return success when probe function is NULL |
| Message-ID | <qAZSq-622-9@gated-at.bofh.it> |
| In reply to | #1279802 |
Hello,
On Mon, Nov 30, 2015 at 12:50:05PM +0100, martin.wilck@ts.fujitsu.com wrote:
> From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
>
> Since b8b2c7d845d5, platform_drv_probe() is called for all platform
> devices. If drv->probe is NULL, and dev_pm_domain_attach() fails,
> platform_drv_probe() will return the error code from dev_pm_domain_attach().
>
> This causes real_probe() to enter the "probe_failed" path and set
> dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume
> success if both dev->bus->probe and drv->probe were missing. As a result,
> a device and driver could be "bound" together just by matching their names;
> this doesn't work any more after b8b2c7d845d5.
>
> This may cause problems later for certain usage of platform_driver_register()
> and platform_device_register_simple(). I observed a panic while loading
> the tpm_tis driver with parameter "force=1" (i.e. registering tpm_tis as
> a platform driver), because tpm_tis_init's assumption that the device
> returned by platform_device_register_simple() was bound didn't hold any more
> (tpmm_chip_alloc() dereferences chip->pdev->driver, causing panic).
I'm a bit uncertain if I should be happy with this wording or not. While
b8b2c7d845d5 has a bug which made the tpm_tis driver provoke a panic and
which needs fixing, this doesn't mean that the tpm_tis driver was right.
So "This may cause problems later ..." isn't a correct justification
because even in the presence of the bug introduced by b8b2c7d845d5, the
tpm_tis driver must not assume that it's device is bound on return of
platform_device_register_simple.
It's just that the bug in b8b2c7d845d5 made a wrong assumption of the
tpm_tis driver obvious, and now both need fixing.
If this were my patch, I'd not talk about tpm_tis at all. b8b2c7d845d5
broke binding for platform drivers with no probe function in certain
situations. This is corrected here.
> This patch restores the previous (4.3.0 and earlier) behavior of
> platform_drv_probe() in the case when the associated platform driver has
> no "probe" function.
>
> v2: fixed style issues, rephrased commit message.
This must go after the triple-dash below to not be included in the
commit.
> Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain callbacks are called unconditionally")
> Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
> ---
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wilck, Martin" <martin.wilck@ts.fujitsu.com> |
|---|---|
| Date | 2015-12-01 11:50 +0100 |
| Message-ID | <qAQFt-8sH-41@gated-at.bofh.it> |
| In reply to | #1278700 |
SGVsbG8gVXdlLAoKPiBUaGlzIHNvdW5kcy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gY3VycmVudCBwYXRjaCBzZXQgaXMgZ29pbmcgdG8KZml4IHRoaXMgZm9yIGdvb2Qg YW55d2F5LgoKUmVnYXJkcwpNYXJ0aW4KCg== -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
|---|---|
| Date | 2015-12-01 14:30 +0100 |
| Message-ID | <qATai-1KL-21@gated-at.bofh.it> |
| In reply to | #1280754 |
Hello Martin,
On Tue, Dec 01, 2015 at 11:41:53AM +0100, Wilck, Martin wrote:
> > This sounds like a separate issue though. Looking at init_tis there is:
> >
> > rc = platform_driver_register(&tis_drv);
> > if (rc < 0)
> > return rc;
> > pdev = platform_device_register_simple("tpm_tis", -1, NULL, 0);
> > if (IS_ERR(pdev)) {
> > rc = PTR_ERR(pdev);
> > goto err_dev;
> > }
> > rc = tpm_tis_init(&pdev->dev, &tis_default_info, NULL);
> >
> > tpm_tis_init calls tpmm_chip_alloc which barfs when pdev (i.e. the return value
> > of platform_device_register_simple above) isn't bound. It is not allowed
> > to assume that the device is bound after the above function calls.
>
> Can you please explain again why you think that assumption is invalid?
You can unbind a device from a driver via sysfs, you can also prevent
binding somehow I think, probing can fail for different reasons, probing
might wait for userspace interaction to load firmware which wasn't
scheduled yet. I'm sure there are still more things that break the
assumption.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wilck, Martin" <martin.wilck@ts.fujitsu.com> |
|---|---|
| Date | 2015-12-01 16:20 +0100 |
| Message-ID | <qAUSJ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hlcmUncyBubyBGVyB0byBsb2FkLCBhbmQgdW5iaW5k aW5nIHZpYSBzeXNmcyB3b3VsZCByZXF1aXJlCm5lYXJseSBpbXBvc3NpYmxlIHRpbWluZyAobm90 IHN1cmUgaWYgaXQgY291bGQgYmUgZG9uZSB3aXRoIHVkZXYpLgoKQW55d2F5LCB0aGUgUmlnaHQg VGhpbmcgdG8gZG8gaXMgdG8gY3JlYXRlIGEgcHJvYmUoKSByb3V0aW5lIGFuZCB0aGF0J3MKd2hh dCBKYXNvbiBkaWQuCgpUaGFua3MgYWdhaW4sCk1hcnRpbgoK -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2015-12-01 18:30 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAWUy-49J-27@gated-at.bofh.it> |
| In reply to | #1280939 |
On Tue, Dec 01, 2015 at 04:19:25PM +0100, Wilck, Martin wrote: > > > > tpm_tis_init calls tpmm_chip_alloc which barfs when pdev (i.e. the return value > > > > of platform_device_register_simple above) isn't bound. It is not allowed > > > > to assume that the device is bound after the above function calls. > > > > > > Can you please explain again why you think that assumption is invalid? > > > > You can unbind a device from a driver via sysfs, you can also prevent > > binding somehow I think, probing can fail for different reasons, probing > > might wait for userspace interaction to load firmware which wasn't > > scheduled yet. I'm sure there are still more things that break the > > assumption. > > Thanks. Out of these, "prevent binding somehow" would be the only > problem that applies to tpm_tis, as probing can't fail (no probe() > routine), there's no FW to load, and unbinding via sysfs would require > nearly impossible timing (not sure if it could be done with udev). > > Anyway, the Right Thing to do is to create a probe() routine and that's > what Jason did. That fixes tpm_tis, but there are other ancient TPM drivers that use the old, now broken way. So, we still need to do something here. Either fixup b8b2c7d845d5 as you have proposed, remove the now broken obsolete TPM drivers, or try and fix them.. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Huewe <peterhuewe@gmx.de> |
|---|---|
| Date | 2015-12-01 19:40 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAY0j-4MF-27@gated-at.bofh.it> |
| In reply to | #1281071 |
Am 1. Dezember 2015 09:25:37 PST, schrieb Jason Gunthorpe <jgunthorpe@obsidianresearch.com>: >On Tue, Dec 01, 2015 at 04:19:25PM +0100, Wilck, Martin wrote: >> > > > tpm_tis_init calls tpmm_chip_alloc which barfs when pdev (i.e. >the return value >> > > > of platform_device_register_simple above) isn't bound. It is >not allowed >> > > > to assume that the device is bound after the above function >calls. >> > > >> > > Can you please explain again why you think that assumption is >invalid? >> > >> > You can unbind a device from a driver via sysfs, you can also >prevent >> > binding somehow I think, probing can fail for different reasons, >probing >> > might wait for userspace interaction to load firmware which wasn't >> > scheduled yet. I'm sure there are still more things that break the >> > assumption. >> >> Thanks. Out of these, "prevent binding somehow" would be the only >> problem that applies to tpm_tis, as probing can't fail (no probe() >> routine), there's no FW to load, and unbinding via sysfs would >require >> nearly impossible timing (not sure if it could be done with udev). >> >> Anyway, the Right Thing to do is to create a probe() routine and >that's >> what Jason did. > >That fixes tpm_tis, but there are other ancient TPM drivers that use >the old, now broken way. > >So, we still need to do something here. Either fixup b8b2c7d845d5 as >you have proposed, remove the now broken obsolete TPM drivers, or try >and fix them.. How broken are they and since when? I thought multiple times about deprecating and finally removing the 1.1b stuff - tpm 1.2 is out for 10? years now? With an expected life span of a TPM of roughly 5years... And also unfortunately the 1.1b legacy drivers usually get loaded first :( (atleast for slb9635) Mark them as obsolete , default them to No and remove them by 4.10 if there are no objections? Peter -- Sent from my mobile -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2015-12-01 19:50 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAY9X-4Q3-1@gated-at.bofh.it> |
| In reply to | #1281108 |
On Tue, Dec 01, 2015 at 10:26:17AM -0800, Peter Huewe wrote: > > > Am 1. Dezember 2015 09:25:37 PST, schrieb Jason Gunthorpe <jgunthorpe@obsidianresearch.com>: > >On Tue, Dec 01, 2015 at 04:19:25PM +0100, Wilck, Martin wrote: > >> > > > tpm_tis_init calls tpmm_chip_alloc which barfs when pdev (i.e. > >the return value > >> > > > of platform_device_register_simple above) isn't bound. It is > >not allowed > >> > > > to assume that the device is bound after the above function > >calls. > >> > > > >> > > Can you please explain again why you think that assumption is > >invalid? > >> > > >> > You can unbind a device from a driver via sysfs, you can also > >prevent > >> > binding somehow I think, probing can fail for different reasons, > >probing > >> > might wait for userspace interaction to load firmware which wasn't > >> > scheduled yet. I'm sure there are still more things that break the > >> > assumption. > >> > >> Thanks. Out of these, "prevent binding somehow" would be the only > >> problem that applies to tpm_tis, as probing can't fail (no probe() > >> routine), there's no FW to load, and unbinding via sysfs would > >require > >> nearly impossible timing (not sure if it could be done with udev). > >> > >> Anyway, the Right Thing to do is to create a probe() routine and > >that's > >> what Jason did. > > > >That fixes tpm_tis, but there are other ancient TPM drivers that use > >the old, now broken way. > > > >So, we still need to do something here. Either fixup b8b2c7d845d5 as > >you have proposed, remove the now broken obsolete TPM drivers, or try > >and fix them.. > > How broken are they and since when? oops the kernel broken, since 4.4-rc1 apparently, so not released yet. > Mark them as obsolete , default them to No and remove them by 4.10 > if there are no objections? Greg KH has been advising just to delete stuff right away. It is easy to undelete something if someone comes around with hardware and is willing to test Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Peter Huewe" <PeterHuewe@gmx.de> |
|---|---|
| Date | 2015-12-01 20:00 +0100 |
| Subject | Aw: Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAYjE-4To-9@gated-at.bofh.it> |
| In reply to | #1281111 |
> > >That fixes tpm_tis, but there are other ancient TPM drivers that use > > >the old, now broken way. > > > > > >So, we still need to do something here. Either fixup b8b2c7d845d5 as > > >you have proposed, remove the now broken obsolete TPM drivers, or try > > >and fix them.. > > > > How broken are they and since when? > oops the kernel broken, since 4.4-rc1 apparently, so not released yet. damn, I was hoping MUCH longer :) > > Mark them as obsolete , default them to No and remove them by 4.10 > > if there are no objections? > Greg KH has been advising just to delete stuff right away. It is easy > to undelete something if someone comes around with hardware and is > willing to test Can you point to that discussion or was it offline? I mean for staging, yes there it is clear, but for stuff that is officially "upstream", I'm not 100% sure. Thanks, Peter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2015-12-01 20:10 +0100 |
| Subject | Re: Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qAYtj-5dB-5@gated-at.bofh.it> |
| In reply to | #1281122 |
On Tue, Dec 01, 2015 at 07:54:59PM +0100, Peter Huewe wrote: > Can you point to that discussion or was it offline? Apparently it was brought up at the most recent kernel summit http://www.spinics.net/lists/linux-rdma/msg29985.html Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2015-11-28 17:40 +0100 |
| Subject | Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL |
| Message-ID | <qzQHw-2L7-27@gated-at.bofh.it> |
| In reply to | #1278404 |
On Thu, Nov 26, 2015 at 08:01:34PM +0100, martin.wilck@ts.fujitsu.com wrote:
> From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
>
> Since b8b2c7d845d5, platform_drv_probe() is called for all platform
> devices. If drv->probe is NULL, and dev_pm_domain_attach() fails,
> platform_drv_probe() will return the error code from dev_pm_domain_attach().
>
> This causes real_probe() to enter the "probe_failed" path and set
> dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume
> success if both dev->bus->probe and drv->probe are missing.
>
> This may cause a panic later. For example, inserting the tpm_tis
> driver with parameter "force=1" (i.e. registering tpm_tis as a platform
> driver) will panic in tpmm_chip_alloc() because dev->driver is NULL:
>
> chip->cdev.owner = chip->pdev->driver->owner;
>
> This patch fixes this by returning success in platform_drv_probe() if
> "just" dev_pm_domain_attach() had failed. This restores the semantics
> of platform_device_register_XXX() if the associated platform driver has
> no "probe" function.
>
> Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain
> callbacks are called unconditionally")
>
> Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> drivers/base/platform.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 1dd6d3b..c994e76 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -513,10 +513,14 @@ static int platform_drv_probe(struct device *_dev)
> return ret;
>
> ret = dev_pm_domain_attach(_dev, true);
> - if (ret != -EPROBE_DEFER && drv->probe) {
> - ret = drv->probe(dev);
> - if (ret)
> - dev_pm_domain_detach(_dev, true);
> + if (ret != -EPROBE_DEFER) {
> + if (drv->probe) {
> + ret = drv->probe(dev);
> + if (ret)
> + dev_pm_domain_detach(_dev, true);
> + } else
> + /* don't fail if just dev_pm_domain_attach failed */
> + ret = 0;
> }
>
> if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
> --
> 1.8.3.1
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web