diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 17:49:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 17:49:48 -0400 |
commit | 441c196e84b11aad3123baa9320eee7abc6b5c98 (patch) | |
tree | ea51d689c9ac09cce10a5758f19d6adbd8a7a9d7 | |
parent | 951cc93a7493a81a47e20231441bc6cf17c98a37 (diff) | |
parent | 9a00c24ae7cb08dcd46edf1327a47871e8466444 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
firewire: document the sysfs ABIs
firewire: cdev: ABI documentation enhancements
firewire: cdev: prevent race between first get_info ioctl and bus reset event queuing
firewire: cdev: return -ENOTTY for unimplemented ioctls, not -EINVAL
firewire: ohci: skip soft reset retries after card ejection
firewire: ohci: fix PHY reg access after card ejection
firewire: ohci: add a comment on PHY reg access serialization
firewire: ohci: reduce potential context_stop latency
firewire: ohci: remove superfluous posted write flushes
firewire: net: replacing deprecated __attribute__((packed)) with __packed
-rw-r--r-- | Documentation/ABI/stable/firewire-cdev | 103 | ||||
-rw-r--r-- | Documentation/ABI/stable/sysfs-bus-firewire | 122 | ||||
-rw-r--r-- | drivers/firewire/core-cdev.c | 20 | ||||
-rw-r--r-- | drivers/firewire/net.c | 5 | ||||
-rw-r--r-- | drivers/firewire/ohci.c | 42 | ||||
-rw-r--r-- | include/linux/firewire-cdev.h | 78 |
6 files changed, 303 insertions, 67 deletions
diff --git a/Documentation/ABI/stable/firewire-cdev b/Documentation/ABI/stable/firewire-cdev new file mode 100644 index 000000000000..16d030827368 --- /dev/null +++ b/Documentation/ABI/stable/firewire-cdev | |||
@@ -0,0 +1,103 @@ | |||
1 | What: /dev/fw[0-9]+ | ||
2 | Date: May 2007 | ||
3 | KernelVersion: 2.6.22 | ||
4 | Contact: linux1394-devel@lists.sourceforge.net | ||
5 | Description: | ||
6 | The character device files /dev/fw* are the interface between | ||
7 | firewire-core and IEEE 1394 device drivers implemented in | ||
8 | userspace. The ioctl(2)- and read(2)-based ABI is defined and | ||
9 | documented in <linux/firewire-cdev.h>. | ||
10 | |||
11 | This ABI offers most of the features which firewire-core also | ||
12 | exposes to kernelspace IEEE 1394 drivers. | ||
13 | |||
14 | Each /dev/fw* is associated with one IEEE 1394 node, which can | ||
15 | be remote or local nodes. Operations on a /dev/fw* file have | ||
16 | different scope: | ||
17 | - The 1394 node which is associated with the file: | ||
18 | - Asynchronous request transmission | ||
19 | - Get the Configuration ROM | ||
20 | - Query node ID | ||
21 | - Query maximum speed of the path between this node | ||
22 | and local node | ||
23 | - The 1394 bus (i.e. "card") to which the node is attached to: | ||
24 | - Isochronous stream transmission and reception | ||
25 | - Asynchronous stream transmission and reception | ||
26 | - Asynchronous broadcast request transmission | ||
27 | - PHY packet transmission and reception | ||
28 | - Allocate, reallocate, deallocate isochronous | ||
29 | resources (channels, bandwidth) at the bus's IRM | ||
30 | - Query node IDs of local node, root node, IRM, bus | ||
31 | manager | ||
32 | - Query cycle time | ||
33 | - Bus reset initiation, bus reset event reception | ||
34 | - All 1394 buses: | ||
35 | - Allocation of IEEE 1212 address ranges on the local | ||
36 | link layers, reception of inbound requests to such | ||
37 | an address range, asynchronous response transmission | ||
38 | to inbound requests | ||
39 | - Addition of descriptors or directories to the local | ||
40 | nodes' Configuration ROM | ||
41 | |||
42 | Due to the different scope of operations and in order to let | ||
43 | userland implement different access permission models, some | ||
44 | operations are restricted to /dev/fw* files that are associated | ||
45 | with a local node: | ||
46 | - Addition of descriptors or directories to the local | ||
47 | nodes' Configuration ROM | ||
48 | - PHY packet transmission and reception | ||
49 | |||
50 | A /dev/fw* file remains associated with one particular node | ||
51 | during its entire life time. Bus topology changes, and hence | ||
52 | node ID changes, are tracked by firewire-core. ABI users do not | ||
53 | need to be aware of topology. | ||
54 | |||
55 | The following file operations are supported: | ||
56 | |||
57 | open(2) | ||
58 | Currently the only useful flags are O_RDWR. | ||
59 | |||
60 | ioctl(2) | ||
61 | Initiate various actions. Some take immediate effect, others | ||
62 | are performed asynchronously while or after the ioctl returns. | ||
63 | See the inline documentation in <linux/firewire-cdev.h> for | ||
64 | descriptions of all ioctls. | ||
65 | |||
66 | poll(2), select(2), epoll_wait(2) etc. | ||
67 | Watch for events to become available to be read. | ||
68 | |||
69 | read(2) | ||
70 | Receive various events. There are solicited events like | ||
71 | outbound asynchronous transaction completion or isochronous | ||
72 | buffer completion, and unsolicited events such as bus resets, | ||
73 | request reception, or PHY packet reception. Always use a read | ||
74 | buffer which is large enough to receive the largest event that | ||
75 | could ever arrive. See <linux/firewire-cdev.h> for descriptions | ||
76 | of all event types and for which ioctls affect reception of | ||
77 | events. | ||
78 | |||
79 | mmap(2) | ||
80 | Allocate a DMA buffer for isochronous reception or transmission | ||
81 | and map it into the process address space. The arguments should | ||
82 | be used as follows: addr = NULL, length = the desired buffer | ||
83 | size, i.e. number of packets times size of largest packet, | ||
84 | prot = at least PROT_READ for reception and at least PROT_WRITE | ||
85 | for transmission, flags = MAP_SHARED, fd = the handle to the | ||
86 | /dev/fw*, offset = 0. | ||
87 | |||
88 | Isochronous reception works in packet-per-buffer fashion except | ||
89 | for multichannel reception which works in buffer-fill mode. | ||
90 | |||
91 | munmap(2) | ||
92 | Unmap the isochronous I/O buffer from the process address space. | ||
93 | |||
94 | close(2) | ||
95 | Besides stopping and freeing I/O contexts that were associated | ||
96 | with the file descriptor, back out any changes to the local | ||
97 | nodes' Configuration ROM. Deallocate isochronous channels and | ||
98 | bandwidth at the IRM that were marked for kernel-assisted | ||
99 | re- and deallocation. | ||
100 | |||
101 | Users: libraw1394 | ||
102 | libdc1394 | ||
103 | tools like jujuutils, fwhack, ... | ||
diff --git a/Documentation/ABI/stable/sysfs-bus-firewire b/Documentation/ABI/stable/sysfs-bus-firewire new file mode 100644 index 000000000000..3d484e5dc846 --- /dev/null +++ b/Documentation/ABI/stable/sysfs-bus-firewire | |||
@@ -0,0 +1,122 @@ | |||
1 | What: /sys/bus/firewire/devices/fw[0-9]+/ | ||
2 | Date: May 2007 | ||
3 | KernelVersion: 2.6.22 | ||
4 | Contact: linux1394-devel@lists.sourceforge.net | ||
5 | Description: | ||
6 | IEEE 1394 node device attributes. | ||
7 | Read-only. Mutable during the node device's lifetime. | ||
8 | See IEEE 1212 for semantic definitions. | ||
9 | |||
10 | config_rom | ||
11 | Contents of the Configuration ROM register. | ||
12 | Binary attribute; an array of host-endian u32. | ||
13 | |||
14 | guid | ||
15 | The node's EUI-64 in the bus information block of | ||
16 | Configuration ROM. | ||
17 | Hexadecimal string representation of an u64. | ||
18 | |||
19 | |||
20 | What: /sys/bus/firewire/devices/fw[0-9]+/units | ||
21 | Date: June 2009 | ||
22 | KernelVersion: 2.6.31 | ||
23 | Contact: linux1394-devel@lists.sourceforge.net | ||
24 | Description: | ||
25 | IEEE 1394 node device attribute. | ||
26 | Read-only. Mutable during the node device's lifetime. | ||
27 | See IEEE 1212 for semantic definitions. | ||
28 | |||
29 | units | ||
30 | Summary of all units present in an IEEE 1394 node. | ||
31 | Contains space-separated tuples of specifier_id and | ||
32 | version of each unit present in the node. Specifier_id | ||
33 | and version are hexadecimal string representations of | ||
34 | u24 of the respective unit directory entries. | ||
35 | Specifier_id and version within each tuple are separated | ||
36 | by a colon. | ||
37 | |||
38 | Users: udev rules to set ownership and access permissions or ACLs of | ||
39 | /dev/fw[0-9]+ character device files | ||
40 | |||
41 | |||
42 | What: /sys/bus/firewire/devices/fw[0-9]+[.][0-9]+/ | ||
43 | Date: May 2007 | ||
44 | KernelVersion: 2.6.22 | ||
45 | Contact: linux1394-devel@lists.sourceforge.net | ||
46 | Description: | ||
47 | IEEE 1394 unit device attributes. | ||
48 | Read-only. Immutable during the unit device's lifetime. | ||
49 | See IEEE 1212 for semantic definitions. | ||
50 | |||
51 | modalias | ||
52 | Same as MODALIAS in the uevent at device creation. | ||
53 | |||
54 | rom_index | ||
55 | Offset of the unit directory within the parent device's | ||
56 | (node device's) Configuration ROM, in quadlets. | ||
57 | Decimal string representation. | ||
58 | |||
59 | |||
60 | What: /sys/bus/firewire/devices/*/ | ||
61 | Date: May 2007 | ||
62 | KernelVersion: 2.6.22 | ||
63 | Contact: linux1394-devel@lists.sourceforge.net | ||
64 | Description: | ||
65 | Attributes common to IEEE 1394 node devices and unit devices. | ||
66 | Read-only. Mutable during the node device's lifetime. | ||
67 | Immutable during the unit device's lifetime. | ||
68 | See IEEE 1212 for semantic definitions. | ||
69 | |||
70 | These attributes are only created if the root directory of an | ||
71 | IEEE 1394 node or the unit directory of an IEEE 1394 unit | ||
72 | actually contains according entries. | ||
73 | |||
74 | hardware_version | ||
75 | Hexadecimal string representation of an u24. | ||
76 | |||
77 | hardware_version_name | ||
78 | Contents of a respective textual descriptor leaf. | ||
79 | |||
80 | model | ||
81 | Hexadecimal string representation of an u24. | ||
82 | |||
83 | model_name | ||
84 | Contents of a respective textual descriptor leaf. | ||
85 | |||
86 | specifier_id | ||
87 | Hexadecimal string representation of an u24. | ||
88 | Mandatory in unit directories according to IEEE 1212. | ||
89 | |||
90 | vendor | ||
91 | Hexadecimal string representation of an u24. | ||
92 | Mandatory in the root directory according to IEEE 1212. | ||
93 | |||
94 | vendor_name | ||
95 | Contents of a respective textual descriptor leaf. | ||
96 | |||
97 | version | ||
98 | Hexadecimal string representation of an u24. | ||
99 | Mandatory in unit directories according to IEEE 1212. | ||
100 | |||
101 | |||
102 | What: /sys/bus/firewire/drivers/sbp2/fw*/host*/target*/*:*:*:*/ieee1394_id | ||
103 | formerly | ||
104 | /sys/bus/ieee1394/drivers/sbp2/fw*/host*/target*/*:*:*:*/ieee1394_id | ||
105 | Date: Feb 2004 | ||
106 | KernelVersion: 2.6.4 | ||
107 | Contact: linux1394-devel@lists.sourceforge.net | ||
108 | Description: | ||
109 | SCSI target port identifier and logical unit identifier of a | ||
110 | logical unit of an SBP-2 target. The identifiers are specified | ||
111 | in SAM-2...SAM-4 annex A. They are persistent and world-wide | ||
112 | unique properties the SBP-2 attached target. | ||
113 | |||
114 | Read-only attribute, immutable during the target's lifetime. | ||
115 | Format, as exposed by firewire-sbp2 since 2.6.22, May 2007: | ||
116 | Colon-separated hexadecimal string representations of | ||
117 | u64 EUI-64 : u24 directory_ID : u16 LUN | ||
118 | without 0x prefixes, without whitespace. The former sbp2 driver | ||
119 | (removed in 2.6.37 after being superseded by firewire-sbp2) used | ||
120 | a somewhat shorter format which was not as close to SAM. | ||
121 | |||
122 | Users: udev rules to create /dev/disk/by-id/ symlinks | ||
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index b1c11775839c..e6ad3bb6c1a6 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -253,14 +253,11 @@ static int fw_device_op_open(struct inode *inode, struct file *file) | |||
253 | init_waitqueue_head(&client->wait); | 253 | init_waitqueue_head(&client->wait); |
254 | init_waitqueue_head(&client->tx_flush_wait); | 254 | init_waitqueue_head(&client->tx_flush_wait); |
255 | INIT_LIST_HEAD(&client->phy_receiver_link); | 255 | INIT_LIST_HEAD(&client->phy_receiver_link); |
256 | INIT_LIST_HEAD(&client->link); | ||
256 | kref_init(&client->kref); | 257 | kref_init(&client->kref); |
257 | 258 | ||
258 | file->private_data = client; | 259 | file->private_data = client; |
259 | 260 | ||
260 | mutex_lock(&device->client_list_mutex); | ||
261 | list_add_tail(&client->link, &device->client_list); | ||
262 | mutex_unlock(&device->client_list_mutex); | ||
263 | |||
264 | return nonseekable_open(inode, file); | 261 | return nonseekable_open(inode, file); |
265 | } | 262 | } |
266 | 263 | ||
@@ -451,15 +448,20 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg) | |||
451 | if (ret != 0) | 448 | if (ret != 0) |
452 | return -EFAULT; | 449 | return -EFAULT; |
453 | 450 | ||
451 | mutex_lock(&client->device->client_list_mutex); | ||
452 | |||
454 | client->bus_reset_closure = a->bus_reset_closure; | 453 | client->bus_reset_closure = a->bus_reset_closure; |
455 | if (a->bus_reset != 0) { | 454 | if (a->bus_reset != 0) { |
456 | fill_bus_reset_event(&bus_reset, client); | 455 | fill_bus_reset_event(&bus_reset, client); |
457 | if (copy_to_user(u64_to_uptr(a->bus_reset), | 456 | ret = copy_to_user(u64_to_uptr(a->bus_reset), |
458 | &bus_reset, sizeof(bus_reset))) | 457 | &bus_reset, sizeof(bus_reset)); |
459 | return -EFAULT; | ||
460 | } | 458 | } |
459 | if (ret == 0 && list_empty(&client->link)) | ||
460 | list_add_tail(&client->link, &client->device->client_list); | ||
461 | 461 | ||
462 | return 0; | 462 | mutex_unlock(&client->device->client_list_mutex); |
463 | |||
464 | return ret ? -EFAULT : 0; | ||
463 | } | 465 | } |
464 | 466 | ||
465 | static int add_client_resource(struct client *client, | 467 | static int add_client_resource(struct client *client, |
@@ -1583,7 +1585,7 @@ static int dispatch_ioctl(struct client *client, | |||
1583 | if (_IOC_TYPE(cmd) != '#' || | 1585 | if (_IOC_TYPE(cmd) != '#' || |
1584 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || | 1586 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || |
1585 | _IOC_SIZE(cmd) > sizeof(buffer)) | 1587 | _IOC_SIZE(cmd) > sizeof(buffer)) |
1586 | return -EINVAL; | 1588 | return -ENOTTY; |
1587 | 1589 | ||
1588 | if (_IOC_DIR(cmd) == _IOC_READ) | 1590 | if (_IOC_DIR(cmd) == _IOC_READ) |
1589 | memset(&buffer, 0, _IOC_SIZE(cmd)); | 1591 | memset(&buffer, 0, _IOC_SIZE(cmd)); |
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index eced1c25bf58..03a7a85d0424 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/bug.h> | 9 | #include <linux/bug.h> |
10 | #include <linux/compiler.h> | ||
10 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
11 | #include <linux/device.h> | 12 | #include <linux/device.h> |
12 | #include <linux/ethtool.h> | 13 | #include <linux/ethtool.h> |
@@ -73,7 +74,7 @@ struct rfc2734_arp { | |||
73 | __be32 fifo_lo; /* lo 32bits of sender's FIFO addr */ | 74 | __be32 fifo_lo; /* lo 32bits of sender's FIFO addr */ |
74 | __be32 sip; /* Sender's IP Address */ | 75 | __be32 sip; /* Sender's IP Address */ |
75 | __be32 tip; /* IP Address of requested hw addr */ | 76 | __be32 tip; /* IP Address of requested hw addr */ |
76 | } __attribute__((packed)); | 77 | } __packed; |
77 | 78 | ||
78 | /* This header format is specific to this driver implementation. */ | 79 | /* This header format is specific to this driver implementation. */ |
79 | #define FWNET_ALEN 8 | 80 | #define FWNET_ALEN 8 |
@@ -81,7 +82,7 @@ struct rfc2734_arp { | |||
81 | struct fwnet_header { | 82 | struct fwnet_header { |
82 | u8 h_dest[FWNET_ALEN]; /* destination address */ | 83 | u8 h_dest[FWNET_ALEN]; /* destination address */ |
83 | __be16 h_proto; /* packet type ID field */ | 84 | __be16 h_proto; /* packet type ID field */ |
84 | } __attribute__((packed)); | 85 | } __packed; |
85 | 86 | ||
86 | /* IPv4 and IPv6 encapsulation header */ | 87 | /* IPv4 and IPv6 encapsulation header */ |
87 | struct rfc2734_header { | 88 | struct rfc2734_header { |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index ebb897329c1e..bcf792fac442 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -253,7 +253,6 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card) | |||
253 | #define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 | 253 | #define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 |
254 | 254 | ||
255 | #define OHCI1394_REGISTER_SIZE 0x800 | 255 | #define OHCI1394_REGISTER_SIZE 0x800 |
256 | #define OHCI_LOOP_COUNT 500 | ||
257 | #define OHCI1394_PCI_HCI_Control 0x40 | 256 | #define OHCI1394_PCI_HCI_Control 0x40 |
258 | #define SELF_ID_BUF_SIZE 0x800 | 257 | #define SELF_ID_BUF_SIZE 0x800 |
259 | #define OHCI_TCODE_PHY_PACKET 0x0e | 258 | #define OHCI_TCODE_PHY_PACKET 0x0e |
@@ -514,6 +513,12 @@ static inline void flush_writes(const struct fw_ohci *ohci) | |||
514 | reg_read(ohci, OHCI1394_Version); | 513 | reg_read(ohci, OHCI1394_Version); |
515 | } | 514 | } |
516 | 515 | ||
516 | /* | ||
517 | * Beware! read_phy_reg(), write_phy_reg(), update_phy_reg(), and | ||
518 | * read_paged_phy_reg() require the caller to hold ohci->phy_reg_mutex. | ||
519 | * In other words, only use ohci_read_phy_reg() and ohci_update_phy_reg() | ||
520 | * directly. Exceptions are intrinsically serialized contexts like pci_probe. | ||
521 | */ | ||
517 | static int read_phy_reg(struct fw_ohci *ohci, int addr) | 522 | static int read_phy_reg(struct fw_ohci *ohci, int addr) |
518 | { | 523 | { |
519 | u32 val; | 524 | u32 val; |
@@ -522,6 +527,9 @@ static int read_phy_reg(struct fw_ohci *ohci, int addr) | |||
522 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); | 527 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); |
523 | for (i = 0; i < 3 + 100; i++) { | 528 | for (i = 0; i < 3 + 100; i++) { |
524 | val = reg_read(ohci, OHCI1394_PhyControl); | 529 | val = reg_read(ohci, OHCI1394_PhyControl); |
530 | if (!~val) | ||
531 | return -ENODEV; /* Card was ejected. */ | ||
532 | |||
525 | if (val & OHCI1394_PhyControl_ReadDone) | 533 | if (val & OHCI1394_PhyControl_ReadDone) |
526 | return OHCI1394_PhyControl_ReadData(val); | 534 | return OHCI1394_PhyControl_ReadData(val); |
527 | 535 | ||
@@ -545,6 +553,9 @@ static int write_phy_reg(const struct fw_ohci *ohci, int addr, u32 val) | |||
545 | OHCI1394_PhyControl_Write(addr, val)); | 553 | OHCI1394_PhyControl_Write(addr, val)); |
546 | for (i = 0; i < 3 + 100; i++) { | 554 | for (i = 0; i < 3 + 100; i++) { |
547 | val = reg_read(ohci, OHCI1394_PhyControl); | 555 | val = reg_read(ohci, OHCI1394_PhyControl); |
556 | if (!~val) | ||
557 | return -ENODEV; /* Card was ejected. */ | ||
558 | |||
548 | if (!(val & OHCI1394_PhyControl_WritePending)) | 559 | if (!(val & OHCI1394_PhyControl_WritePending)) |
549 | return 0; | 560 | return 0; |
550 | 561 | ||
@@ -630,7 +641,6 @@ static void ar_context_link_page(struct ar_context *ctx, unsigned int index) | |||
630 | ctx->last_buffer_index = index; | 641 | ctx->last_buffer_index = index; |
631 | 642 | ||
632 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); | 643 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); |
633 | flush_writes(ctx->ohci); | ||
634 | } | 644 | } |
635 | 645 | ||
636 | static void ar_context_release(struct ar_context *ctx) | 646 | static void ar_context_release(struct ar_context *ctx) |
@@ -1002,7 +1012,6 @@ static void ar_context_run(struct ar_context *ctx) | |||
1002 | 1012 | ||
1003 | reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ctx->descriptors_bus | 1); | 1013 | reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ctx->descriptors_bus | 1); |
1004 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN); | 1014 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN); |
1005 | flush_writes(ctx->ohci); | ||
1006 | } | 1015 | } |
1007 | 1016 | ||
1008 | static struct descriptor *find_branch_descriptor(struct descriptor *d, int z) | 1017 | static struct descriptor *find_branch_descriptor(struct descriptor *d, int z) |
@@ -1202,14 +1211,14 @@ static void context_stop(struct context *ctx) | |||
1202 | 1211 | ||
1203 | reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN); | 1212 | reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN); |
1204 | ctx->running = false; | 1213 | ctx->running = false; |
1205 | flush_writes(ctx->ohci); | ||
1206 | 1214 | ||
1207 | for (i = 0; i < 10; i++) { | 1215 | for (i = 0; i < 1000; i++) { |
1208 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); | 1216 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); |
1209 | if ((reg & CONTEXT_ACTIVE) == 0) | 1217 | if ((reg & CONTEXT_ACTIVE) == 0) |
1210 | return; | 1218 | return; |
1211 | 1219 | ||
1212 | mdelay(1); | 1220 | if (i) |
1221 | udelay(10); | ||
1213 | } | 1222 | } |
1214 | fw_error("Error: DMA context still active (0x%08x)\n", reg); | 1223 | fw_error("Error: DMA context still active (0x%08x)\n", reg); |
1215 | } | 1224 | } |
@@ -1346,12 +1355,10 @@ static int at_context_queue_packet(struct context *ctx, | |||
1346 | 1355 | ||
1347 | context_append(ctx, d, z, 4 - z); | 1356 | context_append(ctx, d, z, 4 - z); |
1348 | 1357 | ||
1349 | if (ctx->running) { | 1358 | if (ctx->running) |
1350 | reg_write(ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); | 1359 | reg_write(ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); |
1351 | flush_writes(ohci); | 1360 | else |
1352 | } else { | ||
1353 | context_run(ctx, 0); | 1361 | context_run(ctx, 0); |
1354 | } | ||
1355 | 1362 | ||
1356 | return 0; | 1363 | return 0; |
1357 | } | 1364 | } |
@@ -1960,14 +1967,18 @@ static irqreturn_t irq_handler(int irq, void *data) | |||
1960 | 1967 | ||
1961 | static int software_reset(struct fw_ohci *ohci) | 1968 | static int software_reset(struct fw_ohci *ohci) |
1962 | { | 1969 | { |
1970 | u32 val; | ||
1963 | int i; | 1971 | int i; |
1964 | 1972 | ||
1965 | reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); | 1973 | reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); |
1974 | for (i = 0; i < 500; i++) { | ||
1975 | val = reg_read(ohci, OHCI1394_HCControlSet); | ||
1976 | if (!~val) | ||
1977 | return -ENODEV; /* Card was ejected. */ | ||
1966 | 1978 | ||
1967 | for (i = 0; i < OHCI_LOOP_COUNT; i++) { | 1979 | if (!(val & OHCI1394_HCControl_softReset)) |
1968 | if ((reg_read(ohci, OHCI1394_HCControlSet) & | ||
1969 | OHCI1394_HCControl_softReset) == 0) | ||
1970 | return 0; | 1980 | return 0; |
1981 | |||
1971 | msleep(1); | 1982 | msleep(1); |
1972 | } | 1983 | } |
1973 | 1984 | ||
@@ -2197,7 +2208,9 @@ static int ohci_enable(struct fw_card *card, | |||
2197 | OHCI1394_LinkControl_rcvPhyPkt); | 2208 | OHCI1394_LinkControl_rcvPhyPkt); |
2198 | 2209 | ||
2199 | ar_context_run(&ohci->ar_request_ctx); | 2210 | ar_context_run(&ohci->ar_request_ctx); |
2200 | ar_context_run(&ohci->ar_response_ctx); /* also flushes writes */ | 2211 | ar_context_run(&ohci->ar_response_ctx); |
2212 | |||
2213 | flush_writes(ohci); | ||
2201 | 2214 | ||
2202 | /* We are ready to go, reset bus to finish initialization. */ | 2215 | /* We are ready to go, reset bus to finish initialization. */ |
2203 | fw_schedule_bus_reset(&ohci->card, false, true); | 2216 | fw_schedule_bus_reset(&ohci->card, false, true); |
@@ -3129,7 +3142,6 @@ static void ohci_flush_queue_iso(struct fw_iso_context *base) | |||
3129 | &container_of(base, struct iso_context, base)->context; | 3142 | &container_of(base, struct iso_context, base)->context; |
3130 | 3143 | ||
3131 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); | 3144 | reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_WAKE); |
3132 | flush_writes(ctx->ohci); | ||
3133 | } | 3145 | } |
3134 | 3146 | ||
3135 | static const struct fw_card_driver ohci_driver = { | 3147 | static const struct fw_card_driver ohci_driver = { |
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h index 4ff09889c5c0..357dbfc2829e 100644 --- a/include/linux/firewire-cdev.h +++ b/include/linux/firewire-cdev.h | |||
@@ -30,10 +30,13 @@ | |||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/firewire-constants.h> | 31 | #include <linux/firewire-constants.h> |
32 | 32 | ||
33 | /* available since kernel version 2.6.22 */ | ||
33 | #define FW_CDEV_EVENT_BUS_RESET 0x00 | 34 | #define FW_CDEV_EVENT_BUS_RESET 0x00 |
34 | #define FW_CDEV_EVENT_RESPONSE 0x01 | 35 | #define FW_CDEV_EVENT_RESPONSE 0x01 |
35 | #define FW_CDEV_EVENT_REQUEST 0x02 | 36 | #define FW_CDEV_EVENT_REQUEST 0x02 |
36 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 | 37 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 |
38 | |||
39 | /* available since kernel version 2.6.30 */ | ||
37 | #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 | 40 | #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 |
38 | #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 | 41 | #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 |
39 | 42 | ||
@@ -120,24 +123,11 @@ struct fw_cdev_event_response { | |||
120 | 123 | ||
121 | /** | 124 | /** |
122 | * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 | 125 | * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 |
123 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl | ||
124 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST | 126 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST |
125 | * @tcode: See &fw_cdev_event_request2 | ||
126 | * @offset: See &fw_cdev_event_request2 | ||
127 | * @handle: See &fw_cdev_event_request2 | ||
128 | * @length: See &fw_cdev_event_request2 | ||
129 | * @data: See &fw_cdev_event_request2 | ||
130 | * | 127 | * |
131 | * This event is sent instead of &fw_cdev_event_request2 if the kernel or | 128 | * This event is sent instead of &fw_cdev_event_request2 if the kernel or |
132 | * the client implements ABI version <= 3. | 129 | * the client implements ABI version <= 3. &fw_cdev_event_request lacks |
133 | * | 130 | * essential information; use &fw_cdev_event_request2 instead. |
134 | * Unlike &fw_cdev_event_request2, the sender identity cannot be established, | ||
135 | * broadcast write requests cannot be distinguished from unicast writes, and | ||
136 | * @tcode of lock requests is %TCODE_LOCK_REQUEST. | ||
137 | * | ||
138 | * Requests to the FCP_REQUEST or FCP_RESPONSE register are responded to as | ||
139 | * with &fw_cdev_event_request2, except in kernel 2.6.32 and older which send | ||
140 | * the response packet of the client's %FW_CDEV_IOC_SEND_RESPONSE ioctl. | ||
141 | */ | 131 | */ |
142 | struct fw_cdev_event_request { | 132 | struct fw_cdev_event_request { |
143 | __u64 closure; | 133 | __u64 closure; |
@@ -452,29 +442,31 @@ union fw_cdev_event { | |||
452 | * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and | 442 | * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and |
453 | * %FW_CDEV_IOC_SET_ISO_CHANNELS | 443 | * %FW_CDEV_IOC_SET_ISO_CHANNELS |
454 | */ | 444 | */ |
455 | #define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ | ||
456 | 445 | ||
457 | /** | 446 | /** |
458 | * struct fw_cdev_get_info - General purpose information ioctl | 447 | * struct fw_cdev_get_info - General purpose information ioctl |
459 | * @version: The version field is just a running serial number. Both an | 448 | * @version: The version field is just a running serial number. Both an |
460 | * input parameter (ABI version implemented by the client) and | 449 | * input parameter (ABI version implemented by the client) and |
461 | * output parameter (ABI version implemented by the kernel). | 450 | * output parameter (ABI version implemented by the kernel). |
462 | * A client must not fill in an %FW_CDEV_VERSION defined from an | 451 | * A client shall fill in the ABI @version for which the client |
463 | * included kernel header file but the actual version for which | 452 | * was implemented. This is necessary for forward compatibility. |
464 | * the client was implemented. This is necessary for forward | 453 | * @rom_length: If @rom is non-zero, up to @rom_length bytes of Configuration |
465 | * compatibility. We never break backwards compatibility, but | ||
466 | * may add more structs, events, and ioctls in later revisions. | ||
467 | * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration | ||
468 | * ROM will be copied into that user space address. In either | 454 | * ROM will be copied into that user space address. In either |
469 | * case, @rom_length is updated with the actual length of the | 455 | * case, @rom_length is updated with the actual length of the |
470 | * configuration ROM. | 456 | * Configuration ROM. |
471 | * @rom: If non-zero, address of a buffer to be filled by a copy of the | 457 | * @rom: If non-zero, address of a buffer to be filled by a copy of the |
472 | * device's configuration ROM | 458 | * device's Configuration ROM |
473 | * @bus_reset: If non-zero, address of a buffer to be filled by a | 459 | * @bus_reset: If non-zero, address of a buffer to be filled by a |
474 | * &struct fw_cdev_event_bus_reset with the current state | 460 | * &struct fw_cdev_event_bus_reset with the current state |
475 | * of the bus. This does not cause a bus reset to happen. | 461 | * of the bus. This does not cause a bus reset to happen. |
476 | * @bus_reset_closure: Value of &closure in this and subsequent bus reset events | 462 | * @bus_reset_closure: Value of &closure in this and subsequent bus reset events |
477 | * @card: The index of the card this device belongs to | 463 | * @card: The index of the card this device belongs to |
464 | * | ||
465 | * The %FW_CDEV_IOC_GET_INFO ioctl is usually the very first one which a client | ||
466 | * performs right after it opened a /dev/fw* file. | ||
467 | * | ||
468 | * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2) | ||
469 | * is started by this ioctl. | ||
478 | */ | 470 | */ |
479 | struct fw_cdev_get_info { | 471 | struct fw_cdev_get_info { |
480 | __u32 version; | 472 | __u32 version; |
@@ -612,7 +604,7 @@ struct fw_cdev_initiate_bus_reset { | |||
612 | * @handle: Handle to the descriptor, written by the kernel | 604 | * @handle: Handle to the descriptor, written by the kernel |
613 | * | 605 | * |
614 | * Add a descriptor block and optionally a preceding immediate key to the local | 606 | * Add a descriptor block and optionally a preceding immediate key to the local |
615 | * node's configuration ROM. | 607 | * node's Configuration ROM. |
616 | * | 608 | * |
617 | * The @key field specifies the upper 8 bits of the descriptor root directory | 609 | * The @key field specifies the upper 8 bits of the descriptor root directory |
618 | * pointer and the @data and @length fields specify the contents. The @key | 610 | * pointer and the @data and @length fields specify the contents. The @key |
@@ -627,9 +619,9 @@ struct fw_cdev_initiate_bus_reset { | |||
627 | * If successful, the kernel adds the descriptor and writes back a @handle to | 619 | * If successful, the kernel adds the descriptor and writes back a @handle to |
628 | * the kernel-side object to be used for later removal of the descriptor block | 620 | * the kernel-side object to be used for later removal of the descriptor block |
629 | * and immediate key. The kernel will also generate a bus reset to signal the | 621 | * and immediate key. The kernel will also generate a bus reset to signal the |
630 | * change of the configuration ROM to other nodes. | 622 | * change of the Configuration ROM to other nodes. |
631 | * | 623 | * |
632 | * This ioctl affects the configuration ROMs of all local nodes. | 624 | * This ioctl affects the Configuration ROMs of all local nodes. |
633 | * The ioctl only succeeds on device files which represent a local node. | 625 | * The ioctl only succeeds on device files which represent a local node. |
634 | */ | 626 | */ |
635 | struct fw_cdev_add_descriptor { | 627 | struct fw_cdev_add_descriptor { |
@@ -641,13 +633,13 @@ struct fw_cdev_add_descriptor { | |||
641 | }; | 633 | }; |
642 | 634 | ||
643 | /** | 635 | /** |
644 | * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM | 636 | * struct fw_cdev_remove_descriptor - Remove contents from the Configuration ROM |
645 | * @handle: Handle to the descriptor, as returned by the kernel when the | 637 | * @handle: Handle to the descriptor, as returned by the kernel when the |
646 | * descriptor was added | 638 | * descriptor was added |
647 | * | 639 | * |
648 | * Remove a descriptor block and accompanying immediate key from the local | 640 | * Remove a descriptor block and accompanying immediate key from the local |
649 | * nodes' configuration ROMs. The kernel will also generate a bus reset to | 641 | * nodes' Configuration ROMs. The kernel will also generate a bus reset to |
650 | * signal the change of the configuration ROM to other nodes. | 642 | * signal the change of the Configuration ROM to other nodes. |
651 | */ | 643 | */ |
652 | struct fw_cdev_remove_descriptor { | 644 | struct fw_cdev_remove_descriptor { |
653 | __u32 handle; | 645 | __u32 handle; |
@@ -863,13 +855,8 @@ struct fw_cdev_stop_iso { | |||
863 | * @local_time: system time, in microseconds since the Epoch | 855 | * @local_time: system time, in microseconds since the Epoch |
864 | * @cycle_timer: Cycle Time register contents | 856 | * @cycle_timer: Cycle Time register contents |
865 | * | 857 | * |
866 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer | 858 | * Same as %FW_CDEV_IOC_GET_CYCLE_TIMER2, but fixed to use %CLOCK_REALTIME |
867 | * and also the system clock (%CLOCK_REALTIME). This allows to express the | 859 | * and only with microseconds resolution. |
868 | * receive time of an isochronous packet as a system time. | ||
869 | * | ||
870 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and | ||
871 | * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register | ||
872 | * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. | ||
873 | * | 860 | * |
874 | * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- | 861 | * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- |
875 | * monotonic) @cycle_timer values on certain controllers. | 862 | * monotonic) @cycle_timer values on certain controllers. |
@@ -886,10 +873,17 @@ struct fw_cdev_get_cycle_timer { | |||
886 | * @clk_id: input parameter, clock from which to get the system time | 873 | * @clk_id: input parameter, clock from which to get the system time |
887 | * @cycle_timer: Cycle Time register contents | 874 | * @cycle_timer: Cycle Time register contents |
888 | * | 875 | * |
889 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 works like | 876 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 ioctl reads the isochronous cycle timer |
890 | * %FW_CDEV_IOC_GET_CYCLE_TIMER but lets you choose a clock like with POSIX' | 877 | * and also the system clock. This allows to correlate reception time of |
891 | * clock_gettime function. Supported @clk_id values are POSIX' %CLOCK_REALTIME | 878 | * isochronous packets with system time. |
892 | * and %CLOCK_MONOTONIC and Linux' %CLOCK_MONOTONIC_RAW. | 879 | * |
880 | * @clk_id lets you choose a clock like with POSIX' clock_gettime function. | ||
881 | * Supported @clk_id values are POSIX' %CLOCK_REALTIME and %CLOCK_MONOTONIC | ||
882 | * and Linux' %CLOCK_MONOTONIC_RAW. | ||
883 | * | ||
884 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and | ||
885 | * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register | ||
886 | * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. | ||
893 | */ | 887 | */ |
894 | struct fw_cdev_get_cycle_timer2 { | 888 | struct fw_cdev_get_cycle_timer2 { |
895 | __s64 tv_sec; | 889 | __s64 tv_sec; |
@@ -1011,4 +1005,6 @@ struct fw_cdev_receive_phy_packets { | |||
1011 | __u64 closure; | 1005 | __u64 closure; |
1012 | }; | 1006 | }; |
1013 | 1007 | ||
1008 | #define FW_CDEV_VERSION 3 /* Meaningless legacy macro; don't use it. */ | ||
1009 | |||
1014 | #endif /* _LINUX_FIREWIRE_CDEV_H */ | 1010 | #endif /* _LINUX_FIREWIRE_CDEV_H */ |