DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wang, Xiao W" <xiao.w.wang@intel.com>
To: "Pei, Andy" <andy.pei@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Xia, Chenbo" <chenbo.xia@intel.com>
Subject: RE: [PATCH 2/3] vdpa/ifc: check lm_cfg is not NULL before use lm_cfg
Date: Mon, 13 Dec 2021 07:09:11 +0000	[thread overview]
Message-ID: <DM8PR11MB5751081A93C35A8B055C5C26B8749@DM8PR11MB5751.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1639369756-103116-1-git-send-email-andy.pei@intel.com>

Hi,

Comments inline.

BRs,
Xiao

> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Monday, December 13, 2021 12:29 PM
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Xia, Chenbo <chenbo.xia@intel.com>;
> Wang, Xiao W <xiao.w.wang@intel.com>
> Subject: [PATCH 2/3] vdpa/ifc: check lm_cfg is not NULL before use lm_cfg
> 
> check lm_cfg is not NULL before use lm_cfg.
> when init hardware, if lm_cfg is NULL, output some debug information.

1. We need to capitalize the first letter in a sentence.
2. If lm_cfg is null, then I assume device doesn't support HW LM feature. But in below code change, many places just return silently, is it an issue?

> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/vdpa/ifc/base/ifcvf.c | 32 ++++++++++++++++++++++++--------
>  1 file changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
> index d10c1fd..b9b061f 100644
> --- a/drivers/vdpa/ifc/base/ifcvf.c
> +++ b/drivers/vdpa/ifc/base/ifcvf.c
> @@ -87,6 +87,8 @@
>  	}
> 
>  	hw->lm_cfg = hw->mem_resource[4].addr;
> +	if (!hw->lm_cfg)
> +		DEBUGOUT("HW mem_resource[4] is NULL, so lm_cfg is
> NULL.\n");

We need to make the debug message more human readable.

> 
>  	if (hw->common_cfg == NULL || hw->notify_base == NULL ||
>  			hw->isr == NULL || hw->dev_cfg == NULL) {
> @@ -218,10 +220,13 @@
>  				&cfg->queue_used_hi);
>  		IFCVF_WRITE_REG16(hw->vring[i].size, &cfg->queue_size);
> 
> -		*(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET +
> -				(i / 2) * IFCVF_LM_CFG_SIZE + (i % 2) * 4) =
> -			(u32)hw->vring[i].last_avail_idx |
> -			((u32)hw->vring[i].last_used_idx << 16);
> +		if (lm_cfg != NULL) {
> +			*(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET +
> +					(i / 2) * IFCVF_LM_CFG_SIZE +
> +					(i % 2) * 4) =
> +				(u32)hw->vring[i].last_avail_idx |
> +				((u32)hw->vring[i].last_used_idx << 16);
> +		}
> 
>  		IFCVF_WRITE_REG16(i + 1, &cfg->queue_msix_vector);
>  		if (IFCVF_READ_REG16(&cfg->queue_msix_vector) ==
> @@ -254,10 +259,14 @@
>  		IFCVF_WRITE_REG16(i, &cfg->queue_select);
>  		IFCVF_WRITE_REG16(0, &cfg->queue_enable);
>  		IFCVF_WRITE_REG16(IFCVF_MSI_NO_VECTOR, &cfg-
> >queue_msix_vector);
> -		ring_state = *(u32 *)(hw->lm_cfg +
> IFCVF_LM_RING_STATE_OFFSET +
> -				(i / 2) * IFCVF_LM_CFG_SIZE + (i % 2) * 4);
> -		hw->vring[i].last_avail_idx = (u16)(ring_state >> 16);
> -		hw->vring[i].last_used_idx = (u16)(ring_state >> 16);
> +		if (hw->lm_cfg != NULL) {
> +			ring_state = *(u32 *)(hw->lm_cfg +
> +					IFCVF_LM_RING_STATE_OFFSET +
> +					(i / 2) * IFCVF_LM_CFG_SIZE +
> +					(i % 2) * 4);
> +			hw->vring[i].last_avail_idx = (u16)(ring_state >> 16);
> +			hw->vring[i].last_used_idx = (u16)(ring_state >> 16);
> +		}
>  	}
>  }
> 
> @@ -292,6 +301,9 @@
> 
>  	lm_cfg = hw->lm_cfg;
> 
> +	if (lm_cfg == NULL)
> +		return;
> +
>  	*(u32 *)(lm_cfg + IFCVF_LM_BASE_ADDR_LOW) =
>  		log_base & IFCVF_32_BIT_MASK;
> 
> @@ -313,6 +325,10 @@
>  	u8 *lm_cfg;
> 
>  	lm_cfg = hw->lm_cfg;
> +
> +	if (lm_cfg == NULL)
> +		return;
> +
>  	*(u32 *)(lm_cfg + IFCVF_LM_LOGGING_CTRL) = IFCVF_LM_DISABLE;
>  }
> 
> --
> 1.8.3.1


      reply	other threads:[~2021-12-13  7:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13  4:29 Andy Pei
2021-12-13  7:09 ` Wang, Xiao W [this message]

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=DM8PR11MB5751081A93C35A8B055C5C26B8749@DM8PR11MB5751.namprd11.prod.outlook.com \
    --to=xiao.w.wang@intel.com \
    --cc=andy.pei@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    /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;
as well as URLs for NNTP newsgroup(s).