This is a note to let you know that I've just added the patch titled
iio: ltc2983: fix device probe
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From b76d26d69ecc97ebb24aaf40427a13c808a4f488 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nuno=20S=C3=A1?= <nuno.sa(a)analog.com>
Date: Wed, 11 Aug 2021 15:32:20 +0200
Subject: iio: ltc2983: fix device probe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There is no reason to assume that the IRQ rising edge (indicating that
the device start up phase is done) will happen after we request the IRQ.
If the device is already up by the time we request it, the call to
'wait_for_completion_timeout()' will timeout and we will fail the device
probe even though there's nothing wrong.
Fix it by just polling the status register until we get the indication that
the device is up and running. As a side effect of this fix, requesting the
IRQ is also moved to after the setup function.
Fixes: f110f3188e563 ("iio: temperature: Add support for LTC2983")
Reported-and-tested-by: Drew Fustini <drew(a)pdp7.com>
Reviewed-by: Drew Fustini <drew(a)pdp7.com>
Signed-off-by: Nuno Sá <nuno.sa(a)analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko(a)gmail.com>
Cc: <Stable(a)vger.kernel.org>
Link: https://lore.kernel.org/r/20210811133220.190264-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron(a)huawei.com>
---
drivers/iio/temperature/ltc2983.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index 3b5ba26d7d86..3b4a0e60e605 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -89,6 +89,8 @@
#define LTC2983_STATUS_START_MASK BIT(7)
#define LTC2983_STATUS_START(x) FIELD_PREP(LTC2983_STATUS_START_MASK, x)
+#define LTC2983_STATUS_UP_MASK GENMASK(7, 6)
+#define LTC2983_STATUS_UP(reg) FIELD_GET(LTC2983_STATUS_UP_MASK, reg)
#define LTC2983_STATUS_CHAN_SEL_MASK GENMASK(4, 0)
#define LTC2983_STATUS_CHAN_SEL(x) \
@@ -1362,17 +1364,16 @@ static int ltc2983_parse_dt(struct ltc2983_data *st)
static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
{
- u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0;
+ u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0, status;
int ret;
- unsigned long time;
-
- /* make sure the device is up */
- time = wait_for_completion_timeout(&st->completion,
- msecs_to_jiffies(250));
- if (!time) {
+ /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */
+ ret = regmap_read_poll_timeout(st->regmap, LTC2983_STATUS_REG, status,
+ LTC2983_STATUS_UP(status) == 1, 25000,
+ 25000 * 10);
+ if (ret) {
dev_err(&st->spi->dev, "Device startup timed out\n");
- return -ETIMEDOUT;
+ return ret;
}
st->iio_chan = devm_kzalloc(&st->spi->dev,
@@ -1492,10 +1493,11 @@ static int ltc2983_probe(struct spi_device *spi)
ret = ltc2983_parse_dt(st);
if (ret)
return ret;
- /*
- * let's request the irq now so it is used to sync the device
- * startup in ltc2983_setup()
- */
+
+ ret = ltc2983_setup(st, true);
+ if (ret)
+ return ret;
+
ret = devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler,
IRQF_TRIGGER_RISING, name, st);
if (ret) {
@@ -1503,10 +1505,6 @@ static int ltc2983_probe(struct spi_device *spi)
return ret;
}
- ret = ltc2983_setup(st, true);
- if (ret)
- return ret;
-
indio_dev->name = name;
indio_dev->num_channels = st->iio_channels;
indio_dev->channels = st->iio_chan;
--
2.32.0
The patch titled
Subject: mm/hwpoison: retry with shake_page() for unhandlable pages
has been added to the -mm tree. Its filename is
mm-hwpoison-retry-with-shake_page-for-unhandlable-pages.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-retry-with-shake_page…
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-retry-with-shake_page…
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Naoya Horiguchi <naoya.horiguchi(a)nec.com>
Subject: mm/hwpoison: retry with shake_page() for unhandlable pages
HWPoisonHandlable() sometimes returns false for typical user pages due to
races with average memory events like transfers over LRU lists. This
causes failures in hwpoison handling.
There's retry code for such a case but does not work because the retry
loop reaches the retry limit too quickly before the page settles down to
handlable state. Let get_any_page() call shake_page() to fix it.
Link: https://lkml.kernel.org/r/20210817053703.2267588-1-naoya.horiguchi@linux.dev
Fixes: 25182f05ffed ("mm,hwpoison: fix race with hugetlb page allocation")
Signed-off-by: Naoya Horiguchi <naoya.horiguchi(a)nec.com>
Reported-by: Tony Luck <tony.luck(a)intel.com>
Cc: Oscar Salvador <osalvador(a)suse.de>
Cc: Muchun Song <songmuchun(a)bytedance.com>
Cc: Mike Kravetz <mike.kravetz(a)oracle.com>
Cc: Michal Hocko <mhocko(a)suse.com>
Cc: <stable(a)vger.kernel.org> [5.13]
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
mm/memory-failure.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/mm/memory-failure.c~mm-hwpoison-retry-with-shake_page-for-unhandlable-pages
+++ a/mm/memory-failure.c
@@ -1146,7 +1146,7 @@ static int __get_hwpoison_page(struct pa
* unexpected races caused by taking a page refcount.
*/
if (!HWPoisonHandlable(head))
- return 0;
+ return -EBUSY;
if (PageTransHuge(head)) {
/*
@@ -1199,9 +1199,14 @@ try_again:
}
goto out;
} else if (ret == -EBUSY) {
- /* We raced with freeing huge page to buddy, retry. */
- if (pass++ < 3)
+ /*
+ * We raced with (possibly temporary) unhandlable
+ * page, retry.
+ */
+ if (pass++ < 3) {
+ shake_page(p, 1);
goto try_again;
+ }
goto out;
}
}
_
Patches currently in -mm which might be from naoya.horiguchi(a)nec.com are
mm-hwpoison-retry-with-shake_page-for-unhandlable-pages.patch
mm-sparse-set-section_nid_shift-to-6.patch
This is the start of the stable review cycle for the 5.4.142 release.
There are 64 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Wed, 18 Aug 2021 17:13:49 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.142-rc…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 5.4.142-rc2
Maxim Levitsky <mlevitsk(a)redhat.com>
KVM: nSVM: always intercept VMLOAD/VMSAVE when nested (CVE-2021-3656)
Maxim Levitsky <mlevitsk(a)redhat.com>
KVM: nSVM: avoid picking up unsupported bits from L2 in int_ctl (CVE-2021-3653)
Saeed Mirzamohammadi <saeed.mirzamohammadi(a)oracle.com>
iommu/vt-d: Fix agaw for a supported 48 bit guest address width
Nathan Chancellor <nathan(a)kernel.org>
vmlinux.lds.h: Handle clang's module.{c,d}tor sections
Jeff Layton <jlayton(a)kernel.org>
ceph: take snap_empty_lock atomically with snaprealm refcount change
Jeff Layton <jlayton(a)kernel.org>
ceph: clean up locking annotation for ceph_get_snap_realm and __lookup_snap_realm
Jeff Layton <jlayton(a)kernel.org>
ceph: add some lockdep assertions around snaprealm handling
Sean Christopherson <seanjc(a)google.com>
KVM: VMX: Use current VMCS to query WAITPKG support for MSR emulation
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Protect msi_desc::masked for multi-MSI
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Use msi_mask_irq() in pci_msi_shutdown()
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Correct misleading comments
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Do not set invalid bits in MSI mask
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Enforce MSI[X] entry updates to be visible
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Enforce that MSI-X table entry is masked for update
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Mask all unused MSI-X entries
Thomas Gleixner <tglx(a)linutronix.de>
PCI/MSI: Enable and mask MSI-X early
Ben Dai <ben.dai(a)unisoc.com>
genirq/timings: Prevent potential array overflow in __irq_timings_store()
Bixuan Cui <cuibixuan(a)huawei.com>
genirq/msi: Ensure deactivation on teardown
Babu Moger <Babu.Moger(a)amd.com>
x86/resctrl: Fix default monitoring groups reporting
Thomas Gleixner <tglx(a)linutronix.de>
x86/ioapic: Force affinity setup before startup
Thomas Gleixner <tglx(a)linutronix.de>
x86/msi: Force affinity setup before startup
Thomas Gleixner <tglx(a)linutronix.de>
genirq: Provide IRQCHIP_AFFINITY_PRE_STARTUP
Randy Dunlap <rdunlap(a)infradead.org>
x86/tools: Fix objdump version check again
Pu Lehui <pulehui(a)huawei.com>
powerpc/kprobes: Fix kprobe Oops happens in booke
Xie Yongji <xieyongji(a)bytedance.com>
nbd: Aovid double completion of a request
Longpeng(Mike) <longpeng2(a)huawei.com>
vsock/virtio: avoid potential deadlock when vsock device remove
Maximilian Heyne <mheyne(a)amazon.de>
xen/events: Fix race in set_evtchn_to_irq
Eric Dumazet <edumazet(a)google.com>
net: igmp: increase size of mr_ifc_count
Neal Cardwell <ncardwell(a)google.com>
tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets
Willy Tarreau <w(a)1wt.eu>
net: linkwatch: fix failure to restore device state across suspend/resume
Yang Yingliang <yangyingliang(a)huawei.com>
net: bridge: fix memleak in br_add_if()
Vladimir Oltean <vladimir.oltean(a)nxp.com>
net: dsa: sja1105: fix broken backpressure in .port_fdb_dump
Vladimir Oltean <vladimir.oltean(a)nxp.com>
net: dsa: lantiq: fix broken backpressure in .port_fdb_dump
Vladimir Oltean <vladimir.oltean(a)nxp.com>
net: dsa: lan9303: fix broken backpressure in .port_fdb_dump
Eric Dumazet <edumazet(a)google.com>
net: igmp: fix data-race in igmp_ifc_timer_expire()
Takeshi Misawa <jeliantsurux(a)gmail.com>
net: Fix memory leak in ieee802154_raw_deliver
Ben Hutchings <ben.hutchings(a)mind.be>
net: dsa: microchip: Fix ksz_read64()
Christian Hewitt <christianshewitt(a)gmail.com>
drm/meson: fix colour distortion from HDR set during vendor u-boot
Aya Levin <ayal(a)nvidia.com>
net/mlx5: Fix return value from tracer initialization
Roi Dayan <roid(a)nvidia.com>
psample: Add a fwd declaration for skbuff
Md Fahad Iqbal Polash <md.fahad.iqbal.polash(a)intel.com>
iavf: Set RSS LUT and key in reset handle path
Hangbin Liu <liuhangbin(a)gmail.com>
net: sched: act_mirred: Reset ct info when mirror/redirect skb
Pali Rohár <pali(a)kernel.org>
ppp: Fix generating ifname when empty IFLA_IFNAME is specified
Ben Hutchings <ben.hutchings(a)mind.be>
net: phy: micrel: Fix link detection on ksz87xx switch"
Hans de Goede <hdegoede(a)redhat.com>
platform/x86: pcengines-apuv2: Add missing terminating entries to gpio-lookup tables
Florian Eckert <fe(a)dev.tdt.de>
platform/x86: pcengines-apuv2: revert wiring up simswitch GPIO as LED
DENG Qingfang <dqfext(a)gmail.com>
net: dsa: mt7530: add the missing RxUnicast MIB counter
Richard Fitzgerald <rf(a)opensource.cirrus.com>
ASoC: cs42l42: Fix LRCLK frame start edge
Yajun Deng <yajun.deng(a)linux.dev>
netfilter: nf_conntrack_bridge: Fix memory leak when error
Richard Fitzgerald <rf(a)opensource.cirrus.com>
ASoC: cs42l42: Remove duplicate control for WNF filter frequency
Richard Fitzgerald <rf(a)opensource.cirrus.com>
ASoC: cs42l42: Fix inversion of ADC Notch Switch control
Richard Fitzgerald <rf(a)opensource.cirrus.com>
ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
Richard Fitzgerald <rf(a)opensource.cirrus.com>
ASoC: cs42l42: Correct definition of ADC Volume control
Dongliang Mu <mudongliangabcd(a)gmail.com>
ieee802154: hwsim: fix GPF in hwsim_new_edge_nl
Dongliang Mu <mudongliangabcd(a)gmail.com>
ieee802154: hwsim: fix GPF in hwsim_set_edge_lqi
Dan Williams <dan.j.williams(a)intel.com>
libnvdimm/region: Fix label activation vs errors
Dan Williams <dan.j.williams(a)intel.com>
ACPI: NFIT: Fix support for virtual SPA ranges
Luis Henriques <lhenriques(a)suse.de>
ceph: reduce contention in ceph_check_delayed_caps()
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
i2c: dev: zero out array used for i2c reads from userspace
Takashi Iwai <tiwai(a)suse.de>
ASoC: intel: atom: Fix reference to PCM buffer address
Takashi Iwai <tiwai(a)suse.de>
ASoC: xilinx: Fix reference to PCM buffer address
Colin Ian King <colin.king(a)canonical.com>
iio: adc: Fix incorrect exit of for-loop
Chris Lesiak <chris.lesiak(a)licor.com>
iio: humidity: hdc100x: Add margin to the conversion time
Uwe Kleine-König <u.kleine-koenig(a)pengutronix.de>
iio: adc: ti-ads7950: Ensure CS is deasserted after reading channels
-------------
Diffstat:
Makefile | 4 +-
arch/powerpc/kernel/kprobes.c | 3 +-
arch/x86/include/asm/svm.h | 2 +
arch/x86/kernel/apic/io_apic.c | 6 +-
arch/x86/kernel/apic/msi.c | 13 ++-
arch/x86/kernel/cpu/resctrl/monitor.c | 27 +++--
arch/x86/kvm/svm.c | 18 +--
arch/x86/kvm/vmx/vmx.h | 2 +-
arch/x86/tools/chkobjdump.awk | 1 +
drivers/acpi/nfit/core.c | 3 +
drivers/base/core.c | 1 +
drivers/block/nbd.c | 14 ++-
drivers/gpu/drm/meson/meson_registers.h | 5 +
drivers/gpu/drm/meson/meson_viu.c | 7 +-
drivers/i2c/i2c-dev.c | 5 +-
drivers/iio/adc/palmas_gpadc.c | 4 +-
drivers/iio/adc/ti-ads7950.c | 1 -
drivers/iio/humidity/hdc100x.c | 6 +-
drivers/iommu/intel-iommu.c | 7 +-
drivers/net/dsa/lan9303-core.c | 34 +++---
drivers/net/dsa/lantiq_gswip.c | 14 ++-
drivers/net/dsa/microchip/ksz_common.h | 8 +-
drivers/net/dsa/mt7530.c | 1 +
drivers/net/dsa/sja1105/sja1105_main.c | 4 +-
drivers/net/ethernet/intel/iavf/iavf_main.c | 13 ++-
.../ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 11 +-
drivers/net/ieee802154/mac802154_hwsim.c | 6 +-
drivers/net/phy/micrel.c | 2 -
drivers/net/ppp/ppp_generic.c | 2 +-
drivers/nvdimm/namespace_devs.c | 17 ++-
drivers/pci/msi.c | 125 +++++++++++++--------
drivers/platform/x86/pcengines-apuv2.c | 5 +-
drivers/xen/events/events_base.c | 20 +++-
fs/ceph/caps.c | 17 ++-
fs/ceph/mds_client.c | 25 +++--
fs/ceph/snap.c | 54 +++++----
fs/ceph/super.h | 2 +-
include/asm-generic/vmlinux.lds.h | 1 +
include/linux/device.h | 1 +
include/linux/inetdevice.h | 2 +-
include/linux/irq.h | 2 +
include/linux/msi.h | 2 +-
include/net/psample.h | 2 +
kernel/irq/chip.c | 5 +-
kernel/irq/msi.c | 13 ++-
kernel/irq/timings.c | 5 +
net/bridge/br_if.c | 2 +
net/bridge/netfilter/nf_conntrack_bridge.c | 6 +
net/core/link_watch.c | 5 +-
net/ieee802154/socket.c | 7 +-
net/ipv4/igmp.c | 21 ++--
net/ipv4/tcp_bbr.c | 2 +-
net/sched/act_mirred.c | 3 +
net/vmw_vsock/virtio_transport.c | 7 +-
sound/soc/codecs/cs42l42.c | 39 +++----
sound/soc/intel/atom/sst-mfld-platform-pcm.c | 3 +-
sound/soc/xilinx/xlnx_formatter_pcm.c | 4 +-
57 files changed, 395 insertions(+), 226 deletions(-)
This is the start of the stable review cycle for the 5.10.59 release.
There are 19 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Sun, 15 Aug 2021 15:05:12 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.59-rc…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.10.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 5.10.59-rc1
YueHaibing <yuehaibing(a)huawei.com>
net: xilinx_emaclite: Do not print real IOMEM pointer
Miklos Szeredi <mszeredi(a)redhat.com>
ovl: prevent private clone if bind mount is not allowed
Pali Rohár <pali(a)kernel.org>
ppp: Fix generating ppp unit id when ifname is not specified
Luke D Jones <luke(a)ljones.dev>
ALSA: hda: Add quirk for ASUS Flow x13
Jeremy Szu <jeremy.szu(a)canonical.com>
ALSA: hda/realtek: fix mute/micmute LEDs for HP ProBook 650 G8 Notebook PC
Takashi Iwai <tiwai(a)suse.de>
ALSA: pcm: Fix mmap breakage without explicit buffer setup
Longfang Liu <liulongfang(a)huawei.com>
USB:ehci:fix Kunpeng920 ehci hardware problem
Hans de Goede <hdegoede(a)redhat.com>
vboxsf: Make vboxsf_dir_create() return the handle for the created file
Hans de Goede <hdegoede(a)redhat.com>
vboxsf: Honor excl flag to the dir-inode create op
Adam Ford <aford173(a)gmail.com>
arm64: dts: renesas: beacon: Fix USB ref clock references
Adam Ford <aford173(a)gmail.com>
arm64: dts: renesas: beacon: Fix USB extal reference
Adam Ford <aford173(a)gmail.com>
arm64: dts: renesas: rzg2: Add usb2_clksel to RZ/G2 M/N/H
Mike Rapoport <rppt(a)kernel.org>
mm: make zone_to_nid() and zone_set_nid() available for DISCONTIGMEM
Reinette Chatre <reinette.chatre(a)intel.com>
Revert "selftests/resctrl: Use resctrl/info for feature detection"
Daniel Borkmann <daniel(a)iogearbox.net>
bpf: Add lockdown check for probe_write_user helper
Daniel Borkmann <daniel(a)iogearbox.net>
bpf: Add _kernel suffix to internal lockdown_bpf_read
Allen Pais <apais(a)linux.microsoft.com>
firmware: tee_bnxt: Release TEE shm, session, and context during kexec
Sumit Garg <sumit.garg(a)linaro.org>
tee: Correct inappropriate usage of TEE_SHM_DMA_BUF flag
Sean Christopherson <seanjc(a)google.com>
KVM: SVM: Fix off-by-one indexing when nullifying last used SEV VMCB
-------------
Diffstat:
Makefile | 4 +-
.../boot/dts/renesas/beacon-renesom-baseboard.dtsi | 4 +-
.../arm64/boot/dts/renesas/beacon-renesom-som.dtsi | 6 ++-
arch/arm64/boot/dts/renesas/r8a774a1.dtsi | 15 +++++++
arch/arm64/boot/dts/renesas/r8a774b1.dtsi | 15 +++++++
arch/arm64/boot/dts/renesas/r8a774e1.dtsi | 15 +++++++
arch/x86/kvm/svm/sev.c | 2 +-
drivers/firmware/broadcom/tee_bnxt_fw.c | 14 ++++--
drivers/net/ethernet/xilinx/xilinx_emaclite.c | 5 +--
drivers/net/ppp/ppp_generic.c | 19 ++++++--
drivers/tee/optee/call.c | 2 +-
drivers/tee/optee/core.c | 3 +-
drivers/tee/optee/rpc.c | 5 ++-
drivers/tee/optee/shm_pool.c | 8 +++-
drivers/tee/tee_shm.c | 4 +-
drivers/usb/host/ehci-pci.c | 3 ++
fs/namespace.c | 42 +++++++++++------
fs/vboxsf/dir.c | 28 +++++++-----
include/linux/mmzone.h | 4 +-
include/linux/security.h | 3 +-
include/linux/tee_drv.h | 1 +
kernel/bpf/helpers.c | 4 +-
kernel/trace/bpf_trace.c | 13 +++---
security/security.c | 3 +-
sound/core/pcm_native.c | 5 ++-
sound/pci/hda/patch_realtek.c | 2 +
tools/testing/selftests/resctrl/resctrl.h | 6 +--
tools/testing/selftests/resctrl/resctrlfs.c | 52 +++++-----------------
28 files changed, 178 insertions(+), 109 deletions(-)
This is a note to let you know that I've just added the patch titled
iio: ltc2983: fix device probe
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-testing branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will be merged to the staging-next branch sometime soon,
after it passes testing, and the merge window is open.
If you have any questions about this process, please let me know.
>From b76d26d69ecc97ebb24aaf40427a13c808a4f488 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nuno=20S=C3=A1?= <nuno.sa(a)analog.com>
Date: Wed, 11 Aug 2021 15:32:20 +0200
Subject: iio: ltc2983: fix device probe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There is no reason to assume that the IRQ rising edge (indicating that
the device start up phase is done) will happen after we request the IRQ.
If the device is already up by the time we request it, the call to
'wait_for_completion_timeout()' will timeout and we will fail the device
probe even though there's nothing wrong.
Fix it by just polling the status register until we get the indication that
the device is up and running. As a side effect of this fix, requesting the
IRQ is also moved to after the setup function.
Fixes: f110f3188e563 ("iio: temperature: Add support for LTC2983")
Reported-and-tested-by: Drew Fustini <drew(a)pdp7.com>
Reviewed-by: Drew Fustini <drew(a)pdp7.com>
Signed-off-by: Nuno Sá <nuno.sa(a)analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko(a)gmail.com>
Cc: <Stable(a)vger.kernel.org>
Link: https://lore.kernel.org/r/20210811133220.190264-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron(a)huawei.com>
---
drivers/iio/temperature/ltc2983.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index 3b5ba26d7d86..3b4a0e60e605 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -89,6 +89,8 @@
#define LTC2983_STATUS_START_MASK BIT(7)
#define LTC2983_STATUS_START(x) FIELD_PREP(LTC2983_STATUS_START_MASK, x)
+#define LTC2983_STATUS_UP_MASK GENMASK(7, 6)
+#define LTC2983_STATUS_UP(reg) FIELD_GET(LTC2983_STATUS_UP_MASK, reg)
#define LTC2983_STATUS_CHAN_SEL_MASK GENMASK(4, 0)
#define LTC2983_STATUS_CHAN_SEL(x) \
@@ -1362,17 +1364,16 @@ static int ltc2983_parse_dt(struct ltc2983_data *st)
static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
{
- u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0;
+ u32 iio_chan_t = 0, iio_chan_v = 0, chan, iio_idx = 0, status;
int ret;
- unsigned long time;
-
- /* make sure the device is up */
- time = wait_for_completion_timeout(&st->completion,
- msecs_to_jiffies(250));
- if (!time) {
+ /* make sure the device is up: start bit (7) is 0 and done bit (6) is 1 */
+ ret = regmap_read_poll_timeout(st->regmap, LTC2983_STATUS_REG, status,
+ LTC2983_STATUS_UP(status) == 1, 25000,
+ 25000 * 10);
+ if (ret) {
dev_err(&st->spi->dev, "Device startup timed out\n");
- return -ETIMEDOUT;
+ return ret;
}
st->iio_chan = devm_kzalloc(&st->spi->dev,
@@ -1492,10 +1493,11 @@ static int ltc2983_probe(struct spi_device *spi)
ret = ltc2983_parse_dt(st);
if (ret)
return ret;
- /*
- * let's request the irq now so it is used to sync the device
- * startup in ltc2983_setup()
- */
+
+ ret = ltc2983_setup(st, true);
+ if (ret)
+ return ret;
+
ret = devm_request_irq(&spi->dev, spi->irq, ltc2983_irq_handler,
IRQF_TRIGGER_RISING, name, st);
if (ret) {
@@ -1503,10 +1505,6 @@ static int ltc2983_probe(struct spi_device *spi)
return ret;
}
- ret = ltc2983_setup(st, true);
- if (ret)
- return ret;
-
indio_dev->name = name;
indio_dev->num_channels = st->iio_channels;
indio_dev->channels = st->iio_chan;
--
2.32.0