kernel: bump 5.4 to 5.4.40
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 701-net-0133-bus-fsl-mc-add-bus-rescan-attribute.patch
1 From 4eba1e0209a52798e1b6a233840a28fc5132cd9c Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Mon, 5 Mar 2018 18:38:46 +0200
4 Subject: [PATCH] bus: fsl-mc: add bus rescan attribute
5
6 Introduce the rescan attribute as a bus attribute to
7 synchronize the fsl-mc bus objects and the MC firmware.
8
9 To rescan the fsl-mc bus, e.g.,
10 echo 1 > /sys/bus/fsl-mc/rescan
11
12 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
13 ---
14 Documentation/ABI/stable/sysfs-bus-fsl-mc | 10 ++++++++
15 drivers/bus/fsl-mc/dprc-driver.c | 4 +--
16 drivers/bus/fsl-mc/fsl-mc-bus.c | 41 +++++++++++++++++++++++++++++++
17 drivers/bus/fsl-mc/fsl-mc-private.h | 2 ++
18 4 files changed, 55 insertions(+), 2 deletions(-)
19
20 --- a/Documentation/ABI/stable/sysfs-bus-fsl-mc
21 +++ b/Documentation/ABI/stable/sysfs-bus-fsl-mc
22 @@ -7,3 +7,13 @@ Description: Writing a non-zero value to
23 synchronize the objects under dprc.X and the
24 Management Complex firmware.
25 Users: Userspace drivers and management tools
26 +
27 +What: /sys/bus/fsl-mc/rescan
28 +Date: November 2018
29 +KernelVersion: 5.0
30 +Contact: Ioana Ciornei <ioana.ciornei@nxp.com>
31 +Description: Writing a non-zero value to this attribute will
32 + force a rescan of fsl-mc bus in the system and
33 + synchronize the objects under fsl-mc bus and the
34 + Management Complex firmware.
35 +Users: Userspace drivers and management tools
36 --- a/drivers/bus/fsl-mc/dprc-driver.c
37 +++ b/drivers/bus/fsl-mc/dprc-driver.c
38 @@ -214,8 +214,8 @@ static void dprc_add_new_devices(struct
39 * populated before they can get allocation requests from probe callbacks
40 * of the device drivers for the non-allocatable devices.
41 */
42 -static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
43 - unsigned int *total_irq_count)
44 +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
45 + unsigned int *total_irq_count)
46 {
47 int num_child_objects;
48 int dprc_get_obj_failures;
49 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
50 +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
51 @@ -154,12 +154,53 @@ static struct attribute *fsl_mc_dev_attr
52
53 ATTRIBUTE_GROUPS(fsl_mc_dev);
54
55 +static int scan_fsl_mc_bus(struct device *dev, void *data)
56 +{
57 + struct fsl_mc_device *root_mc_dev;
58 + struct fsl_mc_bus *root_mc_bus;
59 +
60 + if (!fsl_mc_is_root_dprc(dev))
61 + goto exit;
62 +
63 + root_mc_dev = to_fsl_mc_device(dev);
64 + root_mc_bus = to_fsl_mc_bus(root_mc_dev);
65 + mutex_lock(&root_mc_bus->scan_mutex);
66 + dprc_scan_objects(root_mc_dev, NULL);
67 + mutex_unlock(&root_mc_bus->scan_mutex);
68 +
69 +exit:
70 + return 0;
71 +}
72 +
73 +static ssize_t rescan_store(struct bus_type *bus,
74 + const char *buf, size_t count)
75 +{
76 + unsigned long val;
77 +
78 + if (kstrtoul(buf, 0, &val) < 0)
79 + return -EINVAL;
80 +
81 + if (val)
82 + bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
83 +
84 + return count;
85 +}
86 +static BUS_ATTR_WO(rescan);
87 +
88 +static struct attribute *fsl_mc_bus_attrs[] = {
89 + &bus_attr_rescan.attr,
90 + NULL,
91 +};
92 +
93 +ATTRIBUTE_GROUPS(fsl_mc_bus);
94 +
95 struct bus_type fsl_mc_bus_type = {
96 .name = "fsl-mc",
97 .match = fsl_mc_bus_match,
98 .uevent = fsl_mc_bus_uevent,
99 .dma_configure = fsl_mc_dma_configure,
100 .dev_groups = fsl_mc_dev_groups,
101 + .bus_groups = fsl_mc_bus_groups,
102 };
103 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
104
105 --- a/drivers/bus/fsl-mc/fsl-mc-private.h
106 +++ b/drivers/bus/fsl-mc/fsl-mc-private.h
107 @@ -556,6 +556,8 @@ int __init dprc_driver_init(void);
108
109 void dprc_driver_exit(void);
110
111 +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
112 + unsigned int *total_irq_count);
113 int __init fsl_mc_allocator_driver_init(void);
114
115 void fsl_mc_allocator_driver_exit(void);