linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* broken nouveau dependency on power supply
@ 2012-04-02  1:06 Benjamin Herrenschmidt
  2012-04-02  3:53 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2012-04-02  1:06 UTC (permalink / raw)
  To: linux-kernel, dri-devel

Hi folks !

With CONFIG_POWER_SUPPLY=m & nouveau built-in we get a build failure:

drivers/built-in.o: In function `.nouveau_pm_trigger':
(.text+0xa56e8): undefined reference to `.power_supply_is_system_supplied'

nouveau probably needs to depends on CONFIG_POWER_SUPPLY to force a module
build with the latter is =m

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: broken nouveau dependency on power supply
  2012-04-02  1:06 broken nouveau dependency on power supply Benjamin Herrenschmidt
@ 2012-04-02  3:53 ` Benjamin Herrenschmidt
  2012-04-02  9:00   ` David Airlie
  2012-05-05  4:29   ` Anton Vorontsov
  0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2012-04-02  3:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: dri-devel, Linus Torvalds, Anton Vorontsov, David Woodhouse

On Mon, 2012-04-02 at 11:06 +1000, Benjamin Herrenschmidt wrote:
> Hi folks !
> 
> With CONFIG_POWER_SUPPLY=m & nouveau built-in we get a build failure:
> 
> drivers/built-in.o: In function `.nouveau_pm_trigger':
> (.text+0xa56e8): undefined reference to `.power_supply_is_system_supplied'
> 
> nouveau probably needs to depends on CONFIG_POWER_SUPPLY to force a module
> build with the latter is =m

Ok, not that trivial...

The problem is more like POWER_SUPPLY should be a bool, not a tristate.

If you think about it: you don't want things like nouveau to depend on a
random subsystem like that, people will never get it. In fact,
POWER_SUPPLY provides empty inline stubs when not enabled, so that's
really designed to not have depends...

However that -cannot- work if POWER_SUPPLY is modular and the drivers
who use it are not. The only fixes here that make sense I can think of
that don't also involve Kconfig horrors are:

 - Ugly: in power_supply.h, use the extern variant if

	defined(CONFIG_POWER_SUPPLY) ||
	 (defined(CONFIG_POWER_SUPPLY_MODULE) && defined(MODULE))

IE. use the stub if power supply is a module and what is being built is
built-in. Of course that's not only ugly, it somewhat sucks from a user
perspective as the subsystem now exists but can't be used by some
drivers...

 - Better: Just make the bloody thing a bool :-) The power supply
framework itself is small enough, just make it a boolean option and
avoid the problem entirely. The actual power supply sub drivers can
remain modular of course.

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: broken nouveau dependency on power supply
  2012-04-02  3:53 ` Benjamin Herrenschmidt
@ 2012-04-02  9:00   ` David Airlie
  2012-04-02  9:48     ` Benjamin Herrenschmidt
  2012-05-05  4:29   ` Anton Vorontsov
  1 sibling, 1 reply; 5+ messages in thread
From: David Airlie @ 2012-04-02  9:00 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Anton Vorontsov, Linus Torvalds, Woodhouse, dri-devel, David,
	linux-kernel


> 
> Ok, not that trivial...
> 
> The problem is more like POWER_SUPPLY should be a bool, not a
> tristate.
> 
> If you think about it: you don't want things like nouveau to depend
> on a
> random subsystem like that, people will never get it. In fact,
> POWER_SUPPLY provides empty inline stubs when not enabled, so that's
> really designed to not have depends...
> 
> However that -cannot- work if POWER_SUPPLY is modular and the drivers
> who use it are not. The only fixes here that make sense I can think
> of
> that don't also involve Kconfig horrors are:
> 
>  - Ugly: in power_supply.h, use the extern variant if
> 
> 	defined(CONFIG_POWER_SUPPLY) ||
> 	 (defined(CONFIG_POWER_SUPPLY_MODULE) && defined(MODULE))
> 
> IE. use the stub if power supply is a module and what is being built
> is
> built-in. Of course that's not only ugly, it somewhat sucks from a
> user
> perspective as the subsystem now exists but can't be used by some
> drivers...
> 
>  - Better: Just make the bloody thing a bool :-) The power supply
> framework itself is small enough, just make it a boolean option and
> avoid the problem entirely. The actual power supply sub drivers can
> remain modular of course.

We can just do select POWER_SUPPLY.

Yes it reduces the option range for some stupid corner case but really I don't care, removing features from the kernel that a driver depends on is just leading to insane state combination and QA problems.

Dave.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: broken nouveau dependency on power supply
  2012-04-02  9:00   ` David Airlie
@ 2012-04-02  9:48     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2012-04-02  9:48 UTC (permalink / raw)
  To: David Airlie
  Cc: Anton Vorontsov, Linus Torvalds, Woodhouse, dri-devel, David,
	linux-kernel

