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
6 Introduce the rescan attribute as a device attribute to
7 synchronize the fsl-mc bus objects and the MC firmware.
9 To rescan the root dprc only, e.g.
10 echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan
12 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
14 Documentation/ABI/stable/sysfs-bus-fsl-mc | 9 ++++++++
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
21 +++ b/Documentation/ABI/stable/sysfs-bus-fsl-mc
23 +What: /sys/bus/fsl-mc/devices/dprc.*/rescan
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
34 @@ -13440,6 +13440,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
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
48 +static ssize_t rescan_store(struct device *dev,
49 + struct device_attribute *attr,
50 + const char *buf, size_t count)
52 + struct fsl_mc_device *root_mc_dev;
53 + struct fsl_mc_bus *root_mc_bus;
56 + if (!fsl_mc_is_root_dprc(dev))
59 + root_mc_dev = to_fsl_mc_device(dev);
60 + root_mc_bus = to_fsl_mc_bus(root_mc_dev);
62 + if (kstrtoul(buf, 0, &val) < 0)
66 + mutex_lock(&root_mc_bus->scan_mutex);
67 + dprc_scan_objects(root_mc_dev, NULL);
68 + mutex_unlock(&root_mc_bus->scan_mutex);
73 +static DEVICE_ATTR_WO(rescan);
76 * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
78 @@ -692,6 +719,13 @@ static int dprc_probe(struct fsl_mc_devi
80 mutex_init(&mc_bus->scan_mutex);
82 + error = device_create_file(&mc_dev->dev, &dev_attr_rescan);
84 + dev_err(&mc_dev->dev, "device_create_file() failed: %d\n",
86 + goto error_cleanup_open;
90 * Discover MC objects in DPRC object:
92 @@ -788,6 +822,8 @@ static int dprc_remove(struct fsl_mc_dev
93 fsl_mc_uapi_remove_device_file(mc_bus);
96 + device_remove_file(&mc_dev->dev, &dev_attr_rescan);
98 dev_info(&mc_dev->dev, "DPRC device unbound from driver");