Commit fc4833a2 authored by Russell King's avatar Russell King

[PCMCIA] Move SS_CAP_PAGE_REGS test into find_mem_region()

We must always allocate windows below 1MB when a socket driver
indicates that it does not have "page registers".  Handle this
case in rsrc_mgr.c within find_mem_region rather than each use
of find_mem_region().
parent 3deb6556
...@@ -106,11 +106,10 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag ...@@ -106,11 +106,10 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag
pccard_mem_map *mem = &s->cis_mem; pccard_mem_map *mem = &s->cis_mem;
if (!(s->features & SS_CAP_STATIC_MAP) && if (!(s->features & SS_CAP_STATIC_MAP) &&
mem->sys_start == 0) { mem->sys_start == 0) {
int low = !(s->features & SS_CAP_PAGE_REGS);
validate_mem(s); validate_mem(s);
mem->sys_start = 0; mem->sys_start = 0;
if (find_mem_region(&mem->sys_start, s->map_size, if (find_mem_region(&mem->sys_start, s->map_size,
s->map_size, low, "card services", s)) { s->map_size, 0, "card services", s)) {
printk(KERN_NOTICE "cs: unable to map card memory!\n"); printk(KERN_NOTICE "cs: unable to map card memory!\n");
return NULL; return NULL;
} }
......
...@@ -2043,8 +2043,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle ...@@ -2043,8 +2043,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
if (!(s->features & SS_CAP_STATIC_MAP) && if (!(s->features & SS_CAP_STATIC_MAP) &&
find_mem_region(&win->base, win->size, align, find_mem_region(&win->base, win->size, align,
(req->Attributes & WIN_MAP_BELOW_1MB) || (req->Attributes & WIN_MAP_BELOW_1MB),
!(s->features & SS_CAP_PAGE_REGS),
(*handle)->dev_info, s)) (*handle)->dev_info, s))
return CS_IN_USE; return CS_IN_USE;
(*handle)->state |= CLIENT_WIN_REQ(w); (*handle)->state |= CLIENT_WIN_REQ(w);
......
...@@ -168,7 +168,7 @@ void validate_mem(struct pcmcia_socket *s); ...@@ -168,7 +168,7 @@ void validate_mem(struct pcmcia_socket *s);
int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align, int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align,
char *name, struct pcmcia_socket *s); char *name, struct pcmcia_socket *s);
int find_mem_region(u_long *base, u_long num, u_long align, int find_mem_region(u_long *base, u_long num, u_long align,
int force_low, char *name, struct pcmcia_socket *s); int low, char *name, struct pcmcia_socket *s);
int try_irq(u_int Attributes, int irq, int specific); int try_irq(u_int Attributes, int irq, int specific);
void undo_irq(u_int Attributes, int irq); void undo_irq(u_int Attributes, int irq);
int adjust_resource_info(client_handle_t handle, adjust_t *adj); int adjust_resource_info(client_handle_t handle, adjust_t *adj);
......
...@@ -590,17 +590,19 @@ int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align, ...@@ -590,17 +590,19 @@ int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align,
} }
int find_mem_region(u_long *base, u_long num, u_long align, int find_mem_region(u_long *base, u_long num, u_long align,
int force_low, char *name, struct pcmcia_socket *s) int low, char *name, struct pcmcia_socket *s)
{ {
u_long try; u_long try;
resource_map_t *m; resource_map_t *m;
int ret = -1; int ret = -1;
low = low || !(s->features & SS_CAP_PAGE_REGS);
down(&rsrc_sem); down(&rsrc_sem);
while (1) { while (1) {
for (m = mem_db.next; m != &mem_db; m = m->next) { for (m = mem_db.next; m != &mem_db; m = m->next) {
/* first pass >1MB, second pass <1MB */ /* first pass >1MB, second pass <1MB */
if ((force_low != 0) ^ (m->base < 0x100000)) if ((low != 0) ^ (m->base < 0x100000))
continue; continue;
try = (m->base & ~(align-1)) + *base; try = (m->base & ~(align-1)) + *base;
...@@ -616,9 +618,9 @@ int find_mem_region(u_long *base, u_long num, u_long align, ...@@ -616,9 +618,9 @@ int find_mem_region(u_long *base, u_long num, u_long align,
break; break;
} }
} }
if (force_low) if (low)
break; break;
force_low++; low++;
} }
out: out:
up(&rsrc_sem); up(&rsrc_sem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment