public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "J. German Rivera" <German.Rivera@freescale.com>
Cc: gregkh@linuxfoundation.org, arnd@arndb.de,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	stuart.yoder@freescale.com, bhupesh.sharma@freescale.com,
	agraf@suse.de, bhamciu1@freescale.com, nir.erez@freescale.com,
	itai.katz@freescale.com, scottwood@freescale.com,
	R89243@freescale.com, richard.schmitt@freescale.com
Subject: Re: [PATCH 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls
Date: Thu, 30 Apr 2015 15:59:13 +0300	[thread overview]
Message-ID: <20150430125913.GY14154@mwanda> (raw)
In-Reply-To: <1430242750-17745-7-git-send-email-German.Rivera@freescale.com>

On Tue, Apr 28, 2015 at 12:39:09PM -0500, J. German Rivera wrote:
> @@ -230,15 +235,26 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem *
>   * @cmd: command to be sent
>   *
>   * Returns '0' on Success; Error code otherwise.
> - *
> - * NOTE: This function cannot be invoked from from atomic contexts.
>   */
>  int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
>  {
> +	int error;
>  	enum mc_cmd_status status;
>  	unsigned long jiffies_until_timeout =
>  	    jiffies + MC_CMD_COMPLETION_TIMEOUT_JIFFIES;

We busy loop while holding a spinlock for half a second.  That seems
bad.

>  
> +	if (preemptible()) {

This is wrong.  If the user asked for spinlocks they should always
get spinlocks.  It shouldn't matter that they are not currently holding
a different lock.

I'm skeptical of this locking anyway.

Also what about if they have PREEMPT disabled?  There aren't any users
for this stuff anyway so it's impossible to review how people are
FSL_MC_IO_ATOMIC_CONTEXT_PORTAL.

Let's wait until there is a user before looking at this.

> -		return mc_status_to_error(status);
> +		error = mc_status_to_error(status);
> +		goto common_exit;
>  	}
>  
> -	return 0;
> +	error = 0;
> +
> +common_exit:

Just name this unlock:.

> +	if (preemptible())
> +		mutex_unlock(&mc_io->mutex);
> +	else
> +		spin_unlock(&mc_io->spinlock);
> +
> +	return error;
>  }

regards,
dan carpenter

  reply	other threads:[~2015-04-30 12:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 17:39 [PATCH 0/7] staging: fsl-mc: New functionality to the MC bus driver J. German Rivera
2015-04-28 17:39 ` [PATCH 1/7] staging: fsl-mc: MC bus IRQ support J. German Rivera
2015-04-30 11:49   ` Dan Carpenter
2015-05-04 22:09     ` Jose Rivera
2015-05-05  8:48       ` Dan Carpenter
2015-05-05 16:08         ` Jose Rivera
2015-05-05 16:40           ` Dan Carpenter
2015-05-05 19:56             ` Scott Wood
2015-05-05 20:22               ` Jose Rivera
2015-05-05 20:40                 ` Scott Wood
2015-05-06  6:42               ` Dan Carpenter
2015-05-05 19:42           ` Scott Wood
2015-05-05 20:26             ` Jose Rivera
2015-04-28 17:39 ` [PATCH 2/7] staging: fsl_-mc: add device binding path 'driver_override' J. German Rivera
2015-04-28 17:39 ` [PATCH 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children J. German Rivera
2015-04-28 17:39 ` [PATCH 4/7] staging: fsl-mc: Upgraded MC bus driver to match MC fw 7.0.0 J. German Rivera
2015-04-30 12:12   ` Dan Carpenter
2015-05-04 23:58     ` Jose Rivera
2015-05-05  8:51       ` Dan Carpenter
2015-04-28 17:39 ` [PATCH 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support J. German Rivera
2015-04-28 17:39 ` [PATCH 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls J. German Rivera
2015-04-30 12:59   ` Dan Carpenter [this message]
2015-05-05 16:20     ` Jose Rivera
2015-04-28 17:39 ` [PATCH 7/7] staging: fsl-mc: Use DPMCP IRQ and completion var to wait for MC J. German Rivera
2015-04-30 13:01   ` Dan Carpenter

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=20150430125913.GY14154@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=German.Rivera@freescale.com \
    --cc=R89243@freescale.com \
    --cc=agraf@suse.de \
    --cc=arnd@arndb.de \
    --cc=bhamciu1@freescale.com \
    --cc=bhupesh.sharma@freescale.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=itai.katz@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nir.erez@freescale.com \
    --cc=richard.schmitt@freescale.com \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.com \
    /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