mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
To: Diana Craciun <diana.craciun@oss.nxp.com>,
	linux-kernel@vger.kernel.org, stuyoder@gmail.com,
	leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org,
	bharatb.yadav@gmail.com
Cc: Bharat Bhushan <Bharat.Bhushan@nxp.com>,
	"J . German Rivera" <German.Rivera@freescale.com>,
	Stuart Yoder <stuart.yoder@nxp.com>
Subject: Re: [PATCH 04/10] bus/fsl-mc: Propagate driver_override for a child DPRC's children
Date: Mon, 23 Mar 2020 14:35:14 +0200	[thread overview]
Message-ID: <7ac6caed-d467-790c-7b40-c40f33d69435@nxp.com> (raw)
In-Reply-To: <20200319154051.30609-5-diana.craciun@oss.nxp.com>



On 3/19/2020 5:40 PM, Diana Craciun wrote:
> From: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> 
> When a child DPRC is bound to the vfio_fsl_mc driver via
> driver_override, its own children should not be bound to corresponding
> host kernel drivers, but instead should be bound to the vfio_fsl_mc
> driver as well.
> 
> Currently, when a child container is scanned by the vfio_fsl_mc
> driver, child devices found are automatically bound to corresponding
> host kernel drivers (e.g., DPMCP and DPBP objects are bound to the
> fsl_mc_allocator driver, DPNI objects are bound to the ldpaa_eth
> driver, etc), Then, the user has to manually unbind these child
> devices from their drivers, set the driver_override sysfs attribute
> to vfio_fsl_mc driver, for each of them and rebind them.
> 
> Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
> Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Signed-off-by: Diana Craciun <diana.craciun@oss.nxp.com>
> ---
>  drivers/bus/fsl-mc/dprc-driver.c    | 12 ++++++++----
>  drivers/bus/fsl-mc/fsl-mc-bus.c     | 18 +++++++++++++++++-
>  drivers/bus/fsl-mc/fsl-mc-private.h |  2 ++
>  include/linux/fsl/mc.h              |  2 ++
>  4 files changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
> index d373b28abe2d..7eaf78900dfc 100644
> --- a/drivers/bus/fsl-mc/dprc-driver.c
> +++ b/drivers/bus/fsl-mc/dprc-driver.c
> @@ -155,6 +155,8 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
>   * dprc_add_new_devices - Adds devices to the logical bus for a DPRC
>   *
>   * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
> + * @driver_override: driver override to apply to new objects found in the
> + * DPRC, or NULL, if none.
>   * @obj_desc_array: array of device descriptors for child devices currently
>   * present in the physical DPRC.
>   * @num_child_objects_in_mc: number of entries in obj_desc_array
> @@ -164,6 +166,7 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
>   * in the physical DPRC.
>   */
>  static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
> +				 const char *driver_override,
>  				 struct fsl_mc_obj_desc *obj_desc_array,
>  				 int num_child_objects_in_mc)
>  {
> @@ -188,7 +191,7 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
>  		}
>  
>  		error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
> -					  &child_dev);
> +					  driver_override, &child_dev);
>  		if (error < 0)
>  			continue;
>  	}
> @@ -214,6 +217,7 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
>   * of the device drivers for the non-allocatable devices.
>   */
>  static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
> +			    const char *driver_override,
>  			    bool alloc_interrupts)
>  {
>  	int num_child_objects;
> @@ -313,7 +317,7 @@ static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
>  	dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
>  			    num_child_objects);
>  
> -	dprc_add_new_devices(mc_bus_dev, child_obj_desc_array,
> +	dprc_add_new_devices(mc_bus_dev, driver_override, child_obj_desc_array,
>  			     num_child_objects);
>  
>  	if (child_obj_desc_array)
> @@ -342,7 +346,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
>  	 * Discover objects in the DPRC:
>  	 */
>  	mutex_lock(&mc_bus->scan_mutex);
> -	error = dprc_scan_objects(mc_bus_dev, true);
> +	error = dprc_scan_objects(mc_bus_dev, NULL, true);
>  	mutex_unlock(&mc_bus->scan_mutex);
>  	if (error < 0) {
>  		fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
> @@ -412,7 +416,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
>  		      DPRC_IRQ_EVENT_OBJ_DESTROYED |
>  		      DPRC_IRQ_EVENT_OBJ_CREATED)) {
>  
> -		error = dprc_scan_objects(mc_dev, true);
> +		error = dprc_scan_objects(mc_dev, NULL, true);
>  		if (error < 0) {
>  			/*
>  			 * If the error is -ENXIO, we ignore it, as it indicates
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index baf8259262a9..b9ccac9862b7 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -617,6 +617,7 @@ static void fsl_mc_device_release(struct device *dev)
>  int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
>  		      struct fsl_mc_io *mc_io,
>  		      struct device *parent_dev,
> +		      const char *driver_override,
>  		      struct fsl_mc_device **new_mc_dev)
>  {
>  	int error;
> @@ -649,6 +650,19 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
>  
>  	mc_dev->obj_desc = *obj_desc;
>  	mc_dev->mc_io = mc_io;
> +
> +	if (driver_override) {
> +		/*
> +		 * We trust driver_override, so we don't need to use
> +		 * kstrndup() here
> +		 */
> +		mc_dev->driver_override = kstrdup(driver_override, GFP_KERNEL);
> +		if (!mc_dev->driver_override) {
> +			error = -ENOMEM;
> +			goto error_cleanup_dev;
> +		}
> +	}
> +
>  	device_initialize(&mc_dev->dev);
>  	mc_dev->dev.parent = parent_dev;
>  	mc_dev->dev.bus = &fsl_mc_bus_type;
> @@ -740,6 +754,7 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
>  
>  error_cleanup_dev:
>  	kfree(mc_dev->regions);
> +	kfree(mc_dev->driver_override);
>  	kfree(mc_bus);
>  	kfree(mc_dev);
>  
> @@ -980,7 +995,8 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
>  	obj_desc.irq_count = 1;
>  	obj_desc.region_count = 0;
>  
> -	error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, &mc_bus_dev);
> +	error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, NULL,
> +				 &mc_bus_dev);
>  	if (error < 0)
>  		goto error_cleanup_mc_io;
>  
> diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h b/drivers/bus/fsl-mc/fsl-mc-private.h
> index 21ca8c756ee7..be6bb0fb4603 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-private.h
> +++ b/drivers/bus/fsl-mc/fsl-mc-private.h
> @@ -3,6 +3,7 @@
>   * Freescale Management Complex (MC) bus private declarations
>   *
>   * Copyright (C) 2016 Freescale Semiconductor, Inc.
> + * Copyright 2019-2020 NXP
>   *
>   */
>  #ifndef _FSL_MC_PRIVATE_H_
> @@ -567,6 +568,7 @@ struct fsl_mc_bus {
>  int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
>  				   struct fsl_mc_io *mc_io,
>  				   struct device *parent_dev,
> +				   const char *driver_override,
>  				   struct fsl_mc_device **new_mc_dev);
>  
>  void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
> diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
> index 88095fd30c80..f997f8091408 100644
> --- a/include/linux/fsl/mc.h
> +++ b/include/linux/fsl/mc.h
> @@ -3,6 +3,7 @@
>   * Freescale Management Complex (MC) bus public interface
>   *
>   * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
> + * Copyright 2019-2020 NXP
>   * Author: German Rivera <German.Rivera@freescale.com>
>   *
>   */
> @@ -161,6 +162,7 @@ struct fsl_mc_obj_desc {
>   * @regions: pointer to array of MMIO region entries
>   * @irqs: pointer to array of pointers to interrupts allocated to this device
>   * @resource: generic resource associated with this MC object device, if any.
> + * @driver_override: Driver name to force a match

This was probably meant to go in the previous patch.

---
Best Regards, Laurentiu

>   *
>   * Generic device object for MC object devices that are "attached" to a
>   * MC bus.
> 

  reply	other threads:[~2020-03-23 12:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 15:40 [PATCH 00/10] bus/fsl-mc: Extend mc-bus driver functionalities in preparation for mc-bus VFIO support Diana Craciun
2020-03-19 15:40 ` [PATCH 01/10] bus/fsl-mc: Do no longer export the total number of irqs outside dprc_scan_objects Diana Craciun
2020-04-06 14:46   ` Diana Craciun OSS
2020-03-19 15:40 ` [PATCH 02/10] bus/fsl-mc: Add a new parameter to dprc_scan_objects function Diana Craciun
2020-03-23 12:04   ` Laurentiu Tudor
2020-03-19 15:40 ` [PATCH 03/10] bus/fsl-mc: add support for 'driver_override' in the mc-bus Diana Craciun
2020-03-23 12:30   ` Laurentiu Tudor
2020-04-09 11:14     ` Diana Craciun OSS
2020-03-19 15:40 ` [PATCH 04/10] bus/fsl-mc: Propagate driver_override for a child DPRC's children Diana Craciun
2020-03-23 12:35   ` Laurentiu Tudor [this message]
2020-03-19 15:40 ` [PATCH 05/10] bus/fsl-mc: Set the QMAN/BMAN region flags Diana Craciun
2020-03-19 15:40 ` [PATCH 06/10] bus/fsl-mc: Add dprc-reset-container support Diana Craciun
2020-03-19 15:40 ` [PATCH 07/10] bus/fsl-mc: Export a dprc scan function to be used by multiple entities Diana Craciun
2020-03-23 12:48   ` Laurentiu Tudor
2020-03-19 15:40 ` [PATCH 08/10] bus/fsl-mc: Export a cleanup function for DPRC Diana Craciun
2020-03-23 12:52   ` Laurentiu Tudor
2020-03-19 15:40 ` [PATCH 09/10] bus/fsl-mc: Add a container setup function Diana Craciun
2020-03-23 13:06   ` Laurentiu Tudor
2020-03-19 15:40 ` [PATCH 10/10] bus/fsl-mc: Export IRQ pool handling functions to be used by VFIO Diana Craciun

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=7ac6caed-d467-790c-7b40-c40f33d69435@nxp.com \
    --to=laurentiu.tudor@nxp.com \
    --cc=Bharat.Bhushan@nxp.com \
    --cc=German.Rivera@freescale.com \
    --cc=bharatb.yadav@gmail.com \
    --cc=diana.craciun@oss.nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stuart.yoder@nxp.com \
    --cc=stuyoder@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®