All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V5] acpi: add support for extended IRQ to PCI link
@ 2015-11-24 20:10 Sinan Kaya
  2015-11-25 14:27 ` Sinan Kaya
  0 siblings, 1 reply; 4+ messages in thread
From: Sinan Kaya @ 2015-11-24 20:10 UTC (permalink / raw)
  To: linux-acpi, timur, cov, jcm, helgaas
  Cc: Sinan Kaya, Rafael J. Wysocki, Len Brown, linux-kernel

The ACPI compiler uses the extended format when used interrupt numbers
are greater than 256. The extended IRQ numbers use 32 bits for storing
interrupts. The code already supports parsing extended IRQ type but is
limited by 256 due to used data structure type (u8). This patch changes
the interrupt number type to 32 bits and places an upper limit of 1020
as possible interrupt id. 1020 is the maximum interrupt ID that can be
assigned to an ARM SPI interrupt according to ARM architecture.

Additional checks have been placed to return an error when ACPI_MAX_IRQS
is exceeded.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 drivers/acpi/pci_link.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 7c8408b..8fe4e6f 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -1,6 +1,7 @@
 /*
  *  pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
  *
+ *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
@@ -47,6 +48,14 @@ ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
 #define ACPI_PCI_LINK_MAX_POSSIBLE	16
 
+/*
+ * 1020 is the maximum interrupt ID that can be assigned to
+ * an ARM SPI interrupt according to ARM architecture.
+ */
+#define ACPI_MAX_IRQS		1020
+#define ACPI_MAX_ISA_IRQ	16
+
+
 static int acpi_pci_link_add(struct acpi_device *device,
 			     const struct acpi_device_id *not_used);
 static void acpi_pci_link_remove(struct acpi_device *device);
@@ -67,12 +76,12 @@ static struct acpi_scan_handler pci_link_handler = {
  * later even the link is disable. Instead, we just repick the active irq
  */
 struct acpi_pci_link_irq {
-	u8 active;		/* Current IRQ */
+	u32 active;		/* Current IRQ */
 	u8 triggering;		/* All IRQs */
 	u8 polarity;		/* All IRQs */
 	u8 resource_type;
 	u8 possible_count;
-	u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
+	u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
 	u8 initialized:1;
 	u8 reserved:7;
 };
@@ -147,6 +156,12 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
 					       p->interrupts[i]);
 					continue;
 				}
+				if (p->interrupts[i] > ACPI_MAX_IRQS) {
+					pr_warn("IRQ %d exceeds max (%d)\n",
+						p->interrupts[i],
+						ACPI_MAX_IRQS);
+					continue;
+				}
 				link->irq.possible[i] = p->interrupts[i];
 				link->irq.possible_count++;
 			}
@@ -279,6 +294,11 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
 		result = -ENODEV;
 	}
 
+	if (irq > ACPI_MAX_IRQS) {
+		pr_err("IRQ %d number exceed max IRQ (%d)\n", irq,
+			ACPI_MAX_IRQS);
+		result = -ENODEV;
+	}
 	link->irq.active = irq;
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
@@ -437,9 +457,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
  * enabled system.
  */
 
-#define ACPI_MAX_IRQS		256
-#define ACPI_MAX_ISA_IRQ	16
-
 #define PIRQ_PENALTY_PCI_AVAILABLE	(0)
 #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
 #define PIRQ_PENALTY_PCI_USING		(16*16*16)
-- 
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


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

* Re: [PATCH V5] acpi: add support for extended IRQ to PCI link
  2015-11-24 20:10 [PATCH V5] acpi: add support for extended IRQ to PCI link Sinan Kaya
@ 2015-11-25 14:27 ` Sinan Kaya
  2015-11-25 17:27   ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Sinan Kaya @ 2015-11-25 14:27 UTC (permalink / raw)
  To: linux-acpi, timur, cov, jcm, helgaas
  Cc: Rafael J. Wysocki, Len Brown, linux-kernel

