mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Umang Jain <umang.jain@ideasonboard.com>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Arnd Bergmann <arnd@arndb.de>, Stefan Wahren <wahrenst@gmx.net>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Phil Elwell <phil@raspberrypi.com>
Subject: Re: [PATCH 4/7] staging: vchiq_core: Factor out bulk transfer for (no/)callback mode
Date: Fri, 23 Aug 2024 18:33:15 +0300	[thread overview]
Message-ID: <20240823153315.GA28317@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20240823-to_sent2-v1-4-8bc182a0adaf@ideasonboard.com>

Hi Umang,

Thank you for the patch.

On Fri, Aug 23, 2024 at 08:44:24PM +0530, Umang Jain wrote:
> Factor out bulk transfer for VCHIQ_BULK_MODE_NOCALLBACK and
> VCHIQ_BULK_MODE_CALLBACK mode into a separate dedicated function
> bulk_xfer_callback_interruptible(). It is suffixed by "_interruptible"
> to denote that it can be interrupted and -EAGAIN can be returned. It
> would be up to the users of the function to retry the call in those cases.
> 
> bulk_xfer_callback_interruptible() also takes in 'mode' parameter to
> differentiate between VCHIQ_BULK_MODE_NOCALLBACK and
> VCHIQ_BULK_MODE_CALLBACK, which then is directly passed to
> vchiq_bulk_xfer_queue_msg_interruptible() inside the function.
> 
> Adjust the calls to vchiq-dev.c ioctl interface and vchiq_arm.c
> for the respective bulk transfers.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 15 ++++----
>  .../vc04_services/interface/vchiq_arm/vchiq_core.c | 40 ++++++++++++++++++++++
>  .../vc04_services/interface/vchiq_arm/vchiq_core.h |  6 ++++
>  .../vc04_services/interface/vchiq_arm/vchiq_dev.c  |  6 ++++
>  4 files changed, 60 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index e9b9c76381dc..5210ce8d269e 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -857,10 +857,10 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
>  		switch (mode) {
>  		case VCHIQ_BULK_MODE_NOCALLBACK:
>  		case VCHIQ_BULK_MODE_CALLBACK:
> -			ret = vchiq_bulk_transfer(instance, handle,
> -						  (void *)data, NULL,
> -						  size, userdata, mode,
> -						  VCHIQ_BULK_TRANSMIT);
> +			ret = bulk_xfer_callback_interruptible(instance, handle,
> +							       (void *)data, NULL,
> +							       size, mode, userdata,
> +							       VCHIQ_BULK_TRANSMIT);
>  			break;
>  		case VCHIQ_BULK_MODE_BLOCKING:
>  			ret = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size,
> @@ -895,9 +895,10 @@ int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle,
>  		switch (mode) {
>  		case VCHIQ_BULK_MODE_NOCALLBACK:
>  		case VCHIQ_BULK_MODE_CALLBACK:
> -			ret = vchiq_bulk_transfer(instance, handle, data, NULL,
> -						  size, userdata,
> -						  mode, VCHIQ_BULK_RECEIVE);
> +			ret = bulk_xfer_callback_interruptible(instance, handle,
> +							       (void *)data, NULL,
> +							       size, mode, userdata,
> +							       VCHIQ_BULK_RECEIVE);
>  			break;
>  		case VCHIQ_BULK_MODE_BLOCKING:
>  			ret = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size,
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> index 341a06997848..0606561fd3d0 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -3027,6 +3027,46 @@ bulk_xfer_blocking_interruptible(struct vchiq_instance *instance, unsigned int h
>  	return status;
>  }
>  
> +int
> +bulk_xfer_callback_interruptible(struct vchiq_instance *instance, unsigned int handle,

Please prefix the name of all functions with an appropriate driver
prefix, especially for functions that are not static.

> +				 void *offset, void __user *uoffset, int size,
> +				 enum vchiq_bulk_mode mode, void *userdata,
> +				 enum vchiq_bulk_dir dir)
> +{
> +	struct vchiq_service *service = find_service_by_handle(instance, handle);
> +	int status = -EINVAL;
> +
> +	if (!service)
> +		goto error_exit;
> +
> +	if (mode != VCHIQ_BULK_MODE_CALLBACK &&
> +	    mode != VCHIQ_BULK_MODE_NOCALLBACK)
> +		goto error_exit;
> +
> +	if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
> +		goto error_exit;
> +
> +	if (!offset && !uoffset)
> +		goto error_exit;
> +
> +	if (vchiq_check_service(service))
> +		goto error_exit;
> +
> +	status = vchiq_bulk_xfer_queue_msg_interruptible(service, offset, uoffset,
> +							 size, userdata, mode, dir);
> +	if (status)
> +		goto error_exit;
> +
> +	vchiq_service_put(service);
> +
> +	return 0;
> +
> +error_exit:
> +	if (service)
> +		vchiq_service_put(service);
> +	return status;
> +}
> +
>  /*
>   * This function may be called by kernel threads or user threads.
>   * User threads may receive -EAGAIN to indicate that a signal has been
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> index ff3559c3d1ba..8aaf3c9d3dbe 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> @@ -479,6 +479,12 @@ bulk_xfer_blocking_interruptible(struct vchiq_instance *instance, unsigned int h
>  				 void *offset, void __user *uoffset, int size,
>  				 void __user *userdata, enum vchiq_bulk_dir dir);
>  
> +extern int
> +bulk_xfer_callback_interruptible(struct vchiq_instance *instance, unsigned int handle,
> +				 void *offset, void __user *uoffset, int size,
> +				 enum vchiq_bulk_mode mode, void *userdata,
> +				 enum vchiq_bulk_dir dir);
> +
>  extern int
>  vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *offset,
>  		    void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode mode,
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> index 1bff97ad28fa..7ecfcaa85569 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> @@ -336,6 +336,12 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
>  		goto bulk_transfer_handled;
>  	} else {
>  		userdata = args->userdata;
> +
> +		status = bulk_xfer_callback_interruptible(instance, args->handle,
> +							  NULL, args->data, args->size,
> +							  args->mode, userdata, dir);
> +
> +		goto bulk_transfer_handled;
>  	}
>  
>  	status = vchiq_bulk_transfer(instance, args->handle, NULL, args->data, args->size,
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-08-23 15:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 15:14 [PATCH 0/7] staging: vchiq_core: Refactor vchiq_bulk_transfer() logic Umang Jain
2024-08-23 15:14 ` [PATCH 1/7] staging: vchiq: Factor out bulk transfer for VCHIQ_BULK_MODE_WAITING Umang Jain
2024-08-23 15:23   ` Arnd Bergmann
2024-08-23 21:28   ` Stefan Wahren
2024-08-23 15:14 ` [PATCH 2/7] staging: vchiq_core: Simplify vchiq_bulk_transfer() Umang Jain
2024-08-23 15:14 ` [PATCH 3/7] staging: vchiq_core: Factor out bulk transfer for blocking mode Umang Jain
2024-08-23 21:36   ` Stefan Wahren
2024-08-23 15:14 ` [PATCH 4/7] staging: vchiq_core: Factor out bulk transfer for (no/)callback mode Umang Jain
2024-08-23 15:33   ` Laurent Pinchart [this message]
2024-08-23 15:41   ` Arnd Bergmann
2024-08-31 15:05     ` Umang Jain
2024-08-23 15:14 ` [PATCH 5/7] staging: vchiq_core: Drop vchiq_bulk_transfer() Umang Jain
2024-08-23 15:14 ` [PATCH 6/7] staging: vchiq_core: Remove unused function argument Umang Jain
2024-08-23 21:47   ` Stefan Wahren
2024-08-23 15:14 ` [PATCH 7/7] staging: vchiq_core: Pass enumerated flag instead of int Umang Jain
2024-08-23 21:50   ` Stefan Wahren

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=20240823153315.GA28317@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dan.carpenter@linaro.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=phil@raspberrypi.com \
    --cc=umang.jain@ideasonboard.com \
    --cc=wahrenst@gmx.net \
    /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®