From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Adam Belay <ambx1@neo.rr.com>,
linux@dominikbrodowski.de, akpm@osdl.org, rml@ximian.com,
linux-kernel@vger.kernel.org, linux-pcmcia@lists.infradead.org
Subject: Re: [PATCH] pcmcia driver model support [4/5]
Date: Mon, 23 Aug 2004 19:16:17 +0100 [thread overview]
Message-ID: <20040823191617.C31791@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20040823190539.B31791@flint.arm.linux.org.uk>; from rmk+lkml@arm.linux.org.uk on Mon, Aug 23, 2004 at 07:05:39PM +0100
On Mon, Aug 23, 2004 at 07:05:39PM +0100, Russell King wrote:
> On Thu, Aug 05, 2004 at 10:28:20PM +0000, Adam Belay wrote:
> >...
> > The event is then eventually reported to the ds.c client. DS then informs
> > userspace of the ejection request and waits for userspace to reply with whether
> > the request was successful. pcmcia-cs, in turn, calls DS_GET_FIRST_TUPLE while
> > verifying the ejection request.
>
> The alternative is that we avoid taking the lock when we know that
> we don't need to re-validate the regions. How does this look?
Terrible. 8) This one probably builds.
(Note: I'm expecting that this patch will have offsets, but should
still apply, build and should solve your problem.)
--- linux-2.6-pcmcia/drivers/pcmcia/rsrc_mgr.c Sun Aug 22 15:42:36 2004
+++ linux/drivers/pcmcia/rsrc_mgr.c Mon Aug 23 19:11:40 2004
@@ -88,6 +88,9 @@
};
static DECLARE_MUTEX(rsrc_sem);
+static unsigned int rsrc_mem_probe;
+#define MEM_PROBE_LOW (1 << 0)
+#define MEM_PROBE_HIGH (1 << 1)
#ifdef CONFIG_PCMCIA_PROBE
@@ -451,24 +454,22 @@
return do_mem_probe(m->base, m->num, s);
}
-static void validate_mem(struct pcmcia_socket *s)
+static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
{
resource_map_t *m, mm;
static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
static int hi = 0, lo = 0;
u_long b, i, ok = 0;
- int force_low = !(s->features & SS_CAP_PAGE_REGS);
- down(&rsrc_sem);
/* We do up to four passes through the list */
- if (!force_low) {
- if (hi++ || (inv_probe(mem_db.next, s) > 0))
- goto out;
+ if (probe_mask & MEM_PROBE_HIGH) {
+ if (inv_probe(mem_db.next, s) > 0)
+ return;
printk(KERN_NOTICE "cs: warning: no high memory space "
"available!\n");
}
- if (lo++)
- goto out;
+ if ((probe_mask & MEM_PROBE_LOW) == 0)
+ return;
for (m = mem_db.next; m != &mem_db; m = mm.next) {
mm = *m;
/* Only probe < 1 MB */
@@ -488,38 +489,51 @@
}
}
}
- out:
- up(&rsrc_sem);
}
#else /* CONFIG_PCMCIA_PROBE */
-static void validate_mem(struct pcmcia_socket *s)
+static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
{
- resource_map_t *m, mm;
- static int done = 0;
+ resource_map_t *m, mm;
- if (done++ == 0) {
- down(&rsrc_sem);
for (m = mem_db.next; m != &mem_db; m = mm.next) {
- mm = *m;
- if (do_mem_probe(mm.base, mm.num, s))
- break;
+ mm = *m;
+ if (do_mem_probe(mm.base, mm.num, s))
+ break;
}
- up(&rsrc_sem);
- }
}
#endif /* CONFIG_PCMCIA_PROBE */
+/*
+ * Locking note: this is the only place where we take
+ * both rsrc_sem and skt_sem.
+ */
void pcmcia_validate_mem(struct pcmcia_socket *s)
{
- down(&s->skt_sem);
+ if (probe_mem) {
+ unsigned int probe_mask;
+
+ down(&rsrc_sem);
+
+ probe_mask = MEM_PROBE_LOW;
+ if (s->features & SS_CAP_PAGE_REGS)
+ probe_mask = MEM_PROBE_HIGH;
- if (probe_mem && s->state & SOCKET_PRESENT)
- validate_mem(s);
+ if (probe_mask & ~rsrc_mem_probe) {
+ rsrc_mem_probe |= probe_mask;
- up(&s->skt_sem);
+ down(&s->skt_sem);
+
+ if (s->state & SOCKET_PRESENT)
+ validate_mem(s, probe_mask);
+
+ up(&s->skt_sem);
+ }
+
+ up(&rsrc_sem);
+ }
}
EXPORT_SYMBOL(pcmcia_validate_mem);
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
prev parent reply other threads:[~2004-08-23 18:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-05 22:28 [PATCH] pcmcia driver model support [4/5] Adam Belay
2004-08-06 10:43 ` Russell King
2004-08-06 10:35 ` Adam Belay
2004-08-06 10:44 ` Adam Belay
2004-08-23 18:05 ` Russell King
2004-08-23 18:16 ` Russell King [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=20040823191617.C31791@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=akpm@osdl.org \
--cc=ambx1@neo.rr.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pcmcia@lists.infradead.org \
--cc=linux@dominikbrodowski.de \
--cc=rml@ximian.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