On 11/24/2015 3:10 PM, Sinan Kaya wrote:
> The ACPI compiler uses the extended format when used interrupt numbers
> are greater than 256. The extended IRQ numbers use 32 bits for storing
> interrupts. The code already supports parsing extended IRQ type but is
> limited by 256 due to used data structure type (u8). This patch changes
> the interrupt number type to 32 bits and places an upper limit of 1020
> as possible interrupt id. 1020 is the maximum interrupt ID that can be
> assigned to an ARM SPI interrupt according to ARM architecture.
> 
> Additional checks have been placed to return an error when ACPI_MAX_IRQS
> is exceeded.
> 
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  drivers/acpi/pci_link.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> index 7c8408b..8fe4e6f 100644
> --- a/drivers/acpi/pci_link.c
> +++ b/drivers/acpi/pci_link.c
> @@ -1,6 +1,7 @@
>  /*
>   *  pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
>   *
> + *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
>   *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
>   *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
>   *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
> @@ -47,6 +48,14 @@ ACPI_MODULE_NAME("pci_link");
>  #define ACPI_PCI_LINK_FILE_STATUS	"state"
>  #define ACPI_PCI_LINK_MAX_POSSIBLE	16
>  
> +/*
> + * 1020 is the maximum interrupt ID that can be assigned to
> + * an ARM SPI interrupt according to ARM architecture.
> + */
> +#define ACPI_MAX_IRQS		1020
> +#define ACPI_MAX_ISA_IRQ	16
> +
> +
>  static int acpi_pci_link_add(struct acpi_device *device,
>  			     const struct acpi_device_id *not_used);
>  static void acpi_pci_link_remove(struct acpi_device *device);
> @@ -67,12 +76,12 @@ static struct acpi_scan_handler pci_link_handler = {
>   * later even the link is disable. Instead, we just repick the active irq
>   */
>  struct acpi_pci_link_irq {
> -	u8 active;		/* Current IRQ */
> +	u32 active;		/* Current IRQ */
>  	u8 triggering;		/* All IRQs */
>  	u8 polarity;		/* All IRQs */
>  	u8 resource_type;
>  	u8 possible_count;
> -	u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
> +	u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
>  	u8 initialized:1;
>  	u8 reserved:7;
>  };
> @@ -147,6 +156,12 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
>  					       p->interrupts[i]);
>  					continue;
>  				}
> +				if (p->interrupts[i] > ACPI_MAX_IRQS) {

this should have been >=
> +					pr_warn("IRQ %d exceeds max (%d)\n",
> +						p->interrupts[i],
> +						ACPI_MAX_IRQS);
> +					continue;
> +				}
>  				link->irq.possible[i] = p->interrupts[i];
>  				link->irq.possible_count++;
>  			}
> @@ -279,6 +294,11 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
>  		result = -ENODEV;
>  	}
>  

this should have been >=

> +	if (irq > ACPI_MAX_IRQS) {
> +		pr_err("IRQ %d number exceed max IRQ (%d)\n", irq,
> +			ACPI_MAX_IRQS);
> +		result = -ENODEV;
> +	}
>  	link->irq.active = irq;
>  
>  	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
> @@ -437,9 +457,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
>   * enabled system.
>   */
>  
> -#define ACPI_MAX_IRQS		256
> -#define ACPI_MAX_ISA_IRQ	16
> -
>  #define PIRQ_PENALTY_PCI_AVAILABLE	(0)
>  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
>  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
> 

Bjorn,
Does this look like what you were thinking?
Sinan


-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

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

