[PATCHSET] "client_t" patchset (formerly pcmcia-b15) re-diffed and updated

Dominik Brodowski linux at dominikbrodowski.de
Sun May 16 19:22:33 EDT 2004


I've just re-diffed my proposal for a patchset formerly named
"15-pcmcia", now named "140-client_t". It is built on top of
2.6.6-bk-current, "b100-socket-sysfs", "b110-obsolete",
"b120-nomaster" and "b130-pcmcia_device" which are avaliable at
  
http://www.brodo.de/patches/2004-05-16/pcmcia-b100.tar.bz2
http://www.brodo.de/patches/2004-05-16/pcmcia-b110.tar.bz2
http://www.brodo.de/patches/2004-05-16/pcmcia-b120.tar.bz2
http://www.brodo.de/patches/2004-05-16/pcmcia-b130.tar.bz2
          
Changes to previous implementation sent to list
- re-diffed
- adapted so that "b100-socket-syfs" can be first to be merged,
  especially patch 04

The aim of this patchset is to add struct client_t as a part of
struct pcmcia_device and to use proper reference counting for 
this object. 

The patches are available in compressed form
at:
http://www.brodo.de/patches/2004-05-16/pcmcia-b140.tar.bz2
or
http://www.brodo.de/patches/2004-05-16/pcmcia-b140.tar.gz
or as single diff at:
http://www.brodo.de/patches/2004-05-16/pcmcia-b140-complete



http://www.brodo.de/patches/2004-05-16/01-move-and-remove-stuff

Move pcmcia_{de,}register_client() from cs.c to ds.c,
and remove the unused pcmcia_get_{first,next}_client() calls -- they would
be an unnecessary hassle to deal with in the next patches.

 drivers/pcmcia/cs.c |  181 ----------------------------------------------------
 drivers/pcmcia/ds.c |  129 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 130 insertions(+), 180 deletions(-)

http://www.brodo.de/patches/2004-05-16/02-license

As discussed previously, my integration of ds.c and cs.c 
with the driver model can[*] and will only be available under 
the GPL, as it's too much derived of other buses' implementation 
of integration with the driver model.

cs_internal.h did only contain the MPL header before - I contacted
Dave Hinds because of this, and as far as he can tell, it was just an
oversight that this was not marked as dual-licensed as the other files 
are.
  
 drivers/pcmcia/bulkmem.c     |   45 +++++++++++------------------------------
 drivers/pcmcia/cardbus.c     |   45 +++++++++++------------------------------
 drivers/pcmcia/cistpl.c      |   45 +++++++++++------------------------------
 drivers/pcmcia/cs.c          |   47 ++++++++++++-------------------------------
 drivers/pcmcia/cs_internal.h |   18 ++++++----------
 drivers/pcmcia/rsrc_mgr.c    |   45 +++++++++++------------------------------
 include/pcmcia/bulkmem.h     |   28 ++++---------------------
 include/pcmcia/ciscode.h     |   25 ++++------------------
 include/pcmcia/cisreg.h      |   25 ++++------------------
 include/pcmcia/cistpl.h      |   25 ++++------------------
 include/pcmcia/cs.h          |   25 ++++------------------
 include/pcmcia/cs_types.h    |   25 ++++------------------
 include/pcmcia/mem_op.h      |   25 ++++------------------
 include/pcmcia/ss.h          |   25 ++++------------------
 14 files changed, 113 insertions(+), 335 deletions(-)

http://www.brodo.de/patches/2004-05-16/03-ds-kref

Switch pcmcia_bus_socket's reference counting to struct kref. Also,
split the access by number into two calls, so that get_bus_socket can be
used in a more generic way.

 drivers/pcmcia/ds.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

http://www.brodo.de/patches/2004-05-16/04-cs-class_dev

Add pcmcia_{put,get}_socket

 drivers/pcmcia/cs.c |   23 +++++++++++++++++++++++
 include/pcmcia/cs.h |    3 +++
 2 files changed, 26 insertions(+)

http://www.brodo.de/patches/2004-05-16/05-ds-grab-cs-ref

