From c950d6d40d505edbc1cfd82645e42c665f0788ee Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Oct 24 2007 20:10:53 +0000 Subject: - Update firewire-cdev.h to match kernel --- diff --git a/firewire-cdev.h b/firewire-cdev.h index 026c768..1a45d6f 100644 --- a/firewire-cdev.h +++ b/firewire-cdev.h @@ -1,6 +1,5 @@ -/* -*- c-basic-offset: 8 -*- - * - * fw-device-cdev.h -- Char device interface. +/* + * Char device interface. * * Copyright (C) 2005-2006 Kristian Hoegsberg * @@ -19,66 +18,50 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __fw_cdev_h -#define __fw_cdev_h - -#include -#include - -#define TCODE_WRITE_QUADLET_REQUEST 0 -#define TCODE_WRITE_BLOCK_REQUEST 1 -#define TCODE_WRITE_RESPONSE 2 -#define TCODE_READ_QUADLET_REQUEST 4 -#define TCODE_READ_BLOCK_REQUEST 5 -#define TCODE_READ_QUADLET_RESPONSE 6 -#define TCODE_READ_BLOCK_RESPONSE 7 -#define TCODE_CYCLE_START 8 -#define TCODE_LOCK_REQUEST 9 -#define TCODE_STREAM_DATA 10 -#define TCODE_LOCK_RESPONSE 11 - -#define TCODE_LOCK_MASK_SWAP 0x11 -#define TCODE_LOCK_COMPARE_SWAP 0x12 -#define TCODE_LOCK_FETCH_ADD 0x13 -#define TCODE_LOCK_LITTLE_ADD 0x14 -#define TCODE_LOCK_BOUNDED_ADD 0x15 -#define TCODE_LOCK_WRAP_ADD 0x16 -#define TCODE_LOCK_VENDOR_DEPENDENT 0x17 - -#define RCODE_COMPLETE 0x0 -#define RCODE_CONFLICT_ERROR 0x4 -#define RCODE_DATA_ERROR 0x5 -#define RCODE_TYPE_ERROR 0x6 -#define RCODE_ADDRESS_ERROR 0x7 +#ifndef _LINUX_FIREWIRE_CDEV_H +#define _LINUX_FIREWIRE_CDEV_H -#define RCODE_SEND_ERROR 0x10 -#define RCODE_CANCELLED 0x11 -#define RCODE_BUSY 0x12 -#define RCODE_GENERATION 0x13 -#define RCODE_NO_ACK 0x14 - -#define SCODE_100 0x0 -#define SCODE_200 0x1 -#define SCODE_400 0x2 -#define SCODE_800 0x3 -#define SCODE_1600 0x4 -#define SCODE_3200 0x5 +#include +#include +#include #define FW_CDEV_EVENT_BUS_RESET 0x00 #define FW_CDEV_EVENT_RESPONSE 0x01 #define FW_CDEV_EVENT_REQUEST 0x02 #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 -/* The 'closure' fields are for user space to use. Data passed in the - * 'closure' field for a request will be returned in the corresponding - * event. It's a 64-bit type so that it's a fixed size type big - * enough to hold a pointer on all platforms. */ - +/** + * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types + * @closure: For arbitrary use by userspace + * @type: Discriminates the fw_cdev_event_ types + * + * This struct may be used to access generic members of all fw_cdev_event_ + * types regardless of the specific type. + * + * Data passed in the @closure field for a request will be returned in the + * corresponding event. It is big enough to hold a pointer on all platforms. + * The ioctl used to set @closure depends on the @type of event. + */ struct fw_cdev_event_common { __u64 closure; __u32 type; }; +/** + * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred + * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET + * @node_id: New node ID of this node + * @local_node_id: Node ID of the local node, i.e. of the controller + * @bm_node_id: Node ID of the bus manager + * @irm_node_id: Node ID of the iso resource manager + * @root_node_id: Node ID of the root node + * @generation: New bus generation + * + * This event is sent when the bus the device belongs to goes through a bus + * reset. It provides information about the new bus configuration, such as + * new node ID for this device, new root ID, and others. + */ struct fw_cdev_event_bus_reset { __u64 closure; __u32 type; @@ -90,6 +73,20 @@ struct fw_cdev_event_bus_reset { __u32 generation; }; +/** + * struct fw_cdev_event_response - Sent when a response packet was received + * @closure: See &fw_cdev_event_common; + * set by %FW_CDEV_IOC_SEND_REQUEST ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE + * @rcode: Response code returned by the remote node + * @length: Data length, i.e. the response's payload size in bytes + * @data: Payload data, if any + * + * This event is sent when the stack receives a response to an outgoing request + * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses + * carrying data (read and lock responses) follows immediately and can be + * accessed through the @data field. + */ struct fw_cdev_event_response { __u64 closure; __u32 type; @@ -98,6 +95,25 @@ struct fw_cdev_event_response { __u32 data[0]; }; +/** + * struct fw_cdev_event_request - Sent on incoming request to an address region + * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST + * @tcode: Transaction code of the incoming request + * @offset: The offset into the 48-bit per-node address space + * @handle: Reference to the kernel-side pending request + * @length: Data length, i.e. the request's payload size in bytes + * @data: Incoming data, if any + * + * This event is sent when the stack receives an incoming request to an address + * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is + * guaranteed to be completely contained in the specified region. Userspace is + * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl, + * using the same @handle. + * + * The payload data for requests carrying data (write and lock requests) + * follows immediately and can be accessed through the @data field. + */ struct fw_cdev_event_request { __u64 closure; __u32 type; @@ -108,14 +124,39 @@ struct fw_cdev_event_request { __u32 data[0]; }; +/** + * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed + * @closure: See &fw_cdev_event_common; + * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl + * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT + * @cycle: Cycle counter of the interrupt packet + * @header_length: Total length of following headers, in bytes + * @header: Stripped headers, if any + * + * This event is sent when the controller has completed an &fw_cdev_iso_packet + * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers + * stripped of all packets up until and including the interrupt packet are + * returned in the @header field. + */ struct fw_cdev_event_iso_interrupt { __u64 closure; __u32 type; __u32 cycle; - __u32 header_length; /* Length in bytes of following headers. */ + __u32 header_length; __u32 header[0]; }; +/** + * union fw_cdev_event - Convenience union of fw_cdev_event_ types + * @common: Valid for all types + * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET + * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE + * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST + * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT + * + * Convenience union for userspace use. Events could be read(2) into a char + * buffer and then cast to this union for further processing. + */ union fw_cdev_event { struct fw_cdev_event_common common; struct fw_cdev_event_bus_reset bus_reset; @@ -144,35 +185,47 @@ union fw_cdev_event { */ #define FW_CDEV_VERSION 1 +/** + * struct fw_cdev_get_info - General purpose information ioctl + * @version: The version field is just a running serial number. + * We never break backwards compatibility, but may add more + * structs and ioctls in later revisions. + * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration + * ROM will be copied into that user space address. In either + * case, @rom_length is updated with the actual length of the + * configuration ROM. + * @rom: If non-zero, address of a buffer to be filled by a copy of the + * local node's configuration ROM + * @bus_reset: If non-zero, address of a buffer to be filled by a + * &struct fw_cdev_event_bus_reset with the current state + * of the bus. This does not cause a bus reset to happen. + * @bus_reset_closure: Value of &closure in this and subsequent bus reset events + * @card: The index of the card this device belongs to + */ struct fw_cdev_get_info { - /* The version field is just a running serial number. We - * never break backwards compatibility. Userspace passes in - * the version it expects and the kernel passes back the - * highest version it can provide. Even if the structs in - * this interface are extended in a later version, the kernel - * will not copy back more data than what was present in the - * interface version userspace expects. */ __u32 version; - - /* If non-zero, at most rom_length bytes of config rom will be - * copied into that user space address. In either case, - * rom_length is updated with the actual length of the config - * rom. */ __u32 rom_length; __u64 rom; - - /* If non-zero, a fw_cdev_event_bus_reset struct will be - * copied here with the current state of the bus. This does - * not cause a bus reset to happen. The value of closure in - * this and sub-sequent bus reset events is set to - * bus_reset_closure. */ __u64 bus_reset; __u64 bus_reset_closure; - - /* The index of the card this devices belongs to. */ __u32 card; }; +/** + * struct fw_cdev_send_request - Send an asynchronous request packet + * @tcode: Transaction code of the request + * @length: Length of outgoing payload, in bytes + * @offset: 48-bit offset at destination node + * @closure: Passed back to userspace in the response event + * @data: Userspace pointer to payload + * @generation: The bus generation where packet is valid + * + * Send a request to the device. This ioctl implements all outgoing requests. + * Both quadlet and block request specify the payload as a pointer to the data + * in the @data field. Once the transaction completes, the kernel writes an + * &fw_cdev_event_request event back. The @closure field is passed back to + * user space in the response event. + */ struct fw_cdev_send_request { __u32 tcode; __u32 length; @@ -182,6 +235,19 @@ struct fw_cdev_send_request { __u32 generation; }; +/** + * struct fw_cdev_send_response - Send an asynchronous response packet + * @rcode: Response code as determined by the userspace handler + * @length: Length of outgoing payload, in bytes + * @data: Userspace pointer to payload + * @handle: The handle from the &fw_cdev_event_request + * + * Send a response to an incoming request. By setting up an address range using + * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An + * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must + * send a reply using this ioctl. The event has a handle to the kernel-side + * pending transaction, which should be used with this ioctl. + */ struct fw_cdev_send_response { __u32 rcode; __u32 length; @@ -189,6 +255,21 @@ struct fw_cdev_send_response { __u32 handle; }; +/** + * struct fw_cdev_allocate - Allocate a CSR address range + * @offset: Start offset of the address range + * @closure: To be passed back to userspace in request events + * @length: Length of the address range, in bytes + * @handle: Handle to the allocation, written by the kernel + * + * Allocate an address range in the 48-bit address space on the local node + * (the controller). This allows userspace to listen for requests with an + * offset within that address range. When the kernel receives a request + * within the range, an &fw_cdev_event_request event will be written back. + * The @closure field is passed back to userspace in the response event. + * The @handle field is an out parameter, returning a handle to the allocated + * range to be used for later deallocation of the range. + */ struct fw_cdev_allocate { __u64 offset; __u64 closure; @@ -196,6 +277,11 @@ struct fw_cdev_allocate { __u32 handle; }; +/** + * struct fw_cdev_deallocate - Free an address range allocation + * @handle: Handle to the address range, as returned by the kernel when the + * range was allocated + */ struct fw_cdev_deallocate { __u32 handle; }; @@ -203,10 +289,41 @@ struct fw_cdev_deallocate { #define FW_CDEV_LONG_RESET 0 #define FW_CDEV_SHORT_RESET 1 +/** + * struct fw_cdev_initiate_bus_reset - Initiate a bus reset + * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET + * + * Initiate a bus reset for the bus this device is on. The bus reset can be + * either the original (long) bus reset or the arbitrated (short) bus reset + * introduced in 1394a-2000. + */ struct fw_cdev_initiate_bus_reset { - __u32 type; + __u32 type; /* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */ }; +/** + * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM + * @immediate: If non-zero, immediate key to insert before pointer + * @key: Upper 8 bits of root directory pointer + * @data: Userspace pointer to contents of descriptor block + * @length: Length of descriptor block data, in bytes + * @handle: Handle to the descriptor, written by the kernel + * + * Add a descriptor block and optionally a preceding immediate key to the local + * node's configuration ROM. + * + * The @key field specifies the upper 8 bits of the descriptor root directory + * pointer and the @data and @length fields specify the contents. The @key + * should be of the form 0xXX000000. The offset part of the root directory entry + * will be filled in by the kernel. + * + * If not 0, the @immediate field specifies an immediate key which will be + * inserted before the root directory pointer. + * + * If successful, the kernel adds the descriptor and writes back a handle to the + * kernel-side object to be used for later removal of the descriptor block and + * immediate key. + */ struct fw_cdev_add_descriptor { __u32 immediate; __u32 key; @@ -215,6 +332,14 @@ struct fw_cdev_add_descriptor { __u32 handle; }; +/** + * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM + * @handle: Handle to the descriptor, as returned by the kernel when the + * descriptor was added + * + * Remove a descriptor block and accompanying immediate key from the local + * node's configuration ROM. + */ struct fw_cdev_remove_descriptor { __u32 handle; }; @@ -222,12 +347,24 @@ struct fw_cdev_remove_descriptor { #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 -#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 -#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 - +/** + * struct fw_cdev_create_iso_context - Create a context for isochronous IO + * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE + * @header_size: Header size to strip for receive contexts + * @channel: Channel to bind to + * @speed: Speed to transmit at + * @closure: To be returned in &fw_cdev_event_iso_interrupt + * @handle: Handle to context, written back by kernel + * + * Prior to sending or receiving isochronous I/O, a context must be created. + * The context records information about the transmit or receive configuration + * and typically maps to an underlying hardware resource. A context is set up + * for either sending or receiving. It is bound to a specific isochronous + * channel. + * + * If a context was successfully created, the kernel writes back a handle to the + * context, which must be passed in for subsequent operations on that context. + */ struct fw_cdev_create_iso_context { __u32 type; __u32 header_size; @@ -237,16 +374,52 @@ struct fw_cdev_create_iso_context { __u32 handle; }; +#define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) +#define FW_CDEV_ISO_INTERRUPT (1 << 16) +#define FW_CDEV_ISO_SKIP (1 << 17) +#define FW_CDEV_ISO_SYNC (1 << 17) +#define FW_CDEV_ISO_TAG(v) ((v) << 18) +#define FW_CDEV_ISO_SY(v) ((v) << 20) +#define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) + +/** + * struct fw_cdev_iso_packet - Isochronous packet + * @control: Contains the header length (8 uppermost bits), the sy field + * (4 bits), the tag field (2 bits), a sync flag (1 bit), + * a skip flag (1 bit), an interrupt flag (1 bit), and the + * payload length (16 lowermost bits) + * @header: Header and payload + * + * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. + * + * Use the FW_CDEV_ISO_ macros to fill in @control. The sy and tag fields are + * specified by IEEE 1394a and IEC 61883. + * + * FIXME - finish this documentation + */ struct fw_cdev_iso_packet { - __u16 payload_length; /* Length of indirect payload. */ - __u32 interrupt : 1; /* Generate interrupt on this packet */ - __u32 skip : 1; /* Set to not send packet at all. */ - __u32 tag : 2; - __u32 sy : 4; - __u32 header_length : 8; /* Length of immediate header. */ + __u32 control; __u32 header[0]; }; +/** + * struct fw_cdev_queue_iso - Queue isochronous packets for I/O + * @packets: Userspace pointer to packet data + * @data: Pointer into mmap()'ed payload buffer + * @size: Size of packet data in bytes + * @handle: Isochronous context handle + * + * Queue a number of isochronous packets for reception or transmission. + * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, + * which describe how to transmit from or receive into a contiguous region + * of a mmap()'ed payload buffer. As part of the packet descriptors, + * a series of headers can be supplied, which will be prepended to the + * payload during DMA. + * + * The kernel may or may not queue all packets, but will write back updated + * values of the @packets, @data and @size fields, so the ioctl can be + * resubmitted easily. + */ struct fw_cdev_queue_iso { __u64 packets; __u64 data; @@ -254,6 +427,23 @@ struct fw_cdev_queue_iso { __u32 handle; }; +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 +#define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 +#define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 + +/** + * struct fw_cdev_start_iso - Start an isochronous transmission or reception + * @cycle: Cycle in which to start I/O. If @cycle is greater than or + * equal to 0, the I/O will start on that cycle. + * @sync: Determines the value to wait for for receive packets that have + * the %FW_CDEV_ISO_SYNC bit set + * @tags: Tag filter bit mask. Only valid for isochronous reception. + * Determines the tag values for which packets will be accepted. + * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags. + * @handle: Isochronous context handle within which to transmit or receive + */ struct fw_cdev_start_iso { __s32 cycle; __u32 sync; @@ -261,8 +451,12 @@ struct fw_cdev_start_iso { __u32 handle; }; +/** + * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception + * @handle: Handle of isochronous context to stop + */ struct fw_cdev_stop_iso { __u32 handle; }; -#endif /* __fw_cdev_h */ +#endif /* _LINUX_FIREWIRE_CDEV_H */ diff --git a/libraw1394-juju-no-double-free-on-shutdown.patch b/libraw1394-juju-no-double-free-on-shutdown.patch index 4f35ca4..f05fd63 100644 --- a/libraw1394-juju-no-double-free-on-shutdown.patch +++ b/libraw1394-juju-no-double-free-on-shutdown.patch @@ -1,6 +1,6 @@ diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw1394-iso.c ---- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-19 16:05:09.000000000 -0400 -+++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-19 17:14:40.000000000 -0400 +--- libraw1394-1.3.0/juju/raw1394-iso.c 2007-10-22 13:55:58.000000000 -0400 ++++ libraw1394-1.3.0.fix/juju/raw1394-iso.c 2007-10-22 15:27:54.000000000 -0400 @@ -394,6 +394,7 @@ iso_init(raw1394handle_t handle, int typ handle->iso.fd = open(handle->local_filename, O_RDWR); if (handle->iso.fd < 0) { @@ -34,3 +34,18 @@ diff -Naurp libraw1394-1.3.0/juju/raw1394-iso.c libraw1394-1.3.0.fix/juju/raw139 return -1; } +@@ -515,8 +520,12 @@ void raw1394_iso_stop(raw1394handle_t ha + + void raw1394_iso_shutdown(raw1394handle_t handle) + { +- munmap(handle->iso.buffer, +- handle->iso.buf_packets * handle->iso.max_packet_size); ++ if (handle->iso.buffer) { ++ munmap(handle->iso.buffer, ++ handle->iso.buf_packets * handle->iso.max_packet_size); ++ handle->iso.buffer = NULL; ++ } + close(handle->iso.fd); + free(handle->iso.packets); ++ handle->iso.packets = NULL; + } diff --git a/libraw1394.spec b/libraw1394.spec index e8f1725..9bf1d9a 100644 --- a/libraw1394.spec +++ b/libraw1394.spec @@ -1,7 +1,7 @@ Summary: Library providing low-level IEEE-1394 access Name: libraw1394 Version: 1.3.0 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPL Group: System Environment/Libraries Source: http://www.linux1394.org/dl/libraw1394-%{version}.tar.gz @@ -79,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Oct 24 2007 Jarod Wilson - 1.3.0-3 +- Update firewire-cdev.h to match kernel + * Fri Oct 19 2007 Jarod Wilson - 1.3.0-2 - Fix the 'double free' crash on shutdown (#328011)