* Re: [PATCH V5] acpi: add support for extended IRQ to PCI link
  2015-11-25 14:27 ` Sinan Kaya
@ 2015-11-25 17:27   ` Bjorn Helgaas
  2015-11-25 18:28     ` Sinan Kaya
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2015-11-25 17:27 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: linux-acpi, timur, cov, jcm, Rafael J. Wysocki, Len Brown, linux-kernel

Hi Sinan,

On Wed, Nov 25, 2015 at 09:27:41AM -0500, Sinan Kaya wrote:
> On 11/24/2015 3:10 PM, Sinan Kaya wrote:
> > The ACPI compiler uses the extended format when used interrupt numbers
> > are greater than 256. The extended IRQ numbers use 32 bits for storing
> > interrupts. The code already supports parsing extended IRQ type but is
> > limited by 256 due to used data structure type (u8). This patch changes
> > the interrupt number type to 32 bits and places an upper limit of 1020
> > as possible interrupt id. 1020 is the maximum interrupt ID that can be
> > assigned to an ARM SPI interrupt according to ARM architecture.
> > 
> > Additional checks have been placed to return an error when ACPI_MAX_IRQS
> > is exceeded.
> > 
> > Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> > ---
> >  drivers/acpi/pci_link.c | 27 ++++++++++++++++++++++-----
> >  1 file changed, 22 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
> > index 7c8408b..8fe4e6f 100644
> > --- a/drivers/acpi/pci_link.c
> > +++ b/drivers/acpi/pci_link.c
> > @@ -1,6 +1,7 @@
> >  /*
> >   *  pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
> >   *
> > + *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
> >   *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
> >   *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> >   *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
> > @@ -47,6 +48,14 @@ ACPI_MODULE_NAME("pci_link");
> >  #define ACPI_PCI_LINK_FILE_STATUS	"state"
> >  #define ACPI_PCI_LINK_MAX_POSSIBLE	16
> >  
> > +/*
> > + * 1020 is the maximum interrupt ID that can be assigned to
> > + * an ARM SPI interrupt according to ARM architecture.
> > + */
> > +#define ACPI_MAX_IRQS		1020
> > +#define ACPI_MAX_ISA_IRQ	16
> > +
> > +
> >  static int acpi_pci_link_add(struct acpi_device *device,
> >  			     const struct acpi_device_id *not_used);
> >  static void acpi_pci_link_remove(struct acpi_device *device);
> > @@ -67,12 +76,12 @@ static struct acpi_scan_handler pci_link_handler = {
> >   * later even the link is disable. Instead, we just repick the active irq
> >   */
> >  struct acpi_pci_link_irq {
> > -	u8 active;		/* Current IRQ */
> > +	u32 active;		/* Current IRQ */
> >  	u8 triggering;		/* All IRQs */
> >  	u8 polarity;		/* All IRQs */
> >  	u8 resource_type;
> >  	u8 possible_count;
> > -	u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
> > +	u32 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
> >  	u8 initialized:1;
> >  	u8 reserved:7;
> >  };
> > @@ -147,6 +156,12 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
> >  					       p->interrupts[i]);
> >  					continue;
> >  				}
> > +				if (p->interrupts[i] > ACPI_MAX_IRQS) {
> 
> this should have been >=
> > +					pr_warn("IRQ %d exceeds max (%d)\n",
> > +						p->interrupts[i],
> > +						ACPI_MAX_IRQS);
> > +					continue;
> > +				}
> >  				link->irq.possible[i] = p->interrupts[i];
> >  				link->irq.possible_count++;
> >  			}
> > @@ -279,6 +294,11 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
> >  		result = -ENODEV;
> >  	}
> >  
> 
> this should have been >=
> 
> > +	if (irq > ACPI_MAX_IRQS) {
> > +		pr_err("IRQ %d number exceed max IRQ (%d)\n", irq,
> > +			ACPI_MAX_IRQS);
> > +		result = -ENODEV;
> > +	}
> >  	link->irq.active = irq;
> >  
> >  	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
> > @@ -437,9 +457,6 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
> >   * enabled system.
> >   */
> >  
> > -#define ACPI_MAX_IRQS		256
> > -#define ACPI_MAX_ISA_IRQ	16
> > -
> >  #define PIRQ_PENALTY_PCI_AVAILABLE	(0)
> >  #define PIRQ_PENALTY_PCI_POSSIBLE	(16*16)
> >  #define PIRQ_PENALTY_PCI_USING		(16*16*16)
> > 
> 
> Bjorn,
> Does this look like what you were thinking?

Yes, exactly.  I think it's much nicer if we can avoid putting invalid
data into the list in the first place.

Maybe reword the diagnostic to make it clear that we're ignoring this
IRQ information.  It'd really be nice if the message had a clue about
what it applies to, i.e., the ACPI device path or something, but I
don't know how hard that is, and none of the other messages from that
driver include that information either.

Bjorn

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

* Re: [PATCH V5] acpi: add support for extended IRQ to PCI link
  2015-11-25 17:27   ` Bjorn Helgaas
@ 2015-11-25 18:28     ` Sinan Kaya
  0 siblings, 0 replies; 4+ messages in thread
From: Sinan Kaya @ 2015-11-25 18:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-acpi, timur, cov, jcm, Rafael J. Wysocki, Len Brown, linux-kernel

On 11/25/2015 12:27 PM, Bjorn Helgaas wrote:
> Maybe reword the diagnostic to make it clear that we're ignoring this
> IRQ information.  It'd really be nice if the message had a clue about
> what it applies to, i.e., the ACPI device path or something,

Are we OK with print strings exceeding 80 characters to include detailed
information? Chris Covington pointed out to me that there are exceptions
to 80 characters when it comes to print format strings.

"The limit on the length of lines is 80 columns and this is a strongly
preferred limit. ... However, never break user-visible strings such as
printk messages, because that breaks the ability to grep for them."


-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

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

end of thread, other threads:[~2015-11-25 18:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 20:10 [PATCH V5] acpi: add support for extended IRQ to PCI link Sinan Kaya
2015-11-25 14:27 ` Sinan Kaya
2015-11-25 17:27   ` Bjorn Helgaas
2015-11-25 18:28     ` Sinan Kaya

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.