diff mbox series

[V2,3/4] vhost_vdpa: don't setup irq offloading when irq_num < 0

Message ID 20220125091744.115996-4-lingshan.zhu@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series vDPA/ifcvf: implement shared IRQ feature | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Zhu, Lingshan Jan. 25, 2022, 9:17 a.m. UTC
When irq number is negative(e.g., -EINVAL), the virtqueue
may be disabled or the virtqueues are sharing a device irq.
In such case, we should not setup irq offloading for a virtqueue.

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
---
 drivers/vhost/vdpa.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

kernel test robot Jan. 25, 2022, 7:17 p.m. UTC | #1
Hi Zhu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on horms-ipvs/master linus/master v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Zhu-Lingshan/vDPA-ifcvf-implement-shared-IRQ-feature/20220125-174020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: arm-randconfig-c002-20220124 (https://download.01.org/0day-ci/archive/20220126/202201260245.1yTB6YwE-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/9242eae873643db8562d24857da7d05a2950ecfe
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zhu-Lingshan/vDPA-ifcvf-implement-shared-IRQ-feature/20220125-174020
        git checkout 9242eae873643db8562d24857da7d05a2950ecfe
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/vhost/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/vhost/vdpa.c:99:6: warning: variable 'irq' is uninitialized when used here [-Wuninitialized]
           if (irq < 0)
               ^~~
   drivers/vhost/vdpa.c:94:14: note: initialize the variable 'irq' to silence this warning
           int ret, irq;
                       ^
                        = 0
   1 warning generated.


vim +/irq +99 drivers/vhost/vdpa.c

    88	
    89	static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
    90	{
    91		struct vhost_virtqueue *vq = &v->vqs[qid];
    92		const struct vdpa_config_ops *ops = v->vdpa->config;
    93		struct vdpa_device *vdpa = v->vdpa;
    94		int ret, irq;
    95	
    96		if (!ops->get_vq_irq)
    97			return;
    98	
  > 99		if (irq < 0)
   100			return;
   101	
   102		irq = ops->get_vq_irq(vdpa, qid);
   103		irq_bypass_unregister_producer(&vq->call_ctx.producer);
   104		if (!vq->call_ctx.ctx || irq < 0)
   105			return;
   106	
   107		vq->call_ctx.producer.token = vq->call_ctx.ctx;
   108		vq->call_ctx.producer.irq = irq;
   109		ret = irq_bypass_register_producer(&vq->call_ctx.producer);
   110		if (unlikely(ret))
   111			dev_info(&v->dev, "vq %u, irq bypass producer (token %p) registration fails, ret =  %d\n",
   112				 qid, vq->call_ctx.producer.token, ret);
   113	}
   114	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Michael S. Tsirkin Jan. 25, 2022, 7:30 p.m. UTC | #2
On Tue, Jan 25, 2022 at 05:17:43PM +0800, Zhu Lingshan wrote:
> When irq number is negative(e.g., -EINVAL), the virtqueue
> may be disabled or the virtqueues are sharing a device irq.
> In such case, we should not setup irq offloading for a virtqueue.
> 
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> ---
>  drivers/vhost/vdpa.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 851539807bc9..909891d518e8 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -96,6 +96,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
>  	if (!ops->get_vq_irq)
>  		return;
>  
> +	if (irq < 0)
> +		return;
> +
>  	irq = ops->get_vq_irq(vdpa, qid);

So it's used before it's initialized. Ugh.
How was this patchset tested?

>  	irq_bypass_unregister_producer(&vq->call_ctx.producer);
>  	if (!vq->call_ctx.ctx || irq < 0)
> -- 
> 2.27.0
Zhu, Lingshan Jan. 26, 2022, 12:18 p.m. UTC | #3
On 1/26/2022 3:30 AM, Michael S. Tsirkin wrote:
> On Tue, Jan 25, 2022 at 05:17:43PM +0800, Zhu Lingshan wrote:
>> When irq number is negative(e.g., -EINVAL), the virtqueue
>> may be disabled or the virtqueues are sharing a device irq.
>> In such case, we should not setup irq offloading for a virtqueue.
>>
>> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
>> ---
>>   drivers/vhost/vdpa.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>> index 851539807bc9..909891d518e8 100644
>> --- a/drivers/vhost/vdpa.c
>> +++ b/drivers/vhost/vdpa.c
>> @@ -96,6 +96,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
>>   	if (!ops->get_vq_irq)
>>   		return;
>>   
>> +	if (irq < 0)
>> +		return;
>> +
>>   	irq = ops->get_vq_irq(vdpa, qid);
> So it's used before it's initialized. Ugh.
> How was this patchset tested?
Sorry, my bad, it is not rebased properly, V3 can fix this for sure.

Thanks
>
>>   	irq_bypass_unregister_producer(&vq->call_ctx.producer);
>>   	if (!vq->call_ctx.ctx || irq < 0)
>> -- 
>> 2.27.0
diff mbox series

Patch

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 851539807bc9..909891d518e8 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -96,6 +96,9 @@  static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
 	if (!ops->get_vq_irq)
 		return;
 
+	if (irq < 0)
+		return;
+
 	irq = ops->get_vq_irq(vdpa, qid);
 	irq_bypass_unregister_producer(&vq->call_ctx.producer);
 	if (!vq->call_ctx.ctx || irq < 0)