FAILED: patch "[PATCH] iio: imu: st_lsm6dsx: fix edge-trigger interrupts" failed to apply to 4.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3f9bce7a22a3f8ac9d885c9d75bc45569f24ac8b Mon Sep 17 00:00:00 2001
From: Lorenzo Bianconi <[email protected]>
Date: Sat, 14 Nov 2020 19:39:05 +0100
Subject: [PATCH] iio: imu: st_lsm6dsx: fix edge-trigger interrupts
If we are using edge IRQs, new samples can arrive while processing current interrupt since there are no hw guarantees the irq line stays "low" long enough to properly detect the new interrupt. In this case the new sample will be missed.
Polling FIFO status register in st_lsm6dsx_handler_thread routine allow us to read new samples even if the interrupt arrives while processing previous data and the timeslot where the line is "low" is too short to be properly detected.
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +21 -5
@@ -2069,19 +2069,35 @@ st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw)static irqreturn_t st_lsm6dsx_handler_thread (int irq,void *private) {struct st_lsm6dsx_hw *hw = private; +int fifo_len =0 , len;bool event; -int count; event =st_lsm6dsx_report_motion_event (hw);if (!hw->settings->fifo_ops.read_fifo)return event ?IRQ_HANDLED :IRQ_NONE ; -mutex_lock (&hw->fifo_lock); - count = hw->settings->fifo_ops.read_fifo (hw); -mutex_unlock (&hw->fifo_lock); +/* +* If we are using edge IRQs, new samples can arrive while +* processing current interrupt since there are no hw +* guarantees the irq line stays "low" long enough to properly +* detect the new interrupt. In this case the new sample will +* be missed. +* Polling FIFO status register allow us to read new +* samples even if the interrupt arrives while processing +* previous data and the timeslot where the line is "low" is +* too short to be properly detected. +*/ +do { +mutex_lock (&hw->fifo_lock); + len = hw->settings->fifo_ops.read_fifo (hw); +mutex_unlock (&hw->fifo_lock); + +if (len >0 ) + fifo_len += len; + }while (len >0 ); -return count || event ?IRQ_HANDLED :IRQ_NONE ; +return fifo_len || event ?IRQ_HANDLED :IRQ_NONE ; }static int st_lsm6dsx_irq_setup (struct st_lsm6dsx_hw *hw)
Hi Greg,
Quoted 5 lines · On Mon, Dec 28, 2020 at 12:12:55PM +0100, [email protected] wrote:
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Here is the backport along with ec76d918f230 ("iio: imu: st_lsm6dsx: flip irq return logic") which made backporting little easier.
--
Regards
Sudip
From a1dd5a8427b056ae7574a622090401c455f0e01f Mon Sep 17 00:00:00 2001
From: Sean Nyekjaer <[email protected]>
Date: Mon, 15 Jul 2019 09:07:15 +0200
Subject: [PATCH 1/2] iio: imu: st_lsm6dsx: flip irq return logic
commit ec76d918f23034f9f662539ca9c64e2ae3ba9fba upstream
No need for using reverse logic in the irq return, fix this by flip things around.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +1 -1
@@ -481,7 +481,7 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) count =st_lsm6dsx_read_fifo (hw);mutex_unlock (&hw->fifo_lock); -return !count ?IRQ_NONE :IRQ_HANDLED ; +return count ?IRQ_HANDLED :IRQ_NONE ; }static int st_lsm6dsx_buffer_preenable (struct iio_dev *iio_dev)
Signature · 1 line
2.11.0
From 98d9a672f7da10abf7bb3cb36ec5dc755cf6a70d Mon Sep 17 00:00:00 2001
From: Lorenzo Bianconi <[email protected]>
Date: Sat, 14 Nov 2020 19:39:05 +0100
Subject: [PATCH 2/2] iio: imu: st_lsm6dsx: fix edge-trigger interrupts
commit 3f9bce7a22a3f8ac9d885c9d75bc45569f24ac8b upstream
If we are using edge IRQs, new samples can arrive while processing current interrupt since there are no hw guarantees the irq line stays "low" long enough to properly detect the new interrupt. In this case the new sample will be missed.
Polling FIFO status register in st_lsm6dsx_handler_thread routine allow us to read new samples even if the interrupt arrives while processing previous data and the timeslot where the line is "low" is too short to be properly detected.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +21 -5
@@ -475,13 +475,29 @@ static irqreturn_t st_lsm6dsx_handler_irq(int irq, void *private)static irqreturn_t st_lsm6dsx_handler_thread (int irq,void *private) {struct st_lsm6dsx_hw *hw = private; -int count; +int fifo_len =0 , len; -mutex_lock (&hw->fifo_lock); - count =st_lsm6dsx_read_fifo (hw); -mutex_unlock (&hw->fifo_lock); +/* +* If we are using edge IRQs, new samples can arrive while +* processing current interrupt since there are no hw +* guarantees the irq line stays "low" long enough to properly +* detect the new interrupt. In this case the new sample will +* be missed. +* Polling FIFO status register allow us to read new +* samples even if the interrupt arrives while processing +* previous data and the timeslot where the line is "low" is +* too short to be properly detected. +*/ +do { +mutex_lock (&hw->fifo_lock); + len =st_lsm6dsx_read_fifo (hw); +mutex_unlock (&hw->fifo_lock); + +if (len >0 ) + fifo_len += len; + }while (len >0 ); -return count ?IRQ_HANDLED :IRQ_NONE ; +return fifo_len ?IRQ_HANDLED :IRQ_NONE ; }static int st_lsm6dsx_buffer_preenable (struct iio_dev *iio_dev)
Signature · 1 line
2.11.0