public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Dan Scally <djrscally@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	prabhakar.mahadev-lad.rj@bp.renesas.com, "Krogerus,
	Heikki" <heikki.krogerus@linux.intel.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	laurent.pinchart+renesas@ideasonboard.com,
	kieran.bingham+renesas@ideasonboard.com,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Rob Herring <robh@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Petr Mladek <pmladek@suse.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Tian Shu Qiu <tian.shu.qiu@intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Yong Zhi <yong.zhi@intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tsuchiya Yuto <kitakar@gmail.com>
Subject: Re: [RFC PATCH v3 9/9] ipu3-cio2: Add functionality allowing software_node connections to sensors on platforms designed for Windows
Date: Mon, 16 Nov 2020 18:16:36 +0200	[thread overview]
Message-ID: <20201116161636.GC4077@smile.fi.intel.com> (raw)
In-Reply-To: <3646e11c-a101-74e3-2eb4-7abf29937e9d@gmail.com>

On Mon, Nov 16, 2020 at 02:15:01PM +0000, Dan Scally wrote:
> On 16/11/2020 14:10, Laurent Pinchart wrote:
> > On Mon, Nov 16, 2020 at 03:57:17PM +0200, Andy Shevchenko wrote:
> >> On Mon, Nov 16, 2020 at 10:53 AM Laurent Pinchart wrote:
> >>> On Fri, Nov 13, 2020 at 09:45:00PM +0200, Andy Shevchenko wrote:
> >>>> On Fri, Nov 13, 2020 at 6:22 PM Laurent Pinchart wrote:
> >>>>> On Fri, Nov 13, 2020 at 10:02:30AM +0000, Dan Scally wrote:
> >>>>>> On 29/10/2020 22:51, Laurent Pinchart wrote:
> >>>>>>> On Fri, Oct 30, 2020 at 12:22:15AM +0200, Andy Shevchenko wrote:
> >>>>>>>> On Thu, Oct 29, 2020 at 11:29:30PM +0200, Laurent Pinchart wrote:
> >>>> ...
> >>>>
> >>>>>>>> In this case we probably need something like
> >>>>>>>>
> >>>>>>>> struct acpi_device *
> >>>>>>>> acpi_dev_get_next_match_dev(struct acpi_device *adev,
> >>>>>>>>                        const char *hid, const char *uid, s64 hrv)
> >>>>>>>> {
> >>>>>>>>    struct device *start = adev ? &adev->dev : NULL;
> >>>>>>>>    ...
> >>>>>>>>    dev = bus_find_device(&acpi_bus_type, start, &match, acpi_dev_match_cb);
> >>>>>>>>    ...
> >>>>>>>> }
> >>>>>>>>
> >>>>>>>> in drivers/acpi/utils.c and
> >>>>>>>>
> >>>>>>>> static inline struct acpi_device *
> >>>>>>>> acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
> >>>>>>>> {
> >>>>>>>>    return acpi_dev_get_next_match_dev(NULL, hid, uid, hrv);
> >>>>>>>> }
> >>>>>>>>
> >>>>>>>> in include/linux/acpi.h.
> >>>>>>>>
> >>>>>>>> Then we may add
> >>>>>>>>
> >>>>>>>> #define for_each_acpi_dev_match(adev, hid, uid, hrv)                       \
> >>>>>>>>    for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv);        \
> >>>>>>>>         adev;                                                      \
> >>>>>>>>         adev = acpi_dev_get_next_match_dev(adev, hid, uid, hrv))
> >>>>>>> What the cio2-bridge code needs is indeed
> >>>>>>>
> >>>>>>>     for each hid in supported hids:
> >>>>>>>             for each acpi device that is compatible with hid:
> >>>>>>>                     ...
> >>>>>>>
> >>>>>>> which could also be expressed as
> >>>>>>>
> >>>>>>>     for each acpi device:
> >>>>>>>             if acpi device hid is in supported hids:
> >>>>>>>                     ...
> >>>>>>>
> >>>>>>> I don't mind either option, I'll happily follow the preference of the
> >>>>>>> ACPI maintainers.
> >>>>>> Does this need raising elsewhere then? The original idea of just
> >>>>>> bus_for_each_dev(&acpi_bus_type...) I have now tested and it works fine,
> >>>>>> but it does mean that I need to export acpi_bus_type (currently that
> >>>>>> symbol's not available)...that seems much simpler to me but I'm not sure
> >>>>>> whether that's something to avoid, and if so whether Andy's approach is
> >>>>>> better.
> >>>>>>
> >>>>>> Thoughts?
> >>>>> I like simple options :-) A patch to export acpi_bus_type, with enough
> >>>>> context in the commit message (and in the cover latter of the series),
> >>>>> should be enough to provide all the information the ACPI maintainers
> >>>>> need to decide which option is best. With a bit of luck that patch will
> >>>>> be considered the best option and no extra work will be needed.
> >>>> The problem with ACPI bus is that it is not as simple as other buses,
> >>>> i.e. it may have purely ACPI devices along with *companion* devices,
> >>>> which are usually represented by platform bus. On top of that for
> >>>> several ACPI devices there can be one physical node and it will be not
> >>>> so clear what you are exactly looking for by traversing acpi_bus_type.
> >>>> I believe it's hidden on purpose.
> >>> Maybe there's something I don't get, as I'm not very familiar with the
> >>> ACPI implementation in the kernel, but the code in the cio2-bridge,
> >>> unless I'm mistaken, is really interested in ACPI devices on the ACPI
> >>> bus, not companions or other devices related to the ACPI devices.
> >> AFAICS cio2-bridge wants to find ACPI companion devices which are
> >> enumerated as platform ones (or I²C or SPI).
> > I thought we were looking for ACPI devices, not companion devices, in
> > order to extract information from the DSDT and store it in a software
> > node. I could very well be wrong though.
> This is correct - the code to fetch the various resources we're looking
> at all uses acpi_device. Whether using Andy's iterator suggestions or
> previous bus_for_each_dev(&acpi_bus_type...) I'm just getting the
> acpi_device via to_acpi_dev() and using that.

