Patchwork [3/5] rapidio: run discovery as an asynchronous process

login
register
mail settings
Submitter Andrew Morton
Date Oct. 3, 2012, 10:29 p.m.
Message ID <20121003152953.79aecece.akpm@linux-foundation.org>
Download mbox | patch
Permalink /patch/188949/
State Not Applicable
Headers show

Comments

Andrew Morton - Oct. 3, 2012, 10:29 p.m.
On Wed,  3 Oct 2012 15:18:41 -0400
Alexandre Bounine <alexandre.bounine@idt.com> 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:

Patch

--- 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);