All of lore.kernel.org
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: "david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org"
	<david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>,
	"spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
	<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	"alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org"
	<alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH] spi: enable spi_board_info to be registered after spi_master
Date: Wed, 28 Jul 2010 09:23:06 +0800	[thread overview]
Message-ID: <20100728092306.1168ab7c@feng-i7> (raw)
In-Reply-To: <AANLkTi=C48+mnNjrxha8WqagCybF45f7aTn6nxt2qRuU-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Grant,

Thanks for your thorough reviews!

Will address most of the comments.



On Wed, 28 Jul 2010 01:27:16 +0800
Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:

> 
> for (i = 0, tmp_bi = bi; i < n; i++, tmp_bi++, info++)
> 
> > +               memcpy(&bi->board_info, info, sizeof *info);
> > +               list_add_tail(&bi->list, &board_list);
> > +       }
> >        mutex_unlock(&board_lock);
> > +
> > +       bi = tmp_bi;
> > +       for (i = 0; i < n; i++)
> > +               scan_masterlist(&bi->board_info);
> 
> How does this work?  The same board_info struct is passed to
> scan_masterlist() multiple times.

My bad, I tested 2 cases by calling register_board_info before and
after spi_register_master(), but only with one spi device. Will fix it


> > @@ -537,6 +557,10 @@ int spi_register_master(struct spi_master
> > *master) dev_dbg(dev, "registered master %s%s\n",
> > dev_name(&master->dev), dynamic ? " (dynamic)" : "");
> >
> > +       mutex_lock(&master_lock);
> > +       list_add_tail(&master->list, &master_list);
> > +       mutex_unlock(&master_lock);
> > +
> 
> There seems to be a race condition here.  If a boardinfo is registered
> after this list add, but before scan_boardinfo(master), then a
> boardinfo can get parsed twice for a single master.  I think the
> proper thing to do is to hold the mutex over the whole operation; from
> registering the list or master, until after the scan is complete.
> 

Good point. Maybe moving the list_add(master) after scan_boardinfo() 
can fix this race condition.

Thanks,
Feng

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/

  parent reply	other threads:[~2010-07-28  1:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27  9:42 [PATCH] spi: enable spi_board_info to be registered after spi_master Feng Tang
     [not found] ` <1280223769-19919-1-git-send-email-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2010-07-27 17:27   ` Grant Likely
     [not found]     ` <AANLkTi=C48+mnNjrxha8WqagCybF45f7aTn6nxt2qRuU-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-28  1:23       ` Feng Tang [this message]
2010-07-28  2:22         ` Feng Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100728092306.1168ab7c@feng-i7 \
    --to=feng.tang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.