From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: York Sun <yorksun@freescale.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
galak@kernel.crashing.org,
linux-fbdev-devel@lists.sourceforge.net, timur@freescale.com,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 1/2 v2] Driver for Freescale 8610 and 5121 DIU
Date: Fri, 21 Mar 2008 00:02:16 +0100 [thread overview]
Message-ID: <1206054136.6437.67.camel@lappy> (raw)
In-Reply-To: <20080320152708.23c6c734.akpm@linux-foundation.org>
On Thu, 2008-03-20 at 15:27 -0700, Andrew Morton wrote:
> >
> > +static struct diu_hw dr = {
> > + .mode = MFB_MODE1,
> > + .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
> > +};
>
> I'm not clear on what's supposed to happen with __SPIN_LOCK_UNLOCKED(). I
> do know that its documentation is crap.
>
> I guess you should have used SPIN_LOCK_UNLOCKED there rather than
> open-coding its equivalent. And SPIN_LOCK_UNLOCKED _is_ documented. It
> says "don't use this".
>
> Now, s/documentation/guesswork-and-grep/ says that you're supposed to pick
> a tree-wide-unique string here as your lockdep key.
>
> So I did this:
>
> --- a/drivers/video/fsl-diu-fb.c~fbdev-driver-for-freescale-8610-and-5121-diu-fix
> +++ a/drivers/video/fsl-diu-fb.c
> @@ -274,7 +274,7 @@ static struct mfb_info mfb_template[] =
>
> static struct diu_hw dr = {
> .mode = MFB_MODE1,
> - .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
> + .reg_lock = __SPIN_LOCK_UNLOCKED(diu_hw.reg_lock),
> };
#define __SPIN_LOCK_UNLOCKED(lockname)
seems pretty suggestive to me, also DEFINE_SPINLOCK(x) shows the proper
usage; the right thing would have been:
static struct diu_hw dr = {
.mode = MFB_MODE1,
- .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
+ .reg_lock = __SPIN_LOCK_UNLOCKED(dr.reg_lock),
};
Where 'dr.reg_lock' is the expression to locate the actual object.
Does something like this make sense to you:
---
Subject: lockdep: document __SPIN_LOCK_UNLOCKED() usage
Small comment clarifying the intended usage of __SPIN_LOCK_UNLOCKED()
[ for the observant readers; yes this prescribes a usage that is more
than strictly needed, it does however enable interesting future uses ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index 68d88f7..4278558 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -63,6 +63,10 @@ typedef struct {
# define RW_DEP_MAP_INIT(lockname)
#endif
+/*
+ * __*_LOCK_UNLOCKED(lockname), where 'lockname' is a valid C expression
+ * that evaluates to the actual object being initialized.
+ */
#ifdef CONFIG_DEBUG_SPINLOCK
# define __SPIN_LOCK_UNLOCKED(lockname) \
(spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
---
Perhaps I should make the macros do something like:
typecheck(spinlock_t, lockname)
And sweep the tree to make it compile again.
> static struct diu_pool pool;
>
> > +static struct diu_pool pool;
> > +
> > +/* To allocate memory for framebuffer. First try __get_free_pages(). If it
> > + * fails, try rh_alloc. The reason is __get_free_pages() cannot allocate
> > + * very large memory (more than 4MB). We don't want to allocate all memory
> > + * in rheap since small memory allocation/deallocation will fragment the
> > + * rheap and make the furture large allocation fail.
> > + */
> > +
> > +void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys)
> > +{
> > + void *virt;
> > +
> > + pr_debug("size=%lu\n", size);
> > +
> > + virt = (void *)__get_free_pages(GFP_DMA | GFP_ATOMIC, get_order(size));
>
> GFP_DMA implies GFP_ATOMIC, but it's appropriate for documentation purposes.
FWIW, I prefer the form: GFP_type | __GFP_modifiers
For instance: 'GFP_KERNEL | __GFP_DMA | __GFP_ZERO'
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fbdev-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, York Sun <yorksun@freescale.com>,
linuxppc-dev@ozlabs.org, Ingo Molnar <mingo@elte.hu>,
timur@freescale.com
Subject: Re: [PATCH 1/2 v2] Driver for Freescale 8610 and 5121 DIU
Date: Fri, 21 Mar 2008 00:02:16 +0100 [thread overview]
Message-ID: <1206054136.6437.67.camel@lappy> (raw)
In-Reply-To: <20080320152708.23c6c734.akpm@linux-foundation.org>
On Thu, 2008-03-20 at 15:27 -0700, Andrew Morton wrote:
> >
> > +static struct diu_hw dr = {
> > + .mode = MFB_MODE1,
> > + .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
> > +};
>
> I'm not clear on what's supposed to happen with __SPIN_LOCK_UNLOCKED(). I
> do know that its documentation is crap.
>
> I guess you should have used SPIN_LOCK_UNLOCKED there rather than
> open-coding its equivalent. And SPIN_LOCK_UNLOCKED _is_ documented. It
> says "don't use this".
>
> Now, s/documentation/guesswork-and-grep/ says that you're supposed to pick
> a tree-wide-unique string here as your lockdep key.
>
> So I did this:
>
> --- a/drivers/video/fsl-diu-fb.c~fbdev-driver-for-freescale-8610-and-5121-diu-fix
> +++ a/drivers/video/fsl-diu-fb.c
> @@ -274,7 +274,7 @@ static struct mfb_info mfb_template[] =
>
> static struct diu_hw dr = {
> .mode = MFB_MODE1,
> - .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
> + .reg_lock = __SPIN_LOCK_UNLOCKED(diu_hw.reg_lock),
> };
#define __SPIN_LOCK_UNLOCKED(lockname)
seems pretty suggestive to me, also DEFINE_SPINLOCK(x) shows the proper
usage; the right thing would have been:
static struct diu_hw dr = {
.mode = MFB_MODE1,
- .reg_lock = __SPIN_LOCK_UNLOCKED(old_style_spin_init),
+ .reg_lock = __SPIN_LOCK_UNLOCKED(dr.reg_lock),
};
Where 'dr.reg_lock' is the expression to locate the actual object.
Does something like this make sense to you:
---
Subject: lockdep: document __SPIN_LOCK_UNLOCKED() usage
Small comment clarifying the intended usage of __SPIN_LOCK_UNLOCKED()
[ for the observant readers; yes this prescribes a usage that is more
than strictly needed, it does however enable interesting future uses ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index 68d88f7..4278558 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -63,6 +63,10 @@ typedef struct {
# define RW_DEP_MAP_INIT(lockname)
#endif
+/*
+ * __*_LOCK_UNLOCKED(lockname), where 'lockname' is a valid C expression
+ * that evaluates to the actual object being initialized.
+ */
#ifdef CONFIG_DEBUG_SPINLOCK
# define __SPIN_LOCK_UNLOCKED(lockname) \
(spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
---
Perhaps I should make the macros do something like:
typecheck(spinlock_t, lockname)
And sweep the tree to make it compile again.
> static struct diu_pool pool;
>
> > +static struct diu_pool pool;
> > +
> > +/* To allocate memory for framebuffer. First try __get_free_pages(). If it
> > + * fails, try rh_alloc. The reason is __get_free_pages() cannot allocate
> > + * very large memory (more than 4MB). We don't want to allocate all memory
> > + * in rheap since small memory allocation/deallocation will fragment the
> > + * rheap and make the furture large allocation fail.
> > + */
> > +
> > +void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys)
> > +{
> > + void *virt;
> > +
> > + pr_debug("size=%lu\n", size);
> > +
> > + virt = (void *)__get_free_pages(GFP_DMA | GFP_ATOMIC, get_order(size));
>
> GFP_DMA implies GFP_ATOMIC, but it's appropriate for documentation purposes.
FWIW, I prefer the form: GFP_type | __GFP_modifiers
For instance: 'GFP_KERNEL | __GFP_DMA | __GFP_ZERO'
next prev parent reply other threads:[~2008-03-20 23:02 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-19 18:50 v2 patch for Freescale DIU driver York Sun
2008-03-19 18:50 ` York Sun
2008-03-19 18:50 ` [PATCH 1/2 v2] Driver for Freescale 8610 and 5121 DIU York Sun
2008-03-19 18:50 ` York Sun
2008-03-19 18:50 ` [PATCH 2/2 v2] Add DIU platform code for MPC8610HPCD York Sun
2008-03-19 18:50 ` York Sun
2008-03-20 22:33 ` Andrew Morton
2008-03-20 22:33 ` Andrew Morton
2008-03-20 22:33 ` Andrew Morton
2008-03-25 12:43 ` Andy Whitcroft
2008-03-25 12:43 ` Andy Whitcroft
2008-03-25 19:18 ` Andrew Morton
2008-03-25 19:18 ` Andrew Morton
2008-03-25 19:18 ` Andrew Morton
2008-03-20 22:27 ` [PATCH 1/2 v2] Driver for Freescale 8610 and 5121 DIU Andrew Morton
2008-03-20 22:27 ` Andrew Morton
2008-03-20 22:27 ` Andrew Morton
2008-03-20 23:02 ` Peter Zijlstra [this message]
2008-03-20 23:02 ` Peter Zijlstra
2008-03-21 16:12 ` Timur Tabi
2008-03-21 16:12 ` Timur Tabi
2008-03-21 18:12 ` Andrew Morton
2008-03-21 18:12 ` Andrew Morton
2008-03-21 18:12 ` Andrew Morton
2008-03-24 14:53 ` Timur Tabi
2008-03-24 14:53 ` Timur Tabi
2008-03-24 14:53 ` Timur Tabi
2008-03-24 18:47 ` Andrew Morton
2008-03-24 18:47 ` Andrew Morton
2008-03-24 18:47 ` Andrew Morton
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=1206054136.6437.67.camel@lappy \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=galak@kernel.crashing.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=timur@freescale.com \
--cc=yorksun@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 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.