If you try to get an I²C ore SPI device out of pure ACPI device (with given
APCI _HID) you will fail. So, it's not correct. You are retrieving companion
devices, while they are still in the struct acpi_device.

And don't ask me, why it's so. I wasn't designed that and didn't affect any
decision made there.

> >>> The
> >>> iterators you have proposed above use bus_find_device() on
> >>> acpi_bus_type, so I don't really see how they make a difference from a
> >>> cio2-bridge point of view.
> >> This seems to be true. The iterators have no means to distinguish
> >> between companion devices and pure ACPI, for example.
> >> For this one needs to call something like 'get first physical node'
> >> followed by 'let's check that it has a companion and that the one we
> >> have already got from ACPI bus iterator'.
> >>
> >>> Is your point that acpi_bus_type shouldn't be
> >>> exported because it could then be misused by *other* drivers ? Couldn't
> >>> those drivers then equally misuse the iterators ?
> >> My point is that the ACPI bus type here is not homogenous.
> >> And thus I think it was the reason behind hiding it. I might be
> >> mistaken and you may ask ACPI maintainers for the clarification.
> >>
> >> In summary I think we are trying to solve a problem that has not yet
> >> existed (devices with several same sensors). Do we have a DSDT of such
> >> to look into?
> > Not to my knowledge.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-11-16 16:15 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 22:58 [RFC PATCH v3 0/9] Add functionality to ipu3-cio2 driver allowing software_node connections to sensors on platforms designed for Windows Daniel Scally
2020-10-19 22:58 ` [RFC PATCH v3 1/9] software_node: Add helper function to unregister arrays of software_nodes ordered parent to child Daniel Scally
2020-10-20  9:22   ` Andy Shevchenko
2020-10-20 10:05   ` Sakari Ailus
2020-10-20 11:01     ` Andy Shevchenko
2020-10-20 11:02       ` Andy Shevchenko
2020-10-20 11:04       ` Heikki Krogerus
2020-10-20 22:52     ` Dan Scally
2020-10-21  9:40       ` Andy Shevchenko
2020-10-21  9:54         ` Dan Scally
2020-10-19 22:58 ` [RFC PATCH v3 2/9] lib/test_printf.c: Use helper function to unwind array of software_nodes Daniel Scally
2020-10-20  7:23   ` Petr Mladek
2020-10-20  9:20   ` Andy Shevchenko
2020-10-19 22:58 ` [RFC PATCH v3 3/9] software_node: Fix failure to hold refcount in software_node_get_next_child Daniel Scally
2020-10-20 12:44   ` Rafael J. Wysocki
2020-10-20 13:31   ` Sakari Ailus
2020-10-20 23:25     ` Dan Scally
2020-10-21  9:33       ` Andy Shevchenko
2020-10-21  9:37         ` Sakari Ailus
2020-10-21  9:56         ` Dan Scally
2020-10-19 22:58 ` [RFC PATCH v3 4/9] software_node: Add support for fwnode_graph*() family of functions Daniel Scally
2020-10-20  9:17   ` Andy Shevchenko
2020-10-20 12:35   ` Sakari Ailus
2020-10-20 13:32     ` Sakari Ailus
2020-10-19 22:58 ` [RFC PATCH v3 5/9] ipu3-cio2: Add T: entry to MAINTAINERS Daniel Scally
2020-10-20  9:16   ` Andy Shevchenko
2020-10-24  0:28   ` Laurent Pinchart
2020-10-19 22:59 ` [RFC PATCH v3 6/9] ipu3-cio2: Rename ipu3-cio2.c to allow module to be built from multiple sources files retaining ipu3-cio2 name Daniel Scally
2020-10-20  9:15   ` Andy Shevchenko
2020-10-20 20:41     ` Dan Scally
2020-10-24  0:34   ` Laurent Pinchart
2020-10-19 22:59 ` [RFC PATCH v3 7/9] ipu3-cio2: Check if pci_dev->dev's fwnode is a software_node in cio2_parse_firmware() and set FWNODE_GRAPH_DEVICE_DISABLED if so Daniel Scally
2020-10-20  9:19   ` Andy Shevchenko
2020-10-20 12:06     ` Sakari Ailus
2020-10-20 19:56       ` Dan Scally
2020-10-20 22:49         ` Sakari Ailus
2020-10-20 22:55           ` Dan Scally
2020-10-24  0:39           ` Laurent Pinchart
2020-10-24 14:29             ` Sakari Ailus
2020-10-24 16:33               ` Dan Scally
2020-10-24 16:55                 ` Laurent Pinchart
2020-10-19 22:59 ` [RFC PATCH v3 8/9] media: v4l2-core: v4l2-async: Check possible match in match_fwnode based on sd->fwnode->secondary Daniel Scally
2020-10-19 22:59 ` [RFC PATCH v3 9/9] ipu3-cio2: Add functionality allowing software_node connections to sensors on platforms designed for Windows Daniel Scally
2020-10-20  9:41   ` Andy Shevchenko
2020-10-21 22:05     ` Daniel Scally
2020-10-22 13:40       ` Andy Shevchenko
2020-10-23 10:06         ` Dan Scally
2020-10-24  1:24   ` Laurent Pinchart
2020-10-24  8:50     ` Dan Scally
2020-10-24  9:37       ` Laurent Pinchart
2020-10-24 22:28         ` Daniel Scally
2020-10-24 22:36           ` Laurent Pinchart
2020-10-24 22:50             ` Daniel Scally
2020-10-26  8:20             ` Dan Scally
     [not found]               ` <20201026160549.GO4077@smile.fi.intel.com>
