ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0132-bus-fsl-mc-add-root-dprc-rescan-attribute.patch
1 From 64bd4f6f266110d908e51787a81ed0bc9d325941 Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Mon, 5 Mar 2018 18:37:32 +0200
4 Subject: [PATCH] bus: fsl-mc: add root dprc rescan attribute
5
6 Introduce the rescan attribute as a device attribute to
7 synchronize the fsl-mc bus objects and the MC firmware.
8
9 To rescan the root dprc only, e.g.
10 echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan
11
12 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
13 ---
14  Documentation/ABI/stable/sysfs-bus-fsl-mc |  9 ++++++++
15  MAINTAINERS                               |  1 +
16  drivers/bus/fsl-mc/dprc-driver.c          | 36 +++++++++++++++++++++++++++++++
17  3 files changed, 46 insertions(+)
18  create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc
19
20 --- /dev/null
21 +++ b/Documentation/ABI/stable/sysfs-bus-fsl-mc
22 @@ -0,0 +1,9 @@
23 +What:          /sys/bus/fsl-mc/devices/dprc.*/rescan
24 +Date:          November 2018
25 +KernelVersion: 5.0
26 +Contact:       Ioana Ciornei <ioana.ciornei@nxp.com>
27 +Description:   Writing a non-zero value to this attribute will
28 +               force a rescan of dprc.X container in the system and
29 +               synchronize the objects under dprc.X and the
30 +               Management Complex firmware.
31 +Users:         Userspace drivers and management tools
32 --- a/MAINTAINERS
33 +++ b/MAINTAINERS
34 @@ -13438,6 +13438,7 @@ F:      Documentation/devicetree/bindings/mis
35  F:     Documentation/networking/device_drivers/freescale/dpaa2/overview.rst
36  F:     Documentation/networking/dpaa2/overview.rst
37  F:     include/uapi/linux/fsl_mc.h
38 +F:     Documentation/ABI/stable/sysfs-bus-fsl-mc
39  
40  QT1010 MEDIA DRIVER
41  M:     Antti Palosaari <crope@iki.fi>
42 --- a/drivers/bus/fsl-mc/dprc-driver.c
43 +++ b/drivers/bus/fsl-mc/dprc-driver.c
44 @@ -354,6 +354,33 @@ static int dprc_scan_container(struct fs
45         return 0;
46  }
47  
48 +static ssize_t rescan_store(struct device *dev,
49 +                           struct device_attribute *attr,
50 +                           const char *buf, size_t count)
51 +{
52 +       struct fsl_mc_device *root_mc_dev;
53 +       struct fsl_mc_bus *root_mc_bus;
54 +       unsigned long val;
55 +
56 +       if (!fsl_mc_is_root_dprc(dev))
57 +               return -EINVAL;
58 +
59 +       root_mc_dev = to_fsl_mc_device(dev);
60 +       root_mc_bus = to_fsl_mc_bus(root_mc_dev);
61 +
62 +       if (kstrtoul(buf, 0, &val) < 0)
63 +               return -EINVAL;
64 +
65 +       if (val) {
66 +               mutex_lock(&root_mc_bus->scan_mutex);
67 +               dprc_scan_objects(root_mc_dev, NULL);
68 +               mutex_unlock(&root_mc_bus->scan_mutex);
69 +       }
70 +
71 +       return count;
72 +}
73 +static DEVICE_ATTR_WO(rescan);
74 +
75  /**
76   * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
77   *
78 @@ -692,6 +719,13 @@ static int dprc_probe(struct fsl_mc_devi
79  
80         mutex_init(&mc_bus->scan_mutex);
81  
82 +       error = device_create_file(&mc_dev->dev, &dev_attr_rescan);
83 +       if (error < 0) {
84 +               dev_err(&mc_dev->dev, "device_create_file() failed: %d\n",
85 +                       error);
86 +               goto error_cleanup_open;
87 +       }
88 +
89         /*
90          * Discover MC objects in DPRC object:
91          */
92 @@ -788,6 +822,8 @@ static int dprc_remove(struct fsl_mc_dev
93                 fsl_mc_uapi_remove_device_file(mc_bus);
94         }
95  
96 +       device_remove_file(&mc_dev->dev, &dev_attr_rescan);
97 +
98         dev_info(&mc_dev->dev, "DPRC device unbound from driver");
99         return 0;
100  }