Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp274980lqd; Wed, 24 Apr 2024 01:42:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVVCKII3vLhoLMkDWD1ALTSoDtwk7Hc3/aPww8kgYWPdF5tfN1KzPSENorPwtPoFvigvLnJ0+cxhZwO/B9/mfl5G7HZTSyoc0SeBdp8Q== X-Google-Smtp-Source: AGHT+IEqpu5mcMt5208/w+jKuY966xEObG0bKDictoAUGwZOsyEG6a5J1DWDFrnkCyzfMYcnp4zN X-Received: by 2002:a05:690c:380f:b0:61a:c4a3:8a5c with SMTP id jx15-20020a05690c380f00b0061ac4a38a5cmr2089278ywb.44.1713948148220; Wed, 24 Apr 2024 01:42:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713948148; cv=pass; d=google.com; s=arc-20160816; b=IJwupmXVEhsCApiuQgHB2O/1JQnUqvdXf7B6cHXgFq1HmImzaDd8q1Wa3/iqGqm064 UAEgqHCtaYh2pVQixUo/DByfTN6RZ8XKws5atiGmythzoQf4KyH5PBmCCkW+HOy8KAPl n28FQNjDU8lbNVFDb9G1TFG4G8C3oPk9xEzlxftuIDbu/8GLaObkswqQl+XQbDV83e0G 6yb5bUk154yP/V30Uff6YMPxXlNe+7hlshUYkYGv8RXDxzw6otWezEu9ks8JtlvGNzhx rOJBzfFlngSzkeNmAZdQvP71a3WaGK7l2IWqGnO4QtK8e5jm/emu9J8qkjEWAgTxocjY WO9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=CFvzd10+pAFwDlXm7DV3nfUiTHvsuYS7iTdw26vZNu0=; fh=7pWVbJfrMUh1l1qMES+i847DRl+J2Ny+/+OcujVoTSo=; b=ryic3BjKC3Av484/uovG9uP+VYzkZXykpWCNz2qH7ZUbhy/rzZY0dvSP77ioBXfOEq u4QVehPz1MVYVDXEFjwe7D/HpBactkIk3SVtIiH3UuiWZf+/KU3sZTW4AsuFVhZU7j4L ob2Fq/YPJtBuTlb/QoFdTWp1UYrcpDCEtf1g4b9R/sf6fjTFNy7+wATZAUEU1kFa7rso xHaLCIK+RmwEruBHShNJcauUK2i/CQUasDjhjdkKbDqBCLeMlLCdrGePIDpHO4sr4JA7 FTs8ye9iB1eUcoIIj23yp33PnGKSYGOTeVYfay6kVUeBIr6tP+1mvT9Iw/Bk7QUNpUXI XH5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CFafo2Xe; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-156563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h7-20020a05620a21c700b0078d55a0358csi13255197qka.262.2024.04.24.01.42.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 01:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CFafo2Xe; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-156563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D884D1C20A1E for ; Wed, 24 Apr 2024 08:42:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04CF115887D; Wed, 24 Apr 2024 08:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="CFafo2Xe" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 8647C156C7D; Wed, 24 Apr 2024 08:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713948137; cv=none; b=jr4FzZLWgThnw1ZTCnjQkPgNBgGu8LVEhCmr02LXJH2ArqFMoN6EceWdyjjPHyWbM8WsgZBfHFQIP2sI2dw5B+CeQFUDYRZm0oQJqKbogyBOEnRDr7teE5zvISVzKXKjl9tyV/TzdqDEGu4BlkIPPfhplgzicHKUxh+b2NuTMVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713948137; c=relaxed/simple; bh=5SydQyN/5lWa8I8pFYYcZKMUixYgURPFJ+gffcKbuKw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bGdFZHJ5m3a1PzSI0ITEdgT+316hmnW41phtPMFM3+WAPLBvZqjAXKKGuBmDrtV2zlT94SlW/5GCmOS4xG7+z+R0gURcNXzgVHN8Z2Nc7RBXbJy7bNqQsO3TALcF3Zh9lOjFAxSerE2f4Iyfz5bPY510MHNs9AE5abwvfGYblfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=CFafo2Xe; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713948133; bh=5SydQyN/5lWa8I8pFYYcZKMUixYgURPFJ+gffcKbuKw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=CFafo2XeZwh36dwmwc6mZsXswmvDqENIuTqdFxBIadjxjWz1sg+xqvxUCmw174zc5 mPQDGhV4QOl2fNxMQGY6rhqxoGeS5zb66/H73rGlWhm78kTLwUtnRGvPatWs7/vVV4 Q3NIW21+7/42vLA2grf5T3rEGrfWc+ZOOp06VUOIm+l7VzYrtmUKCVx4BIh/rnfYYV 0iO25WJ8xI3zucQnPBGuJl5DU+JhTYLSJbbVysY9tSK6/s9/BIm4tP+NS+u83srcE2 rqZw4iQSOY+K2RfAn/Scj88VH8/yb3pGpce7+6kZMXnPcT3schLiKsemOcT6PnAVk4 0yvahe9T2JSyQ== Received: from [100.74.67.65] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: jmassot) by madrid.collaboradmins.com (Postfix) with ESMTPSA id D66473781FE9; Wed, 24 Apr 2024 08:42:12 +0000 (UTC) Message-ID: <9075808c-783b-4af6-a92f-2a6d3f25d225@collabora.com> Date: Wed, 24 Apr 2024 10:42:11 +0200 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 v6 4/4] media: i2c: add MAX96714 driver To: Sakari Ailus Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, kernel@collabora.com, linux-kernel@vger.kernel.org, mchehab@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org References: <20240325131634.165361-1-julien.massot@collabora.com> <20240325131634.165361-5-julien.massot@collabora.com> Content-Language: en-US From: Julien Massot In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Sakari, On 4/24/24 10:30, Sakari Ailus wrote: > Hi Julien, > > On Tue, Apr 23, 2024 at 04:01:16PM +0200, Julien Massot wrote: > > ... > >>>> +static int max96714_enable_streams(struct v4l2_subdev *sd, >>>> + struct v4l2_subdev_state *state, >>>> + u32 source_pad, u64 streams_mask) >>>> +{ >>>> + struct max96714_priv *priv = sd_to_max96714(sd); >>>> + u64 sink_streams; >>>> + int ret; >>>> + >>>> + if (!priv->enabled_source_streams) >>>> + max96714_enable_tx_port(priv); >>>> + >>>> + ret = max96714_apply_patgen(priv, state); >>>> + if (ret) >>>> + goto err; >>>> + >>>> + if (!priv->pattern) { >>>> + if (!priv->rxport.source.sd) { >>>> + ret = -ENODEV; >>>> + goto err; >>>> + } On enable streams the check is here :) Streaming is not possible without a remote serializer when pattern generator is disabled. I may refactor this code later when we will have the internal pad, to declare properly this stream. . >>>> + >>>> + sink_streams = >>>> + v4l2_subdev_state_xlate_streams(state, >>>> + MAX96714_PAD_SOURCE, >>>> + MAX96714_PAD_SINK, >>>> + &streams_mask); >>>> + >>>> + ret = v4l2_subdev_enable_streams(priv->rxport.source.sd, >>>> + priv->rxport.source.pad, >>>> + sink_streams); >>>> + if (ret) >>>> + goto err; >>>> + } >>>> + >>>> + priv->enabled_source_streams |= streams_mask; >>>> + >>>> + return 0; >>>> + >>>> +err: >>>> + if (!priv->enabled_source_streams) >>>> + max96714_disable_tx_port(priv); >>>> + >>>> + return ret; >>>> +} >>>> + >>>> +static int max96714_disable_streams(struct v4l2_subdev *sd, >>>> + struct v4l2_subdev_state *state, >>>> + u32 source_pad, u64 streams_mask) >>>> +{ >>>> + struct max96714_priv *priv = sd_to_max96714(sd); >>>> + u64 sink_streams; >>>> + int ret; >>>> + >>>> + if (!priv->pattern && priv->rxport.source.sd) { >>> >>> When will priv->rxport.source.sd be NULL here? >> >> Indeed it should not, the priv->rxport.source.sd can only be null if: >> - There is no serializer >> - The stream has been started with pattern generator and the pattern >> generator >> has been disabled while streaming. > > It seems priv->rxport.source.sd is also accessed in > max96714_enable_streams() without such a check. Please see my reply above :) > >> >> In V7 I will drop this check and add another one to prevent disabling the >> pattern >> generator while streaming. > > Sounds good. > >>>> +static void max96714_v4l2_notifier_unregister(struct max96714_priv *priv) >>>> +{ >>>> + v4l2_async_nf_unregister(&priv->notifier); >>>> + v4l2_async_nf_cleanup(&priv->notifier); >>> >>> It'd be nicer to call these directly IMO. Maybe we could introduce >>> v4l2_async_nf_unregister_cleanup()? Feel free to post a patch. :-) >> Ok, I will call these directly, and I will do the same for the MAX96717 >> serializer. >> >> I will post a patchset later introducing the >> `v4l2_async_nf_unregister_cleanup` >> and converting all the drivers calling these two functions. > > That would be nice. :-) It should be easy to do that with Coccinelle. > > ... > >>>> + ret = max96714_enable_core_hw(priv); >>> >>> Please switch to runtime PM. >> >> Ok, the v7 will use runtime PM and I will use the powerdown gpio >> to poweroff the device. However it implies to move some functions arround >> e.g initialize the tx or the pattern generator .. >> So it it will be done as separate patches. >> >> Playing with the pm_runtime operation also showed up that the connection >> doesn't always resume properly, I will extra patches to fix that. > > Ack. > -- Julien Massot Senior Software Engineer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718