[PATCH v2 2/5] lib: sbi: Remove unnecessary sbi_dbtr_shmem_disabled

Himanshu Chauhan hchauhan at ventanamicro.com
Tue Apr 30 02:41:41 PDT 2024



On 23/04/24 20:27, Xiang W wrote:
> The code of hart_shmem_base is similar to sbi_dbtr_shmem_disabled.
> When hart_shmem_base is used, sbi_dbtr_shmem_disabled can be
> removed.
> 
> Signed-off-by: Xiang W <wxjstz at 126.com>
> ---
>   lib/sbi/sbi_dbtr.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> index 5b07285..ceff185 100644
> --- a/lib/sbi/sbi_dbtr.c
> +++ b/lib/sbi/sbi_dbtr.c
> @@ -537,10 +537,9 @@ int sbi_dbtr_read_trig(unsigned long smode,
>   	    trig_idx_base + trig_count >= hs->total_trigs)
>   		return SBI_ERR_INVALID_PARAM;
>   
> -	if (sbi_dbtr_shmem_disabled())
> -		return SBI_ERR_NO_SHMEM;
> -
>   	shmem_base = hart_shmem_base();
> +	if (shmem_base == NULL)
> +		return SBI_ERR_NO_SHMEM;
>   
>   	for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
>   		sbi_hart_map_saddr((unsigned long)entry, sizeof(*entry));
> @@ -567,10 +566,10 @@ int sbi_dbtr_install_trig(unsigned long smode,
>   	struct sbi_dbtr_trigger *trig;
>   	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>   
> -	if (sbi_dbtr_shmem_disabled())
> +	shmem_base = hart_shmem_base();
> +	if (shmem_base == NULL)
>   		return SBI_ERR_NO_SHMEM;
>   
> -	shmem_base = hart_shmem_base();
>   	hs = dbtr_thishart_state_ptr();
>   
>   	/* Check requested triggers configuration */
> @@ -679,10 +678,10 @@ int sbi_dbtr_update_trig(unsigned long smode,
>   	void *shmem_base = NULL;
>   	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>   
> -	if (sbi_dbtr_shmem_disabled())
> +	shmem_base = hart_shmem_base();
> +	if (shmem_base == NULL)
>   		return SBI_ERR_NO_SHMEM;
>   
> -	shmem_base = hart_shmem_base();
>   	hs = dbtr_thishart_state_ptr();
>   	if (!hs)
>   		return SBI_ERR_FAILED;

I would still keep the sbi_dbtr_shmem_disabled() for brevity of usage.
Better, change sbi_dbtr_shmem_disabled() code to do this check and 
return true/false.

Regards
Himanshu



More information about the opensbi mailing list