mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
driver core: Replace dev->state_synced with dev_state_synced()
In C, bitfields are not necessarily safe to modify from multiple threads without locking. Switch "state_synced" over to the "flags" field so modifications are safe. Cc: Saravana Kannan <saravanak@kernel.org> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://patch.msgid.link/20260406162231.v5.6.Idb4818e1159fef104c7756bfd6e7ba8f374bebcd@changeid Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
9ad67f494b
commit
7befbf1281
|
|
@ -1123,7 +1123,7 @@ static void __device_links_queue_sync_state(struct device *dev,
|
|||
|
||||
if (!dev_has_sync_state(dev))
|
||||
return;
|
||||
if (dev->state_synced)
|
||||
if (dev_state_synced(dev))
|
||||
return;
|
||||
|
||||
list_for_each_entry(link, &dev->links.consumers, s_node) {
|
||||
|
|
@ -1138,7 +1138,7 @@ static void __device_links_queue_sync_state(struct device *dev,
|
|||
* than once. This can happen if new consumers get added to the device
|
||||
* and probed before the list is flushed.
|
||||
*/
|
||||
dev->state_synced = true;
|
||||
dev_set_state_synced(dev);
|
||||
|
||||
if (WARN_ON(!list_empty(&dev->links.defer_sync)))
|
||||
return;
|
||||
|
|
@ -1779,7 +1779,7 @@ static int fw_devlink_dev_sync_state(struct device *dev, void *data)
|
|||
struct device *sup = link->supplier;
|
||||
|
||||
if (!device_link_test(link, DL_FLAG_MANAGED) ||
|
||||
link->status == DL_STATE_ACTIVE || sup->state_synced ||
|
||||
link->status == DL_STATE_ACTIVE || dev_state_synced(sup) ||
|
||||
!dev_has_sync_state(sup))
|
||||
return 0;
|
||||
|
||||
|
|
@ -1793,7 +1793,7 @@ static int fw_devlink_dev_sync_state(struct device *dev, void *data)
|
|||
return 0;
|
||||
|
||||
dev_warn(sup, "Timed out. Forcing sync_state()\n");
|
||||
sup->state_synced = true;
|
||||
dev_set_state_synced(sup);
|
||||
get_device(sup);
|
||||
list_add_tail(&sup->links.defer_sync, data);
|
||||
|
||||
|
|
|
|||
|
|
@ -569,12 +569,10 @@ static ssize_t state_synced_store(struct device *dev,
|
|||
return -EINVAL;
|
||||
|
||||
device_lock(dev);
|
||||
if (!dev->state_synced) {
|
||||
dev->state_synced = true;
|
||||
if (!dev_test_and_set_state_synced(dev))
|
||||
dev_sync_state(dev);
|
||||
} else {
|
||||
else
|
||||
ret = -EINVAL;
|
||||
}
|
||||
device_unlock(dev);
|
||||
|
||||
return ret ? ret : count;
|
||||
|
|
@ -586,7 +584,7 @@ static ssize_t state_synced_show(struct device *dev,
|
|||
bool val;
|
||||
|
||||
device_lock(dev);
|
||||
val = dev->state_synced;
|
||||
val = dev_state_synced(dev);
|
||||
device_unlock(dev);
|
||||
|
||||
return sysfs_emit(buf, "%u\n", val);
|
||||
|
|
|
|||
|
|
@ -524,6 +524,9 @@ struct device_physical_location {
|
|||
* optional (if the coherent mask is large enough) also for dma
|
||||
* allocations. This flag is managed by the dma ops instance from
|
||||
* ->dma_supported.
|
||||
* @DEV_FLAG_STATE_SYNCED: The hardware state of this device has been synced to
|
||||
* match the software state of this device by calling the
|
||||
* driver/bus sync_state() callback.
|
||||
* @DEV_FLAG_COUNT: Number of defined struct_device_flags.
|
||||
*/
|
||||
enum struct_device_flags {
|
||||
|
|
@ -532,6 +535,7 @@ enum struct_device_flags {
|
|||
DEV_FLAG_DMA_IOMMU = 2,
|
||||
DEV_FLAG_DMA_SKIP_SYNC = 3,
|
||||
DEV_FLAG_DMA_OPS_BYPASS = 4,
|
||||
DEV_FLAG_STATE_SYNCED = 5,
|
||||
|
||||
DEV_FLAG_COUNT
|
||||
};
|
||||
|
|
@ -615,9 +619,6 @@ enum struct_device_flags {
|
|||
* @offline: Set after successful invocation of bus type's .offline().
|
||||
* @of_node_reused: Set if the device-tree node is shared with an ancestor
|
||||
* device.
|
||||
* @state_synced: The hardware state of this device has been synced to match
|
||||
* the software state of this device by calling the driver/bus
|
||||
* sync_state() callback.
|
||||
* @dma_coherent: this particular device is dma coherent, even if the
|
||||
* architecture supports non-coherent devices.
|
||||
* @flags: DEV_FLAG_XXX flags. Use atomic bitfield operations to modify.
|
||||
|
|
@ -727,7 +728,6 @@ struct device {
|
|||
bool offline_disabled:1;
|
||||
bool offline:1;
|
||||
bool of_node_reused:1;
|
||||
bool state_synced:1;
|
||||
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
|
||||
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
|
||||
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
|
||||
|
|
@ -764,6 +764,7 @@ __create_dev_flag_accessors(can_match, DEV_FLAG_CAN_MATCH);
|
|||
__create_dev_flag_accessors(dma_iommu, DEV_FLAG_DMA_IOMMU);
|
||||
__create_dev_flag_accessors(dma_skip_sync, DEV_FLAG_DMA_SKIP_SYNC);
|
||||
__create_dev_flag_accessors(dma_ops_bypass, DEV_FLAG_DMA_OPS_BYPASS);
|
||||
__create_dev_flag_accessors(state_synced, DEV_FLAG_STATE_SYNCED);
|
||||
|
||||
#undef __create_dev_flag_accessors
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user