ieee1394: misc updates
cover ieee1394: misc updates
Hi Ben,
here are a few new, updated, or resent patches, most of them janitorial. I created them against 2.6.17-git18 but tested on 2.6.16.x. If they are OK with you, please apply them to your 1394 tree (after you resynced from Linus) for Andrew to pull eventually.
small fixes
-----------
01/19 (old) ieee1394: sbp2: enable auto spin-up for Maxtor disks 02/19 (old) ieee1394: fix calculation of csr->expire 03/19 (new) ieee1394: fix cosmetic problem in speed probe
cleanups
--------
05/19 (new) ieee1394: replace __inline__ by inline
06/19 (new) ieee1394: coding style and comment fixes in midlayer header files 07/19 (new) ieee1394: update #include directives in midlayer header files 08/19 (new) ieee1394: remove redundant code from ieee1394_hotplug.h 09/19 (new) ieee1394: remove unused macros HPSB_PANIC and HPSB_TRACE 10/19 (new) ieee1394: clean up declarations of hpsb_*_config_rom
API conversions and related cleanups
------------------------------------
11/19 (old) ieee1394: dv1394: sem2mutex conversion
12/19 (upd) ieee1394: raw1394: remove redundant counting semaphore 13/19 (old) ieee1394: nodemgr: remove unnecessary includes
14/19 (old) ieee1394: nodemgr: do not spawn kernel_thread for sysfs rescan 15/19 (old) ieee1394: nodemgr: make module parameter ignore_drivers writable 16/19 (upd) ieee1394: nodemgr: switch to kthread api, replace reset semaphore 17/19 (old) ieee1394: nodemgr: convert nodemgr_serialize semaphore to mutex 18/19 (new) ieee1394: fix kerneldoc of hpsb_alloc_host
API conversion, struct hpsb_host size reduction
-----------------------------------------------
19/19 (upd) ieee1394: shrink tlabel pools, remove tpool semaphores
Patch 11/19 is trivial but untested except for loading the driver, writing into its character device, and unloading it.
Patch 16/19 was condensed from two previously posted patches. I merged them because the first stage of the two used kthread_stop_sem() which may vanish from the kernel API at some point.
Patch 19/19 replaces four previously posted patches. They all touched the same code regions, so there was not much point to keep them separate. Among other , this updated version incorporates your suggestion to make tlabel related sysfs attributes only conditionally available as debug code.
The patches are mostly stand-alone WRT what they do; however they apply most easily in above order. After this patch series, the 1394 drivers are completely converted to the kthread API, and all semaphores are removed except for some last few RW semaphores (hl_drivers_sem in highlevel.c, driver core's subsys RW semaphores in nodemgr.c).
drivers/ieee1394/csr.c | 31 -- drivers/ieee1394/csr.h | 107 ++++--- drivers/ieee1394/dma.c | 7 drivers/ieee1394/dma.h | 88 ++++-- drivers/ieee1394/dv1394-private.h | 6 drivers/ieee1394/dv1394.c | 43 +-- drivers/ieee1394/eth1394.c | 11 drivers/ieee1394/highlevel.h | 207 +++++++-------- drivers/ieee1394/hosts.c | 7 - drivers/ieee1394/hosts.h | 51 +-- drivers/ieee1394/ieee1394-ioctl.h | 9 drivers/ieee1394/ieee1394.h | 314 +++++++++++------------ drivers/ieee1394/ieee1394_core.c | 4 drivers/ieee1394/ieee1394_core.h | 27 + drivers/ieee1394/ieee1394_hotplug.h | 30 -- drivers/ieee1394/ieee1394_transactions.c | 114 ++++---- drivers/ieee1394/ieee1394_transactions.h | 41 +-- drivers/ieee1394/ieee1394_types.h | 66 +--- drivers/ieee1394/iso.c | 5 drivers/ieee1394/iso.h | 87 +++--- drivers/ieee1394/nodemgr.c | 216 ++++++--------- drivers/ieee1394/nodemgr.h | 27 - drivers/ieee1394/ohci1394.c | 5 drivers/ieee1394/raw1394-private.h | 3 drivers/ieee1394/raw1394.c | 102 ++++--- drivers/ieee1394/sbp2.c | 7 drivers/ieee1394/video1394.c | 12 27 files changed, 811 insertions(+), 816 deletions(-)
Signature · 3 lines
Stefan Richter -=====-=-==- -=== ---== http://arcgraph.de/sr/
PATCH 1/19 ieee1394: sbp2: enable auto spin-up for Maxtor disks
At least Maxtor OneTouch III require a "start stop unit" command after auto spin-down before the next access can proceed. This patch activates the responsible code in scsi_mod for all Maxtor SBP-2 disks.
https://bugzilla.novell.com/show_bug.cgi?id=183011
Maybe that should be done for all SBP-2 disks, but better be cautious.
---
drivers/ieee1394/sbp2.c +3 -0
@@ -2515,6 +2515,9 @@ static int sbp2scsi_slave_configure(stru sdev->skip_ms_page_8 =1 ;if (scsi_id->workarounds &SBP2_WORKAROUND_FIX_CAPACITY ) sdev->fix_capacity =1 ; +if (scsi_id->ne->guid_vendor_id ==0x0010b9 &&/* Maxtor's OUI */ + (sdev->type ==TYPE_DISK || sdev->type ==TYPE_RBC )) + sdev->allow_restart =1 ;return 0 ; }
PATCH 2/19 ieee1394: fix calculation of csr->expire
In reply to Stefan RichterThis variant of calculate_expire() is more correct and easier to read.
--- drivers/ieee1394/csr.c | 31 ++++++++++--------------------- 1 files changed, 10 insertions(+), 21 deletions(-)
drivers/ieee1394/csr.c +10 -21
@@ -17,11 +17,13 @@* */ -#include <linux/string.h> +#include <linux/jiffies.h> +#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/param.h> #include <linux/spinlock.h> +#include <linux/string.h> #include "csr1212.h" #include "ieee1394_types.h"
@@ -149,31 +151,18 @@ static void host_reset(struct hpsb_host/* * HI == seconds (bits 0:2) -* LO == fraction units of 1/8000 of a second, as per 1394 (bits 19:31) -* -* Convert to units and then to HZ, for comparison to jiffies. -* -* By default this will end up being 800 units, or 100ms (125usec per -* unit). +* LO == fractions of a second in units of 125usec (bits 19:31) * -* NOTE: The spec says 1/8000, but also says we can compute based on 1/8192 -* like CSR specifies. Should make our math less complex. +* Convert SPLIT_TIMEOUT to jiffies. +* The default and minimum as per 1394a-2000 clause 8.3.2.2.6 is 100ms. */ static inline void calculate_expire (struct csr_control *csr) { -unsigned long units; - -/* Take the seconds, and convert to units */ - units = (unsigned long )(csr->split_timeout_hi &0x07 ) <<13 ; - -/* Add in the fractional units */ - units += (unsigned long )(csr->split_timeout_lo >>19 ); - -/* Convert to jiffies */ - csr->expire = (unsigned long )(units *HZ ) >>13UL ; +unsigned long usecs = + (csr->split_timeout_hi &0x07 ) *USEC_PER_SEC + + (csr->split_timeout_lo >>19 ) *125L ; -/* Just to keep from rounding low */ - csr->expire++; + csr->expire =usecs_to_jiffies (usecs >100000L ? usecs :100000L );HPSB_VERBOSE ("CSR: setting expire to %lu, HZ=%u" , csr->expire,HZ ); }
PATCH 3/19 ieee1394: fix cosmetic problem in speed probe
In reply to Stefan RichterIf ieee1394.h::IEEE1394_SPEED_MAX is bigger than the actual speed of an 1394b host adapter and the speed to another 1394b node was probed, a bigger speed than actually used was kept in host->speed[n]. The only resulting problem so far was sbp2 displaying bogus values in the syslog, e.g. S3200 for actual S800 connections if IEEE1394_SPEED_MAX was S3200. But other high-level drivers which access this field could get into more trouble. (Eth1394 is the only other in-tree driver which does so. It seems it is not affected.)
Nodemgr now clips this value according to the host adapter's link speed.
A pointer expression in nodemgr_check_speed is also changed for clarity.
---
drivers/ieee1394/nodemgr.c +8 -5
@@ -71,7 +71,7 @@ static int nodemgr_check_speed(struct nou8 i, *speed, old_speed, good_speed;int ret; - speed = ci->host->speed +NODEID_TO_NODE (ci->nodeid); + speed = &(ci->host->speed[NODEID_TO_NODE (ci->nodeid)]); old_speed = *speed; good_speed =IEEE1394_SPEED_MAX +1 ;
@@ -1251,6 +1251,7 @@ static void nodemgr_node_scan_one(structoctlet_t guid;struct csr1212_csr *csr;struct nodemgr_csr_info *ci; +u8 *speed; ci =kmalloc (sizeof (*ci),GFP_KERNEL );if (!ci)
@@ -1259,8 +1260,12 @@ static void nodemgr_node_scan_one(struct ci->host = host; ci->nodeid = nodeid; ci->generation = generation; - ci->speed_unverified = - host->speed[NODEID_TO_NODE (nodeid)] >IEEE1394_SPEED_100 ; + +/* Prepare for speed probe which occurs when reading the ROM */ + speed = &(host->speed[NODEID_TO_NODE (nodeid)]); +if (*speed > host->csr.lnk_spd) + *speed = host->csr.lnk_spd; + ci->speed_unverified = *speed >IEEE1394_SPEED_100 ;/* We need to detect when the ConfigROM's generation has changed, * so we only update the node's info when it needs to be. */
@@ -1300,8 +1305,6 @@ static void nodemgr_node_scan_one(structnodemgr_create_node (guid, csr, hi, nodeid, generation); elsenodemgr_update_node (ne ,csr ,hi ,nodeid ,generation ); - -return ; }
PATCH 4/19 ieee1394: skip dummy loop in build_speed_map
In reply to Stefan RichterThe last loop in ieee1394 core's speed calculation is not required unless ieee1394.h::IEEE1394_SPEED_MAX is changed from its current value of 3.
---
drivers/ieee1394/ieee1394.h +2 -0
@@ -77,6 +77,8 @@ extern const char *hpsb_speedto_str[];#define SELFID_PORT_NCONN 0x1#define SELFID_PORT_NONE 0x0 +#define SELFID_SPEED_UNKNOWN 0x3/* 1394b PHY */ +#define PHYPACKET_LINKON 0x40000000#define PHYPACKET_PHYCONFIG_R 0x00800000#define PHYPACKET_PHYCONFIG_T 0x00400000
drivers/ieee1394/ieee1394_core.c +3 -1
@@ -355,10 +355,12 @@ static void build_speed_map(struct hpsb_ } } +#if SELFID_SPEED_UNKNOWN !=IEEE1394_SPEED_MAX /* assume maximum speed for 1394b PHYs, nodemgr will correct it */ for (n =0 ; n < nodecount; n++) -if (speedcap[n] ==3 ) +if (speedcap[n] ==SELFID_SPEED_UNKNOWN ) speedcap[n] =IEEE1394_SPEED_MAX ; +#endif }
PATCH 5/19 ieee1394: replace __inline__ by inline
In reply to Stefan Richter---
drivers/ieee1394/ieee1394_types.h +1 -1
@@ -75,7 +75,7 @@ typedef u16 arm_length_t;#ifdef __BIG_ENDIAN -static __inline__void *memcpy_le32 (u32 *dest,const u32 *__src,size_t count) +static inline void *memcpy_le32 (u32 *dest,const u32 *__src,size_t count) {void *tmp = dest;u32 *src = (u32 *)__src;
drivers/ieee1394/ohci1394.c +3 -2
@@ -2598,8 +2598,9 @@ static const int TCODE_SIZE[16] = {20, 0* Determine the length of a packet in the buffer * Optimization suggested by Pascal Drolet <[email protected]> */ -static __inline__int packet_length (struct dma_rcv_ctx *d,int idx,quadlet_t *buf_ptr, -int offset,unsigned char tcode,int noswap) +static inline int packet_length (struct dma_rcv_ctx *d,int idx, +quadlet_t *buf_ptr,int offset, +unsigned char tcode,int noswap) {int length =-1 ;
drivers/ieee1394/sbp2.c +2 -2
@@ -356,7 +356,7 @@ static const struct {/* * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. */ -static __inline__void sbp2util_be32_to_cpu_buffer (void *buffer,int length) +static inline void sbp2util_be32_to_cpu_buffer (void *buffer,int length) {u32 *temp = buffer;
@@ -369,7 +369,7 @@ static __inline__ void sbp2util_be32_to_/* * Converts a buffer from cpu to be32 byte ordering. Length is in bytes. */ -static __inline__void sbp2util_cpu_to_be32_buffer (void *buffer,int length) +static inline void sbp2util_cpu_to_be32_buffer (void *buffer,int length) {u32 *temp = buffer;
PATCH 6/19 ieee1394: coding style and comment fixes in midlayer header files
In reply to Stefan RichterAdjust tabulators, line wraps, empty lines, and comment style. Update comments in ieee1394_transactions.h and highlevel.h. Fix typo in comment in csr.h.
--- drivers/ieee1394/csr.h | 96 +++---- drivers/ieee1394/dma.h | 81 +++-- drivers/ieee1394/highlevel.h | 203 +++++++------- drivers/ieee1394/hosts.h | 15 - drivers/ieee1394/ieee1394-ioctl.h | 9 drivers/ieee1394/ieee1394.h | 312 +++++++++++------------ drivers/ieee1394/ieee1394_core.h | 17 - drivers/ieee1394/ieee1394_transactions.h | 32 -- drivers/ieee1394/ieee1394_types.h | 31 +- drivers/ieee1394/iso.h | 80 +++-- drivers/ieee1394/nodemgr.h | 16 - 11 files changed, 450 insertions(+), 442 deletions(-)
TODO:
Move comments from function declarations to function definitions. Add kernel-doc compliant comments to data type definitions which are part of ieee1394's APIs like done in this patch for dma.h.
drivers/ieee1394/ieee1394_core.h +9 -8
@@ -58,7 +58,6 @@ struct hpsb_packet {size_t header_size;size_t data_size; -struct hpsb_host *host;unsigned int generation;
@@ -80,7 +79,7 @@ struct hpsb_packet {/* Set a task for when a packet completes */ void hpsb_set_packet_complete_task (struct hpsb_packet *packet, -void (*routine)(void *),void *data); +void (*routine)(void *),void *data);static inline struct hpsb_packet *driver_packet (struct list_head *l) {
@@ -92,7 +91,6 @@ void abort_timedouts(unsigned long __opastruct hpsb_packet *hpsb_alloc_packet (size_t data_size);void hpsb_free_packet (struct hpsb_packet *packet); -/* * Generation counter for the complete 1394 subsystem. Generation gets * incremented on every change in the subsystem (e.g. bus reset).
@@ -204,10 +202,14 @@ void hpsb_packet_received(struct hpsb_ho#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) -#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16) -#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) -#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16) -#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) +#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, \ + IEEE1394_MINOR_BLOCK_RAW1394 * 16) +#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, \ + IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) +#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, \ + IEEE1394_MINOR_BLOCK_DV1394 * 16) +#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \ + IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)/* return the index (within a minor number block) of a file */ static inline unsigned char ieee1394_file_to_instance (struct file *file)
@@ -223,4 +225,3 @@ extern struct class hpsb_host_class;extern struct class *hpsb_protocol_class;#endif /* _IEEE1394_CORE_H */ -
drivers/ieee1394/ieee1394.h +155 -157
357 lines not on this page · raw message
drivers/ieee1394/ieee1394-ioctl.h +5 -4
@@ -1,5 +1,7 @@ -/* Base file for all ieee1394 ioctl's. Linux-1394 has allocated base '#' -* with a range of 0x00-0x3f. */ +/* +* Base file for all ieee1394 ioctl's. +* Linux-1394 has allocated base '#' with a range of 0x00-0x3f. +*/ #ifndef __IEEE1394_IOCTL_H#define __IEEE1394_IOCTL_H
@@ -96,8 +98,7 @@ _IOW ('#', 0x27, struct raw1394_iso_packets)#define RAW1394_IOC_ISO_XMIT_SYNC \ _IO ('#', 0x28) -#define RAW1394_IOC_ISO_RECV_FLUSH \ +#define RAW1394_IOC_ISO_RECV_FLUSH \ _IO ('#', 0x29) -#endif /* __IEEE1394_IOCTL_H */
drivers/ieee1394/ieee1394_transactions.h +13 -19
@@ -3,30 +3,25 @@#include "ieee1394_core.h" - -/* -* Get and free transaction labels. -*/ int hpsb_get_tlabel (struct hpsb_packet *packet);void hpsb_free_tlabel (struct hpsb_packet *packet); -struct hpsb_packet *hpsb_make_readpacket (struct hpsb_host *host,nodeid_t node,u64 addr,size_t length);struct hpsb_packet *hpsb_make_lockpacket (struct hpsb_host *host,nodeid_t node, -u64 addr,int extcode,quadlet_t *data, +u64 addr,int extcode,quadlet_t *data,quadlet_t arg); -struct hpsb_packet *hpsb_make_lock64packet (struct hpsb_host *host,nodeid_t node, -u64 addr,int extcode,octlet_t *data, -octlet_t arg); -struct hpsb_packet *hpsb_make_phypacket (struct hpsb_host *host, -quadlet_t data) ; -struct hpsb_packet *hpsb_make_isopacket (struct hpsb_host *host, -int length,int channel, -int tag,int sync); -struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host,nodeid_t node, -u64 addr,quadlet_t *buffer,size_t length); +struct hpsb_packet *hpsb_make_lock64packet (struct hpsb_host *host, +nodeid_t node,u64 addr,int extcode, +octlet_t *data,octlet_t arg); +struct hpsb_packet *hpsb_make_phypacket (struct hpsb_host *host,quadlet_t data); +struct hpsb_packet *hpsb_make_isopacket (struct hpsb_host *host,int length, +int channel,int tag,int sync); +struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, +nodeid_t node,u64 addr, +quadlet_t *buffer,size_t length);struct hpsb_packet *hpsb_make_streampacket (struct hpsb_host *host,u8 *buffer, -int length,int channel,int tag,int sync); +int length,int channel,int tag, +int sync);/* * hpsb_packet_success - Make sense of the ack and reply codes and
@@ -40,9 +35,8 @@ struct hpsb_packet *hpsb_make_streampack*/ int hpsb_packet_success (struct hpsb_packet *packet); -/* -* The generic read, write and lock functions. All recognize the local node ID +* The generic read and write functions. All recognize the local node ID * and act accordingly. Read and write automatically use quadlet commands if * length == 4 and and block commands otherwise (however, they do not yet * support lengths that are not a multiple of 4). You must explicitly specifiy
drivers/ieee1394/ieee1394_types.h +14 -17
@@ -31,7 +31,6 @@ do { \sema_init (&(_tp)->count,63 ); \ }while (0 ) - typedef u32 quadlet_t;typedef u64 octlet_t ;typedef u16 nodeid_t ;
@@ -54,16 +53,17 @@ typedef u16 arm_length_t;#define NODE_BUS_ARGS (__host, __nodeid) \ __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid) -#define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "\n" , ## args) +#define HPSB_PRINT(level, fmt, args...) \ + printk(level "ieee1394: " fmt "\n" , ## args) -#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) -#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args) -#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args) -#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args) -#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args) +#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) +#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args) +#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args) +#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args) +#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)#ifdef CONFIG_IEEE1394_VERBOSEDEBUG -#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) +#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)#else #define HPSB_VERBOSE(fmt, args...)#endif
@@ -77,23 +77,20 @@ typedef u16 arm_length_t;static inline void *memcpy_le32 (u32 *dest,const u32 *__src,size_t count) { -void *tmp = dest; +void *tmp = dest;u32 *src = (u32 *)__src; - count /=4 ; - -while (count--) { - *dest++ =swab32p (src++); - } - -return tmp; + count /=4 ; +while (count--) + *dest++ =swab32p (src++); +return tmp; }#else static __inline__void *memcpy_le32 (u32 *dest,const u32 *src,size_t count) { -return memcpy (dest, src, count); +return memcpy (dest, src, count); }#endif /* __BIG_ENDIAN */
drivers/ieee1394/csr.h +48 -48
124 lines not on this page · raw message
drivers/ieee1394/dma.h +50 -31
116 lines not on this page · raw message
drivers/ieee1394/highlevel.h +100 -103
273 lines not on this page · raw message
drivers/ieee1394/hosts.h +8 -7
@@ -112,7 +112,7 @@ enum devctl_cmd {enum isoctl_cmd {/* rawiso API - see iso.h for the meanings of these commands -(they correspond exactly to the hpsb_iso_* API functions) +* (they correspond exactly to the hpsb_iso_* API functions) * INIT = allocate resources * START = begin transmission/reception * STOP = halt transmission/reception
@@ -160,7 +160,8 @@ struct hpsb_host_driver {/* The hardware driver may optionally support a function that is used * to set the hardware ConfigROM if the hardware supports handling * reads to the ConfigROM on its own. */ -void (*set_hw_config_rom) (struct hpsb_host *host,quadlet_t *config_rom); +void (*set_hw_config_rom)(struct hpsb_host *host, +quadlet_t *config_rom);/* This function shall implement packet transmission based on * packet->type. It shall CRC both parts of the packet (unless
@@ -170,20 +171,21 @@ struct hpsb_host_driver {* called. Return 0 on success, negative errno on failure. * NOTE: The function must be callable in interrupt context. */ -int (*transmit_packet) (struct hpsb_host *host, -struct hpsb_packet *packet); +int (*transmit_packet)(struct hpsb_host *host, +struct hpsb_packet *packet);/* This function requests miscellanous services from the driver, see * above for command codes and expected actions. Return -1 for unknown * command, though that should never happen. */ -int (*devctl) (struct hpsb_host *host,enum devctl_cmd command,int arg); +int (*devctl)(struct hpsb_host *host,enum devctl_cmd command,int arg);/* ISO transmission/reception functions. Return 0 on success, -1 * (or -EXXX errno code) on failure. If the low-level driver does not * support the new ISO API, set isoctl to NULL. */ -int (*isoctl) (struct hpsb_iso *iso,enum isoctl_cmd command,unsigned long arg); +int (*isoctl)(struct hpsb_iso *iso,enum isoctl_cmd command, +unsigned long arg);/* This function is mainly to redirect local CSR reads/locks to the iso * management registers (bus manager id, bandwidth available, channels
@@ -196,7 +198,6 @@ struct hpsb_host_driver { quadlet_t data, quadlet_t compare); }; -struct hpsb_host *hpsb_alloc_host (struct hpsb_host_driver *drv,size_t extra,struct device *dev);int hpsb_add_host (struct hpsb_host *host);
drivers/ieee1394/iso.h +43 -37
152 lines not on this page · raw message
drivers/ieee1394/nodemgr.h +5 -11
@@ -44,7 +44,6 @@ struct bus_options {u16 max_rec;/* Maximum packet size node can receive */ }; -#define UNIT_DIRECTORY_VENDOR_ID 0x01#define UNIT_DIRECTORY_MODEL_ID 0x02#define UNIT_DIRECTORY_SPECIFIER_ID 0x04
@@ -59,8 +58,8 @@ struct bus_options {* unit directory for each of these protocols. */ struct unit_directory { -struct node_entry *ne;/* The node which this directory belongs to */ -octlet_t address;/* Address of the unit directory on the node */ +struct node_entry *ne;/* The node which this directory belongs to */ +octlet_t address;/* Address of the unit directory on the node */ u8 flags;/* Indicates which entries were read */ quadlet_t vendor_id;
@@ -79,11 +78,10 @@ struct unit_directory {int length;/* Number of quadlets */ struct device device; -struct class_device class_dev;struct csr1212_keyval *ud_kv; -u32 lun;/* logical unit number immediate value */ +u32 lun;/* logical unit number immediate value */ };struct node_entry {
@@ -106,7 +104,6 @@ struct node_entry {struct hpsb_tlabel_pool *tpool;struct device device; -struct class_device class_dev;/* Means this node is not attached anymore */
@@ -153,8 +150,8 @@ static inline int hpsb_node_entry_valid(/* * This will fill in the given, pre-initialised hpsb_packet with the current * information from the node entry (host, node ID, generation number). It will -* return false if the node owning the GUID is not accessible (and not modify the -* hpsb_packet) and return true otherwise. +* return false if the node owning the GUID is not accessible (and not modify +* the hpsb_packet) and return true otherwise. * * Note that packet sending may still fail in hpsb_send_packet if a bus reset * happens while you are trying to set up the packet (due to obsolete generation
@@ -170,16 +167,13 @@ int hpsb_node_write(struct node_entry *nint hpsb_node_lock (struct node_entry *ne,u64 addr,int extcode,quadlet_t *data,quadlet_t arg); -/* Iterate the hosts, calling a given function with supplied data for each * host. */ int nodemgr_for_each_host (void *__data,int (*cb)(struct hpsb_host *,void *)); -int init_ieee1394_nodemgr (void );void cleanup_ieee1394_nodemgr (void ); -/* The template for a host device */ extern struct device nodemgr_dev_template_host;
PATCH 7/19 ieee1394: update #include directives in midlayer header files
In reply to Stefan RichterRemove unnecessary includes, add missing includes. Use forward type declarations for some structs.
--- drivers/ieee1394/csr.h | 6 ++---- drivers/ieee1394/dma.c | 7 +++++-- drivers/ieee1394/dma.h | 7 +++++-- drivers/ieee1394/dv1394.c | 12 ++++++------ drivers/ieee1394/eth1394.c | 11 ++++++----- drivers/ieee1394/highlevel.h | 10 ++++++++++ drivers/ieee1394/hosts.h | 10 ++++++---- drivers/ieee1394/ieee1394_core.h | 10 +++++++--- drivers/ieee1394/ieee1394_hotplug.h | 3 +-- drivers/ieee1394/ieee1394_transactions.h | 7 ++++++- drivers/ieee1394/ieee1394_types.h | 7 ++----- drivers/ieee1394/iso.c | 5 ++++- drivers/ieee1394/iso.h | 7 ++++++- drivers/ieee1394/nodemgr.c | 9 +++++---- drivers/ieee1394/nodemgr.h | 10 ++++++++-- drivers/ieee1394/raw1394.c | 11 ++++++----- drivers/ieee1394/video1394.c | 12 ++++++------ 17 files changed, 91 insertions(+), 53 deletions(-)
drivers/ieee1394/ieee1394_core.h +7 -3
@@ -1,12 +1,16 @@ -#ifndef _IEEE1394_CORE_H#define _IEEE1394_CORE_H -#include <linux/slab.h> +#include <linux/device.h> +#include <linux/fs.h> +#include <linux/list.h> +#include <linux/skbuff.h> +#include <linux/types.h> #include <asm/atomic.h> #include <asm/semaphore.h> -#include "hosts.h" +#include "hosts.h" +#include "ieee1394_types.h" struct hpsb_packet {/* This struct is basically read-only for hosts with the exception of
drivers/ieee1394/ieee1394_transactions.h +6 -1
@@ -1,7 +1,12 @@#ifndef _IEEE1394_TRANSACTIONS_H#define _IEEE1394_TRANSACTIONS_H -#include "ieee1394_core.h" +#include <linux/types.h> + +#include "ieee1394_types.h" + +struct hpsb_packet ; +struct hpsb_host ;int hpsb_get_tlabel (struct hpsb_packet *packet);void hpsb_free_tlabel (struct hpsb_packet *packet);
drivers/ieee1394/ieee1394_types.h +2 -5
@@ -1,17 +1,14 @@ -#ifndef _IEEE1394_TYPES_H#define _IEEE1394_TYPES_H#include <linux/kernel.h> -#include <linux/types.h> #include <linux/list.h> -#include <linux/init.h> #include <linux/spinlock.h> #include <linux/string.h> +#include <linux/types.h> -#include <asm/semaphore.h> #include <asm/byteorder.h> - +#include <asm/semaphore.h> /* Transaction Label handling */ struct hpsb_tlabel_pool {
drivers/ieee1394/csr.h +2 -4
@@ -1,12 +1,10 @@ -#ifndef _IEEE1394_CSR_H#define _IEEE1394_CSR_H -#ifdef CONFIG_PREEMPT -#include <linux/sched.h> -#endif +#include <linux/spinlock_types.h> #include "csr1212.h" +#include "ieee1394_types.h" #define CSR_REGISTER_BASE 0xfffff0000000ULL
drivers/ieee1394/dma.c +5 -2
@@ -7,10 +7,13 @@* directory of the kernel sources for details. */ +#include <linux/mm.h> #include <linux/module.h> -#include <linux/vmalloc.h> +#include <linux/pci.h> #include <linux/slab.h> -#include <linux/mm.h> +#include <linux/vmalloc.h> +#include <asm/scatterlist.h> +#include "dma.h" /* dma_prog_region */
drivers/ieee1394/dma.h +5 -2
@@ -10,8 +10,11 @@#ifndef IEEE1394_DMA_H #define IEEE1394_DMA_H -#include <linux/pci.h> -#include <asm/scatterlist.h> +#include <asm/types.h> + +struct pci_dev ; +struct scatterlist ; +struct vm_area_struct ;/** * struct dma_prog_region - small contiguous DMA buffer
drivers/ieee1394/highlevel.h +10 -0
@@ -1,6 +1,16 @@ #ifndef IEEE1394_HIGHLEVEL_H #define IEEE1394_HIGHLEVEL_H +#include <linux/list.h> +#include <linux/spinlock_types.h> +#include <linux/types.h> + +struct module; + +#include "ieee1394_types.h" + +struct hpsb_host; + /* internal to ieee1394 core */ struct hpsb_address_serve { struct list_head host_list; /* per host list */
drivers/ieee1394/hosts.h +6 -4
@@ -2,17 +2,19 @@#define _IEEE1394_HOSTS_H#include <linux/device.h> -#include <linux/wait.h> #include <linux/list.h> -#include <linux/timer.h> #include <linux/skbuff.h> +#include <linux/timer.h> +#include <linux/types.h> +#include <linux/workqueue.h> +#include <asm/atomic.h> -#include <asm/semaphore.h> +struct pci_dev ; +struct module ;#include "ieee1394_types.h" #include "csr.h" -struct hpsb_packet ;struct hpsb_iso ;
drivers/ieee1394/ieee1394_hotplug.h +1 -2
@@ -1,9 +1,8 @@#ifndef _IEEE1394_HOTPLUG_H#define _IEEE1394_HOTPLUG_H -#include <linux/kernel.h> -#include <linux/types.h> #include <linux/mod_devicetable.h> +#include <linux/types.h> /* Unit spec id and sw version entry for some protocols */ #define AVC_UNIT_SPEC_ID_ENTRY 0x0000A02D
drivers/ieee1394/iso.c +4 -1
@@ -9,8 +9,11 @@* directory of the kernel sources for details. */ -#include <linux/slab.h> +#include <linux/pci.h> #include <linux/sched.h> +#include <linux/slab.h> + +#include "hosts.h" #include "iso.h" void hpsb_iso_stop (struct hpsb_iso *iso)
drivers/ieee1394/iso.h +6 -1
@@ -12,9 +12,14 @@#ifndef IEEE1394_ISO_H #define IEEE1394_ISO_H -#include "hosts.h" +#include <linux/spinlock_types.h> +#include <asm/atomic.h> +#include <asm/types.h> +#include "dma.h" +struct hpsb_host ; +/* high-level ISO interface */ /*
drivers/ieee1394/nodemgr.h +8 -2
@@ -21,9 +21,15 @@#define _IEEE1394_NODEMGR_H#include <linux/device.h> -#include "csr1212.h" +#include <asm/types.h> +#include "ieee1394_core.h" -#include "ieee1394_hotplug.h" +#include "ieee1394_types.h" + +struct csr1212_csr ; +struct csr1212_keyval ; +struct hpsb_host ; +struct ieee1394_device_id ;/* '1' '3' '9' '4' in ASCII */ #define IEEE1394_BUSID_MAGIC __constant_cpu_to_be32(0x31333934)
drivers/ieee1394/nodemgr.c +5 -4
@@ -21,13 +21,14 @@#include <linux/moduleparam.h> #include <asm/atomic.h> -#include "ieee1394_types.h" +#include "csr.h" +#include "highlevel.h" +#include "hosts.h" #include "ieee1394.h" #include "ieee1394_core.h" -#include "hosts.h" +#include "ieee1394_hotplug.h" +#include "ieee1394_types.h" #include "ieee1394_transactions.h" -#include "highlevel.h" -#include "csr.h" #include "nodemgr.h" static int ignore_drivers;
drivers/ieee1394/video1394.c +6 -6
@@ -49,16 +49,16 @@#include <linux/compat.h> #include <linux/cdev.h> -#include "ieee1394.h" -#include "ieee1394_types.h" +#include "dma.h" +#include "highlevel.h" #include "hosts.h" +#include "ieee1394.h" #include "ieee1394_core.h" -#include "highlevel.h" -#include "video1394.h" +#include "ieee1394_hotplug.h" +#include "ieee1394_types.h" #include "nodemgr.h" -#include "dma.h" -#include "ohci1394.h" +#include "video1394.h" #define ISO_CHANNELS 64
drivers/ieee1394/raw1394.c +6 -5
@@ -44,14 +44,15 @@#include <linux/compat.h> #include "csr1212.h" +#include "highlevel.h" +#include "hosts.h" #include "ieee1394.h" -#include "ieee1394_types.h" #include "ieee1394_core.h" -#include "nodemgr.h" -#include "hosts.h" -#include "highlevel.h" -#include "iso.h" +#include "ieee1394_hotplug.h" #include "ieee1394_transactions.h" +#include "ieee1394_types.h" +#include "iso.h" +#include "nodemgr.h" #include "raw1394.h" #include "raw1394-private.h"
drivers/ieee1394/dv1394.c +6 -6
@@ -110,15 +110,15 @@#include <linux/compat.h> #include <linux/cdev.h> +#include "dv1394.h" +#include "dv1394-private.h" +#include "highlevel.h" +#include "hosts.h" #include "ieee1394.h" +#include "ieee1394_core.h" +#include "ieee1394_hotplug.h" #include "ieee1394_types.h" #include "nodemgr.h" -#include "hosts.h" -#include "ieee1394_core.h" -#include "highlevel.h" -#include "dv1394.h" -#include "dv1394-private.h" -#include "ohci1394.h" /* DEBUG LEVELS:
drivers/ieee1394/eth1394.c +6 -5
@@ -67,16 +67,17 @@#include <asm/semaphore.h> #include <net/arp.h> +#include "config_roms.h" #include "csr1212.h" -#include "ieee1394_types.h" +#include "eth1394.h" +#include "highlevel.h" +#include "ieee1394.h" #include "ieee1394_core.h" +#include "ieee1394_hotplug.h" #include "ieee1394_transactions.h" -#include "ieee1394.h" -#include "highlevel.h" +#include "ieee1394_types.h" #include "iso.h" #include "nodemgr.h" -#include "eth1394.h" -#include "config_roms.h" #define ETH1394_PRINT_G(level, fmt, args...) \ printk(level "%s: " fmt, driver_name, ## args)
PATCH 8/19 ieee1394: remove redundant code from ieee1394_hotplug.h
In reply to Stefan Richter---
drivers/ieee1394/ieee1394_hotplug.h +8 -21
@@ -1,32 +1,19 @@#ifndef _IEEE1394_HOTPLUG_H#define _IEEE1394_HOTPLUG_H -#include <linux/mod_devicetable.h> -#include <linux/types.h> -/* Unit spec id and sw version entry for some protocols */ #define AVC_UNIT_SPEC_ID_ENTRY 0x0000A02D#define AVC_SW_VERSION_ENTRY 0x00010001#define CAMERA_UNIT_SPEC_ID_ENTRY 0x0000A02D#define CAMERA_SW_VERSION_ENTRY 0x00000100 -/* Check to make sure this all isn't already defined */ -#ifndef IEEE1394_MATCH_VENDOR_ID - -#define IEEE1394_MATCH_VENDOR_ID 0x0001 -#define IEEE1394_MATCH_MODEL_ID 0x0002 -#define IEEE1394_MATCH_SPECIFIER_ID 0x0004 -#define IEEE1394_MATCH_VERSION 0x0008 - -struct ieee1394_device_id { -u32 match_flags; -u32 vendor_id; -u32 model_id; -u32 specifier_id; -u32 version; -void *driver_data; -}; - -#endif +/* /include/linux/mod_devicetable.h defines: +* IEEE1394_MATCH_VENDOR_ID +* IEEE1394_MATCH_MODEL_ID +* IEEE1394_MATCH_SPECIFIER_ID +* IEEE1394_MATCH_VERSION +* struct ieee1394_device_id +*/ +#include <linux/mod_devicetable.h> #endif /* _IEEE1394_HOTPLUG_H */
PATCH 9/19 ieee1394: remove unused macros HPSB_PANIC and HPSB_TRACE
In reply to Stefan Richter---
drivers/ieee1394/ieee1394_transactions.c +3 -3
@@ -14,6 +14,7 @@#include <linux/smp_lock.h> #include <linux/interrupt.h> +#include <asm/bug.h> #include <asm/errno.h> #include "ieee1394.h"
@@ -214,7 +215,7 @@ int hpsb_packet_success(struct hpsb_pack packet->node_id);return -EAGAIN ; } -HPSB_PANIC ("reached unreachable code 1 in %s" , __FUNCTION__); +BUG ();case ACK_BUSY_X :case ACK_BUSY_A :
@@ -261,8 +262,7 @@ int hpsb_packet_success(struct hpsb_pack packet->ack_code, packet->node_id, packet->tcode);return -EAGAIN ; } - -HPSB_PANIC ("reached unreachable code 2 in %s" , __FUNCTION__); +BUG (); } struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
drivers/ieee1394/ieee1394_types.h +0 -5
@@ -65,11 +65,6 @@ typedef u16 arm_length_t; #define HPSB_VERBOSE(fmt, args...)#endif -#define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args) - -#define HPSB_TRACE () HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__) - -#ifdef __BIG_ENDIANstatic inline void *memcpy_le32 (u32 *dest,const u32 *__src,size_t count)
PATCH 10/19 ieee1394: clean up declarations of hpsb_*_config_rom
In reply to Stefan Richterhpsb_update_config_rom() is defined in csr.c, not hosts.c. hpsb_get_config_rom() does not exist.
---
drivers/ieee1394/csr.h +5 -0
@@ -91,4 +91,9 @@ extern struct csr1212_bus_ops csr_bus_opint init_csr (void );void cleanup_csr (void ); +/* hpsb_update_config_rom() is deprecated */ +struct hpsb_host ; +int hpsb_update_config_rom (struct hpsb_host *host,const quadlet_t *new_rom, +size_t size,unsigned char rom_version); +#endif /* _IEEE1394_CSR_H */
drivers/ieee1394/hosts.h +0 -7
@@ -205,13 +205,6 @@ struct hpsb_host *hpsb_alloc_host(structint hpsb_add_host (struct hpsb_host *host);void hpsb_remove_host (struct hpsb_host *h); -/* The following 2 functions are deprecated and will be removed when the -* raw1394/libraw1394 update is complete. */ -int hpsb_update_config_rom (struct hpsb_host *host, -const quadlet_t *new_rom,size_t size,unsigned char rom_version); -int hpsb_get_config_rom (struct hpsb_host *host,quadlet_t *buffer, -size_t buffersize,size_t *rom_size,unsigned char *rom_version); -/* Updates the configuration rom image of a host. rom_version must be the * current version, otherwise it will fail with return value -1. If this * host does not support config-rom-update, it will return -EINVAL.
PATCH 11/19 ieee1394: dv1394: sem2mutex conversion
In reply to Stefan Richter--- drivers/ieee1394/dv1394-private.h | 6 ++--- drivers/ieee1394/dv1394.c | 31 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-)
drivers/ieee1394/dv1394-private.h +3 -3
@@ -460,7 +460,7 @@ struct video_card {int dma_running;/* -3) the sleeping semaphore 'sem' - this is used from process context only, +3) the sleeping mutex 'mtx' - this is used from process context only, to serialize various operations on the video_card. Even though only one open() is allowed, we still need to prevent multiple threads of execution from entering calls like read, write, ioctl, etc.
@@ -468,9 +468,9 @@ struct video_card {I honestly can't think of a good reason to use dv1394 from several threads at once, but we need to serialize anyway to prevent oopses =). -NOTE: if you need both spinlock and sem, take sem first to avoid deadlock! +NOTE: if you need both spinlock and mtx, take mtx first to avoid deadlock! */ -struct semaphore sem; +struct mutex mtx;/* people waiting for buffer space, please form a line here... */ wait_queue_head_t waitq;
drivers/ieee1394/dv1394.c +16 -15
@@ -95,6 +95,7 @@#include <linux/fs.h> #include <linux/poll.h> #include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/bitops.h> #include <asm/byteorder.h> #include <asm/atomic.h>
@@ -247,7 +248,7 @@ static void frame_delete(struct frame *fFrame_prepare() must be called OUTSIDE the video->spinlock. However, frame_prepare() must still be serialized, so -it should be called WITH the video->sem taken. +it should be called WITH the video->mtx taken. */ static void frame_prepare (struct video_card *video,unsigned int this_frame)
@@ -1271,7 +1272,7 @@ static int dv1394_mmap(struct file *fileint retval = -EINVAL ;/* serialize mmap */ -down (&video->sem); +mutex_lock (&video->mtx);if ( !video_card_initialized (video) ) { retval =do_dv1394_init_default (video);
@@ -1281,7 +1282,7 @@ static int dv1394_mmap(struct file *file retval =dma_region_mmap (&video->dv_buf, file, vma); out: -up (&video->sem); +mutex_unlock (&video->mtx);return retval; }
@@ -1337,17 +1338,17 @@ static ssize_t dv1394_write(struct file/* serialize this to prevent multi-threaded mayhem */ if (file->f_flags &O_NONBLOCK ) { -if (down_trylock (&video->sem)) +if (!mutex_trylock (&video->mtx))return -EAGAIN ; }else { -if (down_interruptible (&video->sem)) +if (mutex_lock_interruptible (&video->mtx))return -ERESTARTSYS ; }if ( !video_card_initialized (video) ) { ret =do_dv1394_init_default (video);if (ret) { -up (&video->sem); +mutex_unlock (&video->mtx);return ret; } }
@@ -1418,7 +1419,7 @@ static ssize_t dv1394_write(struct fileremove_wait_queue (&video->waitq, &wait);set_current_state (TASK_RUNNING ); -up (&video->sem); +mutex_unlock (&video->mtx);return ret; }
@@ -1434,17 +1435,17 @@ static ssize_t dv1394_read(struct file */* serialize this to prevent multi-threaded mayhem */ if (file->f_flags &O_NONBLOCK ) { -if (down_trylock (&video->sem)) +if (!mutex_trylock (&video->mtx))return -EAGAIN ; }else { -if (down_interruptible (&video->sem)) +if (mutex_lock_interruptible (&video->mtx))return -ERESTARTSYS ; }if ( !video_card_initialized (video) ) { ret =do_dv1394_init_default (video);if (ret) { -up (&video->sem); +mutex_unlock (&video->mtx);return ret; } video->continuity_counter =-1 ;
@@ -1526,7 +1527,7 @@ static ssize_t dv1394_read(struct file *remove_wait_queue (&video->waitq, &wait);set_current_state (TASK_RUNNING ); -up (&video->sem); +mutex_unlock (&video->mtx);return ret; }
@@ -1547,12 +1548,12 @@ static long dv1394_ioctl(struct file *fi/* serialize this to prevent multi-threaded mayhem */ if (file->f_flags &O_NONBLOCK ) { -if (down_trylock (&video->sem)) { +if (!mutex_trylock (&video->mtx)) {unlock_kernel ();return -EAGAIN ; } }else { -if (down_interruptible (&video->sem)) { +if (mutex_lock_interruptible (&video->mtx)) {unlock_kernel ();return -ERESTARTSYS ; }
@@ -1778,7 +1779,7 @@ static long dv1394_ioctl(struct file *fi } out: -up (&video->sem); +mutex_unlock (&video->mtx);unlock_kernel ();return ret; }
@@ -2253,7 +2254,7 @@ static int dv1394_init(struct ti_ohci *oclear_bit (0 , &video->open);spin_lock_init (&video->spinlock); video->dma_running =0 ; -init_MUTEX (&video->sem); +mutex_init (&video->mtx);init_waitqueue_head (&video->waitq); video->fasync =NULL ;
PATCH 12/19 ieee1394: raw1394: remove redundant counting semaphore
In reply to Stefan RichterAn already existing wait queue replaces raw1394's complete_sem which was maintained in parallel to the wait queue. The role of the semaphore's counter is taken over by a direct check of what was really counted: The presence of items in the list of completed requests.
Notes:
- raw1394_release() sleeps uninterruptibly until all requests were completed. This is the same behaviour as before the patch.
- The macros wait_event and wait_event_interruptible are called with a condition argument which has a side effect, i.e. manipulation of the requests list. This side effect happens only if the condition is true. The patch relies on the fact that wait_event[_interruptible] does not evaluate the condition again after it became true.
- The diffstat looks unfavorable with respect to added lines of code. However 19 of them are comments, and some are due to separation of existing code blocks into two small helper functions.
--- drivers/ieee1394/raw1394-private.h | 3 drivers/ieee1394/raw1394.c | 91 ++++++++++++++++++----------- 2 files changed, 58 insertions(+), 36 deletions(-)
drivers/ieee1394/raw1394-private.h +1 -2
@@ -29,9 +29,8 @@ struct file_info {struct list_head req_pending;struct list_head req_complete; -struct semaphore complete_sem;spinlock_t reqlists_lock; -wait_queue_head_t poll_wait_complete; +wait_queue_head_t wait_complete;struct list_head addr_list;
drivers/ieee1394/raw1394.c +57 -34
150 lines not on this page · raw message
PATCH 13/19 ieee1394: nodemgr: remove unnecessary includes
In reply to Stefan Richter---
drivers/ieee1394/nodemgr.c +0 -4
@@ -12,12 +12,8 @@#include <linux/kernel.h> #include <linux/list.h> #include <linux/slab.h> -#include <linux/smp_lock.h> -#include <linux/interrupt.h> -#include <linux/kmod.h> #include <linux/completion.h> #include <linux/delay.h> -#include <linux/pci.h> #include <linux/moduleparam.h> #include <asm/atomic.h>
PATCH 14/19 ieee1394: nodemgr: do not spawn kernel_thread for sysfs rescan
In reply to Stefan Richternodemgr.c::fw_set_rescan() is used to re-run the driver core over nodemgr's representation of unit directories in order to initiate protocol driver probes. It is initiated via write access to one of nodemgr's sysfs attributes. The purpose is to attach drivers to units after switching a unit's ignore_driver attribute from 1 to 0.
It is not really necessary to fork a kernel_thread for this job. The call to kernel_thread() can be eliminated to avoid the deprecated API and to simplify the code a bit.
---
drivers/ieee1394/nodemgr.c +2 -17
@@ -405,26 +405,11 @@ static ssize_t fw_get_destroy_node(struc } static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node); -static int nodemgr_rescan_bus_thread (void *__unused) -{ -/* No userlevel access needed */ -daemonize ("kfwrescan" ); - -bus_rescan_devices (&ieee1394_bus_type); - -return 0 ; -}static ssize_t fw_set_rescan (struct bus_type *bus,const char *buf,size_t count) { -int state =simple_strtoul (buf,NULL ,10 ); - -/* Don't wait for this, or care about errors. Root could do -* something stupid and spawn this a lot of times, but that's -* root's fault. */ -if (state ==1 ) -kernel_thread (nodemgr_rescan_bus_thread,NULL ,CLONE_KERNEL ); - +if (simple_strtoul (buf,NULL ,10 ) ==1 ) +bus_rescan_devices (&ieee1394_bus_type);return count; }static ssize_t fw_get_rescan (struct bus_type *bus,char *buf)
PATCH 15/19 ieee1394: nodemgr: make module parameter ignore_drivers writable
In reply to Stefan RichterNodemgr's ignore_drivers variable is exposed as a module load parameter (therefore also as a sysfs attribute below /sys/module) and additionally as an attribute below /sys/bus/ieee1394. Since the latter is writable, make the former writable too.
Note, the bus's attribute ignore_drivers is only relevant to newly added units, not to present or suspended or resuming units. Those have their own attribute ignore_driver.
---
drivers/ieee1394/nodemgr.c +1 -1
@@ -28,7 +28,7 @@#include "nodemgr.h" static int ignore_drivers; -module_param (ignore_drivers, int,0444 ); +module_param (ignore_drivers, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (ignore_drivers,"Disable automatic probing for drivers." );struct nodemgr_csr_info {
PATCH 16/19 ieee1394: nodemgr: switch to kthread api, replace reset semaphore
In reply to Stefan RichterConvert nodemgr's host thread from kernel_thread to kthread and its sleep/restart mechanism from a counting semaphore to a schedule()/ wake_up_process() scheme.
---
Replaces the patches
"ieee1394: nodemgr: switch to kthread API"
"ieee1394: nodemgr: replace reset semaphore"
drivers/ieee1394/nodemgr.c | 120 ++++++++++++------------------------- 1 files changed, 41 insertions(+), 79 deletions(-)
drivers/ieee1394/nodemgr.c +41 -79
@@ -12,8 +12,8 @@#include <linux/kernel.h> #include <linux/list.h> #include <linux/slab.h> -#include <linux/completion.h> #include <linux/delay.h> +#include <linux/kthread.h> #include <linux/moduleparam.h> #include <asm/atomic.h>
@@ -163,11 +163,7 @@ static DECLARE_MUTEX(nodemgr_serialize);struct host_info {struct hpsb_host *host;struct list_head list; -struct completion exited; -struct semaphore reset_sem; -int pid; -char daemon_name[15 ]; -int kill_me; +struct task_struct *thread; };static int nodemgr_bus_match (struct device * dev,struct device_driver * drv);
@@ -1477,9 +1473,8 @@ static void nodemgr_node_probe(struct ho/* If we had a bus reset while we were scanning the bus, it is * possible that we did not probe all nodes. In that case, we * skip the clean up for now, since we could remove nodes that -* were still on the bus. The bus reset increased hi->reset_sem, -* so there's a bus scan pending which will do the clean up -* eventually. +* were still on the bus. Another bus scan is pending which will +* do the clean up eventually. * * Now let's tell the bus to rescan our devices. This may seem * like overhead, but the driver-model core will only scan a
@@ -1607,41 +1602,37 @@ static int nodemgr_host_thread(void *__h {struct host_info *hi = (struct host_info *)__hi;struct hpsb_host *host = hi->host; -int reset_cycles =0 ; - -/* No userlevel access needed */ -daemonize (hi->daemon_name); +unsigned int g, generation =get_hpsb_generation (host) -1 ; +int i, reset_cycles =0 ;/* Setup our device-model entries */ nodemgr_create_host_dev_files (host); -/* Sit and wait for a signal to probe the nodes on the bus. This -* happens when we get a bus reset. */ -while (1 ) { -unsigned int generation =0 ; -int i; +for (;;) { +/* Sleep until next bus reset */ +set_current_state (TASK_INTERRUPTIBLE ); +if (get_hpsb_generation (host) == generation) +schedule (); +__set_current_state (TASK_RUNNING ); + +/* Thread may have been woken up to freeze or to exit */ +if (try_to_freeze ()) +continue ; +if (kthread_should_stop ()) + goto exit; -if (down_interruptible (&hi->reset_sem) || -down_interruptible (&nodemgr_serialize)) { +if (down_interruptible (&nodemgr_serialize)) {if (try_to_freeze ())continue ; -printk ("NodeMgr: received unexpected signal?!\n" ); -break ; - } - -if (hi->kill_me) { -up (&nodemgr_serialize); -break ; + goto exit; }/* Pause for 1/4 second in 1/16 second intervals, * to make sure things settle down. */ + g =get_hpsb_generation (host);for (i =0 ; i <4 ; i++) { -set_current_state (TASK_INTERRUPTIBLE ); -if (msleep_interruptible (63 )) { -up (&nodemgr_serialize); - goto caught_signal; - } +if (msleep_interruptible (63 ) ||kthread_should_stop ()) + goto unlock_exit;/* Now get the generation in which the node ID's we collect * are valid. During the bus scan we will use this generation
@@ -1652,14 +1643,8 @@ static int nodemgr_host_thread(void *__h/* If we get a reset before we are done waiting, then * start the the waiting over again */ -while (!down_trylock (&hi->reset_sem)) - i =0 ; - -/* Check the kill_me again */ -if (hi->kill_me) { -up (&nodemgr_serialize); - goto caught_signal; - } +if (generation != g) + g = generation, i =0 ; } if (!nodemgr_check_irm_capability(host, reset_cycles) ||
@@ -1685,11 +1670,11 @@ static int nodemgr_host_thread(void *__hup (&nodemgr_serialize); } - -caught_signal: +unlock_exit: +up (&nodemgr_serialize); +exit:HPSB_VERBOSE ("NodeMgr: Exiting thread" ); - -complete_and_exit (&hi->exited,0 ); +return 0 ; }int nodemgr_for_each_host (void *__data,int (*cb)(struct hpsb_host *,void *))
@@ -1749,41 +1734,27 @@ static void nodemgr_add_host(struct hpsbstruct host_info *hi; hi =hpsb_create_hostinfo (&nodemgr_highlevel, host,sizeof (*hi)); -if (!hi) { -HPSB_ERR ("NodeMgr: out of memory in add host" ); +HPSB_ERR ("NodeMgr: out of memory in add host" );return ; } - hi->host = host; -init_completion (&hi->exited); -sema_init (&hi->reset_sem,0 ); - -sprintf (hi->daemon_name,"knodemgrd_%d" , host->id); - - hi->pid =kernel_thread (nodemgr_host_thread, hi,CLONE_KERNEL ); - -if (hi->pid <0 ) { -HPSB_ERR ("NodeMgr: failed to start %s thread for %s" , - hi->daemon_name, host->driver->name); + hi->thread =kthread_run (nodemgr_host_thread, hi,"knodemgrd_%d" , + host->id); +if (IS_ERR (hi->thread)) { +HPSB_ERR ("NodeMgr: cannot start thread for host %d" , host->id);hpsb_destroy_hostinfo (&nodemgr_highlevel, host); -return ; } - -return ; }static void nodemgr_host_reset (struct hpsb_host *host) {struct host_info *hi =hpsb_get_hostinfo (&nodemgr_highlevel, host); -if (hi !=NULL ) { -HPSB_VERBOSE ("NodeMgr: Processing host reset for %s" , hi->daemon_name); -up (&hi->reset_sem); - }else -HPSB_ERR ("NodeMgr: could not process reset of unused host" ); - -return ; +if (hi) { +HPSB_VERBOSE ("NodeMgr: Processing reset for host %d" , host->id); +wake_up_process (hi->thread); + } }static void nodemgr_remove_host (struct hpsb_host *host)
@@ -1791,18 +1762,9 @@ static void nodemgr_remove_host(struct hstruct host_info *hi =hpsb_get_hostinfo (&nodemgr_highlevel, host);if (hi) { -if (hi->pid >=0 ) { - hi->kill_me =1 ; -mb (); -up (&hi->reset_sem); -wait_for_completion (&hi->exited); -nodemgr_remove_host_dev (&host->device); - } - }else -HPSB_ERR ("NodeMgr: host %s does not exist, cannot remove" , - host->driver->name); - -return ; +kthread_stop (hi->thread); +nodemgr_remove_host_dev (&host->device); + } }static struct hpsb_highlevel nodemgr_highlevel = {
PATCH 17/19 ieee1394: nodemgr: convert nodemgr_serialize semaphore to mutex
In reply to Stefan RichterAnother trivial sem2mutex conversion.
Side note: nodemgr_serialize's purpose, when introduced in linux1394's revision 529 in July 2002, was to protect several data structures which are now largely handled by or together with Linux' driver core and are now protected by the LDM's own mechanisms. It may very well be possible to remove this mutex now. But fully parallelized node scanning is on our long-term TODO list anyway; the mutex will certainly go away then.
---
drivers/ieee1394/nodemgr.c +5 -5
@@ -158,7 +158,7 @@ static struct csr1212_bus_ops nodemgr_cs* but now we are much simpler because of the LDM. */ -static DECLARE_MUTEX (nodemgr_serialize); +static DEFINE_MUTEX (nodemgr_serialize);struct host_info {struct hpsb_host *host;
@@ -1621,7 +1621,7 @@ static int nodemgr_host_thread(void *__hif (kthread_should_stop ()) goto exit; -if (down_interruptible (&nodemgr_serialize)) { +if (mutex_lock_interruptible (&nodemgr_serialize)) {if (try_to_freeze ())continue ; goto exit;
@@ -1650,7 +1650,7 @@ static int nodemgr_host_thread(void *__hif (!nodemgr_check_irm_capability (host, reset_cycles) || !nodemgr_do_irm_duties (host, reset_cycles)) { reset_cycles++; -up (&nodemgr_serialize); +mutex_unlock (&nodemgr_serialize);continue ; } reset_cycles =0 ;
@@ -1668,10 +1668,10 @@ static int nodemgr_host_thread(void *__h/* Update some of our sysfs symlinks */ nodemgr_update_host_dev_links (host); -up (&nodemgr_serialize); +mutex_unlock (&nodemgr_serialize); } unlock_exit: -up (&nodemgr_serialize); +mutex_unlock (&nodemgr_serialize); exit:HPSB_VERBOSE ("NodeMgr: Exiting thread" );return 0 ;
PATCH 18/19 ieee1394: fix kerneldoc of hpsb_alloc_host
In reply to Stefan RichterThere was stuff between the comment and the function.
---
When applied to -mm, this will have a conflict with a lock validator annotations patch which currently lives in -mm. This is easy to resolve but I will post this patch as an -mm version too.
drivers/ieee1394/hosts.c +2 -2
@@ -90,6 +90,8 @@ static int alloc_hostnum_cb(struct hpsb_return 0 ; } +static DEFINE_MUTEX (host_num_alloc); +/** * hpsb_alloc_host - allocate a new host controller. * @drv: the driver that will manage the host controller
@@ -105,8 +107,6 @@ static int alloc_hostnum_cb(struct hpsb_* Return Value: a pointer to the &hpsb_host if successful, %NULL if * no memory was available. */ -static DEFINE_MUTEX (host_num_alloc); -struct hpsb_host *hpsb_alloc_host (struct hpsb_host_driver *drv,size_t extra,struct device *dev) {
PATCH 1/1 ieee1394: fix kerneldoc of hpsb_alloc_host
There was stuff between the comment and the function.
---
This is the version with additional fuzz by -mm's lock validator. Just FYI.
drivers/ieee1394/hosts.c +10 -10
@@ -90,6 +90,16 @@ static int alloc_hostnum_cb(struct hpsb_return 0 ; } +/* +* The pending_packet_queue is special in that it's processed +* from hardirq context too (such as hpsb_bus_reset()). Hence +* split the lock class from the usual networking skb-head +* lock class by using a separate key for it: +*/ +static struct lock_class_key pending_packet_queue_key; + +static DEFINE_MUTEX (host_num_alloc); +/** * hpsb_alloc_host - allocate a new host controller. * @drv: the driver that will manage the host controller
@@ -105,16 +115,6 @@ static int alloc_hostnum_cb(struct hpsb_* Return Value: a pointer to the &hpsb_host if successful, %NULL if * no memory was available. */ -static DEFINE_MUTEX (host_num_alloc); - -/* -* The pending_packet_queue is special in that it's processed -* from hardirq context too (such as hpsb_bus_reset()). Hence -* split the lock class from the usual networking skb-head -* lock class by using a separate key for it: -*/ -static struct lock_class_key pending_packet_queue_key; -struct hpsb_host *hpsb_alloc_host (struct hpsb_host_driver *drv,size_t extra,struct device *dev) {
PATCH 19/19 ieee1394: shrink tlabel pools, remove tpool semaphores
In reply to Stefan RichterThis patch reduces the size of struct hpsb_host and also removes semaphores from ieee1394_transactions.c. On i386, struct hpsb_host shrinks from 10656 bytes to 6688 bytes. This is accomplished by
- using a single wait_queue for hpsb_get_tlabel instead of many instances of semaphores,
- using a single lock to serialize access to all tlabel pools (the protected code regions are small, i.e. lock contention very low),
- omitting the sysfs attribute tlabels_allocations.
Drawback: In the rare case that a process needs to sleep because all transaction labels for the node are temporarily exhausted, it is also woken up if a tlabel for a different node became free, checks for an available tlabel, and is put to sleep again. The check is not costly and the situation occurs very rarely, therefore the benefit of reduced tpool size outweighs this drawback.
The sysfs attributes tlabels_free and tlabels_mask are not compiled anymore unless CONFIG_IEEE1394_VERBOSEDEBUG is set.
The by far biggest member of struct hpsb_host, the struct csr_control csr (5272 bytes on i386), is now placed at the end of struct hpsb_host.
Note, hpsb_get_tlabel calls the macro wait_event_interruptible with a condition argument which has a side effect (allocation of a tlabel and manipulation of the packet). This side effect happens only if the condition is true. The patch relies on wait_event_interruptible not evaluating the condition again after it became true.
---
Replaces the patches
"ieee1394: reduce size of hpsb_host by 252 bytes" "ieee1394: coarser locking for tlabel allocation" "ieee1394: nodemgr: read tlabel attributes atomically" "ieee1394: convert ieee1394_transactions from semaphores to waitqueue"
drivers/ieee1394/hosts.c | 3 drivers/ieee1394/hosts.h | 19 +--- drivers/ieee1394/ieee1394_transactions.c | 108 +++++++++++++---------- drivers/ieee1394/ieee1394_transactions.h | 4 drivers/ieee1394/ieee1394_types.h | 23 ---- drivers/ieee1394/nodemgr.c | 43 +++++---- drivers/ieee1394/nodemgr.h | 1 7 files changed, 102 insertions(+), 99 deletions(-)
drivers/ieee1394/ieee1394_types.h +1 -22
@@ -2,31 +2,9 @@#define _IEEE1394_TYPES_H#include <linux/kernel.h> -#include <linux/list.h> -#include <linux/spinlock.h> #include <linux/string.h> #include <linux/types.h> -#include <asm/byteorder.h> -#include <asm/semaphore.h> - -/* Transaction Label handling */ -struct hpsb_tlabel_pool { - DECLARE_BITMAP(pool, 64); -spinlock_t lock; -u8 next; -u32 allocations; -struct semaphore count; -}; - -#define HPSB_TPOOL_INIT (_tp) \ -do { \ - bitmap_zero((_tp)->pool, 64); \ - spin_lock_init(&(_tp)->lock); \ - (_tp)->next = 0; \ - (_tp)->allocations = 0; \ - sema_init(&(_tp)->count, 63); \ -} while (0)typedef u32 quadlet_t ;typedef u64 octlet_t ;
@@ -61,6 +39,7 @@ typedef u16 arm_length_t;#ifdef CONFIG_IEEE1394_VERBOSEDEBUG #define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) +#define HPSB_DEBUG_TLABELS #else #define HPSB_VERBOSE(fmt, args...)#endif
drivers/ieee1394/hosts.h +8 -11
@@ -35,7 +35,6 @@ struct hpsb_host {int node_count;/* number of identified nodes on this bus */ int selfid_count;/* total number of SelfIDs received */ int nodes_active;/* number of nodes with active link layer */ -u8 speed[ALL_NODES ];/* speed between each node and local node */ nodeid_t node_id;/* node ID of this host */ nodeid_t irm_id;/* ID of this bus' isochronous resource manager */
@@ -55,31 +54,29 @@ struct hpsb_host {int reset_retries;quadlet_t *topology_map;u8 *speed_map; -struct csr_control csr; - -/* Per node tlabel pool allocation */ -struct hpsb_tlabel_pool tpool[ALL_NODES ]; +int id;struct hpsb_host_driver *driver; -struct pci_dev *pdev; - -int id; -struct device device;struct class_device class_dev;int update_config_rom;struct work_struct delayed_reset; -unsigned int config_roms;struct list_head addr_space;u64 low_addr_space;/* upper bound of physical DMA area */ u64 middle_addr_space;/* upper bound of posted write area */ -}; +u8 speed[ALL_NODES ];/* speed between each node and local node */ +/* per node tlabel allocation */ +u8 next_tl[ALL_NODES ]; + struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES]; + +struct csr_control csr; +};enum devctl_cmd {/* Host is requested to reset its bus and cancel all outstanding async
drivers/ieee1394/hosts.c +0 -3
@@ -143,9 +143,6 @@ struct hpsb_host *hpsb_alloc_host(structfor (i =2 ; i <16 ; i++) h->csr.gen_timestamp[i] = jiffies -60 *HZ ; -for (i =0 ; i <ARRAY_SIZE (h->tpool); i++) -HPSB_TPOOL_INIT (&h->tpool[i]); -atomic_set (&h->generation,0 );INIT_WORK (&h->delayed_reset, delayed_reset_bus, h);
drivers/ieee1394/ieee1394_transactions.h +4 -0
@@ -53,4 +53,8 @@ int hpsb_read(struct hpsb_host *host, noint hpsb_write (struct hpsb_host *host,nodeid_t node,unsigned int generation,u64 addr,quadlet_t *buffer,size_t length); +#ifdef HPSB_DEBUG_TLABELS +extern spinlock_t hpsb_tlabel_lock; +#endif +#endif /* _IEEE1394_TRANSACTIONS_H */
drivers/ieee1394/ieee1394_transactions.c +63 -45
159 lines not on this page · raw message
drivers/ieee1394/nodemgr.h +0 -1
@@ -107,7 +107,6 @@ struct node_entry {const char *vendor_oui;u32 capabilities; -struct hpsb_tlabel_pool *tpool;struct device device;struct class_device class_dev;
drivers/ieee1394/nodemgr.c +26 -17
77 lines not on this page · raw message
Quoted 6 lines · Stefan Richter
Hi Ben,
here are a few new, updated, or resent patches, most of them janitorial. I created them against 2.6.17-git18 but tested on 2.6.16.x. If they are OK with you, please apply them to your 1394 tree (after you resynced from Linus) for Andrew to pull eventually.
All patches applied to the linux1394.git:
master.kernel.org:/pub/scm/linux/kernel/git/bcollins/linux1394-2.6.git
It's up-to-date with Linus's tree as well.
Signature · 4 lines
Ubuntu - http://www.ubuntu.com/ Debian - http://www.debian.org/ Linux 1394 - http://www.linux1394.org/ SwissDisk - http://www.swissdisk.com/