From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 500E1C433EF for ; Wed, 19 Jan 2022 15:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MDLmdHFw+N4Mul2Qr5SCsVh6dWAqDMrdsSYFTFUkp4g=; b=bgqal+xXOnJ2GE sFqe9FD9C9ycQFDe/j3xqpEgSq+O50ML6AzWRE4f3nLYdgPOU/ROfpDGU/oqz791ApPlM6+15Ba6j 4pZQXEQqKoEbV+qrXXBqbYTKeeefjjfhM4fqiQ66kx88WipTctzXLXRiq1A7MKqAXuLEKRaJ9DOwQ hJJvtclIFqonsR23TPpbTnmVWDDLx3HhkWUs+fAMze5QZlYtakmEQw89Ec2z0HefCAj5ZD6lyg8aY smDYlQGOvnrBqFT0of0lCxbEtRby6JOVO7fzDQFrKS379bn6ocPETanJy5sRzcGahu2uFFeqfm/WR 90WyKo475xj1PSiv5zAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAD50-006BWc-FI; Wed, 19 Jan 2022 15:40:58 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAD4v-006BUm-Ok for linux-arm-kernel@lists.infradead.org; Wed, 19 Jan 2022 15:40:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1642606853; x=1674142853; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=WpbquxOv2hKLFft1q9cVSl59bXBHEQ9QesFmOnN23mI=; b=p8RtBq3abwQDku52lQVr9tsX+vPYM20c9t2HBElhTNTSa/KjaAuotM5M 5y6xg9W0m6+MFhfozfDjzyL3peb5TotDsfirJ+OUrR9wdrqSd9lOMsy3F kV+UFCHt+zQK1RF7ATbu1o0XMOlytOCNBpB927nowgilb0QBcKpZD7haK jD8eqjwK6UHkvDVNt3Qy+A8SmwCMpIWFgmz5N3nSm3z9zhZle4K9v4za/ b/DZnSPlxnUMh6eXRHm1w7pGsTx5RpIAoD3JPQxc7R82k+xdjb6130x39 3A908uZyACW+wlUJSGsRgXHF1bAW2X8JBsZ9snLj+/0mGedxNd0EOpT3h Q==; IronPort-SDR: I8aFEN/6UYCU4CGRezvyyr2x7JeSsk5UNqwMjEeLUsoMHzXEO5hqcropkzGBOaSqCRY1HKfOK4 8f+u11x8DzCd1ZIuLCz4ySC6eMy05sanEOW7n3VxDvaKoqM9kcd+Ti4+dIRU7sSB1sp1igLlku EjQa5sceKlvXNKSR9hnA0rJzCmfAMRfWCLcounB3DRneNfFAA7LZzxQBBiUPVO4szCEtWClqcK soQrd3b8sKKEOWwZ5Gkzx3KC3gM5s20Y2JixNM4I+57T+LVnEU0xSf/yFekJ4r9RGJDbPZOvwx 08gqJc4kMfo0XM27e6s2HR8r X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="143210706" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Jan 2022 08:40:44 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 19 Jan 2022 08:40:43 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17 via Frontend Transport; Wed, 19 Jan 2022 08:40:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehn9/DvYxOKLHM9jFPs2o65kBZSvRr2Nr3MU1r53GFQmcxH0KD0rvEcQDG79LgfSnJyoGaldnE0ifsAlEMd/JdUkoUx/t9azDeJ7QyTWLkDnfFMrmA1OhGWPa8HPdtS2q2UCQASP56j7Qc4jgeqiZ0Tf0E3sFnH6vOh7amfK8i1bI8O9xWANR4DIdqeTssFwadmi7YglB6LdCbkCHoSVnjnWs3gm3cwNbRouFsbqzy1RfqEwZBtjXN015XxfyVR6Q9h65W7J0UagnuM8j+jwQhAcJveQvQpaB7SarwkH1ere/+pGgnq36wg/dj5YYRHh4a7LlHePN4k/ZD0dkterLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WpbquxOv2hKLFft1q9cVSl59bXBHEQ9QesFmOnN23mI=; b=cdSgkvvdIrAFU9p5I7nLmCsFhZIQZhccw9Ypdi1ENO5U6yqlbRbEoUCEkzoUzNPV7Qi/7Mrax8vr/tZUs9Np8fWvN9KmFg/5KofRfCIcYe18nsYbgvK0bUfGcOqDfDwsXvEMlY7r6QiCQxqd8N8SLXfDyS/qFbVrA/uLY5URJXcZQs6DmpxrnLHxKXAc9qkft7Lv3epYm6pldWXydSwE8gJgYpnU+UBmv57AqIbP23k+d/TZ57f6QGXGIQMLpEBjVGHC5vEmZilu6Zb38zdRmLyI4wvaHm8ieugjPtElWoEbfk3tGxETh7UhrsGhpFb7WLgBSyxJL/Fi/g/OLMYyCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WpbquxOv2hKLFft1q9cVSl59bXBHEQ9QesFmOnN23mI=; b=gdFtDphH8vLTXomFWfYivCHR+jQJ5qhPju32DN3j9LO/EvRynzbTHf3XHCuX/nvfEz3MAoctMe7l56eo170RCLeIlvS8/Ej88RAY9wYAK9GTcRokmd5OxB0lAlWrpn8rlJsph5y7erYauSPSiiwieeyRPlZXNufUnmEXwX+vc5U= Received: from PH0PR11MB4920.namprd11.prod.outlook.com (2603:10b6:510:41::22) by DM6PR11MB4673.namprd11.prod.outlook.com (2603:10b6:5:2a4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 15:40:38 +0000 Received: from PH0PR11MB4920.namprd11.prod.outlook.com ([fe80::d7c:834f:4591:3c0c]) by PH0PR11MB4920.namprd11.prod.outlook.com ([fe80::d7c:834f:4591:3c0c%8]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 15:40:38 +0000 From: To: Subject: Re: [PATCH v3 17/23] media: atmel: atmel-isc-base: use mutex to lock awb workqueue from streaming Thread-Topic: [PATCH v3 17/23] media: atmel: atmel-isc-base: use mutex to lock awb workqueue from streaming Thread-Index: AQHX8CkFHNpo7YqX4EySeyV1oTOVzaxfRNeAgAtwpAA= Date: Wed, 19 Jan 2022 15:40:38 +0000 Message-ID: References: <20211213134940.324266-1-eugen.hristev@microchip.com> <20211213134940.324266-18-eugen.hristev@microchip.com> <20220112085835.twjhxjnigl3uhgqj@uno.localdomain> In-Reply-To: <20220112085835.twjhxjnigl3uhgqj@uno.localdomain> Accept-Language: en-US, ro-RO Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microchip.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1cae5c42-7971-4c9e-8bc2-08d9db620ad4 x-ms-traffictypediagnostic: DM6PR11MB4673:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:644; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3uK3GSbzi/2AwbHogXqaWvzndoMQsU1wNJRIyJ5iWuid++cgkOaNCV2X2sGQXyfsGpIyKBYPIp4qmBSR1oc+w7HS6BLh8e8cnkXG1rJOQknH+v77q/xKvgeRij0BeBwSv6Z/TPkYHJbAJnH1s7n4Sj4KtGj9IF2GPiUPKuCuhBBPbXZHpz5YrnjCPmqI/Wo0mUYDzg0oadc7Bgr+l2twUdH1hUIWa6VnjDX6aCeKJfUhBiFLpyii1wRcF847wJ0Nk2XFdSYNFbjAYB6PpDjs5vsSeRn1YF5hLFVtBFp3TnEo5rFVKLmPgN+N3Tv33+NFvO9TrunEEoKkgVeJFgg4f278a+maomWixmVBbXet1bSxyd3ojCQmDSeQ6kZt5y6MYG7LsLLwYWFjoHAn9Xp1CNaW54bdRBSd8mmvP/4kXPToJjhvDdRrMjueCmE83EApm76mVJd9+FZpOKISSE5kVSHdzzi5d+nzBl0gVuzPTpPJE6wbi6/BnOtw4PohBu6k3EMcealgSZc9E7ExygTUPNINiGhtwh4aIN4IQxjC3aZns2VwbVUI+FGCfe9ZSdQbcSda+xhn+KplDEK8c9mTLgMJRdRa6A5n2r7t3B3FtiW2kldVyRa2KNmtonzBS/eA3WMhKFPDlsVHjkMOQfVkv7ApSpWThQJEsihQ0VA2MKxrhJDd6WJoudmo4dlCE1UX1uirM06F98AikvLkoSA8NfQlKRAKznKOqxGdTpa/bxmejiiXapJmJyclcrNUMKr91lmU5L2tomg4IgMY68cMuuXd6x0NQwrG9HNgC3Q+1/SRBCHlQa2+t/0z3ywVBfIaKa7msTXvK7UyglMDvNJqO/zYL+GL7BJfE5ybPqNP+Q4= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB4920.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(71200400001)(38100700002)(6512007)(122000001)(966005)(186003)(66946007)(31686004)(26005)(86362001)(36756003)(91956017)(76116006)(53546011)(6506007)(508600001)(31696002)(6916009)(316002)(5660300002)(66446008)(64756008)(66556008)(66476007)(83380400001)(6486002)(107886003)(2616005)(8676002)(54906003)(8936002)(4326008)(38070700005)(2906002)(45980500001)(43740500002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?Z2N3WHNWS3NOTWVCaWZsWFhHN2w5Zzc4WjV5empEMWtOYzNYWFBOVGJmV0tU?= =?utf-8?B?WGdHanM1RndIa2Ziajh0Q1YzbGNpNkZ3R2hGNkJtbk54VnFuRmFOQXhFbUNr?= =?utf-8?B?L2JhVTFWYXBOZndBaGU1ZTF2RUtUeEc3d0VmWTZjY3ltbjB1bjlvdG43ZEFs?= =?utf-8?B?S2JIaUJBVzAxOEphejJUblQ0eWhDNjVhenZRSUtOVU9HSzVOUm9FSTNDaDNn?= =?utf-8?B?RFRBMUxkMkFXY0FFdzZUdFplS1VSZ2s5bkI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95d3MzZUF1U0pxUE9ORXVLU0tuNDMzcWxJeU5nOGZ1RTQ0?= =?utf-8?B?YWNHc3hxbzIweUxnQzNFN0dVV2p3M0dCOEYxRlF5S1ZVdUFWQmppUHNWSnNM?= =?utf-8?B?U2RFeEkyUjlKdnpMdXZaeVpNbEhJbUhzcmpwT1BxUlRsenhwVFQ3eWIyTmVC?= =?utf-8?B?bnRNT3Ryb2swNmhqQ2oyNXF5ZHNnPT0=?= Content-ID: <2BCD9C5A714FF94AB7323C0E29DBB0DB@namprd11.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB4920.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cae5c42-7971-4c9e-8bc2-08d9db620ad4 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jan 2022 15:40:38.3834 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KqRNs4Pp2QJqP5qEUVCok0jb1/f80PSDmx0ujYGZK/Jj5OtpESxIEkhswUTrvPS2hed5XzWQOxg07nnpUMehaZ6o60f7E3Md6NvJ31JbTg4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4673 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220119_074054_028241_08E3FD95 X-CRM114-Status: GOOD ( 29.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, sakari.ailus@iki.fi, laurent.pinchart@ideasonboard.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/12/22 10:58 AM, Jacopo Mondi wrote: > Hi Eugen > > On Mon, Dec 13, 2021 at 03:49:34PM +0200, Eugen Hristev wrote: >> The AWB workqueue runs in a kernel thread and needs to be synchronized >> w.r.t. the streaming status. >> It is possible that streaming is stopped while the AWB workq is running. >> In this case it is likely that the check for isc->stop is done at one point >> in time, but the AWB computations are done later, including a call to >> isc_update_profile, which requires streaming to be started. >> Thus , isc_update_profile will fail if during this operation sequence the >> streaming was stopped. >> To solve this issue, a mutex is added, that will serialize the awb work and >> streaming stopping, with the mention that either streaming is stopped >> completely including termination of the last frame is done, and after that >> the AWB work can check stream status and stop; either first AWB work is >> completed and after that the streaming can stop correctly. >> The awb spin lock cannot be used since this spinlock is taken in the same >> context and using it in the stop streaming will result in a recursion BUG. >> >> Signed-off-by: Eugen Hristev >> --- >> drivers/media/platform/atmel/atmel-isc-base.c | 31 ++++++++++++++++--- >> drivers/media/platform/atmel/atmel-isc.h | 1 + >> 2 files changed, 28 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c >> index b0c3ed21f372..53cac1aac0fd 100644 >> --- a/drivers/media/platform/atmel/atmel-isc-base.c >> +++ b/drivers/media/platform/atmel/atmel-isc-base.c >> @@ -401,6 +401,7 @@ static void isc_stop_streaming(struct vb2_queue *vq) >> struct isc_buffer *buf; >> int ret; >> >> + mutex_lock(&isc->awb_mutex); >> v4l2_ctrl_activate(isc->do_wb_ctrl, false); >> >> isc->stop = true; >> @@ -410,6 +411,8 @@ static void isc_stop_streaming(struct vb2_queue *vq) >> v4l2_err(&isc->v4l2_dev, >> "Timeout waiting for end of the capture\n"); >> >> + mutex_unlock(&isc->awb_mutex); >> + >> /* Disable DMA interrupt */ >> regmap_write(isc->regmap, ISC_INTDIS, ISC_INT_DDONE); >> >> @@ -1416,10 +1419,6 @@ static void isc_awb_work(struct work_struct *w) >> u32 min, max; >> int ret; >> >> - /* streaming is not active anymore */ >> - if (isc->stop) >> - return; >> - >> if (ctrls->hist_stat != HIST_ENABLED) >> return; >> >> @@ -1470,7 +1469,24 @@ static void isc_awb_work(struct work_struct *w) >> } >> regmap_write(regmap, ISC_HIS_CFG + isc->offsets.his, >> hist_id | baysel | ISC_HIS_CFG_RAR); > > isc_stop_streaming() calls runtime_put and here you access the hw. Hi Jacopo, That is correct. However the awb routine will call resume and get here (before accessing the hardware) : https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/atmel/atmel-isc-base.c#L1722 So I think that we are good as we are now > > Feels like it's safer to hold the mutex for the whole duration of the > AWB routine ? > I prefer to have the critical section as little as possible. As we are only synchronizing the 'streaming status' , only this should be under the lock. If you have a different opinion, let me know. Eugen >> + >> + /* >> + * We have to make sure the streaming has not stopped meanwhile. >> + * ISC requires a frame to clock the internal profile update. >> + * To avoid issues, lock the sequence with a mutex >> + */ >> + mutex_lock(&isc->awb_mutex); >> + >> + /* streaming is not active anymore */ >> + if (isc->stop) { >> + mutex_unlock(&isc->awb_mutex); >> + return; >> + }; >> + >> isc_update_profile(isc); >> + >> + mutex_unlock(&isc->awb_mutex); >> + >> /* if awb has been disabled, we don't need to start another histogram */ >> if (ctrls->awb) >> regmap_write(regmap, ISC_CTRLEN, ISC_CTRL_HISREQ); >> @@ -1549,6 +1565,8 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl) >> >> isc_update_awb_ctrls(isc); >> >> + mutex_lock(&isc->awb_mutex); >> + >> if (!isc->stop) { >> /* >> * If we are streaming, we can update profile to >> @@ -1563,6 +1581,7 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl) >> */ >> v4l2_ctrl_activate(isc->do_wb_ctrl, false); >> } >> + mutex_unlock(&isc->awb_mutex); >> >> /* if we have autowhitebalance on, start histogram procedure */ >> if (ctrls->awb == ISC_WB_AUTO && !isc->stop && >> @@ -1754,6 +1773,7 @@ static void isc_async_unbind(struct v4l2_async_notifier *notifier, >> { >> struct isc_device *isc = container_of(notifier->v4l2_dev, >> struct isc_device, v4l2_dev); >> + mutex_destroy(&isc->awb_mutex); >> cancel_work_sync(&isc->awb_work); >> video_unregister_device(&isc->video_dev); >> v4l2_ctrl_handler_free(&isc->ctrls.handler); >> @@ -1866,6 +1886,8 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) >> isc->current_subdev = container_of(notifier, >> struct isc_subdev_entity, notifier); >> mutex_init(&isc->lock); >> + mutex_init(&isc->awb_mutex); >> + >> init_completion(&isc->comp); >> >> /* Initialize videobuf2 queue */ >> @@ -1941,6 +1963,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) >> video_unregister_device(vdev); >> >> isc_async_complete_err: >> + mutex_destroy(&isc->awb_mutex); >> mutex_destroy(&isc->lock); >> return ret; >> } >> diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h >> index 0b6370d7775f..c2cb805faff3 100644 >> --- a/drivers/media/platform/atmel/atmel-isc.h >> +++ b/drivers/media/platform/atmel/atmel-isc.h >> @@ -307,6 +307,7 @@ struct isc_device { >> struct work_struct awb_work; >> >> struct mutex lock; /* serialize access to file operations */ >> + struct mutex awb_mutex; /* serialize access to streaming status from awb work queue */ >> spinlock_t awb_lock; /* serialize access to DMA buffers from awb work queue */ >> >> struct regmap_field *pipeline[ISC_PIPE_LINE_NODE_NUM]; >> -- >> 2.25.1 >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel