From patchwork Wed Oct 3 22:29:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3/5] rapidio: run discovery as an asynchronous process Date: Wed, 03 Oct 2012 12:29:53 -0000 From: Andrew Morton X-Patchwork-Id: 188949 Message-Id: <20121003152953.79aecece.akpm@linux-foundation.org> To: Alexandre Bounine Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org On Wed, 3 Oct 2012 15:18:41 -0400 Alexandre Bounine wrote: > Modify mport initialization routine to run the RapidIO discovery process > asynchronously. This allows to have an arbitrary order of enumerating and > discovering ports in systems with multiple RapidIO controllers without > creating a deadlock situation if enumerator port is registered after a > discovering one. > > Making netID matching to mportID ensures consistent net ID assignment in > multiport RapidIO systems with asynchronous discovery process (global counter > implementation is affected by race between threads). > > > ... > > +static void __devinit disc_work_handler(struct work_struct *_work) > +{ > + struct rio_disc_work *work = container_of(_work, > + struct rio_disc_work, work); There's a nice simple way to avoid such ugliness: --- a/drivers/rapidio/rio.c~rapidio-run-discovery-as-an-asynchronous-process-fix +++ a/drivers/rapidio/rio.c @@ -1269,9 +1269,9 @@ struct rio_disc_work { static void __devinit disc_work_handler(struct work_struct *_work) { - struct rio_disc_work *work = container_of(_work, - struct rio_disc_work, work); + struct rio_disc_work *work; + work = container_of(_work, struct rio_disc_work, work); pr_debug("RIO: discovery work for mport %d %s\n", work->mport->id, work->mport->name); rio_disc_mport(work->mport);