linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Duncan <lduncan@suse.com>
To: linux-scsi <linux-scsi@vger.kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	hare@suse.com, jthumshirn@suse.de, JBottomley@Parallels.com
Subject: Re: [PATCH 3/6] Update soc driver to use new ida helper functions
Date: Tue, 8 Sep 2015 09:01:57 -0700	[thread overview]
Message-ID: <55EF0675.7060601@suse.com> (raw)
In-Reply-To: <145dc6d9918fe55a50afd10e22b336a041e8f692.1441416572.git.lduncan@suse.com>

Oops. I see the subject is wrong on this patch.

I will wait for comments (if any) then re-submit the sequence.

On 09/06/2015 10:59 AM, Lee Duncan wrote:
> This simplifies the calling sequence to
> acquire and to release an ida-managed index.
> 
> Note that the ida_destroy() calls here previously
> had no locking, so this may close a race condition
> when errors occur or when removing a soc.
> 
> Signed-off-by: Lee Duncan <lduncan@suse.com>
> ---
>  drivers/base/soc.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/base/soc.c b/drivers/base/soc.c
> index 39fca01c8fa1..7b632f086524 100644
> --- a/drivers/base/soc.c
> +++ b/drivers/base/soc.c
> @@ -122,18 +122,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
>  	}
>  
>  	/* Fetch a unique (reclaimable) SOC ID. */
> -	do {
> -		if (!ida_pre_get(&soc_ida, GFP_KERNEL)) {
> -			ret = -ENOMEM;
> -			goto out2;
> -		}
> -
> -		spin_lock(&soc_lock);
> -		ret = ida_get_new(&soc_ida, &soc_dev->soc_dev_num);
> -		spin_unlock(&soc_lock);
> -
> -	} while (ret == -EAGAIN);
> -
> +	ret = ida_get_index(&soc_ida, &soc_lock, &soc_dev->soc_dev_num);
>  	if (ret)
>  		goto out2;
>  
> @@ -151,7 +140,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
>  	return soc_dev;
>  
>  out3:
> -	ida_remove(&soc_ida, soc_dev->soc_dev_num);
> +	ida_put_index(&soc_ida, &sock_lock, soc_dev->soc_dev_num);
>  out2:
>  	kfree(soc_dev);
>  out1:
> @@ -161,7 +150,7 @@ out1:
>  /* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */
>  void soc_device_unregister(struct soc_device *soc_dev)
>  {
> -	ida_remove(&soc_ida, soc_dev->soc_dev_num);
> +	ida_put_index(&soc_ida, &sock_lock, soc_dev->soc_dev_num);
>  
>  	device_unregister(&soc_dev->dev);
>  }
> 

-- 
Lee Duncan
SUSE Labs

  reply	other threads:[~2015-09-08 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-06 17:59 [PATCH 0/6] Create ida helpers and use them Lee Duncan
2015-09-06 17:59 ` [PATCH 1/6] Add ida helper routines Lee Duncan
2015-09-06 17:59 ` [PATCH 2/6] SCSI: Update sd driver to use new ida helper functions Lee Duncan
2015-09-06 17:59 ` [PATCH 3/6] Update soc " Lee Duncan
2015-09-08 16:01   ` Lee Duncan [this message]
2015-09-06 17:59 ` [PATCH 4/6] " Lee Duncan
2015-09-06 17:59 ` [PATCH 5/6] Update nvme-core " Lee Duncan
2015-09-06 17:59 ` [PATCH 6/6] Update rsxx core " Lee Duncan
2015-09-14 11:11 ` [PATCH 0/6] Create ida helpers and use them Johannes Thumshirn

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=55EF0675.7060601@suse.com \
    --to=lduncan@suse.com \
    --cc=JBottomley@Parallels.com \
    --cc=hare@suse.com \
    --cc=hch@infradead.org \
    --cc=jthumshirn@suse.de \
    --cc=linux-scsi@vger.kernel.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 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).