Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1063960rdb; Wed, 1 Nov 2023 10:13:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtPYppZ6VZDORp14vh5RoI4MU144fbcbGZ5LVmNND4ziUtIcWIYAWkPhol7a6SIoPsqMfw X-Received: by 2002:a17:90a:49ca:b0:27c:f309:f381 with SMTP id l10-20020a17090a49ca00b0027cf309f381mr14920975pjm.6.1698858781822; Wed, 01 Nov 2023 10:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698858781; cv=none; d=google.com; s=arc-20160816; b=PE/e70p6HPWVhygf9dEXUUpOaYvE3z+NscDWYIG+lEVbg2y+BEJKj9+kCZlOCERq5a MyHL9S7SCOg1ZPfBV9fYpw1xwrMGBBlgGegf3yEunAMI7YB7LAKQuoMiUhvOF4bfYJAS JverxW6iMRrzmHLwF3g5WfGd1Fnt0kzhhTQkLkB77czGrGeP1Kt11Bo7ZpGxCQVmEhZD oqnEnRQwBktrJUM4Pl9a8SWZYyeiUQfPyQ3I0hPBmnsG1XAUJKCK1B8LwHPSKJoWNyfQ xR1MgRJBjEgHuxJaYrfIjKyeJX8gmlqTqtOKVY8pzFTmEKlPUJyiykmgzDMXZtcw88eg 0/1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AQy7qK6Zq9rdMdefArobJ1vlG90EN/iB2yTcxQ2LdoA=; fh=q1N+i33hN2fn2+bmgQPLwWv+rSReNGYijv1QHH5SCi0=; b=GjdhMsDMkp4Dc3fWr/Wz4FjWuVIcz9dvtBEj4MdsrnBXbwFKTqJpkqEjbV5hNILc9v cZ7sOsM7QmSWofz1OuVw6XoPKv1YtikCfLb5zThtDst3nHpSBe9RuLIHijTYM+xhtxSu PhBbEJMPvuPgjdfPaNoKjmenE3FWOy40S3mZPZIzbIOoT5kfAQegG0JN4O0SISPxf27r ZL7o49uY3+naFUXJTQhPL0ZQi2XSFP8w3e8iO3tX/xXgbfy3ii3iBw2efTc2/F3ebwbL yXFLD0KEVFzxKTo6kKL4JBA7qRu7mpKSJXACo1d8d841NXvW+F8dSghkOlJauLkFrQAc XUYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M9Vx7dA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q10-20020a17090aa00a00b0028025f366d3si1220069pjp.179.2023.11.01.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M9Vx7dA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 73F2D8184E34; Wed, 1 Nov 2023 10:12:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344629AbjKARMY (ORCPT + 99 others); Wed, 1 Nov 2023 13:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344562AbjKARMW (ORCPT ); Wed, 1 Nov 2023 13:12:22 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA3F124; Wed, 1 Nov 2023 10:12:19 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4083dbc43cfso91155e9.3; Wed, 01 Nov 2023 10:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698858738; x=1699463538; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AQy7qK6Zq9rdMdefArobJ1vlG90EN/iB2yTcxQ2LdoA=; b=M9Vx7dA35ffajNDu+FAZXB6WM9/l58SPQ+mifk3746rcUTpCpzHZFijHoaz8sQ8LXe A075Woi9O0mwdTRabCqxvfIG4sPAtlhs97ktxCOnXTKzWYsVbHFhEvPSy5s2Ibw9aPvq goxSQcEFW05IQ0aQVThmczzBFrMV00tAUBLwSv1Tp8txHTf4qSev9mbmV1rHMiD0QBA/ 7QZEmoWaqozwW6Ew/7zjgadQe2Yy+YMpcUmByDJJVug6u/d4xLXfuBkp23iGPQA+VszX ktVBLszAzXlYkT6pQUakaCYjeH4yGGR8UDjQPs6ZZhMXnCLiRt8I3fjjBjsBg4MLPZV7 4dcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698858738; x=1699463538; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AQy7qK6Zq9rdMdefArobJ1vlG90EN/iB2yTcxQ2LdoA=; b=mjMDycLBmr8LvFNyl9qhP+iaOWU3a8pgIFQ3p7sx8yWF5Tm0NY7kiTJmltVxF7pHQM i0Y90Y2LUnnK7Xa9k9/M3VchdDXmfufW49QJAKTY4c5XHX70tPtxcqh+LXY5qS8b+Pdq Vw9hvARAnbu47HHGIZ25L7cPBCopfr/XZwyShxUCW6RyO2I4JAU97bC9aVcGmX9lyRrx /xQR8Tgyiax0iI1La6c3IBDk7XxGVfxygpDE5MTSrXd6URjrDX6CLdrI0tlnan3dHWpG PmRH4CdEtlLqybQRxztEHJZ4dSiExhDPCn5RmSYOii1j8IWN1cYnVqpeMEDzhpkZq7It n/9Q== X-Gm-Message-State: AOJu0YwpjUvYWM8HunPzX8MLsHOajqcnuuUcz5WIljXjWWdkQKwlBhyK 6EVV+YSM7ET4or32So3rCu4= X-Received: by 2002:a05:600c:1d08:b0:408:4d0e:68ac with SMTP id l8-20020a05600c1d0800b004084d0e68acmr13103609wms.32.1698858737167; Wed, 01 Nov 2023 10:12:17 -0700 (PDT) Received: from tom-HP-ZBook-Fury-15-G7-Mobile-Workstation (net-188-217-59-109.cust.vodafonedsl.it. [188.217.59.109]) by smtp.gmail.com with ESMTPSA id fb13-20020a05600c520d00b00405442edc69sm344125wmb.14.2023.11.01.10.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:12:16 -0700 (PDT) Date: Wed, 1 Nov 2023 18:12:13 +0100 From: Tommaso Merciai To: Sakari Ailus Cc: Christophe JAILLET , martin.hecht@avnet.eu, michael.roeder@avnet.eu, mhecht73@gmail.com, linuxfancy@googlegroups.com, Mauro Carvalho Chehab , Liam Girdwood , Mark Brown , Laurent Pinchart , Hans de Goede , Hans Verkuil , Tomi Valkeinen , Marco Felsch , Gerald Loacker , Andy Shevchenko , Daniel Scally , Shawn Tu , Linus Walleij , linux-kernel@vger.kernel.org, Linux Media Mailing List Subject: Re: [PATCH v10 3/3] media: i2c: Add support for alvium camera Message-ID: References: <20231020141354.2500602-1-tomm.merciai@gmail.com> <20231020141354.2500602-4-tomm.merciai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 10:12:36 -0700 (PDT) Hi Sakari, On Wed, Nov 01, 2023 at 02:13:14PM +0000, Sakari Ailus wrote: > Hi Tommaso, > > On Tue, Oct 31, 2023 at 12:46:09PM +0100, Tommaso Merciai wrote: > > > > +static int alvium_get_dt_data(struct alvium_dev *alvium) > > > > +{ > > > > + struct device *dev = &alvium->i2c_client->dev; > > > > + struct fwnode_handle *fwnode = dev_fwnode(dev); > > > > + struct fwnode_handle *endpoint; > > > > + int ret = -EINVAL; > > > > + > > > > + if (!fwnode) > > > > + return -EINVAL; > > > > + > > > > + /* Only CSI2 is supported for now: */ > > > > + alvium->ep.bus_type = V4L2_MBUS_CSI2_DPHY; > > > > + > > > > + endpoint = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); > > > > + if (!endpoint) { > > > > + dev_err(dev, "endpoint node not found\n"); > > > > + return -EINVAL; > > > > + } > > > > + > > > > + if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &alvium->ep)) { > > > > + dev_err(dev, "could not parse endpoint\n"); > > > > + goto error_out; > > > > > > This could go to another label to be less confusing, but > > > v4l2_fwnode_endpoint_free() looks to be a no-op here, so good enough. > > > > Thanks for the comment. > > To be honest right now this is clear to me > > I prefere to stay on the following :) > > Prefer to keep just only one path. > > You can safely call v4l2_fwnode_endpoint_free() on an unparsed endpoint (or > on and endpoint the parsing of which failed). I prefer this too. > > > > > + ret = -ENODEV; > > > > + goto err_powerdown; > > > > + } > > > > + > > > > + ret = alvium_get_hw_info(alvium); > > > > + if (ret) { > > > > + dev_err(dev, "get_hw_info fail %d\n", ret); > > > > + goto err_powerdown; > > > > + } > > > > + > > > > + ret = alvium_hw_init(alvium); > > > > + if (ret) { > > > > + dev_err(dev, "hw_init fail %d\n", ret); > > > > + goto err_powerdown; > > > > + } > > > > + > > > > + ret = alvium_setup_mipi_fmt(alvium); > > > > + if (ret) { > > > > + dev_err(dev, "setup_mipi_fmt fail %d\n", ret); > > > > + goto err_powerdown; > > > > + } > > > > + > > > > + /* > > > > + * Enable runtime PM without autosuspend: > > > > + * > > > > + * Don't use pm autosuspend (alvium have ~7s boot time). > > > > + * Alvium has been powered manually: > > > > + * - mark it as active > > > > + * - increase the usage count without resuming the device. > > > > + */ > > > > + pm_runtime_set_active(dev); > > > > + pm_runtime_get_noresume(dev); > > > > + pm_runtime_enable(dev); > > > > + > > > > + /* Initialize the V4L2 subdev. */ > > > > + ret = alvium_subdev_init(alvium); > > > > + if (ret) > > > > + goto err_pm; > > > > + > > > > + ret = v4l2_async_register_subdev(&alvium->sd); > > > > + if (ret < 0) { > > > > + dev_err(dev, "Could not register v4l2 device\n"); > > > > + goto err_subdev; > > > > + } > > > > + > > > > + return 0; > > > > + > > > > +err_subdev: > > > > + alvium_subdev_cleanup(alvium); > > > > > > Should this also be called by the remove function? > > > Or is it already handled by an un-register mechanism? > > > > Right, I miss this. > > Thanks. > > I put this to remove function like: > > > > static void alvium_remove(struct i2c_client *client) > > { > > struct v4l2_subdev *sd = i2c_get_clientdata(client); > > struct alvium_dev *alvium = sd_to_alvium(sd); > > struct device *dev = &alvium->i2c_client->dev; > > > > /* > > * Disable runtime PM. In case runtime PM is disabled in the kernel, > > * make sure to turn power off manually. > > */ > > pm_runtime_disable(dev); > > if (!pm_runtime_status_suspended(dev)) > > alvium_power_on(alvium, false); > > pm_runtime_set_suspended(dev); > > > > alvium_subdev_cleanup(alvium); > > i2c_unregister_device(alvium->i2c_client); > > This doesn't belong here (as you didn't register it). It was missed in the > review earlier. Arg.. Good catch! Thanks :) You are right we remove i2c_register into some previous review. Regards, Tommaso > > > } > > > > > > If for you Cristophe, Sakari, Laurent, > > it's ok I prefer to skip v11 that I sent this morning too early. > > I collected hints from Cristophe right now and I plan to send v12 > > this afternoon/evening if for you all is ok. > > > > https://github.com/avs-sas/linux/blob/tm/media_stage/v6.6.0-rc3/alvium_drv/v12/drivers/media/i2c/alvium-csi2.c > > > > Please let me know. > > > > Thanks again to all! :) > > -- > Regards, > > Sakari Ailus