On Mon, 2012-04-02 at 05:00 -0400, David Airlie wrote:
> >  - Better: Just make the bloody thing a bool :-) The power supply
> > framework itself is small enough, just make it a boolean option and
> > avoid the problem entirely. The actual power supply sub drivers can
> > remain modular of course.
> 
> We can just do select POWER_SUPPLY.

Well, select'ing otherwise user configurable options was still frowned
on last we discussed that... and it makes the whole inline stubs in
power_supply.h totally pointless :-)

> Yes it reduces the option range for some stupid corner case but really
> I don't care, removing features from the kernel that a driver depends
> on is just leading to insane state combination and QA problems.

Well, the power supply stuff only works if you have a backend for it,
which not all platforms are, and it's fairly safe to assume AC whenever
it's not actually supported.

(Talking of which, we should be able to do a PowerBook backend
reasonably easily).

I don't care which solution you guys end up choosing though, just fix
it :-)

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: broken nouveau dependency on power supply
  2012-04-02  3:53 ` Benjamin Herrenschmidt
  2012-04-02  9:00   ` David Airlie
@ 2012-05-05  4:29   ` Anton Vorontsov
  1 sibling, 0 replies; 5+ messages in thread
From: Anton Vorontsov @ 2012-05-05  4:29 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linux-kernel, dri-devel, Linus Torvalds, David Woodhouse

Hello Benjamin,

Sorry, it took me some time to get to it.

On Mon, Apr 02, 2012 at 01:53:23PM +1000, Benjamin Herrenschmidt wrote:
[...]
> > With CONFIG_POWER_SUPPLY=m & nouveau built-in we get a build failure:
> > 
> > drivers/built-in.o: In function `.nouveau_pm_trigger':
> > (.text+0xa56e8): undefined reference to `.power_supply_is_system_supplied'
> > 
> > nouveau probably needs to depends on CONFIG_POWER_SUPPLY to force a module
> > build with the latter is =m
> 
> Ok, not that trivial...
> 
> The problem is more like POWER_SUPPLY should be a bool, not a tristate.

I see that nouveau already selects POWER_SUPPLY, but your points are
still valid. Let's make the power supply thing simple. I've applied
the following patch:

- - - -
[PATCH] power_supply: Make the core a boolean instead of a tristate

On Mon, Apr 02, 2012 at 01:53:23PM +1000, Benjamin Herrenschmidt wrote:
> > drivers/built-in.o: In function `.nouveau_pm_trigger':
> > (.text+0xa56e8): undefined reference to `.power_supply_is_system_supplied'
> >
> > nouveau probably needs to depends on CONFIG_POWER_SUPPLY to force a module
> > build with the latter is =m
>
> Ok, not that trivial...
>
> The problem is more like POWER_SUPPLY should be a bool, not a tristate.
>
> If you think about it: you don't want things like nouveau to depend on a
> random subsystem like that, people will never get it. In fact,
> POWER_SUPPLY provides empty inline stubs when not enabled, so that's
> really designed to not have depends...
>
> However that -cannot- work if POWER_SUPPLY is modular and the drivers
> who use it are not.
>
> The only fixes here that make sense I can think of
> that don't also involve Kconfig horrors are:
>
>  - Ugly: in power_supply.h, use the extern variant if
>
>       defined(CONFIG_POWER_SUPPLY) ||
>        (defined(CONFIG_POWER_SUPPLY_MODULE) && defined(MODULE))
>
> IE. use the stub if power supply is a module and what is being built is
> built-in. Of course that's not only ugly, it somewhat sucks from a user
> perspective as the subsystem now exists but can't be used by some
> drivers...
>
>  - Better: Just make the bloody thing a bool :-) The power supply
> framework itself is small enough, just make it a boolean option and
> avoid the problem entirely. The actual power supply sub drivers can
> remain modular of course.

Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---
 drivers/power/Kconfig        |    2 +-
 include/linux/power_supply.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 99dc29f..0c52a40 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -1,5 +1,5 @@
 menuconfig POWER_SUPPLY
-	tristate "Power supply class support"
+	bool "Power supply class support"
 	help
 	  Say Y here to enable power supply class support. This allows
 	  power supply (batteries, AC, USB) monitoring by userspace
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index fd17ae0..3b912be 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -212,7 +212,7 @@ extern void power_supply_changed(struct power_supply *psy);
 extern int power_supply_am_i_supplied(struct power_supply *psy);
 extern int power_supply_set_battery_charged(struct power_supply *psy);
 
-#if defined(CONFIG_POWER_SUPPLY) || defined(CONFIG_POWER_SUPPLY_MODULE)
+#ifdef CONFIG_POWER_SUPPLY
 extern int power_supply_is_system_supplied(void);
 #else
 static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-05  4:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-02  1:06 broken nouveau dependency on power supply Benjamin Herrenschmidt
2012-04-02  3:53 ` Benjamin Herrenschmidt
2012-04-02  9:00   ` David Airlie
2012-04-02  9:48     ` Benjamin Herrenschmidt
2012-05-05  4:29   ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).