Re: [PATCH 2/2] PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 23, 2019 at 01:02:12PM -0800, Maya Nakamura wrote:
> @@ -908,12 +906,12 @@ static void hv_irq_unmask(struct irq_data *data)
>  	struct retarget_msi_interrupt *params;
>  	struct hv_pcibus_device *hbus;
>  	struct cpumask *dest;
> +	cpumask_var_t tmp;
>  	struct pci_bus *pbus;
>  	struct pci_dev *pdev;
>  	unsigned long flags;
>  	u32 var_size = 0;
> -	int cpu_vmbus;
> -	int cpu;
> +	int cpu, nr_bank = 0;
                        ^^^^^
No need to initialize this to a bogus value.  It's misleading and it
turns off GCC's uninitialized variable warning so it can lead to bugs.

>  	u64 res;
>  
>  	dest = irq_data_get_effective_affinity_mask(data);
> @@ -953,29 +951,28 @@ static void hv_irq_unmask(struct irq_data *data)
>  		 */
>  		params->int_target.flags |=
>  			HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
> -		params->int_target.vp_set.valid_bank_mask =
> -			(1ull << HV_VP_SET_BANK_COUNT_MAX) - 1;
> +
> +		if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) {
> +			dev_err(&hbus->hdev->device, "out of memory");


No need for this error message.  alloc_cpumask_var() already has better
debug messages built in.

> +			return;

We can't return directly.  We need to unlock first.

> +		}
> +
> +		cpumask_and(tmp, dest, cpu_online_mask);
> +		nr_bank = cpumask_to_vpset(&params->int_target.vp_set, tmp);
> +		free_cpumask_var(tmp);
> +
> +		if (!nr_bank) {
> +			dev_err(&hbus->hdev->device, "too high CPU");

This error message is not useful.

> +			res = 1;
> +			goto exit_unlock;
> +		}

regards,
dan carpenter




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux