diff mbox

[1/2] vmd: allocate irq lists with correct msix count

Message ID 1472491142-13783-1-git-send-email-jonathan.derrick@intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jon Derrick Aug. 29, 2016, 5:19 p.m. UTC
To reduce the amount of memory required for irq lists, only allocate
their space after calling pci_msix_enable_range which may reduce the
number of msix vectors allocated.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 arch/x86/pci/vmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Keith Busch Aug. 29, 2016, 5:52 p.m. UTC | #1
On Mon, Aug 29, 2016 at 11:19:01AM -0600, Jon Derrick wrote:
> To reduce the amount of memory required for irq lists, only allocate
> their space after calling pci_msix_enable_range which may reduce the
> number of msix vectors allocated.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

Looks good. 

Reviewed-by: Keith Busch <keith.busch@intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas Sept. 12, 2016, 10 p.m. UTC | #2
On Mon, Aug 29, 2016 at 11:19:01AM -0600, Jon Derrick wrote:
> To reduce the amount of memory required for irq lists, only allocate
> their space after calling pci_msix_enable_range which may reduce the
> number of msix vectors allocated.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

Applied both patches to pci/host-vmd for v4.9, with Keith's Reviewed-by,
thanks!

> ---
>  arch/x86/pci/vmd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
> index 8d6bb8a..514b446 100644
> --- a/arch/x86/pci/vmd.c
> +++ b/arch/x86/pci/vmd.c
> @@ -679,11 +679,6 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	if (vmd->msix_count < 0)
>  		return -ENODEV;
>  
> -	vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs),
> -				 GFP_KERNEL);
> -	if (!vmd->irqs)
> -		return -ENOMEM;
> -
>  	vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count,
>  					 sizeof(*vmd->msix_entries),
>  					 GFP_KERNEL);
> @@ -697,6 +692,11 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	if (vmd->msix_count < 0)
>  		return vmd->msix_count;
>  
> +	vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs),
> +				 GFP_KERNEL);
> +	if (!vmd->irqs)
> +		return -ENOMEM;
> +
>  	for (i = 0; i < vmd->msix_count; i++) {
>  		INIT_LIST_HEAD(&vmd->irqs[i].irq_list);
>  		vmd->irqs[i].vmd_vector = vmd->msix_entries[i].vector;
> -- 
> 1.8.3.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
index 8d6bb8a..514b446 100644
--- a/arch/x86/pci/vmd.c
+++ b/arch/x86/pci/vmd.c
@@ -679,11 +679,6 @@  static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (vmd->msix_count < 0)
 		return -ENODEV;
 
-	vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs),
-				 GFP_KERNEL);
-	if (!vmd->irqs)
-		return -ENOMEM;
-
 	vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count,
 					 sizeof(*vmd->msix_entries),
 					 GFP_KERNEL);
@@ -697,6 +692,11 @@  static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (vmd->msix_count < 0)
 		return vmd->msix_count;
 
+	vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs),
+				 GFP_KERNEL);
+	if (!vmd->irqs)
+		return -ENOMEM;
+
 	for (i = 0; i < vmd->msix_count; i++) {
 		INIT_LIST_HEAD(&vmd->irqs[i].irq_list);
 		vmd->irqs[i].vmd_vector = vmd->msix_entries[i].vector;