Grab a reference of struct pcmcia_socket for every struct pcmcia_bus_socket.

 drivers/pcmcia/ds.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

http://www.brodo.de/patches/2004-05-16/06-ds-get-ref-for-p_dev

Obtain a reference to struct pcmcia_bus_socket for each pcmcia_device. This
means that pcmcia_device always holds an indirect reference to struct 
pcmcia_socket as well.

 drivers/pcmcia/ds.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletion(-)

http://www.brodo.de/patches/2004-05-16/07-p_dev-client-pointer

Add a pointer to the "client" structure to struct pcmcia_device.

 drivers/pcmcia/ds.c |    1 +
 include/pcmcia/ds.h |    2 ++
 2 files changed, 3 insertions(+)

http://www.brodo.de/patches/2004-05-16/08-send_event-p_dev

Use a struct pcmcia_device-based approach to inform "clients" of 
events. It needs to be done using bus_for_each_device() so that
we don't need to take the device_list spinlock.

 drivers/pcmcia/cs.c |    5 +++--
 drivers/pcmcia/ds.c |   47 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 40 insertions(+), 12 deletions(-)

http://www.brodo.de/patches/2004-05-16/09-removal-p_dev

Use pcmcia_dev instead of the "client" single-linked list to mark
clients as stale.

 drivers/pcmcia/ds.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

http://www.brodo.de/patches/2004-05-16/10-move-inside-ds

Move some code around in ds.c. Avoids forward-declarations, and keeps
related code close to each other.

 drivers/pcmcia/ds.c |  253 +++++++++++++++++++++++++---------------------------
 1 files changed, 126 insertions(+), 127 deletions(-)

http://www.brodo.de/patches/2004-05-16/11-register_client-p_dev

Search the devices_list for an UNBOUND client in register_client,
instead of the single linked list clients.

 drivers/pcmcia/ds.c |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

http://www.brodo.de/patches/2004-05-16/12-direct_ordered_unbind


Restructure unbind_request():
Before, unbind_request was called by cardmgr on the following occasions:
a) if the CS_EVENT_CARD_INSERTION event failed
b) during do_remove(), which is called on
	1) when cardmgr is informed of a CS_EVENT_CARD_REMOVAL event
	2) when cardmgr is informed of a CS_EVENT_EJECTION_REQUEST event, if
	   do_check() succeeds
	3) cardmgr exit (SIGINT/SIGTERM), if do_check() succeeds

We can ignore a), as the user is informed of the problem anyway, and can
take appropriate action then (eject the card, update config, write new driver,
insert card...).

b1) can be done directly, even before the userspace cardmgr is informed. This
speeds up the call to ->detach().

b2) All drivers I checked were based on the assumption that a 
CS_EVENT_CARD_REMOVAL event is received _first_, before a call to
->detach(). Most notably, some drivers issue first a call to 
their release() function [which else is called during EVENT_CARD_REMOVAL] 
during ->detach() if it hasn't been issued before. So, it doesn't hurt
if unbind is only called during the EVENT_CARD_REMOVAL step, and not
during EJECTION_REQUEST. The REMOVAL step is only called anyway if 
EJECTION_REQUEST succeeds, and the latter can only succeed if do_check() 
succeeds.

b3) If cardmgr exits, ds_release() is called. We can check for any
16-bit devices there, and call a CARD_REMOVAL event there. Only difference
is that a failure of do_check() does not block CARD_REMOVAL. IMHO this
is accepatble.


Consequences:
- call unbind_request during CARD_REMOVAL handling, even before userspace
  is informed.
- return "0" if UNBIND_REQUEST is called from userspace.
- clean up 16-bit pcmcia devices existing during cardmgr exit
- the driver's event handler is called with CARD_REMOVAL _always_ before
  ->detach() is called.

 drivers/pcmcia/ds.c |   69 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 40 insertions(+), 29 deletions(-)

13-bug_on_dev_list_not_null

