mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <Balakrishnan.S@microchip.com>
To: <ehristev@kernel.org>, <mchehab@kernel.org>
Cc: <hverkuil@kernel.org>, <sakari.ailus@linux.intel.com>,
	<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH v4 04/10] media: microchip-isc: disable histogram and flush AWB work on teardown
Date: Tue, 11 Aug 2026 11:25:19 +0000	[thread overview]
Message-ID: <d58256e4-a9c5-413a-bba8-49160b8b738a@microchip.com> (raw)
In-Reply-To: <9ea7468e-73b4-4064-acae-8f9fcb0df447@kernel.org>

Hi Eugen,

On 06/08/26 11:56 am, Eugen Hristev wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 8/3/26 13:20, Balakrishnan Sambath wrote:
>> isc_stop_streaming() and the isc_start_streaming() error path dropped the
>> runtime PM reference with the histogram still enabled. A HISDONE firing
>> just before the stop, or a failed isc_update_profile() on the start path,
>> can queue isc_awb_work(), which reads the histogram registers before
>> taking its own PM reference and faults on the unclocked device.
>>
>> Disable the histogram, synchronize the IRQ and flush the work before
>> dropping the PM reference on both paths. synchronize_irq() must come
>> before cancel_work_sync(), so an in-flight handler cannot re-queue
>> awb_work after it is cancelled.
>>
>> Fixes: 93d4a26c3dab ("[media] atmel-isc: add the isc pipeline function")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
>> ---
>>   drivers/media/platform/microchip/microchip-isc-base.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
>> index debbc38717de..54f3093e14fc 100644
>> --- a/drivers/media/platform/microchip/microchip-isc-base.c
>> +++ b/drivers/media/platform/microchip/microchip-isc-base.c
>> @@ -382,6 +382,13 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count)
>>        return 0;
>>
>>   err_configure:
>> +     isc_set_histogram(isc, false);
> 
> I find it odd that an error path would clean up something that the
> enable path did not do. So if the histogram is enabled by calling a
> different function (isc_configure()) , then if isc_configure() failed,
> isc_configure() should cleanup after itself, and you should not do the
> cleanup here.
> 
>> +
>> +     /* let a running IRQ handler finish before the clock is disabled */
>> +     synchronize_irq(isc->irq);
>> +
>> +     cancel_work_sync(&isc->awb_work);
> Same here, if something failed, there should not be any pending
> workqueue left, it should be cleaned by the failing enabler.
> 
> Am I missing something ?

Nope, you're right. Histogram is enabled in isc_configure(), so it 
should clean up there on the isc_update_profile() failure, not in the 
caller. Will move it in v5 and drop from err_configure.

Thanks for the catch.

> 
>> +
>>        pm_runtime_put_sync(isc->dev);
>>   err_pm_get:
>>        v4l2_subdev_call(isc->current_subdev->sd, video, s_stream, 0);
>> @@ -425,9 +432,13 @@ static void isc_stop_streaming(struct vb2_queue *vq)
>>        /* Disable DMA interrupt */
>>        regmap_write(isc->regmap, ISC_INTDIS, ISC_INT_DDONE);
>>
>> +     isc_set_histogram(isc, false);
>> +
>>        /* let a running IRQ handler finish before the clock is disabled */
>>        synchronize_irq(isc->irq);
>>
>> +     cancel_work_sync(&isc->awb_work);
>> +
>>        pm_runtime_put_sync(isc->dev);
>>
>>        /* Disable stream on the sub device */
>>
> 


  reply	other threads:[~2026-08-11 11:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 10:20 [PATCH v4 00/10] media: microchip-isc: AWB, stream-stop and endpoint-ref fixes Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 01/10] media: microchip-isc: fix awb_mutex and lock lifecycle Balakrishnan Sambath
2026-08-05  6:19   ` Eugen Hristev
2026-08-03 10:20 ` [PATCH v4 02/10] media: microchip-isc: take a reference on the parsed endpoints Balakrishnan Sambath
2026-08-07 10:37   ` Eugen Hristev
2026-08-11 11:03     ` Balakrishnan.S
2026-08-12 17:19       ` Eugen Hristev
2026-08-13  5:25         ` Balakrishnan.S
2026-08-03 10:20 ` [PATCH v4 03/10] media: microchip-isc: synchronize the IRQ before disabling clocks on stop Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 04/10] media: microchip-isc: disable histogram and flush AWB work on teardown Balakrishnan Sambath
2026-08-06  6:26   ` Eugen Hristev
2026-08-11 11:25     ` Balakrishnan.S [this message]
2026-08-03 10:20 ` [PATCH v4 05/10] media: microchip-isc: do not touch WB registers when not streaming Balakrishnan Sambath
2026-08-07 10:42   ` Eugen Hristev
2026-08-03 10:20 ` [PATCH v4 06/10] media: microchip-isc: store the unshifted PFE_CFG0 BPS value Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 07/10] media: microchip-isc: fix ISC_PFG_CFG0_BPS macro name typo Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 08/10] media: microchip-isc: fix PM runtime leak in AWB work handler Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 09/10] media: microchip-isc: fix SBGGR10 Bayer pattern Balakrishnan Sambath
2026-08-03 10:20 ` [PATCH v4 10/10] media: microchip-isc: fix WB offset and gain register field masking Balakrishnan Sambath
2026-08-05  6:17   ` Eugen Hristev

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=d58256e4-a9c5-413a-bba8-49160b8b738a@microchip.com \
    --to=balakrishnan.s@microchip.com \
    --cc=ehristev@kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@vger.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®