Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14373582pxu; Mon, 4 Jan 2021 22:58:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYw3iIp2jY1A5zd2KPJxmizlmqDelcOcLpiOHKL6IcCgmuyE2uCiN7siHcqgC/uGbJD8T1 X-Received: by 2002:a17:907:c15:: with SMTP id ga21mr70095728ejc.472.1609829885501; Mon, 04 Jan 2021 22:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609829885; cv=none; d=google.com; s=arc-20160816; b=diZQFX4rnNs2LGB7Qh5JaK7Q9DlkX3cBb9OaJh/a3N7LarZzjdaUrZoTaZl8h7NHqF M0DqA9Y3EJaQ++3Q3UGIau749xL5M29nGdLdqxKZJtCvZ+BvFQHcScFPq1IIAi8uh51q v+LdB2dR+gfgdhuwKXYBenxgP25ogHW1Ee5xalDMo9O2HNb6he3o4t89AbthNQskVWow FfJ1Fazj5apAQOB6mk4YBvHdIAwNHtfKfPoXb5SePs2a2o5dKgbtMoYsW4ZSyojHbMmN 7qkiUb0EQ/wy7cg4Z/v9gmxB108DJcQtc48EIttfyTcHx/2TSzPiZh4VVQEljKswx8WA yAMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :autocrypt:from:references:cc:to:subject:reply-to:dkim-signature; bh=7ou4hJFCAtaxINAs6YuIH+tqwmkbpDbsiVEClm1keUQ=; b=kZ73JtZuHq6RdK10N9auy/qYNbq5WcEs0DCJGoMHJ5DdTiWtndtnHuYiaquSxF6pNl t+rQkmWfLSZP/cYD49Xkrd2wiZXzVpH1WGTS0g2YlOMjGDALslDuplsF7azB0bDb4svY fb1bqAVOfCXq8jeQNYqG1HFaKG4i4ItBuh0wrNxPM/pmVOzGLwIhTPRMxu2MI+W6veqe 1kbEZZkE1G+OxRI+KBDQekJrHfx+9qWOkytlVuqZbFxZa/rxlGn6MKlTzoLR2XlpkmJ5 qwL/wxarI5nkzTXldH5XAJVkpkbc/qlexcnmv8CyajHXLSxJ2fG6eHCV+4/ua8b70RHF 4sJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=c9hfKJMp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rk15si29722602ejb.170.2021.01.04.22.57.42; Mon, 04 Jan 2021 22:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=c9hfKJMp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbhAEG4d (ORCPT + 99 others); Tue, 5 Jan 2021 01:56:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbhAEG4d (ORCPT ); Tue, 5 Jan 2021 01:56:33 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D30C2C061574; Mon, 4 Jan 2021 22:55:52 -0800 (PST) Received: from [192.168.0.20] (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B46EE3D7; Tue, 5 Jan 2021 07:55:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1609829750; bh=TEHLTrEFWb+Sc7aAPY9GaYBOf2wQ4BYb3ucO6pOMzvE=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=c9hfKJMp4wZKBn8KNKpGc0bYO2vj3Zyid/54B4Lp+7xn2+YfqbokX6eD761eBwnat lZ+0Y5V0d9h3XsiqpRPDWWhP12K68S+Zwtg1CpKg/XZoezcpO1aKv27UfndYuufaSs pVQ/Ien1Bd13IG3+A/bhYLkSrnNd43UnwO/To27I= Reply-To: kieran.bingham@ideasonboard.com Subject: Re: [PATCH v4 15/15] ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver To: Daniel Scally , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org, gregkh@linuxfoundation.org, rjw@rjwysocki.net, sergey.senozhatsky@gmail.com, mchehab@kernel.org Cc: lenb@kernel.org, yong.zhi@intel.com, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, hverkuil-cisco@xs4all.nl, m.felsch@pengutronix.de, niklas.soderlund+renesas@ragnatech.se, slongerbeam@gmail.com, heikki.krogerus@linux.intel.com, linus.walleij@linaro.org, Jordan Hand , Laurent Pinchart , Andy Shevchenko References: <20210103231235.792999-1-djrscally@gmail.com> <20210103231235.792999-16-djrscally@gmail.com> <3d881e2b-747f-dcd7-a0cf-e7309419914b@ideasonboard.com> <9026519f-1f33-9df0-de18-0881069f7aaa@gmail.com> <249b8ad1-5616-596d-4ee6-efcfdda2ca64@ideasonboard.com> <03dc26d0-39d3-174d-f269-426dbc38e62e@gmail.com> From: Kieran Bingham Autocrypt: addr=kieran.bingham@ideasonboard.com; keydata= mQ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DwMZ/kE04 /UqCMK/KnX8pwXEMCjz0h6qWNpGwJ0/tYIgQJZh6bqkvBrDogAvuhf60Sogw+mH8b+PBlx1L oeTK396wc+4c3BfiC6pNtUS5GpsPMMjYMk7kVvEAEQEAAYkCPAQYAQoAJgIbDBYhBJAt15g/ vSj943LUeqEeRnIQpGH9BQJdizzIBQkLSKZiAAoJEKEeRnIQpGH9eYgQAJpjaWNgqNOnMTmD MJggbwjIotypzIXfhHNCeTkG7+qCDlSaBPclcPGYrTwCt0YWPU2TgGgJrVhYT20ierN8LUvj 6qOPTd+Uk7NFzL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz PZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp ECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx S0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j sbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8 pQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc MW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU AfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4 WZw01QYHU/GUV/zHJSFk Organization: Ideas on Board Message-ID: <68813554-c479-7354-26d4-df34f53dee32@ideasonboard.com> Date: Tue, 5 Jan 2021 06:55:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <03dc26d0-39d3-174d-f269-426dbc38e62e@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan, On 04/01/2021 22:02, Daniel Scally wrote: >>>>> On 04/01/2021 13:35, Kieran Bingham wrote: >>>>>>> +/* >>>>>>> + * Extend this array with ACPI Hardware IDs of devices known to be working >>>>>>> + * plus the number of link-frequencies expected by their drivers, along with >>>>>>> + * the frequency values in hertz. This is somewhat opportunistic way of adding >>>>>>> + * support for this for now in the hopes of a better source for the information >>>>>>> + * (possibly some encoded value in the SSDB buffer that we're unaware of) >>>>>>> + * becoming apparent in the future. >>>>>>> + * >>>>>>> + * Do not add an entry for a sensor that is not actually supported. >>>>>>> + */ >>>>>>> +static const struct cio2_sensor_config cio2_supported_sensors[] = { >>>>>>> + CIO2_SENSOR_CONFIG("INT33BE", 0), >>>>>>> + CIO2_SENSOR_CONFIG("OVTI2680", 0), >>>>>> I don't know if these are expressed anywhere else but would it be >>>>>> helpful to add a comment, or indicator as to what the actual sensor is >>>>>> that is represented by this HID? >>>>>> >>>>>> I can make an assumption about what an OVTI2680 might be, but the >>>>>> INT33BE is quite opaque. It's not clear what support that adds. >>>>>> >>>>>> Unless no one cares what the sensor is that is, but I would anticipate >>>>>> anyone looking here to add a new sensor might want to investigate what >>>>>> was already in the table? >>>>> Yeah good point. I'll probably alternate comment and entry then, like: >>>>> >>>>> >>>>> +static const struct cio2_sensor_config cio2_supported_sensors[] = { >>>>> + /* Sensor OVTI5693 */ >>>>> + CIO2_SENSOR_CONFIG("INT33BE", 0), >>>>> + /* Sensor OVTI2680 */ >>>>> + CIO2_SENSOR_CONFIG("OVTI2680", 0), >>>>> >>>>> As an inline comment won't fit for the sensors that we know link-frequencies for. That sound ok? >>>> I might put the whole vendor name in, and no need to prefix 'Sensor' IMO. >>>> >>>> + /* Omnivision OV5693 */ >>>> + CIO2_SENSOR_CONFIG("INT33BE", 0), >>>> + /* Omnivision OV2680 */ >>>> + CIO2_SENSOR_CONFIG("OVTI2680", 0), >>>> >>>> but otherwise, yes a comment the line before works for me, as you are >>>> right - at the end would not be practical. >>> Works for me >>>>>>> +static void cio2_bridge_create_fwnode_properties( >>>>>>> + struct cio2_sensor *sensor, >>>>>>> + const struct cio2_sensor_config *cfg) >>>>>>> +{ >>>>>>> + unsigned int i; >>>>>>> + >>>>>>> + sensor->prop_names = prop_names; >>>>>>> + >>>>>>> + for (i = 0; i < CIO2_MAX_LANES; i++) >>>>>>> + sensor->data_lanes[i] = i + 1; >>>>>> Does something support lane swapping somewhere? >>>>>> I assume this is just mapping each lane directly through. >>>>> I think Sakari said remapping isn't supported in the CIO2 - so yeah this >>>>> is just mapping them directly >>>> So is this needed? Or is it some future compatibility thing? >>>> >>>> I haven't seen where it's used yet, but I'm not too worried about it >>>> though, just not sure what value an array of [1, 2, 3, 4] gives if it's >>>> constant... >>> >>> The endpoints need to have the data-lanes property which passes an array >>> of data lanes, but there may well be a better way of doing this. I'm >>> just using the lanes member of the ssdb data structure to tell the >>> property how many members of the array to look at: >>> >>> >>> +    sensor->cio2_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( >>> +                    sensor->prop_names.data_lanes, >>> +                    sensor->data_lanes, >>> +                    sensor->ssdb.lanes); >>> >>> >>> So if sensor->ssdb.lanes is 2, even though it's passed a pointer to the >>> first member of an array of 4 members, the size calculation of that >>> macro limits it to just those in use. I.E. if sensor->ssdb.lanes is 2 >>> then the property will be given the size 2 * sizeof(u32), and so when >>> its parsed only [1, 2] will be read. >> >> >> Aha, I see, ok - so we are populating an array of [1, 2, 3, 4] for each >> sensor that we add. >> >> What about creating the data_lanes once as a const static array and >> mapping to that? >> >> /* >> * Map the lane arrangement, which is fixed for the IPU3. >> */ >> static const int data_lanes[CIO2_MAX_LANES] = { 1, 2, 3, 4 }; > > > Can't do exactly this; the bridge needs to store everything on heap > incase the module is unloaded, but I could move the data_lanes array to > the struct cio2_bridge instead of against each sensor and then we're > only doing it once. Ahh, yes I remember reading about that already. It maybe worth adding a comment about that in this file, to prevent other people from 'optimising' things out in 5 years ... It probably doesn't make much difference in that case if it's per sensor or per bridge. But indeed at least in the bridge it's only created once. -- Kieran > >> ... >> >> sensor->cio2_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( >> sensor->prop_names.data_lanes, >> data_lanes, >> sensor->ssdb.lanes); >> ... >> >> Then we don't need the loop to populate the array for each sensor >> anymore, or the data_lanes in the sensor struct? >> > -- Regards -- Kieran