Skip to contentSkip to conversation

Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag

PATCH Superseded Masahiro Honda 3 participants 4 messages May 2, 2023 – May 8, 2023

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag

The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt line to indicate the completion of a conversion. However, some devices cannot properly detect the completion of a conversion by an interrupt. This is for the reason mentioned in the following commit.

commit e9849777d0e2 ("genirq: Add flag to force mask in

                      disable_irq[_nosync]()")

A read operation is performed by an extra interrupt before the completion of a conversion. This patch fixes the issue by setting IRQ_DISABLE_UNLAZY flag.

---
v4:
- Remove the callback.
v3: https://lore.kernel.org/linux-iio/[email protected]/
- Remove the Kconfig option.
v2: https://lore.kernel.org/linux-iio/[email protected]/
- Rework commit message.
- Add a new entry in the Kconfig.
- Call irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the IRQ.
v1: https://lore.kernel.org/linux-iio/[email protected]/

 drivers/iio/adc/ad_sigma_delta.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/iio/adc/ad_sigma_delta.c +4 -0
index d8570f6207..7e21928707 100644
@@ -584,6 +584,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_de
 	init_completion(&sigma_delta->completion);
 
 	sigma_delta->irq_dis = true;
+
+	/* the IRQ core clears IRQ_DISABLE_UNLAZY flag when freeing an IRQ */
+	irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY);
+
 	ret = devm_request_irq(dev, sigma_delta->spi->irq,
 			       ad_sd_data_rdy_trig_poll,
 			       sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
Signature · 1 line
2.34.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 8 lines · Masahiro Honda

The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt line to indicate the completion of a conversion. However, some devices cannot properly detect the completion of a conversion by an interrupt. This is for the reason mentioned in the following commit.

commit e9849777d0e2 ("genirq: Add flag to force mask in disable_irq[_nosync]()")

Quoted 6 lines

A read operation is performed by an extra interrupt before the completion of a conversion. This patch fixes the issue by setting IRQ_DISABLE_UNLAZY flag.

---

Quoted 33 lines

v4:
 - Remove the callback.
v3:
https://lore.kernel.org/linux-iio/[email protected]/
 - Remove the Kconfig option.
v2:
https://lore.kernel.org/linux-iio/[email protected]/
 - Rework commit message.
 - Add a new entry in the Kconfig.
 - Call irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the IRQ. v1:
https://lore.kernel.org/linux-iio/[email protected]/

 drivers/iio/adc/ad_sigma_delta.c | 4 ++++

 1 file changed, 4 insertions(+)
drivers/iio/adc/ad_sigma_delta.c +0 -0
index d8570f6207..7e21928707 100644
@@ -584,6 +584,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev,

struct iio_dev *indio_de init_completion(&sigma_delta->completion);
        sigma_delta->irq_dis = true;

drivers/iio/adc/ad_sigma_delta.c +4 -0
+
+       /* the IRQ core clears IRQ_DISABLE_UNLAZY flag when freeing an IRQ */
+       irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY);
+

        ret = devm_request_irq(dev, sigma_delta->spi->irq, ad_sd_data_rdy_trig_poll, sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,

maintainer
#2 lore raw

On Wed, 03 May 2023 10:09:28 +0200
Nuno Sá <[email protected]> wrote:

Patch title should be something like the following so it's easy to see what is affected when looking at a long list of patches.

iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag.

Quoted 9 lines · Masahiro Honda
Quoted 8 lines

The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt line to indicate the completion of a conversion. However, some devices cannot properly detect the completion of a conversion by an interrupt. This is for the reason mentioned in the following commit.

commit e9849777d0e2 ("genirq: Add flag to force mask in disable_irq[_nosync]()")

Quoted 8 lines
Quoted 6 lines

A read operation is performed by an extra interrupt before the completion of a conversion. This patch fixes the issue by setting IRQ_DISABLE_UNLAZY flag.

---

Fixes tag? We'll want to know how far to backport this. I assume it's limited by the above commit as these drivers are older than that.

I'm also not totally sure what this 'looks like' for a user. What happens? Fail to read, wrong value, lock up or something else? It would be helpful to include that information in case anyone else runs into this.

Actual change looks right to me.

Thanks,

Jonathan

Quoted 35 lines
Quoted 34 lines

v4:
 - Remove the callback.
v3:
https://lore.kernel.org/linux-iio/[email protected]/
 - Remove the Kconfig option.
v2:
https://lore.kernel.org/linux-iio/[email protected]/
 - Rework commit message.
 - Add a new entry in the Kconfig.
 - Call irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the IRQ. v1:
https://lore.kernel.org/linux-iio/[email protected]/

 drivers/iio/adc/ad_sigma_delta.c | 4 ++++

 1 file changed, 4 insertions(+)
drivers/iio/adc/ad_sigma_delta.c +0 -0
index d8570f6207..7e21928707 100644
@@ -584,6 +584,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev,

struct iio_dev *indio_de init_completion(&sigma_delta->completion);
        sigma_delta->irq_dis = true;

drivers/iio/adc/ad_sigma_delta.c +4 -0
+
+       /* the IRQ core clears IRQ_DISABLE_UNLAZY flag when freeing an IRQ */
+       irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY);
+

        ret = devm_request_irq(dev, sigma_delta->spi->irq, ad_sd_data_rdy_trig_poll, sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,

#3 lore raw

Hi Jonathan,

Thank you for your advice.

Quoted 9 lines · Jonathan Cameron

On Wed, 03 May 2023 10:09:28 +0200
Nuno Sá <[email protected]> wrote:

Patch title should be something like the following so it's easy to see what is affected when looking at a long list of patches.

iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag.

I'll fix the title.

Quoted 14 lines
Quoted 14 lines · Masahiro Honda
Quoted 12 lines

The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt line to indicate the completion of a conversion. However, some devices cannot properly detect the completion of a conversion by an interrupt. This is for the reason mentioned in the following commit.

commit e9849777d0e2 ("genirq: Add flag to force mask in

                      disable_irq[_nosync]()")

A read operation is performed by an extra interrupt before the completion of a conversion. This patch fixes the issue by setting IRQ_DISABLE_UNLAZY flag.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

---

Fixes tag? We'll want to know how far to backport this. I assume it's limited by the above commit as these drivers are older than that.

I'll try to add a fixes tag.

Quoted 4 lines

I'm also not totally sure what this 'looks like' for a user. What happens? Fail to read, wrong value, lock up or something else? It would be helpful to include that information in case anyone else runs into this.

I'll add information to the commit message.

Regards,

Masahiro

Quoted 43 lines

Actual change looks right to me.

Thanks,

Jonathan

Quoted 35 lines
Quoted 34 lines

v4:
- Remove the callback.
v3:
https://lore.kernel.org/linux-iio/[email protected]/
- Remove the Kconfig option.
v2:
https://lore.kernel.org/linux-iio/[email protected]/
- Rework commit message.
- Add a new entry in the Kconfig.
- Call irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the IRQ.
v1:
https://lore.kernel.org/linux-iio/[email protected]/

 drivers/iio/adc/ad_sigma_delta.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/iio/adc/ad_sigma_delta.c +0 -0
index d8570f6207..7e21928707 100644
@@ -584,6 +584,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev,

struct iio_dev *indio_de

        init_completion(&sigma_delta->completion);

        sigma_delta->irq_dis = true;
drivers/iio/adc/ad_sigma_delta.c +4 -0
+
+       /* the IRQ core clears IRQ_DISABLE_UNLAZY flag when freeing an IRQ */
+       irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY);
+
        ret = devm_request_irq(dev, sigma_delta->spi->irq,
                               ad_sd_data_rdy_trig_poll,
                               sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,