diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-04-12 06:32:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-04-17 05:50:05 -0400 |
commit | ee2d243d6beea21e79631fa3442e92ad0fa11a6a (patch) | |
tree | 1fb02a176ae653ffccd798831558174a44336d90 /drivers/media/rc | |
parent | ca33f8f61a6e4376cc006b713a353e7200e66f59 (diff) |
media: st_rc: Don't stay on an IRQ handler forever
As warned by smatch:
drivers/media/rc/st_rc.c:110 st_rc_rx_interrupt() warn: this loop depends on readl() succeeding
If something goes wrong at readl(), the logic will stay there
inside an IRQ code forever. This is not the nicest thing to
do :-)
So, add a timeout there, preventing staying inside the IRQ
for more than 10ms.
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r-- | drivers/media/rc/st_rc.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c index d2efd7b2c3bc..c855b177103c 100644 --- a/drivers/media/rc/st_rc.c +++ b/drivers/media/rc/st_rc.c | |||
@@ -96,19 +96,24 @@ static void st_rc_send_lirc_timeout(struct rc_dev *rdev) | |||
96 | 96 | ||
97 | static irqreturn_t st_rc_rx_interrupt(int irq, void *data) | 97 | static irqreturn_t st_rc_rx_interrupt(int irq, void *data) |
98 | { | 98 | { |
99 | unsigned long timeout; | ||
99 | unsigned int symbol, mark = 0; | 100 | unsigned int symbol, mark = 0; |
100 | struct st_rc_device *dev = data; | 101 | struct st_rc_device *dev = data; |
101 | int last_symbol = 0; | 102 | int last_symbol = 0; |
102 | u32 status; | 103 | u32 status, int_status; |
103 | DEFINE_IR_RAW_EVENT(ev); | 104 | DEFINE_IR_RAW_EVENT(ev); |
104 | 105 | ||
105 | if (dev->irq_wake) | 106 | if (dev->irq_wake) |
106 | pm_wakeup_event(dev->dev, 0); | 107 | pm_wakeup_event(dev->dev, 0); |
107 | 108 | ||
108 | status = readl(dev->rx_base + IRB_RX_STATUS); | 109 | /* FIXME: is 10ms good enough ? */ |
110 | timeout = jiffies + msecs_to_jiffies(10); | ||
111 | do { | ||
112 | status = readl(dev->rx_base + IRB_RX_STATUS); | ||
113 | if (!(status & (IRB_FIFO_NOT_EMPTY | IRB_OVERFLOW))) | ||
114 | break; | ||
109 | 115 | ||
110 | while (status & (IRB_FIFO_NOT_EMPTY | IRB_OVERFLOW)) { | 116 | int_status = readl(dev->rx_base + IRB_RX_INT_STATUS); |
111 | u32 int_status = readl(dev->rx_base + IRB_RX_INT_STATUS); | ||
112 | if (unlikely(int_status & IRB_RX_OVERRUN_INT)) { | 117 | if (unlikely(int_status & IRB_RX_OVERRUN_INT)) { |
113 | /* discard the entire collection in case of errors! */ | 118 | /* discard the entire collection in case of errors! */ |
114 | ir_raw_event_reset(dev->rdev); | 119 | ir_raw_event_reset(dev->rdev); |
@@ -148,8 +153,7 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data) | |||
148 | 153 | ||
149 | } | 154 | } |
150 | last_symbol = 0; | 155 | last_symbol = 0; |
151 | status = readl(dev->rx_base + IRB_RX_STATUS); | 156 | } while (time_is_after_jiffies(timeout)); |
152 | } | ||
153 | 157 | ||
154 | writel(IRB_RX_INTS, dev->rx_base + IRB_RX_INT_CLEAR); | 158 | writel(IRB_RX_INTS, dev->rx_base + IRB_RX_INT_CLEAR); |
155 | 159 | ||