* [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-28 18:58 ` Nicolas Saenz Julienne
0 siblings, 0 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2020-05-28 18:58 UTC (permalink / raw)
To: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Nicolas Saenz Julienne
Cc: Martin Sperl, linux-spi, linux-rpi-kernel, linux-arm-kernel,
linux-kernel
From: Martin Sperl <kernel@martin.sperl.org>
bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
instances of the bcm2835 SPI controller. So this enables shared
interrupt support for them.
The early bail out in the interrupt routine avoids messing with buffers
of transfers being done by other means. Otherwise, the driver can handle
receiving interrupts asserted by other controllers during an IRQ based
transfer.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
drivers/spi/spi-bcm2835.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 11c235879bb7..ca1085c812f2 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
+ /* check if we got interrupt enabled */
+ if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
+ return IRQ_NONE;
+
/* Read as many bytes as possible from FIFO */
bcm2835_rd_fifo(bs);
/* Write as many bytes as possible to FIFO */
@@ -1340,8 +1344,8 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
bcm2835_wr(bs, BCM2835_SPI_CS,
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
- err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt, 0,
- dev_name(&pdev->dev), ctlr);
+ err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt,
+ IRQF_SHARED, dev_name(&pdev->dev), ctlr);
if (err) {
dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
goto out_dma_release;
--
2.26.2
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-28 18:58 ` Nicolas Saenz Julienne
0 siblings, 0 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2020-05-28 18:58 UTC (permalink / raw)
To: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Nicolas Saenz Julienne
Cc: Martin Sperl, linux-kernel, linux-rpi-kernel, linux-arm-kernel,
linux-spi
From: Martin Sperl <kernel@martin.sperl.org>
bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
instances of the bcm2835 SPI controller. So this enables shared
interrupt support for them.
The early bail out in the interrupt routine avoids messing with buffers
of transfers being done by other means. Otherwise, the driver can handle
receiving interrupts asserted by other controllers during an IRQ based
transfer.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
drivers/spi/spi-bcm2835.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 11c235879bb7..ca1085c812f2 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
+ /* check if we got interrupt enabled */
+ if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
+ return IRQ_NONE;
+
/* Read as many bytes as possible from FIFO */
bcm2835_rd_fifo(bs);
/* Write as many bytes as possible to FIFO */
@@ -1340,8 +1344,8 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
bcm2835_wr(bs, BCM2835_SPI_CS,
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
- err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt, 0,
- dev_name(&pdev->dev), ctlr);
+ err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt,
+ IRQF_SHARED, dev_name(&pdev->dev), ctlr);
if (err) {
dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
goto out_dma_release;
--
2.26.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-28 18:58 ` Nicolas Saenz Julienne
@ 2020-05-28 19:00 ` Florian Fainelli
-1 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-28 19:00 UTC (permalink / raw)
To: Nicolas Saenz Julienne, Mark Brown, Ray Jui, Scott Branden,
bcm-kernel-feedback-list
Cc: Martin Sperl, linux-spi, linux-rpi-kernel, linux-arm-kernel,
linux-kernel
On 5/28/20 11:58 AM, Nicolas Saenz Julienne wrote:
> From: Martin Sperl <kernel@martin.sperl.org>
>
> bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
> instances of the bcm2835 SPI controller. So this enables shared
> interrupt support for them.
>
> The early bail out in the interrupt routine avoids messing with buffers
> of transfers being done by other means. Otherwise, the driver can handle
> receiving interrupts asserted by other controllers during an IRQ based
> transfer.
>
> Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Thanks Nicolas, we have been using this patch on 7211 (which is very
similar to 2711):
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-28 19:00 ` Florian Fainelli
0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-28 19:00 UTC (permalink / raw)
To: Nicolas Saenz Julienne, Mark Brown, Ray Jui, Scott Branden,
bcm-kernel-feedback-list
Cc: Martin Sperl, linux-kernel, linux-rpi-kernel, linux-arm-kernel,
linux-spi
On 5/28/20 11:58 AM, Nicolas Saenz Julienne wrote:
> From: Martin Sperl <kernel@martin.sperl.org>
>
> bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
> instances of the bcm2835 SPI controller. So this enables shared
> interrupt support for them.
>
> The early bail out in the interrupt routine avoids messing with buffers
> of transfers being done by other means. Otherwise, the driver can handle
> receiving interrupts asserted by other controllers during an IRQ based
> transfer.
>
> Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Thanks Nicolas, we have been using this patch on 7211 (which is very
similar to 2711):
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-28 18:58 ` Nicolas Saenz Julienne
@ 2020-05-29 17:18 ` Mark Brown
-1 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2020-05-29 17:18 UTC (permalink / raw)
To: bcm-kernel-feedback-list, Ray Jui, Nicolas Saenz Julienne,
Scott Branden, Florian Fainelli
Cc: linux-spi, linux-arm-kernel, linux-rpi-kernel, linux-kernel,
Martin Sperl
On Thu, 28 May 2020 20:58:04 +0200, Nicolas Saenz Julienne wrote:
> bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
> instances of the bcm2835 SPI controller. So this enables shared
> interrupt support for them.
>
> The early bail out in the interrupt routine avoids messing with buffers
> of transfers being done by other means. Otherwise, the driver can handle
> receiving interrupts asserted by other controllers during an IRQ based
> transfer.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: bcm2835: Enable shared interrupt support
commit: ecfbd3cf3b8bb73ac6a80ddf430b5912fd4402a6
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-29 17:18 ` Mark Brown
0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2020-05-29 17:18 UTC (permalink / raw)
To: bcm-kernel-feedback-list, Ray Jui, Nicolas Saenz Julienne,
Scott Branden, Florian Fainelli
Cc: Martin Sperl, linux-kernel, linux-rpi-kernel, linux-arm-kernel,
linux-spi
On Thu, 28 May 2020 20:58:04 +0200, Nicolas Saenz Julienne wrote:
> bcm2711, Rasberry Pi 4's SoC, shares one interrupt for multiple
> instances of the bcm2835 SPI controller. So this enables shared
> interrupt support for them.
>
> The early bail out in the interrupt routine avoids messing with buffers
> of transfers being done by other means. Otherwise, the driver can handle
> receiving interrupts asserted by other controllers during an IRQ based
> transfer.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: bcm2835: Enable shared interrupt support
commit: ecfbd3cf3b8bb73ac6a80ddf430b5912fd4402a6
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-28 18:58 ` Nicolas Saenz Julienne
` (2 preceding siblings ...)
(?)
@ 2020-05-29 17:43 ` Lukas Wunner
2020-05-29 17:46 ` Florian Fainelli
2020-05-29 17:48 ` Mark Brown
-1 siblings, 2 replies; 15+ messages in thread
From: Lukas Wunner @ 2020-05-29 17:43 UTC (permalink / raw)
To: Nicolas Saenz Julienne
Cc: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Martin Sperl, linux-spi,
linux-rpi-kernel, linux-arm-kernel, linux-kernel
On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
> --- a/drivers/spi/spi-bcm2835.c
> +++ b/drivers/spi/spi-bcm2835.c
> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
>
> + /* check if we got interrupt enabled */
> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
> + return IRQ_NONE;
> +
> /* Read as many bytes as possible from FIFO */
> bcm2835_rd_fifo(bs);
> /* Write as many bytes as possible to FIFO */
This definitely looks wrong. The check whether the interrupt is enabled
should be moved *before* the conditional calls to bcm2835_rd_fifo_blind()
and bcm2835_wr_fifo_blind(), i.e. to the top of the function.
Otherwise if an interrupt is raised by another SPI controller,
this function may perform read/write accesses to the FIFO and
interfere with an ongoing transfer in DMA or poll mode.
Also, instead of performing an MMIO read, just use the "cs" variable
which was assigned at the top of the function.
The code comment should explain that the check is necessary because the
interrupt may be shared with other controllers on the BCM2711.
Finally, it would be nice if the check would be optimized away when
compiling for pre-RasPi4 products, maybe something like:
+ if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
+ return IRQ_NONE;
Thanks,
Lukas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-29 17:43 ` Lukas Wunner
@ 2020-05-29 17:46 ` Florian Fainelli
2020-05-29 17:48 ` Mark Brown
1 sibling, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-29 17:46 UTC (permalink / raw)
To: Lukas Wunner, Nicolas Saenz Julienne
Cc: Mark Brown, Ray Jui, Scott Branden, bcm-kernel-feedback-list,
Martin Sperl, linux-spi, linux-rpi-kernel, linux-arm-kernel,
linux-kernel
On 5/29/20 10:43 AM, Lukas Wunner wrote:
> On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
>> --- a/drivers/spi/spi-bcm2835.c
>> +++ b/drivers/spi/spi-bcm2835.c
>> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
>> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
>> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
>>
>> + /* check if we got interrupt enabled */
>> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
>> + return IRQ_NONE;
>> +
>> /* Read as many bytes as possible from FIFO */
>> bcm2835_rd_fifo(bs);
>> /* Write as many bytes as possible to FIFO */
>
> This definitely looks wrong. The check whether the interrupt is enabled
> should be moved *before* the conditional calls to bcm2835_rd_fifo_blind()
> and bcm2835_wr_fifo_blind(), i.e. to the top of the function.
>
> Otherwise if an interrupt is raised by another SPI controller,
> this function may perform read/write accesses to the FIFO and
> interfere with an ongoing transfer in DMA or poll mode.
>
> Also, instead of performing an MMIO read, just use the "cs" variable
> which was assigned at the top of the function.
>
> The code comment should explain that the check is necessary because the
> interrupt may be shared with other controllers on the BCM2711.
>
> Finally, it would be nice if the check would be optimized away when
> compiling for pre-RasPi4 products, maybe something like:
>
> + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
> + return IRQ_NONE;
Rather than keying this off ARM_LPAE or any other option, this should be
keyed off a compatible string, that way we can even conditionally pass
IRQF_SHARED to the interrupt handler if we care so much about performance.
--
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-29 17:46 ` Florian Fainelli
0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-29 17:46 UTC (permalink / raw)
To: Lukas Wunner, Nicolas Saenz Julienne
Cc: Scott Branden, Ray Jui, linux-kernel, linux-spi, Mark Brown,
bcm-kernel-feedback-list, linux-rpi-kernel, Martin Sperl,
linux-arm-kernel
On 5/29/20 10:43 AM, Lukas Wunner wrote:
> On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
>> --- a/drivers/spi/spi-bcm2835.c
>> +++ b/drivers/spi/spi-bcm2835.c
>> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
>> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
>> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
>>
>> + /* check if we got interrupt enabled */
>> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
>> + return IRQ_NONE;
>> +
>> /* Read as many bytes as possible from FIFO */
>> bcm2835_rd_fifo(bs);
>> /* Write as many bytes as possible to FIFO */
>
> This definitely looks wrong. The check whether the interrupt is enabled
> should be moved *before* the conditional calls to bcm2835_rd_fifo_blind()
> and bcm2835_wr_fifo_blind(), i.e. to the top of the function.
>
> Otherwise if an interrupt is raised by another SPI controller,
> this function may perform read/write accesses to the FIFO and
> interfere with an ongoing transfer in DMA or poll mode.
>
> Also, instead of performing an MMIO read, just use the "cs" variable
> which was assigned at the top of the function.
>
> The code comment should explain that the check is necessary because the
> interrupt may be shared with other controllers on the BCM2711.
>
> Finally, it would be nice if the check would be optimized away when
> compiling for pre-RasPi4 products, maybe something like:
>
> + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
> + return IRQ_NONE;
Rather than keying this off ARM_LPAE or any other option, this should be
keyed off a compatible string, that way we can even conditionally pass
IRQF_SHARED to the interrupt handler if we care so much about performance.
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-29 17:43 ` Lukas Wunner
@ 2020-05-29 17:48 ` Mark Brown
2020-05-29 17:48 ` Mark Brown
1 sibling, 0 replies; 15+ messages in thread
From: Mark Brown @ 2020-05-29 17:48 UTC (permalink / raw)
To: Lukas Wunner
Cc: Nicolas Saenz Julienne, Florian Fainelli, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Martin Sperl, linux-spi,
linux-rpi-kernel, linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 313 bytes --]
On Fri, May 29, 2020 at 07:43:58PM +0200, Lukas Wunner wrote:
> This definitely looks wrong. The check whether the interrupt is enabled
> should be moved *before* the conditional calls to bcm2835_rd_fifo_blind()
> and bcm2835_wr_fifo_blind(), i.e. to the top of the function.
Hrm, right - I'll drop the patch.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-29 17:48 ` Mark Brown
0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2020-05-29 17:48 UTC (permalink / raw)
To: Lukas Wunner
Cc: linux-arm-kernel, Florian Fainelli, Scott Branden, Ray Jui,
linux-kernel, linux-spi, bcm-kernel-feedback-list,
linux-rpi-kernel, Martin Sperl, Nicolas Saenz Julienne
[-- Attachment #1.1: Type: text/plain, Size: 313 bytes --]
On Fri, May 29, 2020 at 07:43:58PM +0200, Lukas Wunner wrote:
> This definitely looks wrong. The check whether the interrupt is enabled
> should be moved *before* the conditional calls to bcm2835_rd_fifo_blind()
> and bcm2835_wr_fifo_blind(), i.e. to the top of the function.
Hrm, right - I'll drop the patch.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-29 17:46 ` Florian Fainelli
(?)
@ 2020-05-29 17:53 ` Lukas Wunner
2020-05-29 18:03 ` Florian Fainelli
-1 siblings, 1 reply; 15+ messages in thread
From: Lukas Wunner @ 2020-05-29 17:53 UTC (permalink / raw)
To: Florian Fainelli
Cc: Nicolas Saenz Julienne, Mark Brown, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Martin Sperl, linux-spi,
linux-rpi-kernel, linux-arm-kernel, linux-kernel
On Fri, May 29, 2020 at 10:46:01AM -0700, Florian Fainelli wrote:
> On 5/29/20 10:43 AM, Lukas Wunner wrote:
> > On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
> >> --- a/drivers/spi/spi-bcm2835.c
> >> +++ b/drivers/spi/spi-bcm2835.c
> >> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
> >> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
> >> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
> >>
> >> + /* check if we got interrupt enabled */
> >> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
> >> + return IRQ_NONE;
> >> +
> >> /* Read as many bytes as possible from FIFO */
> >> bcm2835_rd_fifo(bs);
> >> /* Write as many bytes as possible to FIFO */
[...]
> > Finally, it would be nice if the check would be optimized away when
> > compiling for pre-RasPi4 products, maybe something like:
> >
> > + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
> > + return IRQ_NONE;
>
> Rather than keying this off ARM_LPAE or any other option, this should be
> keyed off a compatible string, that way we can even conditionally pass
> IRQF_SHARED to the interrupt handler if we care so much about performance.
But a compatible string can't be checked at compile time, can it?
The point is that at the least the Foundation compiles and ships a separate
kernel for each of the three platforms BCM2835, BCM2837, BCM2711. It's
unnecessary to check whether an interrupt was actually raised if we *know*
in advance that it's not shared (as is the case with kernels compiled for
BCM2835 and BCM2837).
Thanks,
Lukas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-29 17:53 ` Lukas Wunner
@ 2020-05-29 18:03 ` Florian Fainelli
0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-29 18:03 UTC (permalink / raw)
To: Lukas Wunner
Cc: Nicolas Saenz Julienne, Mark Brown, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Martin Sperl, linux-spi,
linux-rpi-kernel, linux-arm-kernel, linux-kernel
On 5/29/20 10:53 AM, Lukas Wunner wrote:
> On Fri, May 29, 2020 at 10:46:01AM -0700, Florian Fainelli wrote:
>> On 5/29/20 10:43 AM, Lukas Wunner wrote:
>>> On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
>>>> --- a/drivers/spi/spi-bcm2835.c
>>>> +++ b/drivers/spi/spi-bcm2835.c
>>>> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
>>>> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
>>>> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
>>>>
>>>> + /* check if we got interrupt enabled */
>>>> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
>>>> + return IRQ_NONE;
>>>> +
>>>> /* Read as many bytes as possible from FIFO */
>>>> bcm2835_rd_fifo(bs);
>>>> /* Write as many bytes as possible to FIFO */
> [...]
>>> Finally, it would be nice if the check would be optimized away when
>>> compiling for pre-RasPi4 products, maybe something like:
>>>
>>> + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
>>> + return IRQ_NONE;
>>
>> Rather than keying this off ARM_LPAE or any other option, this should be
>> keyed off a compatible string, that way we can even conditionally pass
>> IRQF_SHARED to the interrupt handler if we care so much about performance.
>
> But a compatible string can't be checked at compile time, can it?
No, but you can have a different interrupt handler that it set at
runtime if you want to completely eliminate this comparison.
My point is that CONFIG_ARM_LPAE is just too brittle, there is nothing
that prevents you from using a non-LPAE kernel on the Pi 4, even PCIe
could be made to work if using super section mappings to map the PCIe
outbound space. Even on models with over 4GB of DRAM, if you are willing
to lose some of it, it can work.
>
> The point is that at the least the Foundation compiles and ships a separate
> kernel for each of the three platforms BCM2835, BCM2837, BCM2711. It's
> unnecessary to check whether an interrupt was actually raised if we *know*
> in advance that it's not shared (as is the case with kernels compiled for
> BCM2835 and BCM2837).
I am fine with any solution that does not involve keying off
CONFIG_ARM_LPAE to discriminate 2711 from any other chip.
--
Florian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
@ 2020-05-29 18:03 ` Florian Fainelli
0 siblings, 0 replies; 15+ messages in thread
From: Florian Fainelli @ 2020-05-29 18:03 UTC (permalink / raw)
To: Lukas Wunner
Cc: linux-arm-kernel, Scott Branden, Ray Jui, linux-kernel, linux-spi,
Mark Brown, bcm-kernel-feedback-list, linux-rpi-kernel,
Martin Sperl, Nicolas Saenz Julienne
On 5/29/20 10:53 AM, Lukas Wunner wrote:
> On Fri, May 29, 2020 at 10:46:01AM -0700, Florian Fainelli wrote:
>> On 5/29/20 10:43 AM, Lukas Wunner wrote:
>>> On Thu, May 28, 2020 at 08:58:04PM +0200, Nicolas Saenz Julienne wrote:
>>>> --- a/drivers/spi/spi-bcm2835.c
>>>> +++ b/drivers/spi/spi-bcm2835.c
>>>> @@ -379,6 +379,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
>>>> if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
>>>> bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
>>>>
>>>> + /* check if we got interrupt enabled */
>>>> + if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
>>>> + return IRQ_NONE;
>>>> +
>>>> /* Read as many bytes as possible from FIFO */
>>>> bcm2835_rd_fifo(bs);
>>>> /* Write as many bytes as possible to FIFO */
> [...]
>>> Finally, it would be nice if the check would be optimized away when
>>> compiling for pre-RasPi4 products, maybe something like:
>>>
>>> + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
>>> + return IRQ_NONE;
>>
>> Rather than keying this off ARM_LPAE or any other option, this should be
>> keyed off a compatible string, that way we can even conditionally pass
>> IRQF_SHARED to the interrupt handler if we care so much about performance.
>
> But a compatible string can't be checked at compile time, can it?
No, but you can have a different interrupt handler that it set at
runtime if you want to completely eliminate this comparison.
My point is that CONFIG_ARM_LPAE is just too brittle, there is nothing
that prevents you from using a non-LPAE kernel on the Pi 4, even PCIe
could be made to work if using super section mappings to map the PCIe
outbound space. Even on models with over 4GB of DRAM, if you are willing
to lose some of it, it can work.
>
> The point is that at the least the Foundation compiles and ships a separate
> kernel for each of the three platforms BCM2835, BCM2837, BCM2711. It's
> unnecessary to check whether an interrupt was actually raised if we *know*
> in advance that it's not shared (as is the case with kernels compiled for
> BCM2835 and BCM2837).
I am fine with any solution that does not involve keying off
CONFIG_ARM_LPAE to discriminate 2711 from any other chip.
--
Florian
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] spi: bcm2835: Enable shared interrupt support
2020-05-29 18:03 ` Florian Fainelli
(?)
@ 2020-05-29 18:16 ` Lukas Wunner
-1 siblings, 0 replies; 15+ messages in thread
From: Lukas Wunner @ 2020-05-29 18:16 UTC (permalink / raw)
To: Florian Fainelli
Cc: Nicolas Saenz Julienne, Mark Brown, Ray Jui, Scott Branden,
bcm-kernel-feedback-list, Martin Sperl, linux-spi,
linux-rpi-kernel, linux-arm-kernel, linux-kernel
On Fri, May 29, 2020 at 11:03:48AM -0700, Florian Fainelli wrote:
> On 5/29/20 10:53 AM, Lukas Wunner wrote:
> > On Fri, May 29, 2020 at 10:46:01AM -0700, Florian Fainelli wrote:
> >> On 5/29/20 10:43 AM, Lukas Wunner wrote:
> >>> Finally, it would be nice if the check would be optimized away when
> >>> compiling for pre-RasPi4 products, maybe something like:
> >>>
> >>> + if (IS_ENABLED(CONFIG_ARM_LPAE) && !(cs & BCM2835_SPI_CS_INTR))
> >>> + return IRQ_NONE;
> >>
> >> Rather than keying this off ARM_LPAE or any other option, this should be
> >> keyed off a compatible string, that way we can even conditionally pass
> >> IRQF_SHARED to the interrupt handler if we care so much about performance.
> >
> > But a compatible string can't be checked at compile time, can it?
>
> No, but you can have a different interrupt handler that it set at
> runtime if you want to completely eliminate this comparison.
Good idea. In fact the IRQ handler for platforms with shared interrupts
could just be a wrapper which performs the BCM2835_SPI_CS_INTR check
then tail-calls the existing IRQ handler. The compiler would just
inline it and everything would be fine.
> My point is that CONFIG_ARM_LPAE is just too brittle, there is nothing
> that prevents you from using a non-LPAE kernel on the Pi 4, even PCIe
> could be made to work if using super section mappings to map the PCIe
> outbound space. Even on models with over 4GB of DRAM, if you are willing
> to lose some of it, it can work.
Agreed.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-05-29 18:16 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-28 18:58 [PATCH] spi: bcm2835: Enable shared interrupt support Nicolas Saenz Julienne
2020-05-28 18:58 ` Nicolas Saenz Julienne
2020-05-28 19:00 ` Florian Fainelli
2020-05-28 19:00 ` Florian Fainelli
2020-05-29 17:18 ` Mark Brown
2020-05-29 17:18 ` Mark Brown
2020-05-29 17:43 ` Lukas Wunner
2020-05-29 17:46 ` Florian Fainelli
2020-05-29 17:46 ` Florian Fainelli
2020-05-29 17:53 ` Lukas Wunner
2020-05-29 18:03 ` Florian Fainelli
2020-05-29 18:03 ` Florian Fainelli
2020-05-29 18:16 ` Lukas Wunner
2020-05-29 17:48 ` Mark Brown
2020-05-29 17:48 ` Mark Brown
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.