Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394

Pull firewure updates from Stefan Richter:
- fix controller removal when controller is in suspended state
- fix video reception on VIA VT6306 with gstreamer, MythTV, and maybe dv4l
- fix a startup issue with Agere/LSI FW643-e2
- error logging improvements and other small updates

* tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394:
firewire: ohci: dump_stack() for PHY regs read/write failures
firewire: ohci: Improve bus reset error messages
firewire: ohci: Alias dev_* log functions
firewire: ohci: Fix 'failed to read phy reg' on FW643 rev8
firewire: ohci: fix VIA VT6306 video reception
firewire: ohci: Check LPS before register access on pci removal
firewire: ohci: Fix double free_irq()
firewire: remove unnecessary alloc/OOM messages
firewire: sbp2: replace BUG_ON by WARN_ON
firewire: core: remove an always false test
firewire: Remove two unneeded checks for macros

+166 -152
+10 -17
drivers/firewire/core-cdev.c
··· 389 389 struct bus_reset_event *e; 390 390 391 391 e = kzalloc(sizeof(*e), GFP_KERNEL); 392 - if (e == NULL) { 393 - fw_notice(client->device->card, "out of memory when allocating event\n"); 392 + if (e == NULL) 394 393 return; 395 - } 396 394 397 395 fill_bus_reset_event(&e->reset, client); 398 396 ··· 691 693 692 694 r = kmalloc(sizeof(*r), GFP_ATOMIC); 693 695 e = kmalloc(sizeof(*e), GFP_ATOMIC); 694 - if (r == NULL || e == NULL) { 695 - fw_notice(card, "out of memory when allocating event\n"); 696 + if (r == NULL || e == NULL) 696 697 goto failed; 697 - } 698 + 698 699 r->card = card; 699 700 r->request = request; 700 701 r->data = payload; ··· 927 930 struct iso_interrupt_event *e; 928 931 929 932 e = kmalloc(sizeof(*e) + header_length, GFP_ATOMIC); 930 - if (e == NULL) { 931 - fw_notice(context->card, "out of memory when allocating event\n"); 933 + if (e == NULL) 932 934 return; 933 - } 935 + 934 936 e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; 935 937 e->interrupt.closure = client->iso_closure; 936 938 e->interrupt.cycle = cycle; ··· 946 950 struct iso_interrupt_mc_event *e; 947 951 948 952 e = kmalloc(sizeof(*e), GFP_ATOMIC); 949 - if (e == NULL) { 950 - fw_notice(context->card, "out of memory when allocating event\n"); 953 + if (e == NULL) 951 954 return; 952 - } 955 + 953 956 e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL; 954 957 e->interrupt.closure = client->iso_closure; 955 958 e->interrupt.completed = fw_iso_buffer_lookup(&client->buffer, ··· 1361 1366 int ret; 1362 1367 1363 1368 if ((request->channels == 0 && request->bandwidth == 0) || 1364 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL || 1365 - request->bandwidth < 0) 1369 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL) 1366 1370 return -EINVAL; 1367 1371 1368 1372 r = kmalloc(sizeof(*r), GFP_KERNEL); ··· 1576 1582 1577 1583 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { 1578 1584 e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC); 1579 - if (e == NULL) { 1580 - fw_notice(card, "out of memory when allocating event\n"); 1585 + if (e == NULL) 1581 1586 break; 1582 - } 1587 + 1583 1588 e->phy_packet.closure = client->phy_receiver_closure; 1584 1589 e->phy_packet.type = FW_CDEV_EVENT_PHY_PACKET_RECEIVED; 1585 1590 e->phy_packet.rcode = RCODE_COMPLETE;
+1 -3
drivers/firewire/core-device.c
··· 692 692 * match the drivers id_tables against it. 693 693 */ 694 694 unit = kzalloc(sizeof(*unit), GFP_KERNEL); 695 - if (unit == NULL) { 696 - fw_err(device->card, "out of memory for unit\n"); 695 + if (unit == NULL) 697 696 continue; 698 - } 699 697 700 698 unit->directory = ci.p + value - 1; 701 699 unit->device.bus = &fw_bus_type;
+1 -6
drivers/firewire/net.c
··· 356 356 } 357 357 358 358 new = kmalloc(sizeof(*new), GFP_ATOMIC); 359 - if (!new) { 360 - dev_err(&pd->skb->dev->dev, "out of memory\n"); 359 + if (!new) 361 360 return NULL; 362 - } 363 361 364 362 new->offset = offset; 365 363 new->len = len; ··· 400 402 fail_w_new: 401 403 kfree(new); 402 404 fail: 403 - dev_err(&net->dev, "out of memory\n"); 404 - 405 405 return NULL; 406 406 } 407 407 ··· 605 609 606 610 skb = dev_alloc_skb(len + LL_RESERVED_SPACE(net)); 607 611 if (unlikely(!skb)) { 608 - dev_err(&net->dev, "out of memory\n"); 609 612 net->stats.rx_dropped++; 610 613 611 614 return -ENOMEM;
+151 -119
drivers/firewire/ohci.c
··· 54 54 #include "core.h" 55 55 #include "ohci.h" 56 56 57 + #define ohci_info(ohci, f, args...) dev_info(ohci->card.device, f, ##args) 58 + #define ohci_notice(ohci, f, args...) dev_notice(ohci->card.device, f, ##args) 59 + #define ohci_err(ohci, f, args...) dev_err(ohci->card.device, f, ##args) 60 + 57 61 #define DESCRIPTOR_OUTPUT_MORE 0 58 62 #define DESCRIPTOR_OUTPUT_LAST (1 << 12) 59 63 #define DESCRIPTOR_INPUT_MORE (2 << 12) ··· 71 67 #define DESCRIPTOR_IRQ_ALWAYS (3 << 4) 72 68 #define DESCRIPTOR_BRANCH_ALWAYS (3 << 2) 73 69 #define DESCRIPTOR_WAIT (3 << 0) 70 + 71 + #define DESCRIPTOR_CMD (0xf << 12) 74 72 75 73 struct descriptor { 76 74 __le16 req_count; ··· 155 149 struct descriptor *last; 156 150 157 151 /* 158 - * The last descriptor in the DMA program. It contains the branch 152 + * The last descriptor block in the DMA program. It contains the branch 159 153 * address that must be updated upon appending a new descriptor. 160 154 */ 161 155 struct descriptor *prev; 156 + int prev_z; 162 157 163 158 descriptor_callback_t callback; 164 159 ··· 277 270 #define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 278 271 #define PCI_DEVICE_ID_TI_TSB12LV26 0x8020 279 272 #define PCI_DEVICE_ID_TI_TSB82AA2 0x8025 273 + #define PCI_DEVICE_ID_VIA_VT630X 0x3044 280 274 #define PCI_VENDOR_ID_PINNACLE_SYSTEMS 0x11bd 275 + #define PCI_REV_ID_VIA_VT6306 0x46 281 276 282 277 #define QUIRK_CYCLE_TIMER 1 283 278 #define QUIRK_RESET_PACKET 2 ··· 287 278 #define QUIRK_NO_1394A 8 288 279 #define QUIRK_NO_MSI 16 289 280 #define QUIRK_TI_SLLZ059 32 281 + #define QUIRK_IR_WAKE 64 282 + #define QUIRK_PHY_LCTRL_TIMEOUT 128 290 283 291 284 /* In case of multiple matches in ohci_quirks[], only the first one is used. */ 292 285 static const struct { ··· 301 290 QUIRK_BE_HEADERS}, 302 291 303 292 {PCI_VENDOR_ID_ATT, PCI_DEVICE_ID_AGERE_FW643, 6, 304 - QUIRK_NO_MSI}, 293 + QUIRK_PHY_LCTRL_TIMEOUT | QUIRK_NO_MSI}, 294 + 295 + {PCI_VENDOR_ID_ATT, PCI_ANY_ID, PCI_ANY_ID, 296 + QUIRK_PHY_LCTRL_TIMEOUT}, 305 297 306 298 {PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_SB1394, PCI_ANY_ID, 307 299 QUIRK_RESET_PACKET}, ··· 333 319 {PCI_VENDOR_ID_TI, PCI_ANY_ID, PCI_ANY_ID, 334 320 QUIRK_RESET_PACKET}, 335 321 322 + {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT630X, PCI_REV_ID_VIA_VT6306, 323 + QUIRK_CYCLE_TIMER | QUIRK_IR_WAKE}, 324 + 336 325 {PCI_VENDOR_ID_VIA, PCI_ANY_ID, PCI_ANY_ID, 337 326 QUIRK_CYCLE_TIMER | QUIRK_NO_MSI}, 338 327 }; ··· 350 333 ", no 1394a enhancements = " __stringify(QUIRK_NO_1394A) 351 334 ", disable MSI = " __stringify(QUIRK_NO_MSI) 352 335 ", TI SLLZ059 erratum = " __stringify(QUIRK_TI_SLLZ059) 336 + ", IR wake unreliable = " __stringify(QUIRK_IR_WAKE) 337 + ", phy LCtrl timeout = " __stringify(QUIRK_PHY_LCTRL_TIMEOUT) 353 338 ")"); 354 339 355 340 #define OHCI_PARAM_DEBUG_AT_AR 1 ··· 378 359 !(evt & OHCI1394_busReset)) 379 360 return; 380 361 381 - dev_notice(ohci->card.device, 382 - "IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, 362 + ohci_notice(ohci, "IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, 383 363 evt & OHCI1394_selfIDComplete ? " selfID" : "", 384 364 evt & OHCI1394_RQPkt ? " AR_req" : "", 385 365 evt & OHCI1394_RSPkt ? " AR_resp" : "", ··· 424 406 if (likely(!(param_debug & OHCI_PARAM_DEBUG_SELFIDS))) 425 407 return; 426 408 427 - dev_notice(ohci->card.device, 428 - "%d selfIDs, generation %d, local node ID %04x\n", 429 - self_id_count, generation, ohci->node_id); 409 + ohci_notice(ohci, "%d selfIDs, generation %d, local node ID %04x\n", 410 + self_id_count, generation, ohci->node_id); 430 411 431 412 for (s = ohci->self_id_buffer; self_id_count--; ++s) 432 413 if ((*s & 1 << 23) == 0) 433 - dev_notice(ohci->card.device, 434 - "selfID 0: %08x, phy %d [%c%c%c] " 435 - "%s gc=%d %s %s%s%s\n", 414 + ohci_notice(ohci, 415 + "selfID 0: %08x, phy %d [%c%c%c] %s gc=%d %s %s%s%s\n", 436 416 *s, *s >> 24 & 63, _p(s, 6), _p(s, 4), _p(s, 2), 437 417 speed[*s >> 14 & 3], *s >> 16 & 63, 438 418 power[*s >> 8 & 7], *s >> 22 & 1 ? "L" : "", 439 419 *s >> 11 & 1 ? "c" : "", *s & 2 ? "i" : ""); 440 420 else 441 - dev_notice(ohci->card.device, 421 + ohci_notice(ohci, 442 422 "selfID n: %08x, phy %d [%c%c%c%c%c%c%c%c]\n", 443 423 *s, *s >> 24 & 63, 444 424 _p(s, 16), _p(s, 14), _p(s, 12), _p(s, 10), ··· 486 470 evt = 0x1f; 487 471 488 472 if (evt == OHCI1394_evt_bus_reset) { 489 - dev_notice(ohci->card.device, 490 - "A%c evt_bus_reset, generation %d\n", 491 - dir, (header[2] >> 16) & 0xff); 473 + ohci_notice(ohci, "A%c evt_bus_reset, generation %d\n", 474 + dir, (header[2] >> 16) & 0xff); 492 475 return; 493 476 } 494 477 ··· 506 491 507 492 switch (tcode) { 508 493 case 0xa: 509 - dev_notice(ohci->card.device, 510 - "A%c %s, %s\n", 511 - dir, evts[evt], tcodes[tcode]); 494 + ohci_notice(ohci, "A%c %s, %s\n", 495 + dir, evts[evt], tcodes[tcode]); 512 496 break; 513 497 case 0xe: 514 - dev_notice(ohci->card.device, 515 - "A%c %s, PHY %08x %08x\n", 516 - dir, evts[evt], header[1], header[2]); 498 + ohci_notice(ohci, "A%c %s, PHY %08x %08x\n", 499 + dir, evts[evt], header[1], header[2]); 517 500 break; 518 501 case 0x0: case 0x1: case 0x4: case 0x5: case 0x9: 519 - dev_notice(ohci->card.device, 520 - "A%c spd %x tl %02x, " 521 - "%04x -> %04x, %s, " 522 - "%s, %04x%08x%s\n", 523 - dir, speed, header[0] >> 10 & 0x3f, 524 - header[1] >> 16, header[0] >> 16, evts[evt], 525 - tcodes[tcode], header[1] & 0xffff, header[2], specific); 502 + ohci_notice(ohci, 503 + "A%c spd %x tl %02x, %04x -> %04x, %s, %s, %04x%08x%s\n", 504 + dir, speed, header[0] >> 10 & 0x3f, 505 + header[1] >> 16, header[0] >> 16, evts[evt], 506 + tcodes[tcode], header[1] & 0xffff, header[2], specific); 526 507 break; 527 508 default: 528 - dev_notice(ohci->card.device, 529 - "A%c spd %x tl %02x, " 530 - "%04x -> %04x, %s, " 531 - "%s%s\n", 532 - dir, speed, header[0] >> 10 & 0x3f, 533 - header[1] >> 16, header[0] >> 16, evts[evt], 534 - tcodes[tcode], specific); 509 + ohci_notice(ohci, 510 + "A%c spd %x tl %02x, %04x -> %04x, %s, %s%s\n", 511 + dir, speed, header[0] >> 10 & 0x3f, 512 + header[1] >> 16, header[0] >> 16, evts[evt], 513 + tcodes[tcode], specific); 535 514 } 536 515 } 537 516 ··· 572 563 if (i >= 3) 573 564 msleep(1); 574 565 } 575 - dev_err(ohci->card.device, "failed to read phy reg\n"); 566 + ohci_err(ohci, "failed to read phy reg %d\n", addr); 567 + dump_stack(); 576 568 577 569 return -EBUSY; 578 570 } ··· 595 585 if (i >= 3) 596 586 msleep(1); 597 587 } 598 - dev_err(ohci->card.device, "failed to write phy reg\n"); 588 + ohci_err(ohci, "failed to write phy reg %d, val %u\n", addr, val); 589 + dump_stack(); 599 590 600 591 return -EBUSY; 601 592 } ··· 701 690 reg_write(ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN); 702 691 flush_writes(ohci); 703 692 704 - dev_err(ohci->card.device, "AR error: %s; DMA stopped\n", 705 - error_msg); 693 + ohci_err(ohci, "AR error: %s; DMA stopped\n", error_msg); 706 694 } 707 695 /* FIXME: restart? */ 708 696 } ··· 1167 1157 ctx->buffer_tail->used += sizeof(*ctx->buffer_tail->buffer); 1168 1158 ctx->last = ctx->buffer_tail->buffer; 1169 1159 ctx->prev = ctx->buffer_tail->buffer; 1160 + ctx->prev_z = 1; 1170 1161 1171 1162 return 0; 1172 1163 } ··· 1232 1221 { 1233 1222 dma_addr_t d_bus; 1234 1223 struct descriptor_buffer *desc = ctx->buffer_tail; 1224 + struct descriptor *d_branch; 1235 1225 1236 1226 d_bus = desc->buffer_bus + (d - desc->buffer) * sizeof(*d); 1237 1227 1238 1228 desc->used += (z + extra) * sizeof(*d); 1239 1229 1240 1230 wmb(); /* finish init of new descriptors before branch_address update */ 1241 - ctx->prev->branch_address = cpu_to_le32(d_bus | z); 1242 - ctx->prev = find_branch_descriptor(d, z); 1231 + 1232 + d_branch = find_branch_descriptor(ctx->prev, ctx->prev_z); 1233 + d_branch->branch_address = cpu_to_le32(d_bus | z); 1234 + 1235 + /* 1236 + * VT6306 incorrectly checks only the single descriptor at the 1237 + * CommandPtr when the wake bit is written, so if it's a 1238 + * multi-descriptor block starting with an INPUT_MORE, put a copy of 1239 + * the branch address in the first descriptor. 1240 + * 1241 + * Not doing this for transmit contexts since not sure how it interacts 1242 + * with skip addresses. 1243 + */ 1244 + if (unlikely(ctx->ohci->quirks & QUIRK_IR_WAKE) && 1245 + d_branch != ctx->prev && 1246 + (ctx->prev->control & cpu_to_le16(DESCRIPTOR_CMD)) == 1247 + cpu_to_le16(DESCRIPTOR_INPUT_MORE)) { 1248 + ctx->prev->branch_address = cpu_to_le32(d_bus | z); 1249 + } 1250 + 1251 + ctx->prev = d; 1252 + ctx->prev_z = z; 1243 1253 } 1244 1254 1245 1255 static void context_stop(struct context *ctx) ··· 1280 1248 if (i) 1281 1249 udelay(10); 1282 1250 } 1283 - dev_err(ohci->card.device, "DMA context still active (0x%08x)\n", reg); 1251 + ohci_err(ohci, "DMA context still active (0x%08x)\n", reg); 1284 1252 } 1285 1253 1286 1254 struct driver_data { ··· 1589 1557 goto out; 1590 1558 } 1591 1559 1592 - dev_err(ohci->card.device, "swap not done (CSR lock timeout)\n"); 1560 + ohci_err(ohci, "swap not done (CSR lock timeout)\n"); 1593 1561 fw_fill_response(&response, packet->header, RCODE_BUSY, NULL, 0); 1594 1562 1595 1563 out: ··· 1664 1632 1665 1633 ctl = reg_read(ohci, CONTROL_SET(regs)); 1666 1634 if (ctl & CONTEXT_DEAD) 1667 - dev_err(ohci->card.device, 1668 - "DMA context %s has stopped, error code: %s\n", 1635 + ohci_err(ohci, "DMA context %s has stopped, error code: %s\n", 1669 1636 name, evts[ctl & 0x1f]); 1670 1637 } 1671 1638 ··· 1846 1815 1847 1816 reg = reg_read(ohci, OHCI1394_NodeID); 1848 1817 if (!(reg & OHCI1394_NodeID_idValid)) { 1849 - dev_notice(ohci->card.device, 1850 - "node ID not valid, new bus reset in progress\n"); 1818 + ohci_notice(ohci, 1819 + "node ID not valid, new bus reset in progress\n"); 1851 1820 return -EBUSY; 1852 1821 } 1853 1822 self_id |= ((reg & 0x3f) << 24); /* phy ID */ ··· 1894 1863 1895 1864 reg = reg_read(ohci, OHCI1394_NodeID); 1896 1865 if (!(reg & OHCI1394_NodeID_idValid)) { 1897 - dev_notice(ohci->card.device, 1898 - "node ID not valid, new bus reset in progress\n"); 1866 + ohci_notice(ohci, 1867 + "node ID not valid, new bus reset in progress\n"); 1899 1868 return; 1900 1869 } 1901 1870 if ((reg & OHCI1394_NodeID_nodeNumber) == 63) { 1902 - dev_notice(ohci->card.device, "malconfigured bus\n"); 1871 + ohci_notice(ohci, "malconfigured bus\n"); 1903 1872 return; 1904 1873 } 1905 1874 ohci->node_id = reg & (OHCI1394_NodeID_busNumber | ··· 1913 1882 1914 1883 reg = reg_read(ohci, OHCI1394_SelfIDCount); 1915 1884 if (reg & OHCI1394_SelfIDCount_selfIDError) { 1916 - dev_notice(ohci->card.device, "inconsistent self IDs\n"); 1885 + ohci_notice(ohci, "self ID receive error\n"); 1917 1886 return; 1918 1887 } 1919 1888 /* ··· 1925 1894 self_id_count = (reg >> 3) & 0xff; 1926 1895 1927 1896 if (self_id_count > 252) { 1928 - dev_notice(ohci->card.device, "inconsistent self IDs\n"); 1897 + ohci_notice(ohci, "bad selfIDSize (%08x)\n", reg); 1929 1898 return; 1930 1899 } 1931 1900 ··· 1933 1902 rmb(); 1934 1903 1935 1904 for (i = 1, j = 0; j < self_id_count; i += 2, j++) { 1936 - if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1]) { 1905 + u32 id = cond_le32_to_cpu(ohci->self_id_cpu[i]); 1906 + u32 id2 = cond_le32_to_cpu(ohci->self_id_cpu[i + 1]); 1907 + 1908 + if (id != ~id2) { 1937 1909 /* 1938 1910 * If the invalid data looks like a cycle start packet, 1939 1911 * it's likely to be the result of the cycle master ··· 1944 1910 * so far are valid and should be processed so that the 1945 1911 * bus manager can then correct the gap count. 1946 1912 */ 1947 - if (cond_le32_to_cpu(ohci->self_id_cpu[i]) 1948 - == 0xffff008f) { 1949 - dev_notice(ohci->card.device, 1950 - "ignoring spurious self IDs\n"); 1913 + if (id == 0xffff008f) { 1914 + ohci_notice(ohci, "ignoring spurious self IDs\n"); 1951 1915 self_id_count = j; 1952 1916 break; 1953 - } else { 1954 - dev_notice(ohci->card.device, 1955 - "inconsistent self IDs\n"); 1956 - return; 1957 1917 } 1918 + 1919 + ohci_notice(ohci, "bad self ID %d/%d (%08x != ~%08x)\n", 1920 + j, self_id_count, id, id2); 1921 + return; 1958 1922 } 1959 - ohci->self_id_buffer[j] = 1960 - cond_le32_to_cpu(ohci->self_id_cpu[i]); 1923 + ohci->self_id_buffer[j] = id; 1961 1924 } 1962 1925 1963 1926 if (ohci->quirks & QUIRK_TI_SLLZ059) { 1964 1927 self_id_count = find_and_insert_self_id(ohci, self_id_count); 1965 1928 if (self_id_count < 0) { 1966 - dev_notice(ohci->card.device, 1967 - "could not construct local self ID\n"); 1929 + ohci_notice(ohci, 1930 + "could not construct local self ID\n"); 1968 1931 return; 1969 1932 } 1970 1933 } 1971 1934 1972 1935 if (self_id_count == 0) { 1973 - dev_notice(ohci->card.device, "inconsistent self IDs\n"); 1936 + ohci_notice(ohci, "no self IDs\n"); 1974 1937 return; 1975 1938 } 1976 1939 rmb(); ··· 1988 1957 1989 1958 new_generation = (reg_read(ohci, OHCI1394_SelfIDCount) >> 16) & 0xff; 1990 1959 if (new_generation != generation) { 1991 - dev_notice(ohci->card.device, 1992 - "new bus reset, discarding self ids\n"); 1960 + ohci_notice(ohci, "new bus reset, discarding self ids\n"); 1993 1961 return; 1994 1962 } 1995 1963 ··· 2126 2096 } 2127 2097 2128 2098 if (unlikely(event & OHCI1394_regAccessFail)) 2129 - dev_err(ohci->card.device, "register access failure\n"); 2099 + ohci_err(ohci, "register access failure\n"); 2130 2100 2131 2101 if (unlikely(event & OHCI1394_postedWriteErr)) { 2132 2102 reg_read(ohci, OHCI1394_PostedWriteAddressHi); ··· 2134 2104 reg_write(ohci, OHCI1394_IntEventClear, 2135 2105 OHCI1394_postedWriteErr); 2136 2106 if (printk_ratelimit()) 2137 - dev_err(ohci->card.device, "PCI posted write error\n"); 2107 + ohci_err(ohci, "PCI posted write error\n"); 2138 2108 } 2139 2109 2140 2110 if (unlikely(event & OHCI1394_cycleTooLong)) { 2141 2111 if (printk_ratelimit()) 2142 - dev_notice(ohci->card.device, 2143 - "isochronous cycle too long\n"); 2112 + ohci_notice(ohci, "isochronous cycle too long\n"); 2144 2113 reg_write(ohci, OHCI1394_LinkControlSet, 2145 2114 OHCI1394_LinkControl_cycleMaster); 2146 2115 } ··· 2152 2123 * them at least two cycles later. (FIXME?) 2153 2124 */ 2154 2125 if (printk_ratelimit()) 2155 - dev_notice(ohci->card.device, 2156 - "isochronous cycle inconsistent\n"); 2126 + ohci_notice(ohci, "isochronous cycle inconsistent\n"); 2157 2127 } 2158 2128 2159 2129 if (unlikely(event & OHCI1394_unrecoverableError)) ··· 2274 2246 const __be32 *config_rom, size_t length) 2275 2247 { 2276 2248 struct fw_ohci *ohci = fw_ohci(card); 2277 - struct pci_dev *dev = to_pci_dev(card->device); 2278 2249 u32 lps, version, irqs; 2279 2250 int i, ret; 2280 2251 2281 2252 if (software_reset(ohci)) { 2282 - dev_err(card->device, "failed to reset ohci card\n"); 2253 + ohci_err(ohci, "failed to reset ohci card\n"); 2283 2254 return -EBUSY; 2284 2255 } 2285 2256 ··· 2289 2262 * will lock up the machine. Wait 50msec to make sure we have 2290 2263 * full link enabled. However, with some cards (well, at least 2291 2264 * a JMicron PCIe card), we have to try again sometimes. 2265 + * 2266 + * TI TSB82AA2 + TSB81BA3(A) cards signal LPS enabled early but 2267 + * cannot actually use the phy at that time. These need tens of 2268 + * millisecods pause between LPS write and first phy access too. 2269 + * 2270 + * But do not wait for 50msec on Agere/LSI cards. Their phy 2271 + * arbitration state machine may time out during such a long wait. 2292 2272 */ 2273 + 2293 2274 reg_write(ohci, OHCI1394_HCControlSet, 2294 2275 OHCI1394_HCControl_LPS | 2295 2276 OHCI1394_HCControl_postedWriteEnable); 2296 2277 flush_writes(ohci); 2297 2278 2298 - for (lps = 0, i = 0; !lps && i < 3; i++) { 2279 + if (!(ohci->quirks & QUIRK_PHY_LCTRL_TIMEOUT)) 2299 2280 msleep(50); 2281 + 2282 + for (lps = 0, i = 0; !lps && i < 150; i++) { 2283 + msleep(1); 2300 2284 lps = reg_read(ohci, OHCI1394_HCControlSet) & 2301 2285 OHCI1394_HCControl_LPS; 2302 2286 } 2303 2287 2304 2288 if (!lps) { 2305 - dev_err(card->device, "failed to set Link Power Status\n"); 2289 + ohci_err(ohci, "failed to set Link Power Status\n"); 2306 2290 return -EIO; 2307 2291 } 2308 2292 ··· 2322 2284 if (ret < 0) 2323 2285 return ret; 2324 2286 if (ret) 2325 - dev_notice(card->device, "local TSB41BA3D phy\n"); 2287 + ohci_notice(ohci, "local TSB41BA3D phy\n"); 2326 2288 else 2327 2289 ohci->quirks &= ~QUIRK_TI_SLLZ059; 2328 2290 } ··· 2419 2381 reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); 2420 2382 2421 2383 reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000); 2422 - 2423 - if (!(ohci->quirks & QUIRK_NO_MSI)) 2424 - pci_enable_msi(dev); 2425 - if (request_irq(dev->irq, irq_handler, 2426 - pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED, 2427 - ohci_driver_name, ohci)) { 2428 - dev_err(card->device, "failed to allocate interrupt %d\n", 2429 - dev->irq); 2430 - pci_disable_msi(dev); 2431 - 2432 - if (config_rom) { 2433 - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2434 - ohci->next_config_rom, 2435 - ohci->next_config_rom_bus); 2436 - ohci->next_config_rom = NULL; 2437 - } 2438 - return -EIO; 2439 - } 2440 2384 2441 2385 irqs = OHCI1394_reqTxComplete | OHCI1394_respTxComplete | 2442 2386 OHCI1394_RQPkt | OHCI1394_RSPkt | ··· 3598 3578 3599 3579 if (!(pci_resource_flags(dev, 0) & IORESOURCE_MEM) || 3600 3580 pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) { 3601 - dev_err(&dev->dev, "invalid MMIO resource\n"); 3581 + ohci_err(ohci, "invalid MMIO resource\n"); 3602 3582 err = -ENXIO; 3603 3583 goto fail_disable; 3604 3584 } 3605 3585 3606 3586 err = pci_request_region(dev, 0, ohci_driver_name); 3607 3587 if (err) { 3608 - dev_err(&dev->dev, "MMIO resource unavailable\n"); 3588 + ohci_err(ohci, "MMIO resource unavailable\n"); 3609 3589 goto fail_disable; 3610 3590 } 3611 3591 3612 3592 ohci->registers = pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE); 3613 3593 if (ohci->registers == NULL) { 3614 - dev_err(&dev->dev, "failed to remap registers\n"); 3594 + ohci_err(ohci, "failed to remap registers\n"); 3615 3595 err = -ENXIO; 3616 3596 goto fail_iomem; 3617 3597 } ··· 3695 3675 guid = ((u64) reg_read(ohci, OHCI1394_GUIDHi) << 32) | 3696 3676 reg_read(ohci, OHCI1394_GUIDLo); 3697 3677 3678 + if (!(ohci->quirks & QUIRK_NO_MSI)) 3679 + pci_enable_msi(dev); 3680 + if (request_irq(dev->irq, irq_handler, 3681 + pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED, 3682 + ohci_driver_name, ohci)) { 3683 + ohci_err(ohci, "failed to allocate interrupt %d\n", dev->irq); 3684 + err = -EIO; 3685 + goto fail_msi; 3686 + } 3687 + 3698 3688 err = fw_card_add(&ohci->card, max_receive, link_speed, guid); 3699 3689 if (err) 3700 - goto fail_contexts; 3690 + goto fail_irq; 3701 3691 3702 3692 version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; 3703 - dev_notice(&dev->dev, 3704 - "added OHCI v%x.%x device as card %d, " 3705 - "%d IR + %d IT contexts, quirks 0x%x\n", 3706 - version >> 16, version & 0xff, ohci->card.index, 3707 - ohci->n_ir, ohci->n_it, ohci->quirks); 3693 + ohci_notice(ohci, 3694 + "added OHCI v%x.%x device as card %d, " 3695 + "%d IR + %d IT contexts, quirks 0x%x\n", 3696 + version >> 16, version & 0xff, ohci->card.index, 3697 + ohci->n_ir, ohci->n_it, ohci->quirks); 3708 3698 3709 3699 return 0; 3710 3700 3701 + fail_irq: 3702 + free_irq(dev->irq, ohci); 3703 + fail_msi: 3704 + pci_disable_msi(dev); 3711 3705 fail_contexts: 3712 3706 kfree(ohci->ir_context_list); 3713 3707 kfree(ohci->it_context_list); ··· 3745 3711 kfree(ohci); 3746 3712 pmac_ohci_off(dev); 3747 3713 fail: 3748 - if (err == -ENOMEM) 3749 - dev_err(&dev->dev, "out of memory\n"); 3750 - 3751 3714 return err; 3752 3715 } 3753 3716 3754 3717 static void pci_remove(struct pci_dev *dev) 3755 3718 { 3756 - struct fw_ohci *ohci; 3719 + struct fw_ohci *ohci = pci_get_drvdata(dev); 3757 3720 3758 - ohci = pci_get_drvdata(dev); 3759 - reg_write(ohci, OHCI1394_IntMaskClear, ~0); 3760 - flush_writes(ohci); 3721 + /* 3722 + * If the removal is happening from the suspend state, LPS won't be 3723 + * enabled and host registers (eg., IntMaskClear) won't be accessible. 3724 + */ 3725 + if (reg_read(ohci, OHCI1394_HCControlSet) & OHCI1394_HCControl_LPS) { 3726 + reg_write(ohci, OHCI1394_IntMaskClear, ~0); 3727 + flush_writes(ohci); 3728 + } 3761 3729 cancel_work_sync(&ohci->bus_reset_work); 3762 3730 fw_core_remove_card(&ohci->card); 3763 3731 ··· 3802 3766 int err; 3803 3767 3804 3768 software_reset(ohci); 3805 - free_irq(dev->irq, ohci); 3806 - pci_disable_msi(dev); 3807 3769 err = pci_save_state(dev); 3808 3770 if (err) { 3809 - dev_err(&dev->dev, "pci_save_state failed\n"); 3771 + ohci_err(ohci, "pci_save_state failed\n"); 3810 3772 return err; 3811 3773 } 3812 3774 err = pci_set_power_state(dev, pci_choose_state(dev, state)); 3813 3775 if (err) 3814 - dev_err(&dev->dev, "pci_set_power_state failed with %d\n", err); 3776 + ohci_err(ohci, "pci_set_power_state failed with %d\n", err); 3815 3777 pmac_ohci_off(dev); 3816 3778 3817 3779 return 0; ··· 3825 3791 pci_restore_state(dev); 3826 3792 err = pci_enable_device(dev); 3827 3793 if (err) { 3828 - dev_err(&dev->dev, "pci_enable_device failed\n"); 3794 + ohci_err(ohci, "pci_enable_device failed\n"); 3829 3795 return err; 3830 3796 } 3831 3797 ··· 3871 3837 MODULE_LICENSE("GPL"); 3872 3838 3873 3839 /* Provide a module alias so root-on-sbp2 initrds don't break. */ 3874 - #ifndef CONFIG_IEEE1394_OHCI1394_MODULE 3875 3840 MODULE_ALIAS("ohci1394"); 3876 - #endif
+3 -7
drivers/firewire/sbp2.c
··· 1144 1144 return -ENODEV; 1145 1145 1146 1146 if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE) 1147 - BUG_ON(dma_set_max_seg_size(device->card->device, 1148 - SBP2_MAX_SEG_SIZE)); 1147 + WARN_ON(dma_set_max_seg_size(device->card->device, 1148 + SBP2_MAX_SEG_SIZE)); 1149 1149 1150 1150 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt)); 1151 1151 if (shost == NULL) ··· 1475 1475 } 1476 1476 1477 1477 orb = kzalloc(sizeof(*orb), GFP_ATOMIC); 1478 - if (orb == NULL) { 1479 - dev_notice(lu_dev(lu), "failed to alloc ORB\n"); 1478 + if (orb == NULL) 1480 1479 return SCSI_MLQUEUE_HOST_BUSY; 1481 - } 1482 1480 1483 1481 /* Initialize rcode to something not RCODE_COMPLETE. */ 1484 1482 orb->base.rcode = -1; ··· 1634 1636 MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); 1635 1637 1636 1638 /* Provide a module alias so root-on-sbp2 initrds don't break. */ 1637 - #ifndef CONFIG_IEEE1394_SBP2_MODULE 1638 1639 MODULE_ALIAS("sbp2"); 1639 - #endif 1640 1640 1641 1641 static int __init sbp2_init(void) 1642 1642 {