[PATCH v2 4/9] staging: vchiq_arm: pass vchiq instance to 'find_service_by_handle'

Stefan Wahren stefan.wahren at i2se.com
Mon May 30 12:43:31 PDT 2022


Hi Adrien,

Am 18.05.22 um 21:11 schrieb Adrien Thierry:
> In order to remove the 'vchiq_states' global array, we need to pass the
> vchiq_instance reference to the 'handle_to_service' function, as well as
> to all functions that call 'handle_to_service'. This will allow
> accessing the vchiq state through the vchiq instance instead of through
> the global array.
>
> 'handle_to_service' is called by 'find_service_by_handle'. Therefore,
> pass the vchiq instance reference to 'find_service_by_handle' and to its
> callers.
>
> Signed-off-by: Adrien Thierry <athierry at redhat.com>
> ---
>   .../bcm2835-audio/bcm2835-vchiq.c             | 27 +++++----
>   .../include/linux/raspberrypi/vchiq.h         | 26 +++++----
>   .../interface/vchiq_arm/vchiq_arm.c           | 16 +++---
>   .../interface/vchiq_arm/vchiq_arm.h           |  4 +-
>   .../interface/vchiq_arm/vchiq_core.c          | 47 ++++++++--------
>   .../interface/vchiq_arm/vchiq_core.h          |  9 +--
>   .../interface/vchiq_arm/vchiq_dev.c           | 36 ++++++------
>   .../vc04_services/vchiq-mmal/mmal-vchiq.c     | 56 +++++++++----------
>   8 files changed, 118 insertions(+), 103 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> index c32c8c93a615..aa2ab0df7af5 100644
> --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
> @@ -25,12 +25,14 @@ MODULE_PARM_DESC(force_bulk, "Force use of vchiq bulk for audio");
>   static void bcm2835_audio_lock(struct bcm2835_audio_instance *instance)
>   {
>   	mutex_lock(&instance->vchi_mutex);
> -	vchiq_use_service(instance->service_handle);
> +	vchiq_use_service(instance->alsa_stream->chip->vchi_ctx->instance,
> +			  instance->service_handle);
while being in the interface directory it's clear that "instance" refers 
to vchiq, but here it is a higher chance to mixing things up. But not 
sure if it's okay to use an additional variable "vchiq_instance" to 
clarify here or the naming "instance" is unlucky.
>   }
>   
>   static void bcm2835_audio_unlock(struct bcm2835_audio_instance *instance)
>   {
> -	vchiq_release_service(instance->service_handle);
> +	vchiq_release_service(instance->alsa_stream->chip->vchi_ctx->instance,
> +			      instance->service_handle);
>   	mutex_unlock(&instance->vchi_mutex);
>   }
>   
> @@ -44,8 +46,8 @@ static int bcm2835_audio_send_msg_locked(struct bcm2835_audio_instance *instance
>   		init_completion(&instance->msg_avail_comp);
>   	}
>   
> -	status = vchiq_queue_kernel_message(instance->service_handle,
> -					    m, sizeof(*m));
> +	status = vchiq_queue_kernel_message(instance->alsa_stream->chip->vchi_ctx->instance,
> +					    instance->service_handle, m, sizeof(*m));
>   	if (status) {
>   		dev_err(instance->dev,
>   			"vchi message queue failed: %d, msg=%d\n",
> @@ -115,7 +117,7 @@ static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instan
>   		dev_err(instance->dev, "unexpected callback type=%d\n", m->type);
>   	}
>   
> -	vchiq_release_message(handle, header);
> +	vchiq_release_message(vchiq_instance, instance->service_handle, header);
>   	return VCHIQ_SUCCESS;
>   }
>   
> @@ -144,7 +146,8 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance,
>   	}
>   
>   	/* Finished with the service for now */
> -	vchiq_release_service(instance->service_handle);
> +	vchiq_release_service(instance->alsa_stream->chip->vchi_ctx->instance,
> +			      instance->service_handle);
>   
>   	return 0;
>   }
> @@ -154,10 +157,12 @@ static void vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance)
>   	int status;
>   
>   	mutex_lock(&instance->vchi_mutex);
> -	vchiq_use_service(instance->service_handle);
> +	vchiq_use_service(instance->alsa_stream->chip->vchi_ctx->instance,
> +			  instance->service_handle);
>   
>   	/* Close all VCHI service connections */
> -	status = vchiq_close_service(instance->service_handle);
> +	status = vchiq_close_service(instance->alsa_stream->chip->vchi_ctx->instance,
> +				     instance->service_handle);
>   	if (status) {
>   		dev_err(instance->dev,
>   			"failed to close VCHI service connection (status=%d)\n",
> @@ -227,7 +232,7 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
>   		goto deinit;
>   
>   	bcm2835_audio_lock(instance);
> -	vchiq_get_peer_version(instance->service_handle,
> +	vchiq_get_peer_version(vchi_ctx->instance, instance->service_handle,
>   			       &instance->peer_version);
>   	bcm2835_audio_unlock(instance);
>   	if (instance->peer_version < 2 || force_bulk)
> @@ -352,8 +357,8 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream,
>   		while (count > 0) {
>   			int bytes = min(instance->max_packet, count);
>   
> -			status = vchiq_queue_kernel_message(instance->service_handle,
> -							    src, bytes);
> +			status = vchiq_queue_kernel_message(vchiq_instance,
> +							    instance->service_handle, src, bytes);
>   			src += bytes;
>   			count -= bytes;
>   		}



More information about the linux-arm-kernel mailing list