Skip to contentSkip to conversation

resource: Prevent irqresource_disabled() from erasing flags

PATCH In review Angela Czubak 4 participants 5 messages Mar 29, 2021 – Apr 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resource: Prevent irqresource_disabled() from erasing flags

Do not overwrite flags as it leads to erasing triggering and polarity information which might be useful in case of hard-coded interrupts. This way the information can be read later on even though mapping to APIC domain failed.

---
Some Chromebooks use hard-coded interrupts in their ACPI tables. This is an excerpt as dumped on Relm:

...
            Name (_HID, "ELAN0001")  // _HID: Hardware ID
            Name (_DDN, "Elan Touchscreen ")  // _DDN: DOS Device Name Name (_UID, 0x05)  // _UID: Unique ID
            Name (ISTP, Zero)
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings {
                Name (BUF0, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2C1",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive, ,, ) {
                        0x000000B8,
                    }
                })
                Return (BUF0) /* \_SB_.I2C1.ETSA._CRS.BUF0 */
            }
...

This interrupt is hard-coded to 0xB8 = 184 which is too high to be mapped to IO-APIC, so no triggering information is propagated as acpi_register_gsi() fails and irqresource_disabled() is issued, which leads to erasing triggering and polarity information.
If that function added its flags instead of overwriting them the correct IRQ type would be set even for the hard-coded interrupts, which allows device driver to retrieve it.
Please, let me know if this kind of modification is acceptable. Best Regards,
Angela

 include/linux/ioport.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ioport.h +1 -1
index 55de385c839cf..647744d8514e0 100644
@@ -331,7 +331,7 @@ static inline void irqresource_disabled(struct resource *res, u32 irq)
 {
 	res->start = irq;
 	res->end = irq;
-	res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
+	res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
 }
 
 extern struct address_space *iomem_get_mapping(void);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 32 lines · Angela Czubak

Do not overwrite flags as it leads to erasing triggering and polarity information which might be useful in case of hard-coded interrupts. This way the information can be read later on even though mapping to APIC domain failed.

---
Some Chromebooks use hard-coded interrupts in their ACPI tables. This is an excerpt as dumped on Relm:

...
            Name (_HID, "ELAN0001")  // _HID: Hardware ID
            Name (_DDN, "Elan Touchscreen ")  // _DDN: DOS Device Name Name (_UID, 0x05)  // _UID: Unique ID
            Name (ISTP, Zero)
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings {
                Name (BUF0, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2C1",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive, ,, ) {
                        0x000000B8,
                    }
                })
                Return (BUF0) /* \_SB_.I2C1.ETSA._CRS.BUF0 */
            }
...

Quoted 8 lines

This interrupt is hard-coded to 0xB8 = 184 which is too high to be mapped to IO-APIC, so no triggering information is propagated as acpi_register_gsi() fails and irqresource_disabled() is issued, which leads to erasing triggering and polarity information.
If that function added its flags instead of overwriting them the correct IRQ type would be set even for the hard-coded interrupts, which allows device driver to retrieve it.
Please, let me know if this kind of modification is acceptable.

From the quick look it should not be problematic, but it needs to be checked more carefully.

Mika, what do you think?

Quoted 16 lines
  include/linux/ioport.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ioport.h +1 -1
index 55de385c839cf..647744d8514e0 100644
@@ -331,7 +331,7 @@ static inline void irqresource_disabled(struct resource *res, u32 irq)
  {
  	res->start = irq;
  	res->end = irq;
-	res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
+	res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
  }
 
  extern struct address_space *iomem_get_mapping(void);
#2 lore raw

Hi,

Quoted 42 lines · Rafael J. Wysocki
Quoted 32 lines · Angela Czubak

Do not overwrite flags as it leads to erasing triggering and polarity information which might be useful in case of hard-coded interrupts. This way the information can be read later on even though mapping to APIC domain failed.

---
Some Chromebooks use hard-coded interrupts in their ACPI tables. This is an excerpt as dumped on Relm:

...
            Name (_HID, "ELAN0001")  // _HID: Hardware ID
            Name (_DDN, "Elan Touchscreen ")  // _DDN: DOS Device Name Name (_UID, 0x05)  // _UID: Unique ID
            Name (ISTP, Zero)
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings {
                Name (BUF0, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2C1",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                    Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive, ,, ) {
                        0x000000B8,
                    }
                })
                Return (BUF0) /* \_SB_.I2C1.ETSA._CRS.BUF0 */
            }
...

Quoted 8 lines

This interrupt is hard-coded to 0xB8 = 184 which is too high to be mapped to IO-APIC, so no triggering information is propagated as acpi_register_gsi() fails and irqresource_disabled() is issued, which leads to erasing triggering and polarity information.
If that function added its flags instead of overwriting them the correct IRQ type would be set even for the hard-coded interrupts, which allows device driver to retrieve it.
Please, let me know if this kind of modification is acceptable.

Quoted 4 lines

From the quick look it should not be problematic, but it needs to be checked more carefully.

Mika, what do you think?

I think it makes sense. We still set IORESOURCE_DISABLED unconditionally so this should not cause issues. In theory at least :)

Quoted 16 lines
Quoted 15 lines
  include/linux/ioport.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ioport.h +1 -1
