diff mbox series

[v2,3/5] remoteproc: pru: Deny rproc sysfs ops for PRU client driven boots

Message ID 20201216165239.2744-4-grzegorz.jaszczyk@linaro.org (mailing list archive)
State New, archived
Headers show
Series Introduce PRU remoteproc consumer API | expand

Commit Message

Grzegorz Jaszczyk Dec. 16, 2020, 4:52 p.m. UTC
From: Suman Anna <s-anna@ti.com>

The PRU remoteproc driver is not configured for 'auto-boot' by default,
and allows to be booted either by in-kernel PRU client drivers or by
userspace using the generic remoteproc sysfs interfaces. The sysfs
interfaces should not be permitted to change the remoteproc firmwares
or states when a PRU is being managed by an in-kernel client driver.
Use the newly introduced remoteproc generic 'deny_sysfs_ops' flag to
provide these restrictions by setting and clearing it appropriately
during the PRU acquire and release steps.

Signed-off-by: Suman Anna <s-anna@ti.com>
Co-developed-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
Signed-off-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
---
 drivers/remoteproc/pru_rproc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

kernel test robot Dec. 17, 2020, 10:43 p.m. UTC | #1
Hi Grzegorz,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on next-20201217]
[cannot apply to robh/for-next remoteproc/for-next rpmsg/for-next v5.10]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Grzegorz-Jaszczyk/Introduce-PRU-remoteproc-consumer-API/20201217-005732
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d01e7f10dae29eba0f9ada82b65d24e035d5b2f9
config: arm64-randconfig-r025-20201217 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cee1e7d14f4628d6174b33640d502bff3b54ae45)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/f34d9f03fd4cf7008a1bd30b1cb5ebcab67c97c9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Grzegorz-Jaszczyk/Introduce-PRU-remoteproc-consumer-API/20201217-005732
        git checkout f34d9f03fd4cf7008a1bd30b1cb5ebcab67c97c9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/remoteproc/pru_rproc.c:231:9: error: no member named 'deny_sysfs_ops' in 'struct rproc'
           rproc->deny_sysfs_ops = true;
           ~~~~~  ^
   drivers/remoteproc/pru_rproc.c:262:9: error: no member named 'deny_sysfs_ops' in 'struct rproc'
           rproc->deny_sysfs_ops = false;
           ~~~~~  ^
   2 errors generated.


vim +231 drivers/remoteproc/pru_rproc.c

   186	
   187	/**
   188	 * pru_rproc_get() - get the PRU rproc instance from a device node
   189	 * @np: the user/client device node
   190	 * @index: index to use for the ti,prus property
   191	 * @pru_id: optional pointer to return the PRU remoteproc processor id
   192	 *
   193	 * This function looks through a client device node's "ti,prus" property at
   194	 * index @index and returns the rproc handle for a valid PRU remote processor if
   195	 * found. The function allows only one user to own the PRU rproc resource at a
   196	 * time. Caller must call pru_rproc_put() when done with using the rproc, not
   197	 * required if the function returns a failure.
   198	 *
   199	 * When optional @pru_id pointer is passed the PRU remoteproc processor id is
   200	 * returned.
   201	 *
   202	 * Return: rproc handle on success, and an ERR_PTR on failure using one
   203	 * of the following error values
   204	 *    -ENODEV if device is not found
   205	 *    -EBUSY if PRU is already acquired by anyone
   206	 *    -EPROBE_DEFER is PRU device is not probed yet
   207	 */
   208	struct rproc *pru_rproc_get(struct device_node *np, int index,
   209				    enum pruss_pru_id *pru_id)
   210	{
   211		struct rproc *rproc;
   212		struct pru_rproc *pru;
   213		struct device *dev;
   214	
   215		rproc = __pru_rproc_get(np, index);
   216		if (IS_ERR(rproc))
   217			return rproc;
   218	
   219		pru = rproc->priv;
   220		dev = &rproc->dev;
   221	
   222		mutex_lock(&pru->lock);
   223	
   224		if (pru->client_np) {
   225			mutex_unlock(&pru->lock);
   226			put_device(dev);
   227			return ERR_PTR(-EBUSY);
   228		}
   229	
   230		pru->client_np = np;
 > 231		rproc->deny_sysfs_ops = true;
   232	
   233		mutex_unlock(&pru->lock);
   234	
   235		if (pru_id)
   236			*pru_id = pru->id;
   237	
   238		return rproc;
   239	}
   240	EXPORT_SYMBOL_GPL(pru_rproc_get);
   241	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c
index 568286040bc4..3ffd49f77cfc 100644
--- a/drivers/remoteproc/pru_rproc.c
+++ b/drivers/remoteproc/pru_rproc.c
@@ -228,6 +228,7 @@  struct rproc *pru_rproc_get(struct device_node *np, int index,
 	}
 
 	pru->client_np = np;
+	rproc->deny_sysfs_ops = true;
 
 	mutex_unlock(&pru->lock);
 
@@ -258,6 +259,7 @@  void pru_rproc_put(struct rproc *rproc)
 
 	mutex_lock(&pru->lock);
 	pru->client_np = NULL;
+	rproc->deny_sysfs_ops = false;
 	mutex_unlock(&pru->lock);
 
 	put_device(&rproc->dev);