From 88b060d6c03fcb9e4d2018b4349954c4242a5c7f Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Jan 2010 14:14:23 +0100 Subject: pcmcia: improve check for same card in slot after resume During a suspend/resume cycle, an user may change the card in the PCMCIA/CardBus slot. The pcmcia_core can at least look at the socket state to check whether it is the same. For PCMCIA devices, move the detection and handling of such a change to ds.c. For CardBus devices, the PCI hotplug interface doesn't offer a "rescan" facility which also _removes_ devices no longer to be found behind a bridge. Therefore, remove and re-add all devices unconditionally. CC: Jesse Barnes CC: Linus Torvalds Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index cbfba885eb8..b0ebd11130c 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -137,6 +137,7 @@ struct pcmcia_socket { spinlock_t lock; socket_state_t socket; u_int state; + u_int suspended_state; /* state before suspend */ u_short functions; u_short lock_count; pccard_mem_map cis_mem; -- cgit v1.2.3 From 57197b9b7712eb19f5344c466e8aefbac1adbe55 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Jan 2010 17:27:33 +0100 Subject: pcmcia: CardBus doesn't need CIS access At least no in-kernel CardBus-capable PCI driver makes use of the CIS access functions. Therefore, it seems sensible to remove this unused code, and cleanup cardbus.c a lot. CC: Jesse Barnes CC: Linus Torvalds Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index b0ebd11130c..b4e5cfd49ce 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -244,12 +244,6 @@ struct pcmcia_socket { #endif /* CONFIG_PCMCIA_IOCTL */ #endif /* CONFIG_PCMCIA */ - /* cardbus (32-bit) */ -#ifdef CONFIG_CARDBUS - struct resource *cb_cis_res; - void __iomem *cb_cis_virt; -#endif /* CONFIG_CARDBUS */ - /* socket device */ struct device dev; /* data internal to the socket driver */ -- cgit v1.2.3 From 4e8804ff6dd1a842d9531c819a0acc9eb3bcfa3b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 6 Jan 2010 11:19:25 +0100 Subject: pcmcia: m8xx_pcmcia.c should use iodyn resource manager The socket driver m8xx_pcmcia.c uses a static memory assignment, but io_offset is set to 0. Therefore, it seems proper to use the iodyn resource manager for this driver, as was previously the case (before commit 80128ff79d282cf71b1819dbca9b8dd47d8ed3e8). CC: Vitaly Bordug CC: Arnd Bergmann CC: Olof Johansson Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index b4e5cfd49ce..1a4737933bf 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -258,6 +258,8 @@ struct pcmcia_socket { * - pccard_static_ops iomem and ioport areas are assigned statically * - pccard_iodyn_ops iomem areas is assigned statically, ioport * areas dynamically + * If this option is selected, use + * "select PCCARD_IODYN" in Kconfig. * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. * If this option is selected, use * "select PCCARD_NONSTATIC" in Kconfig. -- cgit v1.2.3 From 3a86e1807a53b7164c4ca2aec538d8a5d15416f1 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 6 Jan 2010 14:33:15 +0100 Subject: pcmcia: do not use resource manager on !PCMCIA If only CardBus cards are used, but not PCMCIA cards, we do not need the extensive resource management functions provided for by rsrc_nonstatic.c (~240K). Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 1a4737933bf..9ab53d87248 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -263,10 +263,20 @@ struct pcmcia_socket { * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. * If this option is selected, use * "select PCCARD_NONSTATIC" in Kconfig. + * */ extern struct pccard_resource_ops pccard_static_ops; +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) extern struct pccard_resource_ops pccard_iodyn_ops; extern struct pccard_resource_ops pccard_nonstatic_ops; +#else +/* If PCMCIA is not used, but only CARDBUS, these functions are not used + * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module + */ +#define pccard_iodyn_ops pccard_static_ops +#define pccard_nonstatic_ops pccard_static_ops +#endif + /* socket drivers are expected to use these callbacks in their .drv struct */ extern int pcmcia_socket_dev_suspend(struct device *dev); -- cgit v1.2.3 From 6b8e087b86c59c3941e125738d30cf38014089e0 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 12 Jan 2010 21:42:51 +0100 Subject: pcmcia: add locking to set_mem_map() Protect the pccard_operations callback "set_mem_map" by a new mutex ops_mutex. This mutex also protects the following values in struct pcmcia_socket: pccard_mem_map win[] pccard_mem_map cis_mem void __iomem *cis_virt Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 9ab53d87248..e756069859b 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -203,6 +203,8 @@ struct pcmcia_socket { unsigned int thread_events; /* protects socket h/w state */ struct mutex skt_mutex; + /* protects PCMCIA state */ + struct mutex ops_mutex; /* protects thread_events */ spinlock_t thread_lock; -- cgit v1.2.3 From 00ce99ff506a17882747a7d6874e3f5206a99043 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 16 Jan 2010 09:14:11 +0100 Subject: pcmcia: simplify locking replace pcmcia_socket->lock and pcmcia_dev_list_lock by using the per-socket "ops_mutex", as we do neither need different locks nor a spinlock here. Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index e756069859b..cfaccc224b5 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -134,7 +134,6 @@ struct pccard_operations { struct pcmcia_socket { struct module *owner; - spinlock_t lock; socket_state_t socket; u_int state; u_int suspended_state; /* state before suspend */ @@ -201,10 +200,12 @@ struct pcmcia_socket { struct task_struct *thread; struct completion thread_done; unsigned int thread_events; - /* protects socket h/w state */ + + /* For the non-trivial interaction between these locks, + * see Documentation/pcmcia/locking.txt */ struct mutex skt_mutex; - /* protects PCMCIA state */ struct mutex ops_mutex; + /* protects thread_events */ spinlock_t thread_lock; -- cgit v1.2.3 From 3f565232c561fbd9d5e03354aac29b90cb2bc78a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 16 Jan 2010 13:06:40 +0100 Subject: pcmcia: use mutex for dynid lock Even though we weren't calling a blocking function within the dynid spinlock, we do not need a spinlock here but can and should be using a mutex. Reported-by: Jiri Slaby Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index ee148573c11..d57847f2f6c 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -40,7 +40,7 @@ struct net_device; * Documentation/pcmcia/driver.txt for details. */ struct pcmcia_dynids { - spinlock_t lock; + struct mutex lock; struct list_head list; }; -- cgit v1.2.3 From f971dbd5da4e2fbf756d07b938a9c65a9c75178b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 17 Jan 2010 18:13:31 +0100 Subject: pcmcia: use pccardd to handle eject, insert, suspend and resume requests This avoids any sysfs-related deadlock (or lockdep warning), such as reported at http://lkml.org/lkml/2010/1/17/88 . Reported-by: Ming Lei Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index cfaccc224b5..ea5dec8c0d7 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -200,13 +200,14 @@ struct pcmcia_socket { struct task_struct *thread; struct completion thread_done; unsigned int thread_events; + unsigned int sysfs_events; /* For the non-trivial interaction between these locks, * see Documentation/pcmcia/locking.txt */ struct mutex skt_mutex; struct mutex ops_mutex; - /* protects thread_events */ + /* protects thread_events and sysfs_events */ spinlock_t thread_lock; /* pcmcia (16-bit) */ -- cgit v1.2.3 From aa584ca4cdd8db370a524c61fd3ca408303281e9 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 24 Jan 2010 14:36:59 +0100 Subject: pcmcia: use state machine for extended requery The requery callback now also handles the addition of a second pseudo multifunction device. Avoids messing with dev_{g,s}et_drvdata(), and fixes any workqueue <-> skt_mutex deadlock. Tested-by: Wolfram Sang Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'include/pcmcia') diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index ea5dec8c0d7..32896a77391 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -230,18 +230,13 @@ struct pcmcia_socket { u8 busy:1; /* pcmcia module is being unloaded */ u8 dead:1; - /* a multifunction-device add event is pending */ - u8 device_add_pending:1; - /* the pending event adds a mfc (1) or pfc (0) */ - u8 mfc_pfc:1; + /* the PCMCIA card consists of two pseudo devices */ + u8 has_pfc:1; - u8 reserved:3; + u8 reserved:4; } pcmcia_state; - /* for adding further pseudo-multifunction devices */ - struct work_struct device_add; - #ifdef CONFIG_PCMCIA_IOCTL struct user_info_t *user; wait_queue_head_t queue; -- cgit v1.2.3