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: fw-ohci: shut up false compiler warning on PPC32
firewire: fw-ohci: use dma_alloc_coherent for ar_buffer
ieee1394: sbp2: fix for SYM13FW500 bridge (Datafab disk)
firewire: fw-sbp2: fix for SYM13FW500 bridge (Datafab disk)
firewire: update Kconfig help text
firewire: warn on fatal condition in topology code
firewire: fw-sbp2: set single-phase retry_limit
firewire: fw-ohci: Apple UniNorth 1st generation support
firewire: fw-ohci: PPC PMac platform code
firewire: endianess annotations
firewire: endianess fix

+143 -67
+19 -31
drivers/firewire/Kconfig
··· 1 - # -*- shell-script -*- 2 - 3 1 comment "An alternative FireWire stack is available with EXPERIMENTAL=y" 4 2 depends on EXPERIMENTAL=n 5 3 ··· 19 21 NOTE: 20 22 21 23 You should only build ONE of the stacks, unless you REALLY know what 22 - you are doing. If you install both, you should configure them only as 23 - modules rather than link them statically, and you should blacklist one 24 - of the concurrent low-level drivers in /etc/modprobe.conf. Add either 25 - 26 - blacklist firewire-ohci 27 - or 28 - blacklist ohci1394 29 - 30 - there depending on which driver you DON'T want to have auto-loaded. 31 - You can optionally do the same with the other IEEE 1394/ FireWire 32 - drivers. 33 - 34 - If you have an old modprobe which doesn't implement the blacklist 35 - directive, use either 36 - 37 - install firewire-ohci /bin/true 38 - or 39 - install ohci1394 /bin/true 40 - 41 - and so on, depending on which modules you DON't want to have 42 - auto-loaded. 24 + you are doing. 43 25 44 26 config FIREWIRE_OHCI 45 27 tristate "Support for OHCI FireWire host controllers" ··· 35 57 36 58 NOTE: 37 59 38 - If you also build ohci1394 of the classic stack, blacklist either 39 - ohci1394 or firewire-ohci to let hotplug load only the desired driver. 60 + You should only build ohci1394 or firewire-ohci, but not both. 61 + If you nevertheless want to install both, you should configure them 62 + only as modules and blacklist the driver(s) which you don't want to 63 + have auto-loaded. Add either 64 + 65 + blacklist firewire-ohci 66 + or 67 + blacklist ohci1394 68 + blacklist video1394 69 + blacklist dv1394 70 + 71 + to /etc/modprobe.conf or /etc/modprobe.d/* and update modprobe.conf 72 + depending on your distribution. The latter two modules should be 73 + blacklisted together with ohci1394 because they depend on ohci1394. 74 + 75 + If you have an old modprobe which doesn't implement the blacklist 76 + directive, use "install modulename /bin/true" for the modules to be 77 + blacklisted. 40 78 41 79 config FIREWIRE_SBP2 42 80 tristate "Support for storage devices (SBP-2 protocol driver)" ··· 69 75 70 76 You should also enable support for disks, CD-ROMs, etc. in the SCSI 71 77 configuration section. 72 - 73 - NOTE: 74 - 75 - If you also build sbp2 of the classic stack, blacklist either sbp2 76 - or firewire-sbp2 to let hotplug load only the desired driver. 77 -
+81 -27
drivers/firewire/fw-ohci.c
··· 33 33 #include <asm/page.h> 34 34 #include <asm/system.h> 35 35 36 + #ifdef CONFIG_PPC_PMAC 37 + #include <asm/pmac_feature.h> 38 + #endif 39 + 36 40 #include "fw-ohci.h" 37 41 #include "fw-transaction.h" 38 42 ··· 179 175 int generation; 180 176 int request_generation; 181 177 u32 bus_seconds; 178 + bool old_uninorth; 182 179 183 180 /* 184 181 * Spinlock for accessing fw_ohci data. Never call out of ··· 281 276 { 282 277 struct device *dev = ctx->ohci->card.device; 283 278 struct ar_buffer *ab; 284 - dma_addr_t ab_bus; 279 + dma_addr_t uninitialized_var(ab_bus); 285 280 size_t offset; 286 281 287 - ab = (struct ar_buffer *) __get_free_page(GFP_ATOMIC); 282 + ab = dma_alloc_coherent(dev, PAGE_SIZE, &ab_bus, GFP_ATOMIC); 288 283 if (ab == NULL) 289 284 return -ENOMEM; 290 - 291 - ab_bus = dma_map_single(dev, ab, PAGE_SIZE, DMA_BIDIRECTIONAL); 292 - if (dma_mapping_error(ab_bus)) { 293 - free_page((unsigned long) ab); 294 - return -ENOMEM; 295 - } 296 285 297 286 memset(&ab->descriptor, 0, sizeof(ab->descriptor)); 298 287 ab->descriptor.control = cpu_to_le16(DESCRIPTOR_INPUT_MORE | ··· 298 299 ab->descriptor.res_count = cpu_to_le16(PAGE_SIZE - offset); 299 300 ab->descriptor.branch_address = 0; 300 301 301 - dma_sync_single_for_device(dev, ab_bus, PAGE_SIZE, DMA_BIDIRECTIONAL); 302 - 303 302 ctx->last_buffer->descriptor.branch_address = cpu_to_le32(ab_bus | 1); 304 303 ctx->last_buffer->next = ab; 305 304 ctx->last_buffer = ab; ··· 308 311 return 0; 309 312 } 310 313 314 + #if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) 315 + #define cond_le32_to_cpu(v) \ 316 + (ohci->old_uninorth ? (__force __u32)(v) : le32_to_cpu(v)) 317 + #else 318 + #define cond_le32_to_cpu(v) le32_to_cpu(v) 319 + #endif 320 + 311 321 static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer) 312 322 { 313 323 struct fw_ohci *ohci = ctx->ohci; 314 324 struct fw_packet p; 315 325 u32 status, length, tcode; 316 326 317 - p.header[0] = le32_to_cpu(buffer[0]); 318 - p.header[1] = le32_to_cpu(buffer[1]); 319 - p.header[2] = le32_to_cpu(buffer[2]); 327 + p.header[0] = cond_le32_to_cpu(buffer[0]); 328 + p.header[1] = cond_le32_to_cpu(buffer[1]); 329 + p.header[2] = cond_le32_to_cpu(buffer[2]); 320 330 321 331 tcode = (p.header[0] >> 4) & 0x0f; 322 332 switch (tcode) { ··· 335 331 break; 336 332 337 333 case TCODE_READ_BLOCK_REQUEST : 338 - p.header[3] = le32_to_cpu(buffer[3]); 334 + p.header[3] = cond_le32_to_cpu(buffer[3]); 339 335 p.header_length = 16; 340 336 p.payload_length = 0; 341 337 break; ··· 344 340 case TCODE_READ_BLOCK_RESPONSE: 345 341 case TCODE_LOCK_REQUEST: 346 342 case TCODE_LOCK_RESPONSE: 347 - p.header[3] = le32_to_cpu(buffer[3]); 343 + p.header[3] = cond_le32_to_cpu(buffer[3]); 348 344 p.header_length = 16; 349 345 p.payload_length = p.header[3] >> 16; 350 346 break; ··· 361 357 362 358 /* FIXME: What to do about evt_* errors? */ 363 359 length = (p.header_length + p.payload_length + 3) / 4; 364 - status = le32_to_cpu(buffer[length]); 360 + status = cond_le32_to_cpu(buffer[length]); 365 361 366 362 p.ack = ((status >> 16) & 0x1f) - 16; 367 363 p.speed = (status >> 21) & 0x7; ··· 379 375 */ 380 376 381 377 if (p.ack + 16 == 0x09) 382 - ohci->request_generation = (buffer[2] >> 16) & 0xff; 378 + ohci->request_generation = (p.header[2] >> 16) & 0xff; 383 379 else if (ctx == &ohci->ar_request_ctx) 384 380 fw_core_handle_request(&ohci->card, &p); 385 381 else ··· 401 397 402 398 if (d->res_count == 0) { 403 399 size_t size, rest, offset; 400 + dma_addr_t buffer_bus; 404 401 405 402 /* 406 403 * This descriptor is finished and we may have a ··· 410 405 */ 411 406 412 407 offset = offsetof(struct ar_buffer, data); 413 - dma_unmap_single(ohci->card.device, 414 - le32_to_cpu(ab->descriptor.data_address) - offset, 415 - PAGE_SIZE, DMA_BIDIRECTIONAL); 408 + buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset; 416 409 417 410 buffer = ab; 418 411 ab = ab->next; ··· 426 423 while (buffer < end) 427 424 buffer = handle_ar_packet(ctx, buffer); 428 425 429 - free_page((unsigned long)buffer); 426 + dma_free_coherent(ohci->card.device, PAGE_SIZE, 427 + buffer, buffer_bus); 430 428 ar_context_add_page(ctx); 431 429 } else { 432 430 buffer = ctx->pointer; ··· 536 532 context_add_buffer(struct context *ctx) 537 533 { 538 534 struct descriptor_buffer *desc; 539 - dma_addr_t bus_addr; 535 + dma_addr_t uninitialized_var(bus_addr); 540 536 int offset; 541 537 542 538 /* ··· 1026 1022 */ 1027 1023 1028 1024 self_id_count = (reg_read(ohci, OHCI1394_SelfIDCount) >> 3) & 0x3ff; 1029 - generation = (le32_to_cpu(ohci->self_id_cpu[0]) >> 16) & 0xff; 1025 + generation = (cond_le32_to_cpu(ohci->self_id_cpu[0]) >> 16) & 0xff; 1030 1026 rmb(); 1031 1027 1032 1028 for (i = 1, j = 0; j < self_id_count; i += 2, j++) { 1033 1029 if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1]) 1034 1030 fw_error("inconsistent self IDs\n"); 1035 - ohci->self_id_buffer[j] = le32_to_cpu(ohci->self_id_cpu[i]); 1031 + ohci->self_id_buffer[j] = 1032 + cond_le32_to_cpu(ohci->self_id_cpu[i]); 1036 1033 } 1037 1034 rmb(); 1038 1035 ··· 1321 1316 unsigned long flags; 1322 1317 int retval = -EBUSY; 1323 1318 __be32 *next_config_rom; 1324 - dma_addr_t next_config_rom_bus; 1319 + dma_addr_t uninitialized_var(next_config_rom_bus); 1325 1320 1326 1321 ohci = fw_ohci(card); 1327 1322 ··· 1492 1487 void *p, *end; 1493 1488 int i; 1494 1489 1495 - if (db->first_res_count > 0 && db->second_res_count > 0) { 1490 + if (db->first_res_count != 0 && db->second_res_count != 0) { 1496 1491 if (ctx->excess_bytes <= le16_to_cpu(db->second_req_count)) { 1497 1492 /* This descriptor isn't done yet, stop iteration. */ 1498 1493 return 0; ··· 1518 1513 memcpy(ctx->header + i + 4, p + 8, ctx->base.header_size - 4); 1519 1514 i += ctx->base.header_size; 1520 1515 ctx->excess_bytes += 1521 - (le32_to_cpu(*(u32 *)(p + 4)) >> 16) & 0xffff; 1516 + (le32_to_cpu(*(__le32 *)(p + 4)) >> 16) & 0xffff; 1522 1517 p += ctx->base.header_size + 4; 1523 1518 } 1524 1519 ctx->header_length = i; ··· 2053 2048 int err; 2054 2049 size_t size; 2055 2050 2051 + #ifdef CONFIG_PPC_PMAC 2052 + /* Necessary on some machines if fw-ohci was loaded/ unloaded before */ 2053 + if (machine_is(powermac)) { 2054 + struct device_node *ofn = pci_device_to_OF_node(dev); 2055 + 2056 + if (ofn) { 2057 + pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 1); 2058 + pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1); 2059 + } 2060 + } 2061 + #endif /* CONFIG_PPC_PMAC */ 2062 + 2056 2063 ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); 2057 2064 if (ohci == NULL) { 2058 2065 fw_error("Could not malloc fw_ohci data.\n"); ··· 2083 2066 pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0); 2084 2067 pci_set_drvdata(dev, ohci); 2085 2068 2069 + #if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) 2070 + ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE && 2071 + dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW; 2072 + #endif 2086 2073 spin_lock_init(&ohci->lock); 2087 2074 2088 2075 tasklet_init(&ohci->bus_reset_tasklet, ··· 2203 2182 pci_disable_device(dev); 2204 2183 fw_card_put(&ohci->card); 2205 2184 2185 + #ifdef CONFIG_PPC_PMAC 2186 + /* On UniNorth, power down the cable and turn off the chip clock 2187 + * to save power on laptops */ 2188 + if (machine_is(powermac)) { 2189 + struct device_node *ofn = pci_device_to_OF_node(dev); 2190 + 2191 + if (ofn) { 2192 + pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0); 2193 + pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0); 2194 + } 2195 + } 2196 + #endif /* CONFIG_PPC_PMAC */ 2197 + 2206 2198 fw_notify("Removed fw-ohci device.\n"); 2207 2199 } 2208 2200 ··· 2236 2202 if (err) 2237 2203 fw_error("pci_set_power_state failed with %d\n", err); 2238 2204 2205 + /* PowerMac suspend code comes last */ 2206 + #ifdef CONFIG_PPC_PMAC 2207 + if (machine_is(powermac)) { 2208 + struct device_node *ofn = pci_device_to_OF_node(pdev); 2209 + 2210 + if (ofn) 2211 + pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0); 2212 + } 2213 + #endif /* CONFIG_PPC_PMAC */ 2214 + 2239 2215 return 0; 2240 2216 } 2241 2217 ··· 2253 2209 { 2254 2210 struct fw_ohci *ohci = pci_get_drvdata(pdev); 2255 2211 int err; 2212 + 2213 + /* PowerMac resume code comes first */ 2214 + #ifdef CONFIG_PPC_PMAC 2215 + if (machine_is(powermac)) { 2216 + struct device_node *ofn = pci_device_to_OF_node(pdev); 2217 + 2218 + if (ofn) 2219 + pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1); 2220 + } 2221 + #endif /* CONFIG_PPC_PMAC */ 2256 2222 2257 2223 pci_set_power_state(pdev, PCI_D0); 2258 2224 pci_restore_state(pdev);
+32 -4
drivers/firewire/fw-sbp2.c
··· 173 173 #define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */ 174 174 #define SBP2_ORB_NULL 0x80000000 175 175 #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 176 + #define SBP2_RETRY_LIMIT 0xf /* 15 retries */ 176 177 177 178 #define SBP2_DIRECTION_TO_MEDIA 0x0 178 179 #define SBP2_DIRECTION_FROM_MEDIA 0x1 ··· 328 327 }, 329 328 /* Symbios bridge */ { 330 329 .firmware_revision = 0xa0b800, 330 + .model = ~0, 331 + .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 332 + }, 333 + /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 334 + .firmware_revision = 0x002600, 331 335 .model = ~0, 332 336 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 333 337 }, ··· 818 812 kref_put(&tgt->kref, sbp2_release_target); 819 813 } 820 814 815 + static void 816 + complete_set_busy_timeout(struct fw_card *card, int rcode, 817 + void *payload, size_t length, void *done) 818 + { 819 + complete(done); 820 + } 821 + 822 + static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) 823 + { 824 + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 825 + DECLARE_COMPLETION_ONSTACK(done); 826 + struct fw_transaction t; 827 + static __be32 busy_timeout; 828 + 829 + /* FIXME: we should try to set dual-phase cycle_limit too */ 830 + busy_timeout = cpu_to_be32(SBP2_RETRY_LIMIT); 831 + 832 + fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, 833 + lu->tgt->node_id, lu->generation, device->max_speed, 834 + CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &busy_timeout, 835 + sizeof(busy_timeout), complete_set_busy_timeout, &done); 836 + wait_for_completion(&done); 837 + } 838 + 821 839 static void sbp2_reconnect(struct work_struct *work); 822 840 823 841 static void sbp2_login(struct work_struct *work) ··· 894 864 fw_notify("%s: logged in to LUN %04x (%d retries)\n", 895 865 tgt->bus_id, lu->lun, lu->retries); 896 866 897 - #if 0 898 - /* FIXME: The linux1394 sbp2 does this last step. */ 899 - sbp2_set_busy_timeout(scsi_id); 900 - #endif 867 + /* set appropriate retry limit(s) in BUSY_TIMEOUT register */ 868 + sbp2_set_busy_timeout(lu); 901 869 902 870 PREPARE_DELAYED_WORK(&lu->work, sbp2_reconnect); 903 871 sbp2_agent_reset(lu);
+2 -1
drivers/firewire/fw-topology.c
··· 21 21 #include <linux/module.h> 22 22 #include <linux/wait.h> 23 23 #include <linux/errno.h> 24 + #include <asm/bug.h> 24 25 #include <asm/system.h> 25 26 #include "fw-transaction.h" 26 27 #include "fw-topology.h" ··· 425 424 node1 = fw_node(list1.next); 426 425 427 426 while (&node0->link != &list0) { 427 + WARN_ON(node0->port_count != node1->port_count); 428 428 429 - /* assert(node0->port_count == node1->port_count); */ 430 429 if (node0->link_on && !node1->link_on) 431 430 event = FW_NODE_LINK_OFF; 432 431 else if (!node0->link_on && node1->link_on)
+1 -1
drivers/firewire/fw-transaction.c
··· 751 751 void *payload, size_t length, void *callback_data) 752 752 { 753 753 int i, start, end; 754 - u32 *map; 754 + __be32 *map; 755 755 756 756 if (!TCODE_IS_READ_REQUEST(tcode)) { 757 757 fw_send_response(card, request, RCODE_TYPE_ERROR);
+3 -3
drivers/firewire/fw-transaction.h
··· 86 86 static inline void 87 87 fw_memcpy_from_be32(void *_dst, void *_src, size_t size) 88 88 { 89 - u32 *dst = _dst; 90 - u32 *src = _src; 89 + u32 *dst = _dst; 90 + __be32 *src = _src; 91 91 int i; 92 92 93 93 for (i = 0; i < size / 4; i++) 94 - dst[i] = cpu_to_be32(src[i]); 94 + dst[i] = be32_to_cpu(src[i]); 95 95 } 96 96 97 97 static inline void
+5
drivers/ieee1394/sbp2.c
··· 376 376 .model_id = SBP2_ROM_VALUE_WILDCARD, 377 377 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 378 378 }, 379 + /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 380 + .firmware_revision = 0x002600, 381 + .model_id = SBP2_ROM_VALUE_WILDCARD, 382 + .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 383 + }, 379 384 /* iPod 4th generation */ { 380 385 .firmware_revision = 0x0a2700, 381 386 .model_id = 0x000021,