From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Peter Chen <peter.chen@freescale.com>,
Rob Herring <robh@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Sricharan R <sricharan@codeaurora.org>,
Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
linux-pm@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 0/7] driver core/USB/thermal: fix device-tree node reuse
Date: Tue, 30 May 2017 18:25:47 +0200 [thread overview]
Message-ID: <20170530162554.26159-1-johan@kernel.org> (raw)
This series fixes a few issues related to device-tree node reuse.
It is fairly common for drivers to reuse the device-tree node of a
parent (or other ancestor) device when creating class or bus devices
(e.g. gpio chips, i2c adapters, iio chips, spi masters, serdev, phys,
usb root hubs). But reusing a device-tree node may cause problems *if*
the new device is later probed as for example driver core would
currently attempt to reinitialise an already active associated pinmux
configuration.
[ NB: For most examples above this is currently not a problem as the
devices reusing a node are never probed. ]
Other potential issues include the platform-bus code unconditionally
dropping the device-tree-node reference in its device destructor,
reinitialisation of other bus-managed resources such as clocks, and
(possibly) the recently added DMA-setup in driver core.
Instead of having drivers try to work around this (as is currently done
for USB root hubs), we can allow devices to reuse a device-tree node by
setting a flag in their struct device that can be used by core, bus and
driver code to avoid resources from being over-allocated.
The first two patches fix a device-tree node reference leak for
non-root-hub devices in USB. These were submitted yesterday to the USB
list, but are included here for completeness.
The third and fourth patches add a helper that can be used when reusing
a device-tree node of another device and that specifically sets a new
of_node_reused flag which is then used by driver core to skip the
automatic pinctrl configuration during probe.
The fifth patch removes the pinctrl over-allocation workaround from USB
core, which also had some undesirable side-effects.
The final two patches fix a device-tree node imbalance and
use-after-free in an thermal driver, where a platform device was reusing
the device-tree node of its parent mfd during probe. This would also
prevent the child device from being reprobed (e.g. due to probe
deferral) if the parent node defines a pinctrl configuration.
Note that this series is against 4.12-rc3.
For reference, here is a list of relevant commits leading up to the
current situation:
- [2013-01-22] ab78029ecc34 ("drivers/pinctrl: grab default handles from device core")
- [2016-02-19] 69bec7259853 ("USB: core: let USB device know device node")
- [2016-04-25] dc5878abf49c ("usb: core: move root hub's device node assignment after it is added to bus")
- [2016-10-06] 51fa91475e43 ("usb/core: Added devspec sysfs entry for devices behind the usb hub")
- [2017-03-13] a8c06e407ef9 ("usb: separate out sysdev pointer from usb_bus")
- [2017-04-10] 09515ef5ddad ("of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices")
Johan
Johan Hovold (7):
USB: core: fix device node leak
USB: of: document reference taken by child-lookup helper
driver core: add helper to reuse a device-tree node
driver core: fix automatic pinctrl management
USB: of: fix root-hub device-tree node handling
thermal: max77620: fix device-node reference imbalance
thermal: max77620: fix pinmux conflict on reprobe
drivers/base/core.c | 16 ++++++++++++++++
drivers/base/pinctrl.c | 3 +++
drivers/thermal/max77620_thermal.c | 8 ++++++--
drivers/usb/core/hcd.c | 2 --
drivers/usb/core/of.c | 3 +++
drivers/usb/core/usb.c | 2 ++
include/linux/device.h | 2 ++
7 files changed, 32 insertions(+), 4 deletions(-)
--
2.13.0
next reply other threads:[~2017-05-30 16:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-30 16:25 Johan Hovold [this message]
2017-05-30 16:25 ` [PATCH 1/7] USB: core: fix device node leak Johan Hovold
2017-05-30 22:55 ` Tyrel Datwyler
[not found] ` <9aff0d42-ff3e-963a-7aaa-752c2f592d0d-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2017-05-31 8:25 ` Johan Hovold
2017-05-31 8:25 ` Johan Hovold
[not found] ` <20170530162554.26159-2-johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-05 3:35 ` Peter Chen
2017-06-05 3:35 ` Peter Chen
2017-05-30 16:25 ` [PATCH 2/7] USB: of: document reference taken by child-lookup helper Johan Hovold
2017-05-30 22:40 ` Tyrel Datwyler
2017-06-06 15:38 ` Johan Hovold
2017-05-30 16:25 ` [PATCH 3/7] driver core: add helper to reuse a device-tree node Johan Hovold
2017-05-30 22:52 ` kbuild test robot
2017-05-30 22:52 ` kbuild test robot
[not found] ` <201705310637.M1OKh99R%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-31 8:38 ` Johan Hovold
2017-05-31 8:38 ` Johan Hovold
2017-05-30 16:25 ` [PATCH 4/7] driver core: fix automatic pinctrl management Johan Hovold
[not found] ` <20170530162554.26159-5-johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-05-31 0:39 ` Linus Walleij
2017-05-31 0:39 ` Linus Walleij
[not found] ` <CACRpkda2PFrua01uKy3b2Zvqi3SH1i0tsxOfWhNP8bB7RCo45g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-31 8:35 ` Johan Hovold
2017-05-31 8:35 ` Johan Hovold
2017-05-30 16:25 ` [PATCH 5/7] USB: of: fix root-hub device-tree node handling Johan Hovold
2017-06-05 4:51 ` Peter Chen
2017-06-05 4:51 ` Peter Chen
2017-06-06 15:44 ` Johan Hovold
2017-05-30 16:25 ` [PATCH 6/7] thermal: max77620: fix device-node reference imbalance Johan Hovold
2017-05-30 22:59 ` Tyrel Datwyler
2017-05-31 8:28 ` Johan Hovold
2017-05-30 16:25 ` [PATCH 7/7] thermal: max77620: fix pinmux conflict on reprobe Johan Hovold
2017-05-30 18:57 ` Eduardo Valentin
2017-05-30 18:57 ` Eduardo Valentin
2017-05-31 8:23 ` Johan Hovold
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=20170530162554.26159-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=arnd@arndb.de \
--cc=edubezval@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@freescale.com \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=sricharan@codeaurora.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.