index 55de385c839cf..647744d8514e0 100644
@@ -331,7 +331,7 @@ static inline void irqresource_disabled(struct resource *res, u32 irq)
  {
  	res->start = irq;
  	res->end = irq;
-	res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
+	res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
  }
  extern struct address_space *iomem_get_mapping(void);
#3 lore raw
Quoted 46 lines · Mika Westerberg

Hi,

Quoted 42 lines · Rafael J. Wysocki
Quoted 40 lines · Angela Czubak

Do not overwrite flags as it leads to erasing triggering and polarity information which might be useful in case of hard-coded interrupts. This way the information can be read later on even though mapping to APIC domain failed.

---
Some Chromebooks use hard-coded interrupts in their ACPI tables. This is an excerpt as dumped on Relm:

...

             Name (_HID, "ELAN0001")  // _HID: Hardware ID
             Name (_DDN, "Elan Touchscreen ")  // _DDN: DOS Device Name
             Name (_UID, 0x05)  // _UID: Unique ID
             Name (ISTP, Zero)
             Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
             {
                 Name (BUF0, ResourceTemplate ()
                 {
                     I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80,
                         AddressingMode7Bit, "\\_SB.I2C1",
                         0x00, ResourceConsumer, , Exclusive,
                         )
                     Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive, ,, )
                     {
                         0x000000B8,
                     }
                 })
                 Return (BUF0) /* \_SB_.I2C1.ETSA._CRS.BUF0 */
             }

...

This interrupt is hard-coded to 0xB8 = 184 which is too high to be mapped to IO-APIC, so no triggering information is propagated as acpi_register_gsi() fails and irqresource_disabled() is issued, which leads to erasing triggering and polarity information.
If that function added its flags instead of overwriting them the correct IRQ type would be set even for the hard-coded interrupts, which allows device driver to retrieve it.
Please, let me know if this kind of modification is acceptable.

Quoted 8 lines
Quoted 4 lines

From the quick look it should not be problematic, but it needs to be checked more carefully.

Mika, what do you think?

I think it makes sense. We still set IORESOURCE_DISABLED unconditionally so this should not cause issues. In theory at least :)

Is there anything else you would need me to do regarding the patch? I suppose there are more platforms that could benefit from not erasing the flags, so if this patch is fit for upstream, can we continue the process?

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
  include/linux/ioport.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ioport.h +1 -1
index 55de385c839cf..647744d8514e0 100644
@@ -331,7 +331,7 @@ static inline void irqresource_disabled(struct resource *res, u32 irq)
  {
    res->start = irq;
    res->end = irq;
-   res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
+   res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
  }
  extern struct address_space *iomem_get_mapping(void);
#4 lore raw
Quoted 52 lines · Angela Czubak
Quoted 49 lines · Mika Westerberg

Hi,

Quoted 45 lines · Rafael J. Wysocki
Quoted 32 lines · Angela Czubak

Do not overwrite flags as it leads to erasing triggering and polarity information which might be useful in case of hard-coded interrupts. This way the information can be read later on even though mapping to APIC domain failed.

---
Some Chromebooks use hard-coded interrupts in their ACPI tables. This is an excerpt as dumped on Relm:

...

             Name (_HID, "ELAN0001")  // _HID: Hardware ID
             Name (_DDN, "Elan Touchscreen ")  // _DDN: DOS Device Name
             Name (_UID, 0x05)  // _UID: Unique ID
             Name (ISTP, Zero)
             Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
             {
                 Name (BUF0, ResourceTemplate ()
                 {
                     I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80,
                         AddressingMode7Bit, "\\_SB.I2C1",
                         0x00, ResourceConsumer, , Exclusive,
                         )
                     Interrupt (ResourceConsumer, Edge, ActiveLow, Exclusive, ,, )
                     {
                         0x000000B8,
                     }
                 })
                 Return (BUF0) /* \_SB_.I2C1.ETSA._CRS.BUF0 */
             }

...

Quoted 8 lines

This interrupt is hard-coded to 0xB8 = 184 which is too high to be mapped to IO-APIC, so no triggering information is propagated as acpi_register_gsi() fails and irqresource_disabled() is issued, which leads to erasing triggering and polarity information.
If that function added its flags instead of overwriting them the correct IRQ type would be set even for the hard-coded interrupts, which allows device driver to retrieve it.
Please, let me know if this kind of modification is acceptable.

From the quick look it should not be problematic, but it needs to be checked more carefully.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Mika, what do you think?

I think it makes sense. We still set IORESOURCE_DISABLED unconditionally so this should not cause issues. In theory at least :)

Is there anything else you would need me to do regarding the patch?

Yes, please resend it with a CC to [email protected] for more visibility.

Quoted 20 lines

I suppose there are more platforms that could benefit from not erasing the flags, so if this patch is fit for upstream, can we continue the process?

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
  include/linux/ioport.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ioport.h +1 -1
index 55de385c839cf..647744d8514e0 100644
@@ -331,7 +331,7 @@ static inline void irqresource_disabled(struct resource *res, u32 irq)
  {
    res->start = irq;
    res->end = irq;
-   res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
+   res->flags |= IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
  }
  extern struct address_space *iomem_get_mapping(void);