Re: [PATCH] nubus: Unconditionally register bus type

From: Greg Kroah-Hartman
Date: Tue May 08 2018 - 03:00:57 EST

On Mon, May 07, 2018 at 09:51:12AM +1200, Michael Schmitz wrote:
> Hi Greg,
> the BUG() was triggered by loading a Mac Nubus network card module on
> a multiplatform kernel running on an Amiga machine. Up to Finn's Nubus
> core rewrite (this February), we've seen no errors. Since then, Nubus
> drivers fail to register because the Nubus bus is only registered on
> Macs.
> Can't see link order involved here at all.

The link order is totally involved here :)

Link order determines the order in which init calls are run, so you need
to ensure that your bus code comes before any drivers that use that bus
code in link order. That way, at init time, your bus is created first,
preventing this type of error to happen.

> Safeguarding against this bug could be done by checking a
> bus-is-registered flag, or checking what machine model the kernel runs
> on. Simply registering the Nubus bus driver regardless of machine
> model seemed the easiest way.

If you really have this problem due to link ordering issues not being
able to be worked around (due to different directories and the like),
then put a "bus is registered" flag in your bus code. That will solve
the initial BUG_ON() problem, and you should return an error that allows
the driver code to probe your driver later on after your bus is enabled.

Hope this helps,

greg k-h