Message ID | 20220415152811.636419-42-paul.kocialkowski@bootlin.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Allwinner A31/A83T MIPI CSI-2 and A31 ISP / CSI Rework | expand |
Dne petek, 15. april 2022 ob 17:28:07 CEST je Paul Kocialkowski napisal(a): > Check against the enabled bits and make sure capture is running before > serving an interrupt, to add extra safety in the process. > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Best regards, Jernej > --- > drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c > b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index > 43b6557b3207..3963a88a2e0b 100644 > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c > @@ -105,13 +105,17 @@ static void sun6i_csi_v4l2_cleanup(struct > sun6i_csi_device *csi_dev) static irqreturn_t sun6i_csi_interrupt(int irq, > void *private) > { > struct sun6i_csi_device *csi_dev = private; > + bool capture_streaming = csi_dev->capture.state.streaming; > struct regmap *regmap = csi_dev->regmap; > - u32 status; > + u32 status = 0, enable = 0; > > regmap_read(regmap, SUN6I_CSI_CH_INT_STA_REG, &status); > + regmap_read(regmap, SUN6I_CSI_CH_INT_EN_REG, &enable); > > - if (!(status & 0xFF)) > + if (!status) > return IRQ_NONE; > + else if (!(status & enable) || !capture_streaming) > + goto complete; > > if ((status & SUN6I_CSI_CH_INT_STA_FIFO0_OF) || > (status & SUN6I_CSI_CH_INT_STA_FIFO1_OF) || > @@ -132,6 +136,7 @@ static irqreturn_t sun6i_csi_interrupt(int irq, void > *private) if (status & SUN6I_CSI_CH_INT_STA_VS) > sun6i_csi_capture_sync(csi_dev); > > +complete: > regmap_write(regmap, SUN6I_CSI_CH_INT_STA_REG, status); > > return IRQ_HANDLED;
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 43b6557b3207..3963a88a2e0b 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -105,13 +105,17 @@ static void sun6i_csi_v4l2_cleanup(struct sun6i_csi_device *csi_dev) static irqreturn_t sun6i_csi_interrupt(int irq, void *private) { struct sun6i_csi_device *csi_dev = private; + bool capture_streaming = csi_dev->capture.state.streaming; struct regmap *regmap = csi_dev->regmap; - u32 status; + u32 status = 0, enable = 0; regmap_read(regmap, SUN6I_CSI_CH_INT_STA_REG, &status); + regmap_read(regmap, SUN6I_CSI_CH_INT_EN_REG, &enable); - if (!(status & 0xFF)) + if (!status) return IRQ_NONE; + else if (!(status & enable) || !capture_streaming) + goto complete; if ((status & SUN6I_CSI_CH_INT_STA_FIFO0_OF) || (status & SUN6I_CSI_CH_INT_STA_FIFO1_OF) || @@ -132,6 +136,7 @@ static irqreturn_t sun6i_csi_interrupt(int irq, void *private) if (status & SUN6I_CSI_CH_INT_STA_VS) sun6i_csi_capture_sync(csi_dev); +complete: regmap_write(regmap, SUN6I_CSI_CH_INT_STA_REG, status); return IRQ_HANDLED;
Check against the enabled bits and make sure capture is running before serving an interrupt, to add extra safety in the process. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> --- drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)