Re: [PATCH] i2c: pasemi: Add IRQ support for Apple Silicon
From: Arnd Bergmann <arnd@arndb.de>
Date: 2022-08-25 12:29:59
Also in:
linux-i2c, linuxppc-dev, lkml
On Sat, Aug 20, 2022 at 9:45 PM Arminder Singh [off-list ref] wrote:
I also fixed a quick checkpatch warning on line 303. "i ++" is now "i++".
In general, anything that is mentioned in the changelog as "also done this" is worth splitting into a separate patch, or dropping from the patch, to make reviewing easier. In this case, I would just not do the trivial change. Alternatively you can consider doing a larger patch for coding style cleanup on the patch, as there are possibly other issues as well. Usually it's not worth changing things unless they hurt readability.
quoted hunk ↗ jump to hunk
@@ -80,14 +81,21 @@ static int pasemi_smb_waitready(struct pasemi_smbus *smbus) { int timeout = 10; unsigned int status; + unsigned int bitmask = SMSTA_XEN | SMSTA_MTN; + if (smbus->use_irq) { + reinit_completion(&smbus->irq_completion); + reg_write(smbus, REG_IMASK, bitmask); + wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(10)); status = reg_read(smbus, REG_SMSTA); } + /* Got NACK? */ if (status & SMSTA_MTN) return -ENXIO;
...
quoted hunk ↗ jump to hunk
@@ -356,3 +366,12 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) return 0; } + +irqreturn_t pasemi_irq_handler(int irq, void *dev_id) +{ + struct pasemi_smbus *smbus = (struct pasemi_smbus *)dev_id; + + reg_write(smbus, REG_IMASK, 0); + complete(&smbus->irq_completion); + return IRQ_HANDLED; +}
I think the completion structure gets out of sync if you run into a
timeout here,
so a subsequent wait_for_completion will never complete after we missed one
interrupt.
Since this already causes a bus reset, I think you can just do
reinit_completion() at the end of pasemi_reset() to avoid this.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel