linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Valentine Barshak <vbarshak@ru.mvista.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [RFC][PATCH] PowerPC: 4xx PCIe indirect DCR spinlock fix.
Date: Wed, 06 Feb 2008 07:47:41 +1100	[thread overview]
Message-ID: <1202244461.7079.65.camel@pasglop> (raw)
In-Reply-To: <20080205183649.GA5136@ru.mvista.com>


On Tue, 2008-02-05 at 21:36 +0300, Valentine Barshak wrote:
> Since we have mfdcri() and mtdcri() as macros, we can't use constructions, such
> as "mtdcri(base, reg, mfdcri(base, reg) | val)". In this case the mfdcri() stuff
> is not evaluated first. It's evaluated inside the mtdcri() macro and we have
> the dcr_ind_lock spinlock acquired twice. To avoid this error, I've added
> __mfdcri()/__mtdcri() inline functions that take the lock after register name
> fix-up.
> 
> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> ---
>  include/asm-powerpc/dcr-native.h |   49 +++++++++++++++++++++++----------------
>  1 files changed, 30 insertions(+), 19 deletions(-)
> 
> diff -pruN linux-2.6.orig/include/asm-powerpc/dcr-native.h linux-2.6.bld/include/asm-powerpc/dcr-native.h
> --- linux-2.6.orig/include/asm-powerpc/dcr-native.h	2008-02-05 16:44:54.000000000 +0300
> +++ linux-2.6.bld/include/asm-powerpc/dcr-native.h	2008-02-05 19:11:55.000000000 +0300
> @@ -59,25 +59,36 @@ do {								\
>  /* R/W of indirect DCRs make use of standard naming conventions for DCRs */
>  extern spinlock_t dcr_ind_lock;
>  
> -#define mfdcri(base, reg)				\
> -({							\
> -	unsigned long flags; 				\
> -	unsigned int val;				\
> -	spin_lock_irqsave(&dcr_ind_lock, flags);	\
> -	mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg);	\
> -	val = mfdcr(DCRN_ ## base ## _CONFIG_DATA);	\
> -	spin_unlock_irqrestore(&dcr_ind_lock, flags);	\
> -	val;						\
> -})
> -
> -#define mtdcri(base, reg, data)				\
> -do {							\
> -	unsigned long flags; 				\
> -	spin_lock_irqsave(&dcr_ind_lock, flags);	\
> -	mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg);	\
> -	mtdcr(DCRN_ ## base ## _CONFIG_DATA, data);	\
> -	spin_unlock_irqrestore(&dcr_ind_lock, flags);	\
> -} while (0)
> +static inline unsigned __mfdcri(int base_addr, int base_data, int reg)
> +{
> +	unsigned long flags;
> +	unsigned int val;
> +
> +	spin_lock_irqsave(&dcr_ind_lock, flags);
> +	__mtdcr(base_addr, reg);
> +	val = __mfdcr(base_data);
> +	spin_unlock_irqrestore(&dcr_ind_lock, flags);
> +	return val;
> +}
> +
> +static inline void __mtdcri(int base_addr, int base_data, int reg,
> +			    unsigned val)
> +{
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&dcr_ind_lock, flags);
> +	__mtdcr(base_addr, reg);
> +	__mtdcr(base_data, val);
> +	spin_unlock_irqrestore(&dcr_ind_lock, flags);
> +}
> +
> +#define mfdcri(base, reg)	__mfdcri(DCRN_ ## base ## _CONFIG_ADDR,	\
> +					 DCRN_ ## base ## _CONFIG_DATA,	\
> +					 reg)
> +
> +#define mtdcri(base, reg, data)	__mtdcri(DCRN_ ## base ## _CONFIG_ADDR,	\
> +					 DCRN_ ## base ## _CONFIG_DATA,	\
> +					 reg, data)
>  
>  #endif /* __ASSEMBLY__ */
>  #endif /* __KERNEL__ */

      reply	other threads:[~2008-02-05 20:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 18:27 [RFC][PATCH] PowerPC: 4xx PCIe indirect DCR spinlock fix Valentine Barshak
2008-02-04 20:50 ` Benjamin Herrenschmidt
2008-02-05 18:36   ` Valentine Barshak
2008-02-05 20:47     ` Benjamin Herrenschmidt [this message]

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=1202244461.7079.65.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=vbarshak@ru.mvista.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;
as well as URLs for NNTP newsgroup(s).