stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	kernel test robot <lkp@intel.com>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15 065/110] gpio: Return EPROBE_DEFER if gc->to_irq is NULL
Date: Mon, 14 Mar 2022 12:54:07 +0100	[thread overview]
Message-ID: <20220314112744.849259089@linuxfoundation.org> (raw)
In-Reply-To: <20220314112743.029192918@linuxfoundation.org>

From: Shreeya Patel <shreeya.patel@collabora.com>

[ Upstream commit ae42f9288846353982e2eab181fb41e7fd8bf60f ]

We are racing the registering of .to_irq when probing the
i2c driver. This results in random failure of touchscreen
devices.

Following explains the race condition better.

[gpio driver] gpio driver registers gpio chip
[gpio consumer] gpio is acquired
[gpio consumer] gpiod_to_irq() fails with -ENXIO
[gpio driver] gpio driver registers irqchip
gpiod_to_irq works at this point, but -ENXIO is fatal

We could see the following errors in dmesg logs when gc->to_irq is NULL

[2.101857] i2c_hid i2c-FTS3528:00: HID over i2c has not been provided an Int IRQ
[2.101953] i2c_hid: probe of i2c-FTS3528:00 failed with error -22

To avoid this situation, defer probing until to_irq is registered.
Returning -EPROBE_DEFER would be the first step towards avoiding
the failure of devices due to the race in registration of .to_irq.
Final solution to this issue would be to avoid using gc irq members
until they are fully initialized.

This issue has been reported many times in past and people have been
using workarounds like changing the pinctrl_amd to built-in instead
of loading it as a module or by adding a softdep for pinctrl_amd into
the config file.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209413
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 9e151413f51a..358f0ad9d0f8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3116,6 +3116,16 @@ int gpiod_to_irq(const struct gpio_desc *desc)
 
 		return retirq;
 	}
+#ifdef CONFIG_GPIOLIB_IRQCHIP
+	if (gc->irq.chip) {
+		/*
+		 * Avoid race condition with other code, which tries to lookup
+		 * an IRQ before the irqchip has been properly registered,
+		 * i.e. while gpiochip is still being brought up.
+		 */
+		return -EPROBE_DEFER;
+	}
+#endif
 	return -ENXIO;
 }
 EXPORT_SYMBOL_GPL(gpiod_to_irq);
-- 
2.34.1




  parent reply	other threads:[~2022-03-14 12:11 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 11:53 [PATCH 5.15 000/110] 5.15.29-rc1 review Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 001/110] arm64: dts: qcom: sm8350: Describe GCC dependency clocks Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 002/110] arm64: dts: qcom: sm8350: Correct UFS symbol clocks Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 003/110] HID: elo: Revert USB reference counting Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 004/110] HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 005/110] ARM: boot: dts: bcm2711: Fix HVS register range Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 006/110] clk: qcom: gdsc: Add support to update GDSC transition delay Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 007/110] clk: qcom: dispcc: Update the transition delay for MDSS GDSC Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 008/110] HID: vivaldi: fix sysfs attributes leak Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 009/110] arm64: dts: armada-3720-turris-mox: Add missing ethernet0 alias Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 010/110] tipc: fix kernel panic when enabling bearer Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 011/110] vdpa/mlx5: add validation for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 012/110] vduse: Fix returning wrong type in vduse_domain_alloc_iova() Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 013/110] net: phy: meson-gxl: fix interrupt handling in forced mode Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 014/110] mISDN: Fix memory leak in dsp_pipeline_build() Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 015/110] vhost: fix hung thread due to erroneous iotlb entries Greg Kroah-Hartman
