From 7a410e8d4d97457c8c381e2de9cdc7bd3306badc Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Wed, 10 Mar 2010 15:57:56 +0900 Subject: pcmcia/vrc4171: use local spinlock for device local lock. struct pcmcia_socket lock had been used before. Signed-off-by: Yoichi Yuasa Signed-off-by: Dominik Brodowski --- drivers/pcmcia/vrc4171_card.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c index c9fcbdc..aaccdb9 100644 --- a/drivers/pcmcia/vrc4171_card.c +++ b/drivers/pcmcia/vrc4171_card.c @@ -105,6 +105,7 @@ typedef struct vrc4171_socket { char name[24]; int csc_irq; int io_irq; + spinlock_t lock; } vrc4171_socket_t; static vrc4171_socket_t vrc4171_sockets[CARD_MAX_SLOTS]; @@ -327,7 +328,7 @@ static int pccard_set_socket(struct pcmcia_socket *sock, socket_state_t *state) slot = sock->sock; socket = &vrc4171_sockets[slot]; - spin_lock_irq(&sock->lock); + spin_lock_irq(&socket->lock); voltage = set_Vcc_value(state->Vcc); exca_write_byte(slot, CARD_VOLTAGE_SELECT, voltage); @@ -370,7 +371,7 @@ static int pccard_set_socket(struct pcmcia_socket *sock, socket_state_t *state) cscint |= I365_CSC_DETECT; exca_write_byte(slot, I365_CSCINT, cscint); - spin_unlock_irq(&sock->lock); + spin_unlock_irq(&socket->lock); return 0; } -- cgit v1.1 From 7a96e87d6e58a07235a2bc3eff9b093af4937a72 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 13 Mar 2010 17:42:39 +0100 Subject: pcmcia: pd6729, i82092: use parent (PCI) resources A newly added parent resource entry for the root PCI bus, such as 40000000-ffffffff : PCI Bus #00 means that the pd6729 and i82092 drivers cannot allocate iomem as freely as before, unless they do so as PCI devices. Therefore, set socket->cb_dev so that rsrc_nonstatic.c does the right thing. Reported-by: Komuro Signed-off-by: Dominik Brodowski --- drivers/pcmcia/i82092.c | 1 + drivers/pcmcia/pd6729.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index a04f21c..f5da626 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c @@ -133,6 +133,7 @@ static int __devinit i82092aa_pci_probe(struct pci_dev *dev, const struct pci_de sockets[i].socket.map_size = 0x1000; sockets[i].socket.irq_mask = 0; sockets[i].socket.pci_irq = dev->irq; + sockets[i].socket.cb_dev = dev; sockets[i].socket.owner = THIS_MODULE; sockets[i].number = i; diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index 7c20491..7ba57a5 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c @@ -671,6 +671,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev, socket[i].socket.map_size = 0x1000; socket[i].socket.irq_mask = mask; socket[i].socket.pci_irq = dev->irq; + socket[i].socket.cb_dev = dev; socket[i].socket.owner = THIS_MODULE; socket[i].number = i; -- cgit v1.1 From b416cd8efb6ce2661f8f98f603972f0b8f796ee4 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 9 Mar 2010 17:17:36 +0100 Subject: pcmcia: revert "irq probe can be done without risking an IRQ storm" This reverts commit 635416ef393e8cec5a89fc6c1de710ee9596a51e. The argument passed to request_irq() only affects action->flags (IRQF_*), but IRQ_NOAUTOEN relates to desc->status. Reported-by: Jan Beulich CC: Alan Cox Signed-off-by: Dominik Brodowski --- drivers/pcmcia/pcmcia_resource.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index b2df041..ef782c0 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -752,14 +752,6 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) #ifdef CONFIG_PCMCIA_PROBE -#ifdef IRQ_NOAUTOEN - /* if the underlying IRQ infrastructure allows for it, only allocate - * the IRQ, but do not enable it - */ - if (!(req->Handler)) - type |= IRQ_NOAUTOEN; -#endif /* IRQ_NOAUTOEN */ - if (s->irq.AssignedIRQ != 0) { /* If the interrupt is already assigned, it must be the same */ irq = s->irq.AssignedIRQ; -- cgit v1.1 From 28ca8dd71fc170090edca62cb8129625d01b7760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCnzer?= Date: Sat, 6 Mar 2010 07:46:16 +0100 Subject: pcmcia: honor saved flags in yenta_socket's I365_CSCINT register Instead of overwriting the I365_CSCINT register, save the old value and merely change the bits we care about. Part 1 of a series to allow the ISA irq to be used for Cardbus devices if the socket's PCI irq is unusable. [linux@dominikbrodowski.net: split up the original patch, commit message] Signed-off-by: Jens Kuenzer Signed-off-by: Dominik Brodowski --- drivers/pcmcia/i82365.h | 1 + drivers/pcmcia/yenta_socket.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/pcmcia/i82365.h b/drivers/pcmcia/i82365.h index 849ef1b..3f84d7a 100644 --- a/drivers/pcmcia/i82365.h +++ b/drivers/pcmcia/i82365.h @@ -95,6 +95,7 @@ #define I365_CSC_DETECT 0x08 #define I365_CSC_ANY 0x0F #define I365_CSC_GPI 0x10 +#define I365_CSC_IRQ_MASK 0xF0 /* Flags for I365_ADDRWIN */ #define I365_ENA_IO(map) (0x40 << (map)) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 967c766..42f6763 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -356,7 +356,9 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) exca_writeb(socket, I365_POWER, reg); /* CSC interrupt: no ISA irq for CSC */ - reg = I365_CSC_DETECT; + reg = exca_readb(socket, I365_CSCINT); + reg &= I365_CSC_IRQ_MASK; + reg |= I365_CSC_DETECT; if (state->flags & SS_IOCARD) { if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG; @@ -912,6 +914,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas int i; unsigned long val; u32 mask; + u8 reg; /* * Probe for usable interrupts using the force @@ -919,6 +922,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas */ cb_writel(socket, CB_SOCKET_EVENT, -1); cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); + reg = exca_readb(socket, I365_CSCINT); exca_writeb(socket, I365_CSCINT, 0); val = probe_irq_on() & isa_irq_mask; for (i = 1; i < 16; i++) { @@ -930,7 +934,7 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas cb_writel(socket, CB_SOCKET_EVENT, -1); } cb_writel(socket, CB_SOCKET_MASK, 0); - exca_writeb(socket, I365_CSCINT, 0); + exca_writeb(socket, I365_CSCINT, reg); mask = probe_irq_mask(val) & 0xffff; @@ -967,6 +971,8 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id) /* probes the PCI interrupt, use only on override functions */ static int yenta_probe_cb_irq(struct yenta_socket *socket) { + u8 reg; + if (!socket->cb_irq) return -1; @@ -979,7 +985,8 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) } /* generate interrupt, wait */ - exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG); + reg = exca_readb(socket, I365_CSCINT); + exca_writeb(socket, I365_CSCINT, reg | I365_CSC_STSCHG); cb_writel(socket, CB_SOCKET_EVENT, -1); cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); @@ -988,7 +995,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) /* disable interrupts */ cb_writel(socket, CB_SOCKET_MASK, 0); - exca_writeb(socket, I365_CSCINT, 0); + exca_writeb(socket, I365_CSCINT, reg); cb_writel(socket, CB_SOCKET_EVENT, -1); exca_readb(socket, I365_CSC); -- cgit v1.1 From ba8819e991ac507fcbfa080eacdff3e7eea4dc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCnzer?= Date: Sat, 6 Mar 2010 08:02:24 +0100 Subject: pcmcia: allow for cb_irq to differ from pci_dev's irq in yenta_socket cb_irq is presumed to be the same as the pci_dev's irq. This won't be true any more as soon as we allow the ISA irq to be used for Cardbus devices. Therefore, use the pci_dev's irq explicitely whenever we care about it. Part 2 of a series to allow the ISA irq to be used for Cardbus devices if the socket's PCI irq is unusable. [linux@dominikbrodowski.net: split up the original patch, commit message] Signed-off-by: Jens Kuenzer Signed-off-by: Dominik Brodowski --- drivers/pcmcia/yenta_socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 42f6763..51ee68d 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -329,8 +329,8 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) /* ISA interrupt control? */ intr = exca_readb(socket, I365_INTCTL); intr = (intr & ~0xf); - if (!socket->cb_irq) { - intr |= state->io_irq; + if (!socket->dev->irq) { + intr |= socket->cb_irq ? socket->cb_irq : state->io_irq; bridge |= CB_BRIDGE_INTR; } exca_writeb(socket, I365_INTCTL, intr); @@ -340,7 +340,7 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA); reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET; reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0; - if (state->io_irq != socket->cb_irq) { + if (state->io_irq != socket->dev->irq) { reg |= state->io_irq; bridge |= CB_BRIDGE_INTR; } -- cgit v1.1 From 0d3a940de51c47a3d6322537c8dce925db755477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BCnzer?= Date: Sat, 6 Mar 2010 08:27:22 +0100 Subject: pcmcia: re-route Cardbus IRQ to ISA on ti1130 bridges if necessary As the PCI irq pin of the ti1130 pcmcia bridge is not connected (at least on some old IBM Thinkpad 760ED notebooks), the Cardbus IRQ has to be routed to an ISA irq. Part 3 of a series to allow the ISA irq to be used for Cardbus devices if the socket's PCI irq is unusable. [linux@dominikbrodowski.net: split up the original patch, commit message, cleanup] Signed-off-by: Jens Kuenzer Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ti113x.h | 37 +++++++++++++++++++++++++++++++++++-- drivers/pcmcia/yenta_socket.c | 25 ++++++++++++++----------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h index aaa7022..9ffa97d 100644 --- a/drivers/pcmcia/ti113x.h +++ b/drivers/pcmcia/ti113x.h @@ -296,7 +296,7 @@ static int ti_init(struct yenta_socket *socket) u8 new, reg = exca_readb(socket, I365_INTCTL); new = reg & ~I365_INTR_ENA; - if (socket->cb_irq) + if (socket->dev->irq) new |= I365_INTR_ENA; if (new != reg) exca_writeb(socket, I365_INTCTL, new); @@ -316,14 +316,47 @@ static int ti_override(struct yenta_socket *socket) return 0; } +static void ti113x_use_isa_irq(struct yenta_socket *socket) +{ + int isa_irq = -1; + u8 intctl; + u32 isa_irq_mask = 0; + + if (!isa_probe) + return; + + /* get a free isa int */ + isa_irq_mask = yenta_probe_irq(socket, isa_interrupts); + if (!isa_irq_mask) + return; /* no useable isa irq found */ + + /* choose highest available */ + for (; isa_irq_mask; isa_irq++) + isa_irq_mask >>= 1; + socket->cb_irq = isa_irq; + + exca_writeb(socket, I365_CSCINT, (isa_irq << 4)); + + intctl = exca_readb(socket, I365_INTCTL); + intctl &= ~(I365_INTR_ENA | I365_IRQ_MASK); /* CSC Enable */ + exca_writeb(socket, I365_INTCTL, intctl); + + dev_info(&socket->dev->dev, + "Yenta TI113x: using isa irq %d for CardBus\n", isa_irq); +} + + static int ti113x_override(struct yenta_socket *socket) { u8 cardctl; cardctl = config_readb(socket, TI113X_CARD_CONTROL); cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC); - if (socket->cb_irq) + if (socket->dev->irq) cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ; + else + ti113x_use_isa_irq(socket); + config_writeb(socket, TI113X_CARD_CONTROL, cardctl); return ti_override(socket); diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 51ee68d..418988a 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -42,6 +42,18 @@ module_param_string(o2_speedup, o2_speedup, sizeof(o2_speedup), 0444); MODULE_PARM_DESC(o2_speedup, "Use prefetch/burst for O2-bridges: 'on', 'off' " "or 'default' (uses recommended behaviour for the detected bridge)"); +/* + * Only probe "regular" interrupts, don't + * touch dangerous spots like the mouse irq, + * because there are mice that apparently + * get really confused if they get fondled + * too intimately. + * + * Default to 11, 10, 9, 7, 6, 5, 4, 3. + */ +static u32 isa_interrupts = 0x0ef8; + + #define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args) /* Don't ask.. */ @@ -54,6 +66,8 @@ MODULE_PARM_DESC(o2_speedup, "Use prefetch/burst for O2-bridges: 'on', 'off' " */ #ifdef CONFIG_YENTA_TI static int yenta_probe_cb_irq(struct yenta_socket *socket); +static unsigned int yenta_probe_irq(struct yenta_socket *socket, + u32 isa_irq_mask); #endif @@ -898,17 +912,6 @@ static struct cardbus_type cardbus_type[] = { }; -/* - * Only probe "regular" interrupts, don't - * touch dangerous spots like the mouse irq, - * because there are mice that apparently - * get really confused if they get fondled - * too intimately. - * - * Default to 11, 10, 9, 7, 6, 5, 4, 3. - */ -static u32 isa_interrupts = 0x0ef8; - static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask) { int i; -- cgit v1.1 From e794c01b7de40d180417eacbd910e8f31f2fafeb Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 15 Mar 2010 11:25:10 +0300 Subject: pcmcia: add important if statement There was a problem introduced in Jul 2008 by: 0e6f9d270840 pcmcia: use pcmcia_loop_config in scsi pcmcia drivers Signed-off-by: Dan Carpenter Signed-off-by: Dominik Brodowski --- drivers/scsi/pcmcia/nsp_cs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index c2341af..0212464 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -1717,6 +1717,7 @@ static int nsp_cs_config(struct pcmcia_device *link) cfg_mem->data = data; ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); + if (ret) goto cs_failed; if (link->conf.Attributes & CONF_ENABLE_IRQ) { -- cgit v1.1 From 4e06e240dcbb803433ee31bfe89a3e785a77cd3b Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Tue, 16 Mar 2010 15:57:44 +0100 Subject: PCMCIA: resource, fix lock imbalance Stanse found that one error path (when alloc_skb fails) in netdev_tx omits to unlock hw_priv->hwlock. Fix that by moving away from unlock in each fail path. Unlock at one place instead. Introduced in 94a819f80297e1f635a7cde4ed5317612e512ba7 (pcmcia: assert locking to struct pcmcia_device) Signed-off-by: Jiri Slaby Signed-off-by: Dominik Brodowski --- drivers/pcmcia/pcmcia_resource.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index ef782c0..c4612c5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -256,6 +256,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, { struct pcmcia_socket *s; config_t *c; + int ret; s = p_dev->socket; @@ -264,13 +265,13 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, if (!(s->state & SOCKET_PRESENT)) { dev_dbg(&s->dev, "No card present\n"); - mutex_unlock(&s->ops_mutex); - return -ENODEV; + ret = -ENODEV; + goto unlock; } if (!(c->state & CONFIG_LOCKED)) { dev_dbg(&s->dev, "Configuration isnt't locked\n"); - mutex_unlock(&s->ops_mutex); - return -EACCES; + ret = -EACCES; + goto unlock; } if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { @@ -286,7 +287,8 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, if (mod->Attributes & CONF_VCC_CHANGE_VALID) { dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); - return -EINVAL; + ret = -EINVAL; + goto unlock; } /* We only allow changing Vpp1 and Vpp2 to the same value */ @@ -294,21 +296,21 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) { dev_dbg(&s->dev, "Vpp1 and Vpp2 must be the same\n"); - mutex_unlock(&s->ops_mutex); - return -EINVAL; + ret = -EINVAL; + goto unlock; } s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) { - mutex_unlock(&s->ops_mutex); dev_printk(KERN_WARNING, &s->dev, "Unable to set VPP\n"); - return -EIO; + ret = -EIO; + goto unlock; } } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); - mutex_unlock(&s->ops_mutex); - return -EINVAL; + ret = -EINVAL; + goto unlock; } if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { @@ -332,9 +334,11 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, s->ops->set_io_map(s, &io_on); } } + ret = 0; +unlock: mutex_unlock(&s->ops_mutex); - return 0; + return ret; } /* modify_configuration */ EXPORT_SYMBOL(pcmcia_modify_configuration); -- cgit v1.1