mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "mirela.rabulea@oss.nxp.com" <mirela.rabulea@oss.nxp.com>
To: Ming Qian <ming.qian@nxp.com>,
	mchehab@kernel.org, hverkuil-cisco@xs4all.nl
Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interrupt
Date: Sun, 5 Jun 2022 19:42:48 +0300	[thread overview]
Message-ID: <69817804-a618-32ba-06ca-3ec38ff1f124@oss.nxp.com> (raw)
In-Reply-To: <20220530074756.14585-1-ming.qian@nxp.com>

Hi Ming,

On 30.05.2022 10:47, Ming Qian wrote:
> The interrupt STMBUF_HALF may be triggered after frame done.
> It may led to system hang if driver try to access the register after
> power off.
> And interrupt STMBUF_HALF and STMBUF_RTND have no other effect.
> So disable them and the unused interrupts.
> 
> Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> ---
> v2
> - add Fixes tag
>   drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c
> index c482228262a3..258fbee7ab66 100644
> --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c
> +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c
> @@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)
>   
>   void mxc_jpeg_enable_irq(void __iomem *reg, int slot)
>   {
> -	writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));
> +	writel(0xF0C, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));

There is another way, less aggressive, to go around this, disable all 
the interrupts once FRMDONE is received (or some other error condition), 
interrupts will get re-enabled at the next device_run. I checked this 
works, in mxc_jpeg_dec_irq:
buffers_done:
	writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));

Either way, I would also replace this:
	if (!ctx) {
		dev_err(dev,
			"Instance released before the end of transaction.\n");
		/* soft reset only resets internal state, not registers */
		mxc_jpeg_sw_reset(reg);
		/* clear all interrupts */
		writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS));
		goto job_unlock;
	}

With something like:
BUG_ON(!ctx)

The initial intent of this code was to cope with the same problem, 
STMBUF_HALF interrupt received after FRMDONE, which could not be 
cleared, but it was not done right, I can see the hang in some rare 
cases. We should not run into it anymore, with interrupts disabled, 
either the way you proposed, or mine.

Regards,
Mirela

>   }
>   
>   void mxc_jpeg_sw_reset(void __iomem *reg)

  reply	other threads:[~2022-06-05 16:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30  7:47 Ming Qian
2022-06-05 16:42 ` mirela.rabulea [this message]
2022-06-06  2:33   ` Ming Qian
2022-06-06  9:41     ` mirela.rabulea
2022-06-07  1:49       ` Ming Qian
2022-06-07  7:26         ` Ming Qian

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=69817804-a618-32ba-06ca-3ec38ff1f124@oss.nxp.com \
    --to=mirela.rabulea@oss.nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@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

all inboxes | Powered by JetHome®