All in-kernel PCMCIA devices do unregister their client in their respective
->detach() function after a REMOVAL event. So, AFAICS, the dev_list iteration
should always be false.

 drivers/bluetooth/bluecard_cs.c    |    5 +----
 drivers/bluetooth/bt3c_cs.c        |    5 +----
 drivers/bluetooth/btuart_cs.c      |    5 +----
 drivers/bluetooth/dtl1_cs.c        |    5 +----
 drivers/char/pcmcia/synclink_cs.c  |    8 +-------
 drivers/ide/legacy/ide-cs.c        |    3 +--
 drivers/isdn/hardware/avm/avm_cs.c |    8 +-------
 drivers/isdn/hisax/avma1_cs.c      |    8 +-------
 drivers/isdn/hisax/elsa_cs.c       |    5 +----
 drivers/isdn/hisax/sedlbauer_cs.c  |    8 +-------
 drivers/isdn/hisax/teles_cs.c      |    5 +----
 drivers/mtd/maps/pcmciamtd.c       |   30 +-----------------------------
 drivers/net/pcmcia/3c574_cs.c      |    3 +--
 drivers/net/pcmcia/3c589_cs.c      |    3 +--
 drivers/net/pcmcia/axnet_cs.c      |    3 +--
 drivers/net/pcmcia/com20020_cs.c   |    3 +--
 drivers/net/pcmcia/fmvj18x_cs.c    |    3 +--
 drivers/net/pcmcia/ibmtr_cs.c      |    3 +--
 drivers/net/pcmcia/nmclan_cs.c     |    3 +--
 drivers/net/pcmcia/pcnet_cs.c      |    3 +--
 drivers/net/pcmcia/smc91c92_cs.c   |    3 +--
 drivers/net/pcmcia/xirc2ps_cs.c    |    4 +---
 drivers/net/wireless/airo_cs.c     |    8 +-------
 drivers/net/wireless/atmel_cs.c    |    8 +-------
 drivers/net/wireless/netwave_cs.c  |    4 +---
 drivers/net/wireless/orinoco_cs.c  |    9 +--------
 drivers/net/wireless/ray_cs.c      |    3 +--
 drivers/net/wireless/wl3501_cs.c   |    8 +-------
 drivers/parport/parport_cs.c       |    5 +----
 drivers/scsi/pcmcia/aha152x_stub.c |    5 +----
 drivers/scsi/pcmcia/fdomain_stub.c |    5 +----
 drivers/scsi/pcmcia/nsp_cs.c       |    4 ++--
 drivers/scsi/pcmcia/qlogic_stub.c  |    5 +----
 drivers/serial/serial_cs.c         |    5 +----
 drivers/telephony/ixj_pcmcia.c     |    5 +----
 sound/pcmcia/pdaudiocf/pdaudiocf.c |   11 +----------
 sound/pcmcia/vx/vx_entry.c         |   10 ----------
 sound/pcmcia/vx/vxpocket.c         |    2 +-
 sound/pcmcia/vx/vxpocket.h         |    1 -
 39 files changed, 38 insertions(+), 186 deletions(-)

http://www.brodo.de/patches/2004-05-16/14-bug_on_list

BUG if the socket's list of clients is not empty on shutdown and/or
removal

 drivers/pcmcia/cs.c |   19 ++-----------------
 drivers/pcmcia/ds.c |   13 +++++++------
 2 files changed, 9 insertions(+), 23 deletions(-)

http://www.brodo.de/patches/2004-05-16/15-move_client

Move the struct client_t inside struct pcmcia_device. This means it gets
proper reference counting as well. The clients list inside struct pcmcia_socket
can be removed now.

 drivers/pcmcia/bulkmem.c     |    1
 drivers/pcmcia/cs.c          |    4 --
 drivers/pcmcia/cs_internal.h |   14 -------
 drivers/pcmcia/ds.c          |   82 ++++++++++++-------------------------------
 include/pcmcia/ds.h          |   17 +++++++-
 include/pcmcia/ss.h          |    1
 6 files changed, 41 insertions(+), 78 deletions(-)



More information about the linux-pcmcia mailing list