2020-10-29 20:17                 ` Laurent Pinchart
2020-10-29 22:36                   ` Dan Scally
     [not found]         ` <20201026161050.GQ4077@smile.fi.intel.com>
2020-10-29 20:19           ` Laurent Pinchart
2020-10-29 20:26             ` Andy Shevchenko
2020-10-29 21:29               ` Laurent Pinchart
2020-10-29 22:22                 ` Andy Shevchenko
2020-10-29 22:51                   ` Laurent Pinchart
2020-11-13 10:02                     ` Dan Scally
2020-11-13 16:22                       ` Laurent Pinchart
2020-11-13 19:45                         ` Andy Shevchenko
2020-11-15  8:45                           ` Daniel Scally
2020-11-16  8:53                           ` Laurent Pinchart
2020-11-16 13:57                             ` Andy Shevchenko
2020-11-16 14:10                               ` Laurent Pinchart
2020-11-16 14:15                                 ` Dan Scally
2020-11-16 16:16                                   ` Andy Shevchenko [this message]
2020-11-17 12:01                                     ` Dan Scally
2020-11-17 16:42                                       ` Andy Shevchenko
2020-11-17 22:59                                         ` Dan Scally
2020-10-24 15:11     ` Sakari Ailus
2020-10-24 15:14   ` Sakari Ailus
2020-10-24 20:28     ` Dan Scally
2020-10-25 11:18       ` Sakari Ailus
2020-10-20  9:24 ` [RFC PATCH v3 0/9] Add functionality to ipu3-cio2 driver " Andy Shevchenko
2020-10-20 13:38 ` Rafael J. Wysocki
2020-10-21 20:59   ` 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=20201116161636.GC4077@smile.fi.intel.com \
    --to=andy.shevchenko@gmail.com \
    --cc=bingbu.cao@intel.com \
    --cc=davem@davemloft.net \
    --cc=djrscally@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kitakar@gmail.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mchehab@kernel.org \
    --cc=pmladek@suse.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sergey.senozhatsky@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