Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp17215lqp; Thu, 4 Apr 2024 06:06:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZJyiGiJ6jmrPnkjByrfxZqPf0Qiq1LaML5gp3WEPXFIb1IQeWhBQDp0iuDr4GzTU1HYwKcIJnQhNkZZMQYmcR50xJU3c/6h9hu6YyWw== X-Google-Smtp-Source: AGHT+IFLbvwcz83uJ+CmFcIkhEJZiwu0s9IQbSTLj+XR2K4FntYtcFI69muzDBFVrm6G2zOiQQpz X-Received: by 2002:a05:6512:4d1:b0:516:d14b:435f with SMTP id w17-20020a05651204d100b00516d14b435fmr521469lfq.14.1712236018218; Thu, 04 Apr 2024 06:06:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712236018; cv=pass; d=google.com; s=arc-20160816; b=KSXlMB7bQIVNlK2unTkfsc1Rr81hO7lN/OK5IUAJmE5WNjYKFwJQ1uyXR9ERz+VFoF cbkhFQtxgfF1ljoPKaGVg/FPJc1FbQfHd40v6d538B1Z9SyjycJDhYPpYAlyKjIghGVq jKuVnKFafXa8QhLcNLelZVxVprHatQYoRqC/48CA/mByGORwNxabkyCkR36PTHXA2KIv E1M4O19fb0xuWTMosagwhfFnySjagDhkKMez9AENynzfYb0fjnFfMUzOQpBuxS3RMaal nI5uVEylSxfy2tgbtfSphb7+ZbdbhxiKoXyOFTo/yI52ma7SBbN4nn3EYtDGYbGgj6jt gSQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=3m0OMHpON345MeR0wjFXDy3P/7mbhAzLFnOy/lxEsho=; fh=vVMXen7LgEIt3T4ZRK1KNs4b5yhOtL/lEbm6K1tfPPo=; b=z9/zjyfZ14fMGmQEFgcyLgfP4Q8HvOZ+6eNuk1djsoAGKq6IhDh0a/RMDChPMwTO3c aQh+Z7vyt0p9vwW4C0bx3mQVQT68WrVWc/xOm+w3LU5zJLFpHV2W4Mt7kAwQvvMuWts3 ZeHOl+A6xWzA1zLrc95LnGYwT1RdD+35c0U121j7L5W97kCBrzCoU1ESpDB/DeyZA0dC tbuKG6lhJeR4OfvswBiB6Eu+4HT8GEkqDM2s7YoDFBzyzRZvPgt6WoV9PFCLw2hhQ7tS /3tdgl65oDO7iLv7Om3MN4HfkobNfVcYNzttZEeohF/gzk+AUoiuRhHgfTWre9G2nXgU HnlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=hZb9bTie; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-131485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131485-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id js9-20020a17090797c900b00a4ea2bec81fsi1699179ejc.128.2024.04.04.06.06.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 06:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=hZb9bTie; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-131485-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131485-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B79531F2546E for ; Thu, 4 Apr 2024 13:06:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93CAFEDF; Thu, 4 Apr 2024 13:06:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hZb9bTie" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED2C2763F4; Thu, 4 Apr 2024 13:06:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712236009; cv=none; b=MUnMD8YV76oSqWhSMI7xpjUv6MQzFhPSQK3e/FomZZd8tm+BkFOm3T9G0fCeK1iwKhtIxXD+bEXWSkLNVEeVRYKZSzbxWcDfdr6hHXCBGwzbBjrt6b0G1s9vraykPHRe4/ttIcLXAbEDcveQg62gyFf622LUc7teXrJw06+Nrdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712236009; c=relaxed/simple; bh=VHskOTBOqICY1MwbN4wvhawfGTGgcbvKXeRdEiLLxXY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EhmF9KuSpDyJwt/hn8K9CG3NI2iF+UHhhIzOSnd3qmyUZYxWw/1RnjrtODWt4l6LY48v6fN/1KvtsNGx1yPpP9JQsIspR9Syhj3nnijAbcPKLAXdQREXgNYfbFu0I328BA1NHOt2Kiwb19zFBGbR4mJFV8BWqk0lChjWZ89c9TA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=hZb9bTie; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from [192.168.88.20] (91-154-34-181.elisa-laajakaista.fi [91.154.34.181]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7EF0512D; Thu, 4 Apr 2024 15:06:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712235968; bh=VHskOTBOqICY1MwbN4wvhawfGTGgcbvKXeRdEiLLxXY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hZb9bTietCbCo5gxz1tor0WQFUdDmOBqAvVrDGNJ57LyQeagwmrqB+5dmysZR2MKF 6IkdijPs/HrzbUS87gsDtr1S9aR009XzJ7QLmnLQcnZaDUa9Unok0RAlEYkrcHCPrN LSMVf6+Ir3pbtxBEd0lcjy5rRbti2PyY+H68YaRU= Message-ID: <1d1d5631-4758-46ad-a62b-8fe767e2c681@ideasonboard.com> Date: Thu, 4 Apr 2024 16:06:43 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] media: subdev: Fix use of sd->enabled_streams in call_s_stream() To: Laurent Pinchart Cc: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Umang Jain , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240404-enable-streams-impro-v1-0-1017a35bbe07@ideasonboard.com> <20240404-enable-streams-impro-v1-2-1017a35bbe07@ideasonboard.com> <20240404130022.GQ23803@pendragon.ideasonboard.com> Content-Language: en-US From: Tomi Valkeinen Autocrypt: addr=tomi.valkeinen@ideasonboard.com; keydata= xsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi9Z4l+uUN4Zdw2 wCEZjx3o0Z34diXBaMRJ3rAk9yB90UJAnLtb8A97Oq64DskLF81GCYB2P1i0qrG7UjpASgCA Ru0lVvxsWyIwSfoYoLrazbT1wkWRs8YBkkXQFfL7Mn3ZMoGPcpfwYH9O7bV1NslbmyJzRCMO eYV258gjCcwYlrkyIratlHCek4GrwV8Z9NQcjD5iLzrONjfafrWPwj6yn2RlL0mQEwt1lOvn LnI7QRtB3zxA3yB+FLsT1hx0va6xCHpX3QO2gBsyHCyVafFMrg3c/7IIWkDLngJxFgz6DLiA G4ld1QK/jsYqfP2GIMH1mFdjY+iagG4DqOsjip479HCWAptpNxSOCL6z3qxCU8MCz8iNOtZk DYXQWVscM5qgYSn+fmMM2qN+eoWlnCGVURZZLDjg387S2E1jT/dNTOsM/IqQj+ZROUZuRcF7 0RTtuU5q1HnbRNwy+23xeoSGuwmLQ2UsUk7Q5CnrjYfiPo3wHze8avK95JBoSd+WIRmV3uoO rXCoYOIRlDhg9XJTrbnQ3Ot5zOa0Y9c4IpyAlut6mDtxtKXr4+8OzjSVFww7tIwadTK3wDQv Bus4jxHjS6dz1g2ypT65qnHen6mUUH63lhzewqO9peAHJ0SLrQARAQABzTBUb21pIFZhbGtl aW5lbiA8dG9taS52YWxrZWluZW5AaWRlYXNvbmJvYXJkLmNvbT7CwY4EEwEIADgWIQTEOAw+ ll79gQef86f6PaqMvJYe9QUCX/HruAIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRD6 PaqMvJYe9WmFD/99NGoD5lBJhlFDHMZvO+Op8vCwnIRZdT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=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 04/04/2024 16:00, Laurent Pinchart wrote: > Hi Tomi, > > Thank you for the patch. > > On Thu, Apr 04, 2024 at 01:50:01PM +0300, Tomi Valkeinen wrote: >> call_s_stream() uses sd->enabled_streams to track whether streaming has >> already been enabled. However, >> v4l2_subdev_enable/disable_streams_fallback(), which was the original >> user of this field, already uses it, and >> v4l2_subdev_enable/disable_streams_fallback() will call call_s_stream(). >> >> This leads to a conflict as both functions set the field. Afaics, both >> functions set the field to the same value, so it won't cause a runtime >> bug, but it's still wrong and if we, e.g., change how >> v4l2_subdev_enable/disable_streams_fallback() operates we might easily >> cause bugs. >> >> Fix this by adding a new field, 'streaming_enabled', for >> call_s_stream(). >> >> Signed-off-by: Tomi Valkeinen >> --- >> drivers/media/v4l2-core/v4l2-subdev.c | 8 ++------ >> include/media/v4l2-subdev.h | 2 ++ >> 2 files changed, 4 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c >> index b90b5185e87f..3b3310bce5d4 100644 >> --- a/drivers/media/v4l2-core/v4l2-subdev.c >> +++ b/drivers/media/v4l2-core/v4l2-subdev.c >> @@ -404,12 +404,8 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) >> * The .s_stream() operation must never be called to start or stop an >> * already started or stopped subdev. Catch offenders but don't return >> * an error yet to avoid regressions. >> - * >> - * As .s_stream() is mutually exclusive with the .enable_streams() and >> - * .disable_streams() operation, we can use the enabled_streams field >> - * to store the subdev streaming state. >> */ >> - if (WARN_ON(!!sd->enabled_streams == !!enable)) >> + if (WARN_ON(!!sd->streaming_enabled == !!enable)) >> return 0; >> >> #if IS_REACHABLE(CONFIG_LEDS_CLASS) >> @@ -429,7 +425,7 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) >> } >> >> if (!ret) >> - sd->enabled_streams = enable ? BIT(0) : 0; >> + sd->streaming_enabled = !!enable; >> >> return ret; >> } >> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h >> index a9e6b8146279..8bd1e3c96d2b 100644 >> --- a/include/media/v4l2-subdev.h >> +++ b/include/media/v4l2-subdev.h >> @@ -1043,6 +1043,7 @@ struct v4l2_subdev_platform_data { >> * v4l2_subdev_enable_streams() and >> * v4l2_subdev_disable_streams() helper functions for fallback >> * cases. >> + * @streaming_enabled: Tracks whether streaming has been enabled with s_stream. > > Could you extend this to indicate this field can't be used by anything > else than call_s_stream() ? Yes, I'll add that. > I'm also getting a bit concerned about having multiple fields with > similar purposes. Another option would be to call the .s_stream() I agree, it's getting slightly complex. The reason is that we support many ways for the subdev to implement these things. > operation directly from the fallback handlers, instead of going through > call_s_stream(). That may be considered as a bit of a hack though. I thought about the same thing, but I felt it might just make things more complex. However, with my new unsent series, I add the privacy_led code also to the v4l2_subdev_enable_streams() function, so it's even more similar to the call_s_stream. Maybe I'll try it out and see how it looks like if I call the op directly. Tomi >> * >> * Each instance of a subdev driver should create this struct, either >> * stand-alone or embedded in a larger struct. >> @@ -1091,6 +1092,7 @@ struct v4l2_subdev { >> */ >> struct v4l2_subdev_state *active_state; >> u64 enabled_streams; >> + bool streaming_enabled; >> }; >> >> >