[PATCH v2 8/9] staging: vchiq_arm: use state from vchiq instance

Stefan Wahren stefan.wahren at i2se.com
Mon May 30 13:09:05 PDT 2022


Hi Adrien,

Am 18.05.22 um 21:11 schrieb Adrien Thierry:
> In 'handle_to_service', access the vchiq state from the vchiq instance
> instead of the global 'vchiq_states' array. This will allow getting rid
> of the global 'vchiq_states' array.
>
> Signed-off-by: Adrien Thierry <athierry at redhat.com>
> ---
>   .../vc04_services/interface/vchiq_arm/vchiq_core.c   |  7 +++++++
>   .../vc04_services/interface/vchiq_arm/vchiq_core.h   | 12 +-----------
>   2 files changed, 8 insertions(+), 11 deletions(-)
>
> 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 be2ee84686b7..cd23d18f8b3c 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -13,6 +13,7 @@
>   #include <linux/rcupdate.h>
>   #include <linux/sched/signal.h>
>   
> +#include "vchiq_arm.h"
>   #include "vchiq_core.h"
>   
>   #define VCHIQ_SLOT_HANDLER_STACK 8192
> @@ -234,6 +235,12 @@ set_service_state(struct vchiq_service *service, int newstate)
>   	service->srvstate = newstate;
>   }
>   
> +struct vchiq_service *handle_to_service(struct vchiq_instance *instance, unsigned int handle)
> +{
> +	int idx = handle & (VCHIQ_MAX_SERVICES - 1);
> +
> +	return rcu_dereference(instance->state->services[idx]);
looking at vchiq_initialise() and vchiq_get_state() let me think that we 
cannot assume that instance->state is always different from NULL.
> +}
>   struct vchiq_service *
>   find_service_by_handle(struct vchiq_instance *instance, unsigned int handle)
>   {
> 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 07c3a82e6084..f87b4b9b3596 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
> @@ -509,17 +509,7 @@ extern void
>   request_poll(struct vchiq_state *state, struct vchiq_service *service,
>   	     int poll_type);
>   
> -static inline struct vchiq_service *
> -handle_to_service(struct vchiq_instance *instance, unsigned int handle)
> -{
> -	int idx = handle & (VCHIQ_MAX_SERVICES - 1);
> -	struct vchiq_state *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) &
> -		(VCHIQ_MAX_STATES - 1)];
> -
> -	if (!state)
> -		return NULL;
> -	return rcu_dereference(state->services[idx]);
> -}
> +struct vchiq_service *handle_to_service(struct vchiq_instance *instance, unsigned int handle);
>   
>   extern struct vchiq_service *
>   find_service_by_handle(struct vchiq_instance *instance, unsigned int handle);



More information about the linux-arm-kernel mailing list