All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev-owner@vger.kernel.org" <netdev-owner@vger.kernel.org>,
	Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>,
	Horia Geanta <horia.geanta@nxp.com>, Leo Li <leoyang.li@nxp.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH v3 3/4] bus: fsl-mc: add root dprc rescan attribute
Date: Tue, 20 Nov 2018 15:39:45 +0000	[thread overview]
Message-ID: <1542728371-6972-4-git-send-email-ioana.ciornei@nxp.com> (raw)
In-Reply-To: <1542728371-6972-1-git-send-email-ioana.ciornei@nxp.com>

Introduce the rescan attribute as a device attribute to
synchronize the fsl-mc bus objects and the MC firmware.

To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
   - remove the rescan dev_attr on the remove path
Changes in v3:
   - none

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  9 ++++++++
 MAINTAINERS                               |  1 +
 drivers/bus/fsl-mc/dprc-driver.c          | 36 +++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc

diff --git a/Documentation/ABI/stable/sysfs-bus-fsl-mc b/Documentation/ABI/stable/sysfs-bus-fsl-mc
new file mode 100644
index 0000000..9f3a95e
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-bus-fsl-mc
@@ -0,0 +1,9 @@
+What:		/sys/bus/fsl-mc/devices/dprc.*/rescan
+Date:		November 2018
+KernelVersion:	5.0
+Contact:	Ioana Ciornei <ioana.ciornei@nxp.com>
+Description:	Writing a non-zero value to this attribute will
+		force a rescan of dprc.X container in the system and
+		synchronize the objects under dprc.X and the
+		Management Complex firmware.
+Users:		Userspace drivers and management tools
diff --git a/MAINTAINERS b/MAINTAINERS
index e841cc4..7b76a80 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12283,6 +12283,7 @@ F:	drivers/bus/fsl-mc/
 F:	Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt
 F:	Documentation/networking/dpaa2/overview.rst
 F:	include/uapi/linux/fsl_mc.h
+F:	Documentation/ABI/stable/sysfs-bus-fsl-mc
 
 QT1010 MEDIA DRIVER
 M:	Antti Palosaari <crope@iki.fi>
diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index bab0d5a..2f94aba 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -354,6 +354,33 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 	return 0;
 }
 
+static ssize_t rescan_store(struct device *dev,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+	unsigned long val;
+
+	if (!fsl_mc_is_root_dprc(dev))
+		return -EINVAL;
+
+	root_mc_dev = to_fsl_mc_device(dev);
+	root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
+	if (val) {
+		mutex_lock(&root_mc_bus->scan_mutex);
+		dprc_scan_objects(root_mc_dev, NULL);
+		mutex_unlock(&root_mc_bus->scan_mutex);
+	}
+
+	return count;
+}
+static DEVICE_ATTR_WO(rescan);
+
 /**
  * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
  *
@@ -692,6 +719,13 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 
 	mutex_init(&mc_bus->scan_mutex);
 
+	error = device_create_file(&mc_dev->dev, &dev_attr_rescan);
+	if (error < 0) {
+		dev_err(&mc_dev->dev, "device_create_file() failed: %d\n",
+			error);
+		goto error_cleanup_open;
+	}
+
 	/*
 	 * Discover MC objects in DPRC object:
 	 */
@@ -788,6 +822,8 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 		fsl_mc_uapi_remove_device_file(mc_bus);
 	}
 
+	device_remove_file(&mc_dev->dev, &dev_attr_rescan);
+
 	dev_info(&mc_dev->dev, "DPRC device unbound from driver");
 	return 0;
 }
-- 
1.9.1


  parent reply	other threads:[~2018-11-20 15:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 15:39 [PATCH v3 0/4] bus: fsl-mc: enhance Management Complex userspace support Ioana Ciornei
2018-11-20 15:39 ` [PATCH v3 1/4] bus: fsl-mc: move fsl_mc_command struct in a uapi header Ioana Ciornei
2018-11-20 15:39 ` [PATCH v3 2/4] bus: fsl-mc: add fsl-mc userspace support Ioana Ciornei
2018-11-20 16:44   ` gregkh
2018-11-20 16:51     ` Ioana Ciornei
2018-11-20 16:58       ` gregkh
2018-11-20 16:48   ` gregkh
2018-11-20 17:59     ` Ioana Ciornei
2018-11-21  8:14       ` gregkh
2018-11-29 16:55         ` Ioana Ciornei
2018-11-20 15:39 ` Ioana Ciornei [this message]
2018-11-20 15:39 ` [PATCH v3 4/4] bus: fsl-mc: add bus rescan attribute Ioana Ciornei
  -- strict thread matches above, loose matches on Subject: below --
2018-03-23 15:38 [PATCH v3 0/4] bus: fsl-mc: enhance Management Complex userspace support Ioana Ciornei
2018-03-23 15:38 ` [PATCH v3 3/4] bus: fsl-mc: add root dprc rescan attribute Ioana Ciornei
2018-03-23 15:48   ` Greg KH
2018-03-23 16:00     ` Ioana Ciornei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542728371-6972-4-git-send-email-ioana.ciornei@nxp.com \
    --to=ioana.ciornei@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horia.geanta@nxp.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-owner@vger.kernel.org \
    --cc=ruxandra.radulescu@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.