aboutsummaryrefslogtreecommitdiff
path: root/drivers/base
AgeCommit message (Collapse)AuthorFilesLines
2019-09-11software node: Initialize the return value in software_node_find_by_name()Heikki Krogerus1-1/+1
The software node is searched from a list that may be empty when the function is called. This makes sure that the function returns NULL if the list is empty. Fixes: 1666faedb567 ("software node: Add software_node_find_by_name()") Reported-by: kbuild test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-09-05make shmem_fill_super() staticAl Viro1-1/+1
... have callers use shmem_mount() Signed-off-by: Al Viro <[email protected]>
2019-09-05devtmpfs: don't mix {ramfs,shmem}_fill_super() with mount_single()Al Viro1-6/+30
Create an internal-only type matching the current devtmpfs, never register it and have one kernel-internal mount done. That thing gets mounted only once, so it is free to use mount_nodev(). The "public" devtmpfs (the one we do register, and only after the internal mount of the real thing is done) simply gets and returns an extra reference to the internal superblock. Signed-off-by: Al Viro <[email protected]>
2019-09-05Merge branch 'pm-cpufreq-qos'Rafael J. Wysocki1-1/+1
* pm-cpufreq-qos: Documentation: cpufreq: Update policy notifier documentation cpufreq: Remove CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier video: pxafb: Remove cpufreq policy notifier video: sa1100fb: Remove cpufreq policy notifier arch_topology: Use CPUFREQ_CREATE_POLICY instead of CPUFREQ_NOTIFY cpufreq: powerpc_cbe: Switch to QoS requests for freq limits cpufreq: powerpc: macintosh: Switch to QoS requests for freq limits thermal: cpu_cooling: Switch to QoS requests for freq limits cpufreq: Add policy create/remove notifiers back
2019-09-04software node: Initialize the return value in software_node_to_swnode()Heikki Krogerus1-1/+1
The software node is searched from a list that may be empty when the function is called. This makes sure that the function returns NULL even if the list is empty. Fixes: 80488a6b1d3c ("software node: Add support for static node descriptors") Reported-by: kbuild test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-09-03Merge generic_lookup_helpers into usb-nextGreg Kroah-Hartman4-39/+46
The lookup helpers are needed here. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-09-03device connection: Add fwnode_connection_find_match()Heikki Krogerus1-12/+31
The fwnode_connection_find_match() function is exactly the same as device_connection_find_match(), except it takes struct fwnode_handle as parameter instead of struct device. That allows locating device connections before the device entries have been created. Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-09-02PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state()Ulf Hansson1-2/+2
The dev_pm_genpd_set_performance_state() could in principle be called for a device that has a different PM domain type attached than a genpd. This would lead to a problem as dev_to_genpd() uses the container_of macro. Address this problem by using dev_to_genpd_safe() instead. Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-09-02PM / Domains: Simplify genpd_lookup_dev()Ulf Hansson1-13/+8
genpd_lookup_dev(), is a bit unnecessary heavy, as it walks the gpd_list to try to find a valid PM domain corresponding to the device's attached genpd. Instead of walking the gpd_list, let's use the fact that a genpd always has the ->runtime_suspend() callback assigned to the genpd_runtime_suspend() function. While changing this, let's take the opportunity to also rename genpd_lookup_dev(), into dev_to_genpd_safe() to better reflect its purpose. Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-29driver core: platform: Export platform_get_irq_optional()Thierry Reding1-0/+1
This function can be used by modules, so it needs to be exported. Reported-by: kbuild test robot <[email protected]> Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-28driver core: platform: Introduce platform_get_irq_optional()Thierry Reding1-0/+22
In some cases the interrupt line of a device is optional. Introduce a new platform_get_irq_optional() that works much like platform_get_irq() but does not output an error on failure to find the interrupt. Signed-off-by: Thierry Reding <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-27Revert "driver core: Add support for linking devices during device addition"Greg Kroah-Hartman1-83/+0
This reverts commit 5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886. Based on a lot of email and in-person discussions, this patch series is being reworked to address a number of issues that were pointed out that needed to be taken care of before it should be merged. It will be resubmitted with those changes hopefully soon. Cc: Frank Rowand <[email protected]> Cc: Saravana Kannan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-27Revert "driver core: Add edit_links() callback for drivers"Greg Kroah-Hartman2-51/+2
This reverts commit 134b23eec9e3a3c795a6ceb0efe2fa63e87983b2. Based on a lot of email and in-person discussions, this patch series is being reworked to address a number of issues that were pointed out that needed to be taken care of before it should be merged. It will be resubmitted with those changes hopefully soon. Cc: Frank Rowand <[email protected]> Cc: Saravana Kannan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-27Revert "driver core: Add sync_state driver/bus callback"Greg Kroah-Hartman1-65/+0
This reverts commit 8f8184d6bf676a8680d6f441e40317d166b46f73. Based on a lot of email and in-person discussions, this patch series is being reworked to address a number of issues that were pointed out that needed to be taken care of before it should be merged. It will be resubmitted with those changes hopefully soon. Cc: Frank Rowand <[email protected]> Cc: Saravana Kannan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-26software node: Add software_node_find_by_name()Heikki Krogerus1-0/+37
Function that searches software nodes by node name. Signed-off-by: Heikki Krogerus <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Tested-by: Hans de Goede <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-26arch_topology: Use CPUFREQ_CREATE_POLICY instead of CPUFREQ_NOTIFYViresh Kumar1-1/+1
CPUFREQ_NOTIFY is going to get removed soon, lets use CPUFREQ_CREATE_POLICY instead of that here. CPUFREQ_CREATE_POLICY is called only once (which is exactly what we want here) for each cpufreq policy when it is first created. Signed-off-by: Viresh Kumar <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-22Merge branch 'for-mingo' of ↵Ingo Molnar3-5/+23
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu Pull RCU and LKMM changes from Paul E. McKenney: - A few more RCU flavor consolidation cleanups. - Miscellaneous fixes. - Updates to RCU's list-traversal macros improving lockdep usability. - Torture-test updates. - Forward-progress improvements for no-CBs CPUs: Avoid ignoring incoming callbacks during grace-period waits. - Forward-progress improvements for no-CBs CPUs: Use ->cblist structure to take advantage of others' grace periods. - Also added a small commit that avoids needlessly inflicting scheduler-clock ticks on callback-offloaded CPUs. - Forward-progress improvements for no-CBs CPUs: Reduce contention on ->nocb_lock guarding ->cblist. - Forward-progress improvements for no-CBs CPUs: Add ->nocb_bypass list to further reduce contention on ->nocb_lock guarding ->cblist. - LKMM updates. Signed-off-by: Ingo Molnar <[email protected]>
2019-08-22driver core: initialize a default DMA mask for platform deviceChristoph Hellwig1-21/+16
We still treat devices without a DMA mask as defaulting to 32-bits for both mask, but a few releases ago we've started warning about such cases, as they require special cases to work around this sloppyness. Add a dma_mask field to struct platform_device so that we can initialize the dma_mask pointer in struct device and initialize both masks to 32-bits by default, replacing similar functionality in m68k and powerpc. The arch_setup_pdev_archdata hooks is now unused and removed. Note that the code looks a little odd with the various conditionals because we have to support platform_device structures that are statically allocated. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-21PM / wakeup: Unexport wakeup_source_sysfs_{add,remove}()Stephen Boyd1-2/+0
These functions are just used by the PM core, and that isn't modular so these functions don't need to be exported. Drop the exports. Fixes: c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs") Reviewed-by: Tri Vo <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-21PM / wakeup: Register wakeup class kobj after device is addedStephen Boyd4-4/+34
The device_set_wakeup_enable() function can be called on a device that hasn't been registered with device_add() yet. This allows the device to be in a state where wakeup is enabled for it but the device isn't published to userspace in sysfs yet. After commit c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs"), calling device_set_wakeup_enable() will fail for a device that hasn't been registered with the driver core via device_add(). This is because we try to create sysfs entries for the device and associate a wakeup class kobject with it before the device has been registered. Let's follow a similar approach that device_set_wakeup_capable() takes here and register the wakeup class either from device_set_wakeup_enable() when the device is already registered, or from dpm_sysfs_add() when the device is being registered with the driver core via device_add(). Fixes: c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs") Reported-by: Qian Cai <[email protected]> Reviewed-by: Tri Vo <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-21PM / wakeup: Fix sysfs registration error pathStephen Boyd1-4/+9
We shouldn't call wakeup_source_destroy() from the error path in wakeup_source_register() because that calls __pm_relax() which takes a lock that isn't initialized until wakeup_source_add() is called. Add a new function, wakeup_source_free(), that just does the bare minimum to free a wakeup source that was created but hasn't been added yet and use it from the two places it's needed. This fixes the following problem seen on various x86 server boxes: INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 12 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc4- Hardware name: HP ProLiant XL420 Gen9/ProLiant XL420 Gen9, BIOS U19 12/27/2015 Call Trace:   dump_stack+0x62/0x9a   register_lock_class+0x95a/0x960   ? __platform_driver_probe+0xcd/0x230   ? __platform_create_bundle+0xc0/0xe0   ? i8042_init+0x4ec/0x578   ? do_one_initcall+0xfe/0x45a   ? kernel_init_freeable+0x614/0x6a7   ? kernel_init+0x11/0x138   ? ret_from_fork+0x35/0x40   ? is_dynamic_key+0xf0/0xf0   ? rwlock_bug.part.0+0x60/0x60   ? __debug_check_no_obj_freed+0x8e/0x250   __lock_acquire.isra.13+0x5f/0x830   ? __debug_check_no_obj_freed+0x152/0x250   lock_acquire+0x107/0x220   ? __pm_relax.part.2+0x21/0xa0   _raw_spin_lock_irqsave+0x35/0x50   ? __pm_relax.part.2+0x21/0xa0   __pm_relax.part.2+0x21/0xa0   wakeup_source_destroy.part.3+0x18/0x190   wakeup_source_register+0x43/0x50 Fixes: c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs") Reported-by: Qian Cai <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-21PM / wakeup: Show wakeup sources stats in sysfsTri Vo4-5/+237
Add an ID and a device pointer to 'struct wakeup_source'. Use them to to expose wakeup sources statistics in sysfs under /sys/class/wakeup/wakeup<ID>/*. Co-developed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Co-developed-by: Stephen Boyd <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Tri Vo <[email protected]> Tested-by: Kalesh Singh <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-21PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare()Tri Vo1-20/+13
wakeup_source_init() has no users. Remove it. As a result, wakeup_source_prepare() is only called from wakeup_source_create(). Merge wakeup_source_prepare() into wakeup_source_create() and remove it. Change wakeup_source_create() behavior so that assigning NULL to wakeup source's name throws an error. Signed-off-by: Tri Vo <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2019-08-19Merge 5.3-rc5 into usb-nextGreg Kroah-Hartman1-1/+1
We need the usb fixes in here as well for other patches to build on. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-16Merge tag 'soundwire-5.3-rc5' of ↵Greg Kroah-Hartman1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire into char-misc-linus Vinod writes: soundwire fixes for v5.3-rc5 Pierre sent fixes which are queued now for v5.3-rc5 are: - regmap dependecy - cadence register definitions * tag 'soundwire-5.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: soundwire: fix regmap dependencies and align with other serial links soundwire: cadence_master: fix definitions for INTSTAT0/1 soundwire: cadence_master: fix register definition for SLAVE_STATE
2019-08-15devcoredump: fix typo in commentAkinobu Mita1-1/+1
s/dev_coredumpmsg/dev_coredumpsg/ in the kernel-doc Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Akinobu Mita <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-15devcoredump: use memory_read_from_bufferAkinobu Mita1-10/+1
Use memory_read_from_buffer() to simplify devcd_readv(). Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: Akinobu Mita <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-14Merge tag 'common/for-v5.4-rc1/cpu-topology' of ↵Will Deacon2-1/+299
git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux into for-next/cpu-topology Pull in generic CPU topology changes from Paul Walmsley (RISC-V). * tag 'common/for-v5.4-rc1/cpu-topology' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: MAINTAINERS: Add an entry for generic architecture topology base: arch_topology: update Kconfig help description RISC-V: Parse cpu topology during boot. arm: Use common cpu_topology structure and functions. cpu-topology: Move cpu topology code to common code. dt-binding: cpu-topology: Move cpu-map to a common binding. Documentation: DT: arm: add support for sockets defining package boundaries
2019-08-13driver/core: Convert to use built-in RCU list checkingJoel Fernandes (Google)3-5/+23
This commit applies the consolidated hlist_for_each_entry_rcu() support for lockdep conditions. Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
2019-08-12Merge branch 'regmap-5.4' into regmap-nextMark Brown1-12/+0
2019-08-12Merge branch 'regmap-5.3' into regmap-linusMark Brown1-6/+1
2019-08-12regmap-irq: Correct error paths in regmap_irq_thread for pm_runtimeCharles Keepax1-6/+1
Some error paths in regmap_irq_thread put the pm_runtime others do not, there is no reason to leave the pm_runtime enabled in some cases so update those paths to also put the pm_runtime. Signed-off-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2019-08-12Merge 5.3-rc4 into usb-nextGreg Kroah-Hartman2-3/+59
We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-12Merge 5.3-rc4 into driver-core-nextGreg Kroah-Hartman3-13/+83
We need the driver core fixes in here as well. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-10Merge tag 'driver-core-5.3-rc4' of ↵Linus Torvalds2-3/+59
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core fixes from Greg KH: "Here are two small fixes for some driver core issues that have been reported. There is also a kernfs "fix" here, which was then reverted because it was found to cause problems in linux-next. The driver core fixes both resolve reported issues, one with gpioint stuff that showed up in 5.3-rc1, and the other finally (and hopefully) resolves a very long standing race when removing glue directories. It's nice to get that issue finally resolved and the developers involved should be applauded for the persistence it took to get this patch finally accepted. All of these have been in linux-next for a while with no reported issues. Well, the one reported issue, hence the revert :)" * tag 'driver-core-5.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: Revert "kernfs: fix memleak in kernel_ops_readdir()" kernfs: fix memleak in kernel_ops_readdir() driver core: Fix use-after-free and double free on glue directory driver core: platform: return -ENXIO for missing GpioInt
2019-08-09soundwire: fix regmap dependencies and align with other serial linksPierre-Louis Bossart1-1/+1
The existing code has a mixed select/depend usage which makes no sense. config SOUNDWIRE_BUS tristate select REGMAP_SOUNDWIRE config REGMAP_SOUNDWIRE tristate depends on SOUNDWIRE_BUS Let's remove one layer of Kconfig definitions and align with the solutions used by all other serial links. Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
2019-08-06Merge tag 'dev_groups_all_drivers' of ↵Greg Kroah-Hartman1-0/+14
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core into usb-next dev_groups added to struct driver Persistent tag for others to pull this branch from This is the first patch in a longer series that adds the ability for the driver core to create and remove a list of attribute groups automatically when the device is bound/unbound from a specific driver. See: https://lore.kernel.org/r/[email protected] for details on this patch, and examples of how to use it in other drivers. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-05base: soc: Export soc_device_register/unregister APIsVinod Koul1-0/+2
Qcom Socinfo driver can be built as a module, so export these two APIs. Tested-by: Vinod Koul <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Vaishali Thakkar <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]>
2019-08-05base: soc: Add serial_number attribute to socBjorn Andersson1-0/+7
Add new attribute named "serial_number" as a standard interface for user space to acquire the serial number of the device. For ST-Ericsson SoCs this is exposed by the cryptically named "soc_id" attribute, but this provides a human readable standardized name for this property. Tested-by: Vinod Koul <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]> Signed-off-by: Vaishali Thakkar <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Vinod Koul <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]>
2019-08-02Merge tag 'dev_groups_all_drivers' into driver-core-nextGreg Kroah-Hartman1-0/+14
dev_groups added to struct driver Persistent tag for others to pull this branch from This is the first patch in a longer series that adds the ability for the driver core to create and remove a list of attribute groups automatically when the device is bound/unbound from a specific driver. See: https://lore.kernel.org/r/[email protected] for details on this patch, and examples of how to use it in other drivers. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-02driver core: add dev_groups to all driversDmitry Torokhov1-0/+14
Add the ability for the driver core to create and remove a list of attribute groups automatically when the device is bound/unbound from a specific driver. Signed-off-by: Dmitry Torokhov <[email protected]> Tested-by: Richard Gong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-01driver core: Add sync_state driver/bus callbackSaravana Kannan1-0/+65
This sync_state driver/bus callback is called once all the consumers of a supplier have probed successfully. This allows the supplier device's driver/bus to sync the supplier device's state to the software state with the guarantee that all the consumers are actively managing the resources provided by the supplier device. To maintain backwards compatibility and ease transition from existing frameworks and resource cleanup schemes, late_initcall_sync is the earliest when the sync_state callback might be called. There is no upper bound on the time by which the sync_state callback has to be called. This is because if a consumer device never probes, the supplier has to maintain its resources in the state left by the bootloader. For example, if the bootloader leaves the display backlight at a fixed voltage and the backlight driver is never probed, you don't want the backlight to ever be turned off after boot up. Also, when multiple devices are added after kernel init, some suppliers could be added before their consumer devices get added. In these instances, the supplier devices could get their sync_state callback called right after they probe because the consumers devices haven't had a chance to create device links to the suppliers. To handle this correctly, this change also provides APIs to pause/resume sync state callbacks so that when multiple devices are added, their sync_state callback evaluation can be postponed to happen after all of them are added. kbuild test robot reported missing documentation for device.state_synced Reported-by: kbuild test robot <[email protected]> Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-01driver core: Add edit_links() callback for driversSaravana Kannan2-2/+51
The driver core/bus adding supplier-consumer dependencies by default enables functional dependencies to be tracked correctly even when the consumer devices haven't had their drivers registered or loaded (if they are modules). However, when the bus incorrectly adds dependencies that it shouldn't have added, the devices might never probe. For example, if device-C is a consumer of device-S and they have phandles to each other in DT, the following could happen: 1. Device-S get added first. 2. The bus add_links() callback will (incorrectly) try to link it as a consumer of device-C. 3. Since device-C isn't present, device-S will be put in "waiting-for-supplier" list. 4. Device-C gets added next. 5. All devices in "waiting-for-supplier" list are retried for linking. 6. Device-S gets linked as consumer to Device-C. 7. The bus add_links() callback will (correctly) try to link it as a consumer of device-S. 8. This isn't allowed because it would create a cyclic device links. Neither devices will get probed since the supplier is marked as dependent on the consumer. And the consumer will never probe because the consumer can't get resources from the supplier. Without this patch, things stay in this broken state. However, with this patch, the execution will continue like this: 9. Device-C's driver is loaded. 10. Device-C's driver removes Device-S as a consumer of Device-C. 11. Device-C's driver adds Device-C as a consumer of Device-S. 12. Device-S probes. 14. Device-C probes. kbuild test robot reported missing documentation for device.has_edit_links Reported-by: kbuild test robot <[email protected]> Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-01driver core: Add support for linking devices during device additionSaravana Kannan1-0/+83
When devices are added, the bus might want to create device links to track functional dependencies between supplier and consumer devices. This tracking of supplier-consumer relationship allows optimizing device probe order and tracking whether all consumers of a supplier are active. The add_links bus callback is added to support this. However, when consumer devices are added, they might not have a supplier device to link to despite needing mandatory resources/functionality from one or more suppliers. A waiting_for_suppliers list is created to track such consumers and retry linking them when new devices get added. Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-08-01regmap: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-12/+0
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. The debugfs core will warn if a file or directory can not be created, so there's no need to duplicate the warning, nor really do anything else. Cc: Mark Brown <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2019-07-30driver core: Fix use-after-free and double free on glue directoryMuchun Song1-1/+52
There is a race condition between removing glue directory and adding a new device under the glue dir. It can be reproduced in following test: CPU1: CPU2: device_add() get_device_parent() class_dir_create_and_add() kobject_add_internal() create_dir() // create glue_dir device_add() get_device_parent() kobject_get() // get glue_dir device_del() cleanup_glue_dir() kobject_del(glue_dir) kobject_add() kobject_add_internal() create_dir() // in glue_dir sysfs_create_dir_ns() kernfs_create_dir_ns(sd) sysfs_remove_dir() // glue_dir->sd=NULL sysfs_put() // free glue_dir->sd // sd is freed kernfs_new_node(sd) kernfs_get(glue_dir) kernfs_add_one() kernfs_put() Before CPU1 remove last child device under glue dir, if CPU2 add a new device under glue dir, the glue_dir kobject reference count will be increase to 2 via kobject_get() in get_device_parent(). And CPU2 has been called kernfs_create_dir_ns(), but not call kernfs_new_node(). Meanwhile, CPU1 call sysfs_remove_dir() and sysfs_put(). This result in glue_dir->sd is freed and it's reference count will be 0. Then CPU2 call kernfs_get(glue_dir) will trigger a warning in kernfs_get() and increase it's reference count to 1. Because glue_dir->sd is freed by CPU1, the next call kernfs_add_one() by CPU2 will fail(This is also use-after-free) and call kernfs_put() to decrease reference count. Because the reference count is decremented to 0, it will also call kmem_cache_free() to free the glue_dir->sd again. This will result in double free. In order to avoid this happening, we also should make sure that kernfs_node for glue_dir is released in CPU1 only when refcount for glue_dir kobj is 1 to fix this race. The following calltrace is captured in kernel 4.14 with the following patch applied: commit 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier") -------------------------------------------------------------------------- [ 3.633703] WARNING: CPU: 4 PID: 513 at .../fs/kernfs/dir.c:494 Here is WARN_ON(!atomic_read(&kn->count) in kernfs_get(). .... [ 3.633986] Call trace: [ 3.633991] kernfs_create_dir_ns+0xa8/0xb0 [ 3.633994] sysfs_create_dir_ns+0x54/0xe8 [ 3.634001] kobject_add_internal+0x22c/0x3f0 [ 3.634005] kobject_add+0xe4/0x118 [ 3.634011] device_add+0x200/0x870 [ 3.634017] _request_firmware+0x958/0xc38 [ 3.634020] request_firmware_into_buf+0x4c/0x70 .... [ 3.634064] kernel BUG at .../mm/slub.c:294! Here is BUG_ON(object == fp) in set_freepointer(). .... [ 3.634346] Call trace: [ 3.634351] kmem_cache_free+0x504/0x6b8 [ 3.634355] kernfs_put+0x14c/0x1d8 [ 3.634359] kernfs_create_dir_ns+0x88/0xb0 [ 3.634362] sysfs_create_dir_ns+0x54/0xe8 [ 3.634366] kobject_add_internal+0x22c/0x3f0 [ 3.634370] kobject_add+0xe4/0x118 [ 3.634374] device_add+0x200/0x870 [ 3.634378] _request_firmware+0x958/0xc38 [ 3.634381] request_firmware_into_buf+0x4c/0x70 -------------------------------------------------------------------------- Fixes: 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier") Signed-off-by: Muchun Song <[email protected]> Reviewed-by: Mukesh Ojha <[email protected]> Signed-off-by: Prateek Sood <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-07-30driver core: platform: Add an error message to platform_get_irq*()Stephen Boyd1-8/+34
A grep of the kernel shows that many drivers print an error message if they fail to get the irq they're looking for. Furthermore, those drivers all decide to print the device name, or not, and the irq they were requesting, or not, etc. Let's consolidate all these error messages into the API itself, allowing us to get rid of the error messages in each driver. Cc: Rob Herring <[email protected]> Cc: Bartlomiej Zolnierkiewicz <[email protected]> Cc: Javier Martinez Canillas <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Mark Brown <[email protected]> Cc: Russell King - ARM Linux <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Markus Elfring <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-07-30driver core: platform: return -ENXIO for missing GpioIntBrian Norris1-2/+7
Commit daaef255dc96 ("driver: platform: Support parsing GpioInt 0 in platform_get_irq()") broke the Embedded Controller driver on most LPC Chromebooks (i.e., most x86 Chromebooks), because cros_ec_lpc expects platform_get_irq() to return -ENXIO for non-existent IRQs. Unfortunately, acpi_dev_gpio_irq_get() doesn't follow this convention and returns -ENOENT instead. So we get this error from cros_ec_lpc: couldn't retrieve IRQ number (-2) I see a variety of drivers that treat -ENXIO specially, so rather than fix all of them, let's fix up the API to restore its previous behavior. I reported this on v2 of this patch: https://lore.kernel.org/lkml/[email protected]/ but apparently the patch had already been merged before v3 got sent out: https://lore.kernel.org/lkml/[email protected]/ and the result is that the bug landed and remains unfixed. I differ from the v3 patch by: * allowing for ret==0, even though acpi_dev_gpio_irq_get() specifically documents (and enforces) that 0 is not a valid return value (noted on the v3 review) * adding a small comment Reported-by: Brian Norris <[email protected]> Reported-by: Salvatore Bellizzi <[email protected]> Cc: Enrico Granata <[email protected]> Cc: <[email protected]> Fixes: daaef255dc96 ("driver: platform: Support parsing GpioInt 0 in platform_get_irq()") Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Enrico Granata <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-07-30Merge branch 'generic_lookup_helpers' into driver-core-nextGreg Kroah-Hartman4-39/+46
This was on a separate branch so that others can pull it in. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-07-30platform: Add platform_find_device_by_driver() helperSuzuki K Poulose1-0/+14
Provide a helper to lookup platform devices by matching device driver in order to avoid drivers trying to use platform bus internals. Cc: Eric Anholt <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "Heiko Stübner" <[email protected]> Cc: Inki Dae <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Sandy Huang <[email protected]> Cc: Seung-Woo Kim <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>