All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] vmd: allocate irq lists with correct msix count
@ 2016-08-29 17:19 Jon Derrick
  2016-08-29 17:19 ` [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api Jon Derrick
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jon Derrick @ 2016-08-29 17:19 UTC (permalink / raw)
  To: helgaas; +Cc: Jon Derrick, keith.busch, linux-pci

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(-)

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api
  2016-08-29 17:19 [PATCH 1/2] vmd: allocate irq lists with correct msix count Jon Derrick
@ 2016-08-29 17:19 ` Jon Derrick
  2016-08-29 17:55   ` Keith Busch
  2016-08-29 17:52 ` [PATCH 1/2] vmd: allocate irq lists with correct msix count Keith Busch
  2016-09-12 22:00 ` Bjorn Helgaas
  2 siblings, 1 reply; 5+ messages in thread
From: Jon Derrick @ 2016-08-29 17:19 UTC (permalink / raw)
  To: helgaas; +Cc: Jon Derrick, keith.busch, linux-pci

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

diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
index 514b446..4c0eac7 100644
--- a/arch/x86/pci/vmd.c
+++ b/arch/x86/pci/vmd.c
@@ -78,7 +78,6 @@ struct vmd_dev {
 	char __iomem		*cfgbar;
 
 	int msix_count;
-	struct msix_entry	*msix_entries;
 	struct vmd_irq_list	*irqs;
 
 	struct pci_sysdata	sysdata;
@@ -679,16 +678,8 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (vmd->msix_count < 0)
 		return -ENODEV;
 
-	vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count,
-					 sizeof(*vmd->msix_entries),
-					 GFP_KERNEL);
-	if (!vmd->msix_entries)
-		return -ENOMEM;
-	for (i = 0; i < vmd->msix_count; i++)
-		vmd->msix_entries[i].entry = i;
-
-	vmd->msix_count = pci_enable_msix_range(vmd->dev, vmd->msix_entries, 1,
-						vmd->msix_count);
+	vmd->msix_count = pci_alloc_irq_vectors(dev, 1, vmd->msix_count,
+					PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
 	if (vmd->msix_count < 0)
 		return vmd->msix_count;
 
@@ -699,7 +690,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	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;
+		vmd->irqs[i].vmd_vector = pci_irq_vector(dev, i);
 		vmd->irqs[i].index = i;
 
 		err = devm_request_irq(&dev->dev, vmd->irqs[i].vmd_vector,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] vmd: allocate irq lists with correct msix count
  2016-08-29 17:19 [PATCH 1/2] vmd: allocate irq lists with correct msix count Jon Derrick
  2016-08-29 17:19 ` [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api Jon Derrick
@ 2016-08-29 17:52 ` Keith Busch
  2016-09-12 22:00 ` Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2016-08-29 17:52 UTC (permalink / raw)
  To: Jon Derrick; +Cc: helgaas, linux-pci

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api
  2016-08-29 17:19 ` [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api Jon Derrick
@ 2016-08-29 17:55   ` Keith Busch
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2016-08-29 17:55 UTC (permalink / raw)
  To: Jon Derrick; +Cc: helgaas, linux-pci

On Mon, Aug 29, 2016 at 11:19:02AM -0600, Jon Derrick wrote:
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

Nice simplification, looks good.

Reviewed-by: Keith Busch <keith.busch@intel.com>



> diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c
> index 514b446..4c0eac7 100644
> --- a/arch/x86/pci/vmd.c
> +++ b/arch/x86/pci/vmd.c
> @@ -78,7 +78,6 @@ struct vmd_dev {
>  	char __iomem		*cfgbar;
>  
>  	int msix_count;
> -	struct msix_entry	*msix_entries;
>  	struct vmd_irq_list	*irqs;
>  
>  	struct pci_sysdata	sysdata;
> @@ -679,16 +678,8 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	if (vmd->msix_count < 0)
>  		return -ENODEV;
>  
> -	vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count,
> -					 sizeof(*vmd->msix_entries),
> -					 GFP_KERNEL);
> -	if (!vmd->msix_entries)
> -		return -ENOMEM;
> -	for (i = 0; i < vmd->msix_count; i++)
> -		vmd->msix_entries[i].entry = i;
> -
> -	vmd->msix_count = pci_enable_msix_range(vmd->dev, vmd->msix_entries, 1,
> -						vmd->msix_count);
> +	vmd->msix_count = pci_alloc_irq_vectors(dev, 1, vmd->msix_count,
> +					PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
>  	if (vmd->msix_count < 0)
>  		return vmd->msix_count;
>  
> @@ -699,7 +690,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  
>  	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;
> +		vmd->irqs[i].vmd_vector = pci_irq_vector(dev, i);
>  		vmd->irqs[i].index = i;
>  
>  		err = devm_request_irq(&dev->dev, vmd->irqs[i].vmd_vector,
> -- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] vmd: allocate irq lists with correct msix count
  2016-08-29 17:19 [PATCH 1/2] vmd: allocate irq lists with correct msix count Jon Derrick
  2016-08-29 17:19 ` [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api Jon Derrick
  2016-08-29 17:52 ` [PATCH 1/2] vmd: allocate irq lists with correct msix count Keith Busch
@ 2016-09-12 22:00 ` Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-09-12 22:00 UTC (permalink / raw)
  To: Jon Derrick; +Cc: keith.busch, linux-pci

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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-12 22:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-29 17:19 [PATCH 1/2] vmd: allocate irq lists with correct msix count Jon Derrick
2016-08-29 17:19 ` [PATCH 2/2] vmd: convert to use pci_alloc_irq_vectors api Jon Derrick
2016-08-29 17:55   ` Keith Busch
2016-08-29 17:52 ` [PATCH 1/2] vmd: allocate irq lists with correct msix count Keith Busch
2016-09-12 22:00 ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.