public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Scally <djrscally@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: 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,
	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,
	linux@rasmusvillemoes.dk,
	laurent.pinchart+renesas@ideasonboard.com,
	jacopo+renesas@jmondi.org,
	kieran.bingham+renesas@ideasonboard.com,
	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 <jorhand@linux.microsoft.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH v4 15/15] ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver
Date: Mon, 4 Jan 2021 13:00:24 +0000	[thread overview]
Message-ID: <2f64873d-0413-3614-34e2-139b4a4d9da6@gmail.com> (raw)
In-Reply-To: <20210104120905.GR4077@smile.fi.intel.com>

Hi Andy

On 04/01/2021 12:09, Andy Shevchenko wrote:
> On Sun, Jan 03, 2021 at 11:12:35PM +0000, Daniel Scally wrote:
>> Currently on platforms designed for Windows, connections between CIO2 and
>> sensors are not properly defined in DSDT. This patch extends the ipu3-cio2
>> driver to compensate by building software_node connections, parsing the
>> connection properties from the sensor's SSDB buffer.
> Few nitpicks below (I consider it's good enough as is, though).
Thanks!
>> +static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>> +				      struct cio2_bridge *bridge,
>> +				      struct pci_dev *cio2)
>> +{
>> +	struct fwnode_handle *fwnode;
>> +	struct cio2_sensor *sensor;
>> +	struct acpi_device *adev;
>> +	int ret;
>> +	for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
> (1)
>
>> +		if (bridge->n_sensors >= CIO2_NUM_PORTS) {
>> +			dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
>> +			cio2_bridge_unregister_sensors(bridge);
>> +			ret = -EINVAL;
>> +			goto err_out;
>> +		}
>> +		if (!adev->status.enabled)
>> +			continue;
> A nit: this would be better to be at (1) location.


Yep, agreed

>
> Then possible to factor out the rest of the body of this loop as well.
>
> (Also can be considered as a hint for the future improvement)
Yeah I can look at this, there will probably be some future changes
anyway as we discover more details about the data in the SSDB buffer and
so on
> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
> new file mode 100644
> index 000000000000..3ec4ed44aced
> --- /dev/null
> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
> @@ -0,0 +1,125 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Author: Dan Scally <djrscally@gmail.com> */
> +#ifndef __CIO2_BRIDGE_H
> +#define __CIO2_BRIDGE_H
> +
> +#include <linux/property.h>
> +#include <linux/types.h>
> +
> +#include "ipu3-cio2.h"
> +
> +#define CIO2_HID				"INT343E"
> +#define CIO2_MAX_LANES				4
> +#define MAX_NUM_LINK_FREQS			3
> +
> +#define CIO2_SENSOR_CONFIG(_HID, _NR, ...)	\
> +	{					\
> +		.hid = _HID,			\
> +		.nr_link_freqs = _NR,		\
> +		.link_freqs = { __VA_ARGS__ }	\
> +	}
> Perhaps also good to declare it as a compound literal.
>
> (Means to add (struct ...) to the initializer.
>
Yep ok
>> +#define NODE_SENSOR(_HID, _PROPS)		\
>> +	((const struct software_node) {		\
>> +		.name = _HID,			\
>> +		.properties = _PROPS,		\
>> +	})
>> +
>> +#define NODE_PORT(_PORT, _SENSOR_NODE)		\
>> +	((const struct software_node) {		\
>> +		.name = _PORT,			\
>> +		.parent = _SENSOR_NODE,		\
>> +	})
>> +
>> +#define NODE_ENDPOINT(_EP, _PORT, _PROPS)	\
>> +	((const struct software_node) {		\
>> +		.name = _EP,			\
>> +		.parent = _PORT,		\
>> +		.properties = _PROPS,		\
>> +	})
> In all three I didn't get why you need outer parentheses. Without them it will
> be well defined compound literal and should work as is.
The code works fine, but checkpatch complains that macros with complex
values should be enclosed in parentheses. I guess now that I'm more
familiar with the code I'd call that a false-positive though, as nowhere
else in the kernel that I've seen encloses them the same way.
>>  static int cio2_pci_probe(struct pci_dev *pci_dev,
>>  			  const struct pci_device_id *id)
>>  {
>> +	struct fwnode_handle *fwnode = dev_fwnode(&pci_dev->dev);
>>  	struct cio2_device *cio2;
>>  	int r;
>>  
>> @@ -1715,6 +1732,22 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
>>  		return -ENOMEM;
>>  	cio2->pci_dev = pci_dev;
>>  
>> +	/*
>> +	 * On some platforms no connections to sensors are defined in firmware,
>> +	 * if the device has no endpoints then we can try to build those as
>> +	 * software_nodes parsed from SSDB.
>> +	 */
>> +	if (!cio2_check_fwnode_graph(fwnode)) {
> A nit:
> I prefer form of
>
> 	r = cio2_check_fwnode_graph(fwnode);
> 	if (!r) { // alternatively if (r == 0), depends on maintainer's taste
This is fine by me; I can switch to that
>
>> +		if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) {
>> +			dev_err(&pci_dev->dev, "fwnode graph has no endpoints connected\n");
>> +			return -EINVAL;
>> +		}
>> +
>> +		r = cio2_bridge_init(pci_dev);
>> +		if (r)
>> +			return r;
>> +	}
>> +
>>  	r = pcim_enable_device(pci_dev);
>>  	if (r) {
>>  		dev_err(&pci_dev->dev, "failed to enable device (%d)\n", r);
>> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
>> index 62187ab5ae43..dc3e343a37fb 100644
>> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h
>> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
>> @@ -455,4 +455,10 @@ static inline struct cio2_queue *vb2q_to_cio2_queue(struct vb2_queue *vq)
>>  	return container_of(vq, struct cio2_queue, vbq);
>>  }
>>  
>> +#if IS_ENABLED(CONFIG_CIO2_BRIDGE)
>> +int cio2_bridge_init(struct pci_dev *cio2);
>> +#else
>> +int cio2_bridge_init(struct pci_dev *cio2) { return 0; }
> static inline?

Ah, yes - thanks. Hadn't read about inline until now


  reply	other threads:[~2021-01-04 13:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-03 23:12 [PATCH v4 00/15] Add functionality to ipu3-cio2 driver allowing software_node connections to sensors on platforms designed for Windows Daniel Scally
2021-01-03 23:12 ` [PATCH v4 01/15] software_node: Fix refcounts in software_node_get_next_child() Daniel Scally
2021-01-03 23:12 ` [PATCH v4 02/15] media: ipu3-cio2: Add headers that ipu3-cio2.h is direct user of Daniel Scally
2021-01-03 23:12 ` [PATCH v4 03/15] property: Return true in fwnode_device_is_available for NULL ops Daniel Scally
2021-01-03 23:12 ` [PATCH v4 04/15] property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary Daniel Scally
2021-01-03 23:12 ` [PATCH v4 05/15] software_node: Enforce parent before child ordering of nodes arrays Daniel Scally
2021-01-03 23:12 ` [PATCH v4 06/15] software_node: unregister software_nodes in reverse order Daniel Scally
2021-01-03 23:12 ` [PATCH v4 07/15] include: fwnode.h: Define format macros for ports and endpoints Daniel Scally
2021-01-04 14:24   ` Andy Shevchenko
2021-01-04 14:25     ` Daniel Scally
2021-01-03 23:12 ` [PATCH v4 08/15] software_node: Add support for fwnode_graph*() family of functions Daniel Scally
2021-01-04 10:22   ` Andy Shevchenko
2021-01-04 10:35     ` Daniel Scally
2021-01-03 23:12 ` [PATCH v4 09/15] lib/test_printf.c: Use helper function to unwind array of software_nodes Daniel Scally
2021-01-03 23:12 ` [PATCH v4 10/15] ipu3-cio2: Add T: entry to MAINTAINERS Daniel Scally
2021-01-03 23:12 ` [PATCH v4 11/15] ipu3-cio2: Rename ipu3-cio2.c Daniel Scally
2021-01-03 23:12 ` [PATCH v4 12/15] media: v4l2-core: v4l2-async: Check sd->fwnode->secondary in match_fwnode() Daniel Scally
2021-01-03 23:12 ` [PATCH v4 13/15] acpi: Add acpi_dev_get_next_match_dev() and helper macro Daniel Scally
2021-01-04 12:42   ` Andy Shevchenko
2021-01-04 12:57     ` Daniel Scally
2021-01-04 14:26   ` Andy Shevchenko
2021-01-03 23:12 ` [PATCH v4 14/15] include: media: v4l2-fwnode: Include v4l2_fwnode_bus_type Daniel Scally
2021-01-04 14:22   ` Andy Shevchenko
2021-01-03 23:12 ` [PATCH v4 15/15] ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver Daniel Scally
2021-01-04 12:09   ` Andy Shevchenko
2021-01-04 13:00     ` Daniel Scally [this message]
2021-01-04 13:38       ` Andy Shevchenko
2021-01-04 13:56         ` Daniel Scally
2021-01-04 13:35   ` Kieran Bingham
2021-01-04 13:55     ` Daniel Scally
2021-01-04 14:12       ` Andy Shevchenko
2021-01-04 15:13       ` Kieran Bingham
2021-01-04 15:31         ` Daniel Scally
2021-01-04 16:13           ` Kieran Bingham
2021-01-04 22:02             ` Daniel Scally
2021-01-05  6:55               ` Kieran Bingham
2021-01-05  8:22                 ` Daniel Scally

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f64873d-0413-3614-34e2-139b4a4d9da6@gmail.com \
    --to=djrscally@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=devel@acpica.org \
    --cc=erik.kaneda@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=jorhand@linux.microsoft.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=m.felsch@pengutronix.de \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=pmladek@suse.com \
    --cc=rjw@rjwysocki.net \
    --cc=robert.moore@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=slongerbeam@gmail.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox