[PATCH 00/17] Add export symbol namespace PL_CHROMEOS

Gwendal Grignou posted 17 patches 4 years, 5 months ago
drivers/extcon/extcon-usbc-cros-ec.c           |  1 +
drivers/hid/hid-google-hammer.c                |  1 +
drivers/i2c/busses/i2c-cros-ec-tunnel.c        |  1 +
.../cros_ec_sensors/cros_ec_sensors_core.c     |  1 +
drivers/iio/proximity/cros_ec_mkbp_proximity.c |  1 +
drivers/input/keyboard/cros_ec_keyb.c          |  1 +
.../media/cec/platform/cros-ec/cros-ec-cec.c   |  1 +
drivers/mfd/cros_ec_dev.c                      |  1 +
drivers/platform/chrome/cros_ec.c              |  1 +
drivers/platform/chrome/cros_ec_chardev.c      |  1 +
drivers/platform/chrome/cros_ec_debugfs.c      |  1 +
drivers/platform/chrome/cros_ec_i2c.c          |  1 +
drivers/platform/chrome/cros_ec_ishtp.c        |  1 +
drivers/platform/chrome/cros_ec_lightbar.c     |  1 +
drivers/platform/chrome/cros_ec_lpc.c          |  1 +
drivers/platform/chrome/cros_ec_proto.c        | 18 +++++++++---------
drivers/platform/chrome/cros_ec_rpmsg.c        |  1 +
drivers/platform/chrome/cros_ec_sensorhub.c    |  1 +
.../platform/chrome/cros_ec_sensorhub_ring.c   |  4 ++--
drivers/platform/chrome/cros_ec_spi.c          |  1 +
drivers/platform/chrome/cros_ec_sysfs.c        |  1 +
drivers/platform/chrome/cros_ec_typec.c        |  1 +
drivers/platform/chrome/cros_ec_vbc.c          |  1 +
drivers/platform/chrome/cros_usbpd_logger.c    |  1 +
drivers/platform/chrome/cros_usbpd_notify.c    |  5 +++--
drivers/platform/chrome/wilco_ec/debugfs.c     |  1 +
drivers/platform/chrome/wilco_ec/mailbox.c     |  2 +-
drivers/platform/chrome/wilco_ec/properties.c  |  8 ++++----
drivers/platform/chrome/wilco_ec/telemetry.c   |  1 +
drivers/power/supply/cros_peripheral_charger.c |  1 +
drivers/power/supply/cros_usbpd-charger.c      |  1 +
drivers/power/supply/wilco-charger.c           |  1 +
drivers/pwm/pwm-cros-ec.c                      |  1 +
drivers/regulator/cros-ec-regulator.c          |  1 +
drivers/rtc/rtc-cros-ec.c                      |  1 +
drivers/rtc/rtc-wilco-ec.c                     |  1 +
sound/soc/codecs/cros_ec_codec.c               |  1 +
37 files changed, 51 insertions(+), 18 deletions(-)
[PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Gwendal Grignou 4 years, 5 months ago
Add a symbol namespace for functions exported by the plaform chromeos
subsystem.
Add depenencies for all drivers using these function.

'make nsdeps' is used to fix the dependencies.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

Gwendal Grignou (17):
  plaform: chrome: Add PL_CHROMEOS export symbol namespace
  iio:cros_ec_sensors: Add PL_CHROMEOS dependency
  platform/chrome: Add PL_CHROMEOS dependency
  power_supply: chromeos: Add PL_CHROMEOS dependency
  rtc: wilco: Add PL_CHROMEOS dependency
  mfd: cros_ec_dev: Add PL_CHROMEOS dependency
  platform: chrome: Add PL_CHROMEOS dependency
  rtc: cros_ec: Add PL_CHROMEOS dependency
  extcon: cros_ec: Add PL_CHROMEOS dependency
  HID: google: Add PL_CHROMEOS dependency
  i2c: cros-ec-tunnel: Add PL_CHROMEOS dependency
  Input: cros_ec_keyb - Add PL_CHROMEOS dependency
  media: cros-ec-cec: Add PL_CHROMEOS dependency
  power: supply: PCHG: Add PL_CHROMEOS dependency
  pwm: cros-ec: Add PL_CHROMEOS dependency
  regulator: cros-ec-regulator: Add PL_CHROMEOS dependency
  ASoC: cros_ec_codec: Add PL_CHROMEOS dependency

 drivers/extcon/extcon-usbc-cros-ec.c           |  1 +
 drivers/hid/hid-google-hammer.c                |  1 +
 drivers/i2c/busses/i2c-cros-ec-tunnel.c        |  1 +
 .../cros_ec_sensors/cros_ec_sensors_core.c     |  1 +
 drivers/iio/proximity/cros_ec_mkbp_proximity.c |  1 +
 drivers/input/keyboard/cros_ec_keyb.c          |  1 +
 .../media/cec/platform/cros-ec/cros-ec-cec.c   |  1 +
 drivers/mfd/cros_ec_dev.c                      |  1 +
 drivers/platform/chrome/cros_ec.c              |  1 +
 drivers/platform/chrome/cros_ec_chardev.c      |  1 +
 drivers/platform/chrome/cros_ec_debugfs.c      |  1 +
 drivers/platform/chrome/cros_ec_i2c.c          |  1 +
 drivers/platform/chrome/cros_ec_ishtp.c        |  1 +
 drivers/platform/chrome/cros_ec_lightbar.c     |  1 +
 drivers/platform/chrome/cros_ec_lpc.c          |  1 +
 drivers/platform/chrome/cros_ec_proto.c        | 18 +++++++++---------
 drivers/platform/chrome/cros_ec_rpmsg.c        |  1 +
 drivers/platform/chrome/cros_ec_sensorhub.c    |  1 +
 .../platform/chrome/cros_ec_sensorhub_ring.c   |  4 ++--
 drivers/platform/chrome/cros_ec_spi.c          |  1 +
 drivers/platform/chrome/cros_ec_sysfs.c        |  1 +
 drivers/platform/chrome/cros_ec_typec.c        |  1 +
 drivers/platform/chrome/cros_ec_vbc.c          |  1 +
 drivers/platform/chrome/cros_usbpd_logger.c    |  1 +
 drivers/platform/chrome/cros_usbpd_notify.c    |  5 +++--
 drivers/platform/chrome/wilco_ec/debugfs.c     |  1 +
 drivers/platform/chrome/wilco_ec/mailbox.c     |  2 +-
 drivers/platform/chrome/wilco_ec/properties.c  |  8 ++++----
 drivers/platform/chrome/wilco_ec/telemetry.c   |  1 +
 drivers/power/supply/cros_peripheral_charger.c |  1 +
 drivers/power/supply/cros_usbpd-charger.c      |  1 +
 drivers/power/supply/wilco-charger.c           |  1 +
 drivers/pwm/pwm-cros-ec.c                      |  1 +
 drivers/regulator/cros-ec-regulator.c          |  1 +
 drivers/rtc/rtc-cros-ec.c                      |  1 +
 drivers/rtc/rtc-wilco-ec.c                     |  1 +
 sound/soc/codecs/cros_ec_codec.c               |  1 +
 37 files changed, 51 insertions(+), 18 deletions(-)

-- 
2.34.1.448.ga2b2bfdf31-goog

Re: [PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Dmitry Torokhov 4 years, 5 months ago
Hi Gwendal,

On Wed, Jan 5, 2022 at 2:07 PM Gwendal Grignou <gwendal@chromium.org> wrote:
>
> Add a symbol namespace for functions exported by the plaform chromeos
> subsystem.

It would be great to explain why this is needed/desirable. What are
the benefits of introducing this namespace? What problem are you
trying to solve?

> Add depenencies for all drivers using these function.
>
> 'make nsdeps' is used to fix the dependencies.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
>
> Gwendal Grignou (17):
>   plaform: chrome: Add PL_CHROMEOS export symbol namespace
>   iio:cros_ec_sensors: Add PL_CHROMEOS dependency

I wonder if ordering patches this way breaks compilation (patches
should be structured in such a way that one need not apply entire
series to get to buildable kernel). Isn't putting symbols into new
namespace makes them unavailable to modules unless they explicitly
import it?

Thanks.

-- 
Dmitry
Re: [PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Gwendal Grignou 4 years, 5 months ago
On Wed, Jan 5, 2022 at 2:58 PM Dmitry Torokhov <dtor@chromium.org> wrote:
>
> Hi Gwendal,
>
> On Wed, Jan 5, 2022 at 2:07 PM Gwendal Grignou <gwendal@chromium.org> wrote:
> >
> > Add a symbol namespace for functions exported by the plaform chromeos
> > subsystem.
>
> It would be great to explain why this is needed/desirable. What are
> the benefits of introducing this namespace? What problem are you
> trying to solve?
The issue came when reviewing an iio sensor
(https://www.spinics.net/lists/linux-iio/msg66280.html). I wanted to
be ahead of the curve (for once).

>
> > Add depenencies for all drivers using these function.
> >
> > 'make nsdeps' is used to fix the dependencies.
> >
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> >
> > Gwendal Grignou (17):
> >   plaform: chrome: Add PL_CHROMEOS export symbol namespace
> >   iio:cros_ec_sensors: Add PL_CHROMEOS dependency
>
> I wonder if ordering patches this way breaks compilation (patches
> should be structured in such a way that one need not apply entire
> series to get to buildable kernel). Isn't putting symbols into new
> namespace makes them unavailable to modules unless they explicitly
> import it?
From https://www.kernel.org/doc/html/latest/core-api/symbol-namespaces.html#loading-modules-that-use-namespaced-symbols,
since MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is set by default, this
is just a warning at load time.

Gwendal.
>
> Thanks.
>
> --
> Dmitry
Re: [PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Mauro Carvalho Chehab 4 years, 5 months ago
Em Wed, 5 Jan 2022 20:26:36 -0800
Gwendal Grignou <gwendal@chromium.org> escreveu:

> On Wed, Jan 5, 2022 at 2:58 PM Dmitry Torokhov <dtor@chromium.org> wrote:
> >
> > Hi Gwendal,
> >
> > On Wed, Jan 5, 2022 at 2:07 PM Gwendal Grignou <gwendal@chromium.org> wrote:  
> > >
> > > Add a symbol namespace for functions exported by the plaform chromeos
> > > subsystem.  
> >
> > It would be great to explain why this is needed/desirable. What are
> > the benefits of introducing this namespace? What problem are you
> > trying to solve?  
> The issue came when reviewing an iio sensor
> (https://www.spinics.net/lists/linux-iio/msg66280.html). I wanted to
> be ahead of the curve (for once).

Patch 01 should clearly document the reason why this is needed.
Yet, see below.

While I see value on using namespaces, we should have extra care when
this is used for kAPIs designed for a product/system. I mean, what
prevents that the affected drivers won't support some day different
non-ChromeOS products? We have a media driver originally written to 
work with the One Laptop Per Children hardware, that used some
product-specific kAPIs, that were extended a couple years later to
cover different types of hardware.

What happens if some day, a driver introduced to be used on a ChromeOS
hardware would also be used by a non-ChromeOS hardware? This could
become messy as times goes by.

Instead, IMO, it would make sense to have per-subsystem namespaces.
So, for instance, placing iio under an IIO-specific namespace
(and the same for other subsystems) makes more sense on my
eyes, as the namespace boundary will be clearer, and an IIO driver
will always be IIO, no matter on what hardware such driver would
be used.

Thanks,
Mauro
Re: [PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Gwendal Grignou 4 years, 5 months ago
On Thu, Jan 6, 2022 at 2:06 AM Mauro Carvalho Chehab <mchehab@kernel.org> wrote:
>
> Em Wed, 5 Jan 2022 20:26:36 -0800
> Gwendal Grignou <gwendal@chromium.org> escreveu:
>
> > On Wed, Jan 5, 2022 at 2:58 PM Dmitry Torokhov <dtor@chromium.org> wrote:
> > >
> > > Hi Gwendal,
> > >
> > > On Wed, Jan 5, 2022 at 2:07 PM Gwendal Grignou <gwendal@chromium.org> wrote:
> > > >
> > > > Add a symbol namespace for functions exported by the plaform chromeos
> > > > subsystem.
> > >
> > > It would be great to explain why this is needed/desirable. What are
> > > the benefits of introducing this namespace? What problem are you
> > > trying to solve?
> > The issue came when reviewing an iio sensor
> > (https://www.spinics.net/lists/linux-iio/msg66280.html). I wanted to
> > be ahead of the curve (for once).
>
> Patch 01 should clearly document the reason why this is needed.
> Yet, see below.
>
> While I see value on using namespaces, we should have extra care when
> this is used for kAPIs designed for a product/system. I mean, what
> prevents that the affected drivers won't support some day different
> non-ChromeOS products? We have a media driver originally written to
> work with the One Laptop Per Children hardware, that used some
> product-specific kAPIs, that were extended a couple years later to
> cover different types of hardware.
>
> What happens if some day, a driver introduced to be used on a ChromeOS
> hardware would also be used by a non-ChromeOS hardware? This could
> become messy as times goes by.
>
> Instead, IMO, it would make sense to have per-subsystem namespaces.
> So, for instance, placing iio under an IIO-specific namespace
> (and the same for other subsystems) makes more sense on my
> eyes, as the namespace boundary will be clearer, and an IIO driver
> will always be IIO, no matter on what hardware such driver would
> be used.
I based this patchset on the current/future use in the IIO subsystem,
where the namespaces are used for small subsystem like HID,
IIO_HID_ATTRIBUTES, or code shared among sensors drivers of the same
vendor (LTC2497, more to come).
Since the usage of namespace in the kernel is not clearly defined yet,
I wait for the dust to settle and more usage to emerge before tuning
this patchset.

Thanks,
Gwendal.
>
> Thanks,
> Mauro
Re: [PATCH 00/17] Add export symbol namespace PL_CHROMEOS
Posted by Jonathan Cameron 4 years, 5 months ago
On Mon, 10 Jan 2022 01:31:23 -0800
Gwendal Grignou <gwendal@chromium.org> wrote:

> On Thu, Jan 6, 2022 at 2:06 AM Mauro Carvalho Chehab <mchehab@kernel.org> wrote:
> >
> > Em Wed, 5 Jan 2022 20:26:36 -0800
> > Gwendal Grignou <gwendal@chromium.org> escreveu:
> >  
> > > On Wed, Jan 5, 2022 at 2:58 PM Dmitry Torokhov <dtor@chromium.org> wrote:  
> > > >
> > > > Hi Gwendal,
> > > >
> > > > On Wed, Jan 5, 2022 at 2:07 PM Gwendal Grignou <gwendal@chromium.org> wrote:  
> > > > >
> > > > > Add a symbol namespace for functions exported by the plaform chromeos
> > > > > subsystem.  
> > > >
> > > > It would be great to explain why this is needed/desirable. What are
> > > > the benefits of introducing this namespace? What problem are you
> > > > trying to solve?  
> > > The issue came when reviewing an iio sensor
> > > (https://www.spinics.net/lists/linux-iio/msg66280.html). I wanted to
> > > be ahead of the curve (for once).  
> >
> > Patch 01 should clearly document the reason why this is needed.
> > Yet, see below.
> >
> > While I see value on using namespaces, we should have extra care when
> > this is used for kAPIs designed for a product/system. I mean, what
> > prevents that the affected drivers won't support some day different
> > non-ChromeOS products? We have a media driver originally written to
> > work with the One Laptop Per Children hardware, that used some
> > product-specific kAPIs, that were extended a couple years later to
> > cover different types of hardware.
> >
> > What happens if some day, a driver introduced to be used on a ChromeOS
> > hardware would also be used by a non-ChromeOS hardware? This could
> > become messy as times goes by.
Hi Mauro,

I'm not sure I see why this case is a problem or any worse than the
namespacing that already exists in the function names.  We name a lot
of stuff after first device that used it and some of it lives for ever.
Sure, sometime it makes sense to rename when something becomes more
generic, but we can do that here as needed.

> >
> > Instead, IMO, it would make sense to have per-subsystem namespaces.
> > So, for instance, placing iio under an IIO-specific namespace
> > (and the same for other subsystems) makes more sense on my
> > eyes, as the namespace boundary will be clearer, and an IIO driver
> > will always be IIO, no matter on what hardware such driver would
> > be used.  
> I based this patchset on the current/future use in the IIO subsystem,
> where the namespaces are used for small subsystem like HID,
> IIO_HID_ATTRIBUTES, or code shared among sensors drivers of the same
> vendor (LTC2497, more to come).

Not particularly intended to be vendor based, more library module and client
of library cases.  Obviously it's relatively rare for multiple vendors
to produce IIO devices that are sufficiently compatible to share code
beyond the IIO core, but it does happen.  In that particular case the
library is called LTC2497 as it was the first part to use it it and
there wasn't a sensible generic name.  Vast majority of IIO cases will
be a core module exporting stuff to i2c and spi specific modules.

We have drivers named after a particular part that support parts from
multiple vendors of many different names.  So in a similar fashion
I'm not that worried about having some future driver have to include
one of the namespaces that is named after some other part. Perhaps
the issue here is that the chromeos platform stuff has a name tightly
coupled to a somewhat 'generic' but also somewhat closed hardware
ecosystem?

(Not really relevant here but I do longer term plan to move the main
IIO core into a namespace, but focusing on the smaller cases first as
I think both are valid).

So I'm in support of this series but maybe you are right in waiting for
the dust to settle :)  Note I'd also like to see an IIO_CHROMEOS or
similar NS for the symbols exported by cros_ec_sensors_core.c.

Eventually I'd expect some of the IIO chromeos modules to have
MODULE_IMPORT_NS(IIO);
MODULE_IMPORT_NS(IIO_CHROMEOS);
MODULE_IMPORT_NS(PL_CHROMEOS);

and probably some others...

Jonathan

> Since the usage of namespace in the kernel is not clearly defined yet,
> I wait for the dust to settle and more usage to emerge before tuning
> this patchset.
> 
> Thanks,
> Gwendal.
> >
> > Thanks,
> > Mauro