2022-03-14 16:14   ` Anirudh Rayabharam
2022-03-15  9:19     ` Greg Kroah-Hartman
2022-03-15 11:50       ` Michael S. Tsirkin
2022-03-15 12:39         ` Greg Kroah-Hartman
2022-03-15 13:30           ` Michael S. Tsirkin
2022-03-14 11:53 ` [PATCH 5.15 016/110] virtio-blk: Dont use MAX_DISCARD_SEGMENTS if max_discard_seg is zero Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 017/110] vdpa: fix use-after-free on vp_vdpa_remove Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 018/110] isdn: hfcpci: check the return value of dma_set_mask() in setup_hw() Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 019/110] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 020/110] esp: Fix possible buffer overflow in ESP transformation Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 021/110] esp: Fix BEET mode inter address family tunneling on GSO Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 022/110] qed: return status of qed_iov_get_link Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 023/110] smsc95xx: Ignore -ENODEV errors when device is unplugged Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 024/110] gpiolib: acpi: Convert ACPI value of debounce to microseconds Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 025/110] drm/sun4i: mixer: Fix P010 and P210 format numbers Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 026/110] net: dsa: mt7530: fix incorrect test in mt753x_phylink_validate() Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 027/110] ARM: dts: aspeed: Fix AST2600 quad spi group Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 028/110] iavf: Fix handling of vlan strip virtual channel messages Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 029/110] i40e: stop disabling VFs due to PF error responses Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 030/110] ice: " Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 031/110] ice: Fix error with handling of bonding MTU Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 032/110] ice: Dont use GFP_KERNEL in atomic context Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 033/110] ice: Fix curr_link_speed advertised speed Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 034/110] ethernet: Fix error handling in xemaclite_of_probe Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 035/110] tipc: fix incorrect order of state message data sanity check Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 036/110] net: ethernet: ti: cpts: Handle error for clk_enable Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 037/110] net: ethernet: lpc_eth: " Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 038/110] net: marvell: prestera: Add missing of_node_put() in prestera_switch_set_base_mac_addr Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 039/110] ax25: Fix NULL pointer dereference in ax25_kill_by_device Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 040/110] net/mlx5: Fix size field in bufferx_reg struct Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 041/110] net/mlx5: Fix a race on command flush flow Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 042/110] net/mlx5e: Lag, Only handle events from highest priority multipath entry Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 043/110] NFC: port100: fix use-after-free in port100_send_complete Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 044/110] selftests: pmtu.sh: Kill tcpdump processes launched by subshell Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 045/110] selftests: pmtu.sh: Kill nettest processes launched in subshell Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 046/110] gpio: ts4900: Do not set DAT and OE together Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 047/110] gianfar: ethtool: Fix refcount leak in gfar_get_ts_info Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 048/110] net: phy: DP83822: clear MISR2 register to disable interrupts Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 049/110] sctp: fix kernel-infoleak for SCTP sockets Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 050/110] net: bcmgenet: Dont claim WOL when its not available Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 051/110] net: phy: meson-gxl: improve link-up behavior Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 052/110] selftests/bpf: Add test for bpf_timer overwriting crash Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 053/110] swiotlb: fix info leak with DMA_FROM_DEVICE Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 054/110] usb: dwc3: pci: add support for the Intel Raptor Lake-S Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 055/110] pinctrl: tigerlake: Revert "Add Alder Lake-M ACPI ID" Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 056/110] KVM: Fix lockdep false negative during host resume Greg Kroah-Hartman
2022-03-14 11:53 ` [PATCH 5.15 057/110] kvm: x86: Disable KVM_HC_CLOCK_PAIRING if tsc is in always catchup mode Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 058/110] spi: rockchip: Fix error in getting num-cs property Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 059/110] spi: rockchip: terminate dma transmission when slave abort Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 060/110] drm/vc4: hdmi: Unregister codec device on unbind Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 061/110] x86/kvm: Dont use pv tlb/ipi/sched_yield if on 1 vCPU Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 062/110] net-sysfs: add check for netdevice being present to speed_show Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 063/110] hwmon: (pmbus) Clear pmbus fault/warning bits after read Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 064/110] PCI: Mark all AMD Navi10 and Navi14 GPU ATS as broken Greg Kroah-Hartman
2022-03-14 11:54 ` Greg Kroah-Hartman [this message]
2022-03-14 11:54 ` [PATCH 5.15 066/110] drm/amdgpu: bypass tiling flag check in virtual display case (v2) Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 067/110] Revert "xen-netback: remove hotplug-status once it has served its purpose" Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 068/110] Revert "xen-netback: Check for hotplug-status existence before watching" Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 069/110] ipv6: prevent a possible race condition with lifetimes Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 070/110] tracing: Ensure trace buffer is at least 4096 bytes large Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 071/110] tracing/osnoise: Make osnoise_main to sleep for microseconds Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 072/110] selftest/vm: fix map_fixed_noreplace test failure Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 073/110] selftests/memfd: clean up mapping in mfd_fail_write Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 074/110] ARM: Spectre-BHB: provide empty stub for non-config Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 075/110] fuse: fix fileattr op failure Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 076/110] fuse: fix pipe buffer lifetime for direct_io Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 077/110] staging: rtl8723bs: Fix access-point mode deadlock Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 078/110] staging: gdm724x: fix use after free in gdm_lte_rx() Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 079/110] net: macb: Fix lost RX packet wakeup race in NAPI receive Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 080/110] riscv: alternative only works on !XIP_KERNEL Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 081/110] mmc: meson: Fix usage of meson_mmc_post_req() Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 082/110] riscv: Fix auipc+jalr relocation range checks Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 083/110] tracing/osnoise: Force quiescent states while tracing Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 084/110] arm64: dts: marvell: armada-37xx: Remap IO space to bus address 0x0 Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 085/110] arm64: Ensure execute-only permissions are not allowed without EPAN Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 086/110] arm64: kasan: fix include error in MTE functions Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 087/110] swiotlb: rework "fix info leak with DMA_FROM_DEVICE" Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 088/110] KVM: x86/mmu: kvm_faultin_pfn has to return false if pfh is returned Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 089/110] virtio: unexport virtio_finalize_features Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 090/110] virtio: acknowledge all features before access Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 091/110] net/mlx5: Fix offloading with ESWITCH_IPV4_TTL_MODIFY_ENABLE Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 092/110] ARM: fix Thumb2 regression with Spectre BHB Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 093/110] watch_queue: Fix filter limit check Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 094/110] watch_queue, pipe: Free watchqueue state after clearing pipe ring Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 095/110] watch_queue: Fix to release page in ->release() Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 096/110] watch_queue: Fix to always request a pow-of-2 pipe ring size Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 097/110] watch_queue: Fix the alloc bitmap size to reflect notes allocated Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 098/110] watch_queue: Free the alloc bitmap when the watch_queue is torn down Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 099/110] watch_queue: Fix lack of barrier/sync/lock between post and read Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 100/110] watch_queue: Make comment about setting ->defunct more accurate Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 101/110] x86/boot: Fix memremap of setup_indirect structures Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 102/110] x86/boot: Add setup_indirect support in early_memremap_is_setup_data() Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 103/110] x86/sgx: Free backing memory after faulting the enclave page Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 104/110] x86/traps: Mark do_int3() NOKPROBE_SYMBOL Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 105/110] drm/panel: Select DRM_DP_HELPER for DRM_PANEL_EDP Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 106/110] btrfs: make send work with concurrent block group relocation Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 107/110] drm/i915: Workaround broken BIOS DBUF configuration on TGL/RKL Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 108/110] riscv: dts: k210: fix broken IRQs on hart1 Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 109/110] block: drop unused includes in <linux/genhd.h> Greg Kroah-Hartman
2022-03-14 11:54 ` [PATCH 5.15 110/110] Revert "net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN" Greg Kroah-Hartman
2022-03-14 22:37 ` [PATCH 5.15 000/110] 5.15.29-rc1 review Florian Fainelli
2022-03-14 22:43 ` Ron Economos
2022-03-15  0:53 ` Guenter Roeck
2022-03-15  5:13 ` Naresh Kamboju
2022-03-15  9:04 ` Jon Hunter
2022-03-15 10:58 ` Bagas Sanjaya
2022-03-15 12:32 ` Sudip Mukherjee
2022-03-15 13:49 ` Fox Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220314112744.849259089@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=sashal@kernel.org \
    --cc=shreeya.patel@collabora.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).