openwrt/target/linux/bcm27xx/patches-6.1/950-0704-pinctrl-bcm2835-Workaround-for-edge-IRQ-loss.patch

68 lines
2.3 KiB
Diff
Raw Normal View History

From dcb717bc899cd55a969fb4f1f8526f313efe148c Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Fri, 5 May 2023 11:25:48 +0100
Subject: [PATCH] pinctrl: bcm2835: Workaround for edge IRQ loss
It has been observed that edge events can be lost when GPIO edges occur
close to each other. Investigation suggests this is due to a hardware
bug, although no mechanism has been identified.
Work around the event loss by moving the IRQ acknowledgement into the
main ISR, adding missing events by explicit level-change detection.
See: https://forums.raspberrypi.com/viewtopic.php?t=350295
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
kernel: bump 6.1 to 6.1.39 Removed upstreamed: generic/backport-6.1/803-v6.5-01-leds-trigger-netdev-Recheck-NETDEV_LED_MODE_LINKUP-o.patch[1] generic/pending-6.1/143-jffs2-reduce-stack-usage-in-jffs2_build_xattr_subsys.patch[2] bcm27xx/patches-6.1/950-0034-drm-bridge-Introduce-pre_enable_upstream_first-to-al.patch[3] bcm27xx/patches-6.1/950-0439-nvmem-Use-NVMEM_DEVID_AUTO.patch[4] bcm4908/patches-6.1/040-mtd-parsers-refer-to-ARCH_BCMBCA-instead-of-ARCH_BCM.patch[5] bcm53xx/patches-6.1/031-v6.5-0003-ARM-dts-BCM5301X-Drop-clock-names-from-the-SPI-node.patch[6] bcm53xx/patches-6.1/031-v6.5-0015-ARM-dts-BCM5301X-fix-duplex-full-full-duplex.patch[7] mediatek/patches-6.1/351-cpufreq-mediatek-correct-voltages-for-MT7622-and-MT7.patch[8] qualcommax/patches-6.1/0008-v6.2-clk-qcom-reset-support-resetting-multiple-bits.patch[9] Manually rebased: bcm27xx/patches-6.1/950-0035-drm-panel-Add-prepare_upstream_first-flag-to-drm_pan.patch bcm27xx/patches-6.1/950-0404-drm-panel-panel-ilitek9881c-Add-prepare_upstream_fir.patch bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch mediatek/patches-6.1/350-21-cpufreq-mediatek-Add-support-for-MT7988.patch All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=ab0bd172d6289310a05a0cd15e1432e828d386ae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=6df680709d901346831ef8f221cc90a42062c526 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=5044e5f2511c9afdf9880d2bb6b9d37dfc345dac 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=e27948f329f7e02591ed1feb9a7710c2ccf89a83 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=ad2928e7f3f6120a0bd18aa1056b3b24068027c5 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=2b55a985727833f37c39911f34096b3fdf2a367d 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=90d4c487cd658b51212eb65ae804ab11af193672 8. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=7e3ee25e8c7c7be1eacdfc6d9f5f0e550a2af241 9. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=b20854ef6c4955be3310975a72f02d92cb01d6d4 Build system: x86/64 Build-tested: x86/64 Run-tested: x86/64 Co-authored-by: Hauke Mehrtens <hauke@hauke-m.de> Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: John Audia <therealgraysky@proton.me> [ rebase bcm27xx and mediatek patches, refresh commit description ] Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> [ minor fixup to bcm27xx patches, refresh commit description ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-07-20 09:51:10 +00:00
@@ -420,15 +420,32 @@ static void bcm2835_gpio_irq_handle_bank
unsigned long events;
unsigned offset;
unsigned gpio;
+ u32 levs, levs2;
events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4);
+ levs = bcm2835_gpio_rd(pc, GPLEV0 + bank * 4);
events &= mask;
events &= pc->enabled_irq_map[bank];
+ bcm2835_gpio_wr(pc, GPEDS0 + bank * 4, events);
+
+retry:
for_each_set_bit(offset, &events, 32) {
gpio = (32 * bank) + offset;
generic_handle_domain_irq(pc->gpio_chip.irq.domain,
gpio);
}
+ events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4);
+ levs2 = bcm2835_gpio_rd(pc, GPLEV0 + bank * 4);
+
+ events |= levs2 & ~levs & bcm2835_gpio_rd(pc, GPREN0 + bank * 4);
+ events |= ~levs2 & levs & bcm2835_gpio_rd(pc, GPFEN0 + bank * 4);
+ events &= mask;
+ events &= pc->enabled_irq_map[bank];
+ if (events) {
+ bcm2835_gpio_wr(pc, GPEDS0 + bank * 4, events);
+ levs = levs2;
+ goto retry;
+ }
}
static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
kernel: bump 6.1 to 6.1.39 Removed upstreamed: generic/backport-6.1/803-v6.5-01-leds-trigger-netdev-Recheck-NETDEV_LED_MODE_LINKUP-o.patch[1] generic/pending-6.1/143-jffs2-reduce-stack-usage-in-jffs2_build_xattr_subsys.patch[2] bcm27xx/patches-6.1/950-0034-drm-bridge-Introduce-pre_enable_upstream_first-to-al.patch[3] bcm27xx/patches-6.1/950-0439-nvmem-Use-NVMEM_DEVID_AUTO.patch[4] bcm4908/patches-6.1/040-mtd-parsers-refer-to-ARCH_BCMBCA-instead-of-ARCH_BCM.patch[5] bcm53xx/patches-6.1/031-v6.5-0003-ARM-dts-BCM5301X-Drop-clock-names-from-the-SPI-node.patch[6] bcm53xx/patches-6.1/031-v6.5-0015-ARM-dts-BCM5301X-fix-duplex-full-full-duplex.patch[7] mediatek/patches-6.1/351-cpufreq-mediatek-correct-voltages-for-MT7622-and-MT7.patch[8] qualcommax/patches-6.1/0008-v6.2-clk-qcom-reset-support-resetting-multiple-bits.patch[9] Manually rebased: bcm27xx/patches-6.1/950-0035-drm-panel-Add-prepare_upstream_first-flag-to-drm_pan.patch bcm27xx/patches-6.1/950-0404-drm-panel-panel-ilitek9881c-Add-prepare_upstream_fir.patch bcm27xx/patches-6.1/950-0699-Bluetooth-hci_sync-Add-fallback-bd-address-prop.patch mediatek/patches-6.1/350-21-cpufreq-mediatek-Add-support-for-MT7988.patch All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=ab0bd172d6289310a05a0cd15e1432e828d386ae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=6df680709d901346831ef8f221cc90a42062c526 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=5044e5f2511c9afdf9880d2bb6b9d37dfc345dac 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=e27948f329f7e02591ed1feb9a7710c2ccf89a83 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=ad2928e7f3f6120a0bd18aa1056b3b24068027c5 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=2b55a985727833f37c39911f34096b3fdf2a367d 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=90d4c487cd658b51212eb65ae804ab11af193672 8. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=7e3ee25e8c7c7be1eacdfc6d9f5f0e550a2af241 9. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.39&id=b20854ef6c4955be3310975a72f02d92cb01d6d4 Build system: x86/64 Build-tested: x86/64 Run-tested: x86/64 Co-authored-by: Hauke Mehrtens <hauke@hauke-m.de> Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: John Audia <therealgraysky@proton.me> [ rebase bcm27xx and mediatek patches, refresh commit description ] Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> [ minor fixup to bcm27xx patches, refresh commit description ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-07-20 09:51:10 +00:00
@@ -668,11 +685,7 @@ static int bcm2835_gpio_irq_set_type(str
static void bcm2835_gpio_irq_ack(struct irq_data *data)
{
- struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
- struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
- unsigned gpio = irqd_to_hwirq(data);
-
- bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
+ /* Nothing to do - the main interrupt handler includes the ACK */
}
static int bcm2835_gpio_irq_set_wake(struct irq_data *data, unsigned int on)