Pull USB / Thunderbolt fixes from Greg KH: "Here are some USB fixes for 6.4-rc3, as well as a driver core fix that resolves a memory leak that shows up in USB devices easier than other subsystems. Included in here are: - driver core memory leak as reported and tested by syzbot and developers - dwc3 driver fixes for reported problems - xhci driver fixes for reported problems - USB gadget driver reverts to resolve regressions - usbtmc driver fix for syzbot reported problem - thunderbolt driver fixes for reported issues - other small USB fixes All of these, except for the driver core fix, have been in linux-next with no reported problems. The driver core fix was tested and verified to solve the issue by syzbot and the original reporter" * tag 'usb-6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: driver core: class: properly reference count class_dev_iter() xhci: Fix incorrect tracking of free space on transfer rings xhci-pci: Only run d3cold avoidance quirk for s2idle usb-storage: fix deadlock when a scsi command timeouts more than once usb: dwc3: fix a test for error in dwc3_core_init() usb: typec: tps6598x: Fix fault at module removal usb: gadget: u_ether: Fix host MAC address case usb: typec: altmodes/displayport: fix pin_assignment_show Revert "usb: gadget: udc: core: Invoke usb_gadget_connect only when started" Revert "usb: gadget: udc: core: Prevent redundant calls to pullup" usb: gadget: drop superfluous ':' in doc string usb: dwc3: debugfs: Resume dwc3 before accessing registers USB: UHCI: adjust zhaoxin UHCI controllers OverCurrent bit value usb: dwc3: fix gadget mode suspend interrupt handler issue usb: dwc3: gadget: Improve dwc3_gadget_suspend() and dwc3_gadget_resume() USB: usbtmc: Fix direction for 0-length ioctl control messages thunderbolt: Clear registers properly when auto clear isn't in use
Unified · Split
| @@ -320,6 +320,7 @@ void class_dev_iter_init(struct class_dev_iter *iter, const struct class *class, · 319 unmodified lines | |||
| 320 | start_knode = &start->p->knode_class; | 320 | start_knode = &start->p->knode_class; |
| 321 | klist_iter_init_node(&sp->klist_devices, &iter->ki, start_knode); | 321 | klist_iter_init_node(&sp->klist_devices, &iter->ki, start_knode); |
| 322 | iter->type = type; | 322 | iter->type = type; |
| 323 | iter->sp = sp; | ||
| 323 | } | 324 | } |
| 324 | EXPORT_SYMBOL_GPL(class_dev_iter_init); | 325 | EXPORT_SYMBOL_GPL(class_dev_iter_init); |
| 325 | 326 | ||
| @@ -361,6 +362,7 @@ EXPORT_SYMBOL_GPL(class_dev_iter_next); · 35 unmodified lines | |||
| 361 | void class_dev_iter_exit(struct class_dev_iter *iter) | 362 | void class_dev_iter_exit(struct class_dev_iter *iter) |
| 362 | { | 363 | { |
| 363 | klist_iter_exit(&iter->ki); | 364 | klist_iter_exit(&iter->ki); |
| 365 | subsys_put(iter->sp); | ||
| 364 | } | 366 | } |
| 365 | EXPORT_SYMBOL_GPL(class_dev_iter_exit); | 367 | EXPORT_SYMBOL_GPL(class_dev_iter_exit); |
| 366 | 368 | ||
| @@ -54,6 +54,21 @@ static int ring_interrupt_index(const struct tb_ring *ring) · 53 unmodified lines | |||
| 54 | return bit; | 54 | return bit; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static void nhi_mask_interrupt(struct tb_nhi *nhi, int mask, int ring) | ||
| 58 | { | ||
| 59 | if (nhi->quirks & QUIRK_AUTO_CLEAR_INT) | ||
| 60 | return; | ||
| 61 | iowrite32(mask, nhi->iobase + REG_RING_INTERRUPT_MASK_CLEAR_BASE + ring); | ||
| 62 | } | ||
| 63 | |||
| 64 | static void nhi_clear_interrupt(struct tb_nhi *nhi, int ring) | ||
| 65 | { | ||
| 66 | if (nhi->quirks & QUIRK_AUTO_CLEAR_INT) | ||
| 67 | ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + ring); | ||
| 68 | else | ||
| 69 | iowrite32(~0, nhi->iobase + REG_RING_INT_CLEAR + ring); | ||
| 70 | } | ||
| 71 | |||
| 57 | /* | 72 | /* |
| 58 | * ring_interrupt_active() - activate/deactivate interrupts for a single ring | 73 | * ring_interrupt_active() - activate/deactivate interrupts for a single ring |
| 59 | * | 74 | * |
| @@ -61,8 +76,8 @@ static int ring_interrupt_index(const struct tb_ring *ring) · 1 unmodified line | |||
| 61 | */ | 76 | */ |
| 62 | static void ring_interrupt_active(struct tb_ring *ring, bool active) | 77 | static void ring_interrupt_active(struct tb_ring *ring, bool active) |
| 63 | { | 78 | { |
| 64 | int reg = REG_RING_INTERRUPT_BASE + | 79 | int index = ring_interrupt_index(ring) / 32 * 4; |
| 65 | ring_interrupt_index(ring) / 32 * 4; | 80 | int reg = REG_RING_INTERRUPT_BASE + index; |
| 66 | int interrupt_bit = ring_interrupt_index(ring) & 31; | 81 | int interrupt_bit = ring_interrupt_index(ring) & 31; |
| 67 | int mask = 1 << interrupt_bit; | 82 | int mask = 1 << interrupt_bit; |
| 68 | u32 old, new; | 83 | u32 old, new; |
| @@ -123,7 +138,11 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active) · 54 unmodified lines | |||
| 123 | "interrupt for %s %d is already %s\n", | 138 | "interrupt for %s %d is already %s\n", |
| 124 | RING_TYPE(ring), ring->hop, | 139 | RING_TYPE(ring), ring->hop, |
| 125 | active ? "enabled" : "disabled"); | 140 | active ? "enabled" : "disabled"); |
| 126 | iowrite32(new, ring->nhi->iobase + reg); | 141 | |
| 142 | if (active) | ||
| 143 | iowrite32(new, ring->nhi->iobase + reg); | ||
| 144 | else | ||
| 145 | nhi_mask_interrupt(ring->nhi, mask, index); | ||
| 127 | } | 146 | } |
| 128 | 147 | ||
| 129 | /* | 148 | /* |
| @@ -136,11 +155,11 @@ static void nhi_disable_interrupts(struct tb_nhi *nhi) · 6 unmodified lines | |||
| 136 | int i = 0; | 155 | int i = 0; |
| 137 | /* disable interrupts */ | 156 | /* disable interrupts */ |
| 138 | for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++) | 157 | for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++) |
| 139 | iowrite32(0, nhi->iobase + REG_RING_INTERRUPT_BASE + 4 * i); | 158 | nhi_mask_interrupt(nhi, ~0, 4 * i); |
| 140 | 159 | ||
| 141 | /* clear interrupt status bits */ | 160 | /* clear interrupt status bits */ |
| 142 | for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++) | 161 | for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++) |
| 143 | ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + 4 * i); | 162 | nhi_clear_interrupt(nhi, 4 * i); |
| 144 | } | 163 | } |
| 145 | 164 | ||
| 146 | /* ring helper methods */ | 165 | /* ring helper methods */ |
| @@ -93,6 +93,8 @@ struct ring_desc { · 92 unmodified lines | |||
| 93 | #define REG_RING_INTERRUPT_BASE 0x38200 | 93 | #define REG_RING_INTERRUPT_BASE 0x38200 |
| 94 | #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32) | 94 | #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32) |
| 95 | 95 | ||
| 96 | #define REG_RING_INTERRUPT_MASK_CLEAR_BASE 0x38208 | ||
| 97 | |||
| 96 | #define REG_INT_THROTTLING_RATE 0x38c00 | 98 | #define REG_INT_THROTTLING_RATE 0x38c00 |
| 97 | 99 | ||
| 98 | /* Interrupt Vector Allocation */ | 100 | /* Interrupt Vector Allocation */ |
| @@ -1928,6 +1928,8 @@ static int usbtmc_ioctl_request(struct usbtmc_device_data *data, · 1927 unmodified lines | |||
| 1928 | 1928 | ||
| 1929 | if (request.req.wLength > USBTMC_BUFSIZE) | 1929 | if (request.req.wLength > USBTMC_BUFSIZE) |
| 1930 | return -EMSGSIZE; | 1930 | return -EMSGSIZE; |
| 1931 | if (request.req.wLength == 0) /* Length-0 requests are never IN */ | ||
| 1932 | request.req.bRequestType &= ~USB_DIR_IN; | ||
| 1931 | 1933 | ||
| 1932 | is_in = request.req.bRequestType & USB_DIR_IN; | 1934 | is_in = request.req.bRequestType & USB_DIR_IN; |
| 1933 | 1935 | ||
| @@ -1137,7 +1137,7 @@ static int dwc3_core_init(struct dwc3 *dwc) · 1136 unmodified lines | |||
| 1137 | 1137 | ||
| 1138 | dwc3_set_incr_burst_type(dwc); | 1138 | dwc3_set_incr_burst_type(dwc); |
| 1139 | 1139 | ||
| 1140 | dwc3_phy_power_on(dwc); | 1140 | ret = dwc3_phy_power_on(dwc); |
| 1141 | if (ret) | 1141 | if (ret) |
| 1142 | goto err_exit_phy; | 1142 | goto err_exit_phy; |
| 1143 | 1143 | ||
| @@ -1116,6 +1116,7 @@ struct dwc3_scratchpad_array { · 1115 unmodified lines | |||
| 1116 | * @dis_metastability_quirk: set to disable metastability quirk. | 1116 | * @dis_metastability_quirk: set to disable metastability quirk. |
| 1117 | * @dis_split_quirk: set to disable split boundary. | 1117 | * @dis_split_quirk: set to disable split boundary. |
| 1118 | * @wakeup_configured: set if the device is configured for remote wakeup. | 1118 | * @wakeup_configured: set if the device is configured for remote wakeup. |
| 1119 | * @suspended: set to track suspend event due to U3/L2. | ||
| 1119 | * @imod_interval: set the interrupt moderation interval in 250ns | 1120 | * @imod_interval: set the interrupt moderation interval in 250ns |
| 1120 | * increments or 0 to disable. | 1121 | * increments or 0 to disable. |
| 1121 | * @max_cfg_eps: current max number of IN eps used across all USB configs. | 1122 | * @max_cfg_eps: current max number of IN eps used across all USB configs. |
| @@ -1332,6 +1333,7 @@ struct dwc3 { · 210 unmodified lines | |||
| 1332 | unsigned dis_split_quirk:1; | 1333 | unsigned dis_split_quirk:1; |
| 1333 | unsigned async_callbacks:1; | 1334 | unsigned async_callbacks:1; |
| 1334 | unsigned wakeup_configured:1; | 1335 | unsigned wakeup_configured:1; |
| 1336 | unsigned suspended:1; | ||
| 1335 | 1337 | ||
| 1336 | u16 imod_interval; | 1338 | u16 imod_interval; |
| 1337 | 1339 | ||
| @@ -332,6 +332,11 @@ static int dwc3_lsp_show(struct seq_file *s, void *unused) · 331 unmodified lines | |||
| 332 | unsigned int current_mode; | 332 | unsigned int current_mode; |
| 333 | unsigned long flags; | 333 | unsigned long flags; |
| 334 | u32 reg; | 334 | u32 reg; |
| 335 | int ret; | ||
| 336 | |||
| 337 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 338 | if (ret < 0) | ||
| 339 | return ret; | ||
| 335 | 340 | ||
| 336 | spin_lock_irqsave(&dwc->lock, flags); | 341 | spin_lock_irqsave(&dwc->lock, flags); |
| 337 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); | 342 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); |
| @@ -350,6 +355,8 @@ static int dwc3_lsp_show(struct seq_file *s, void *unused) · 12 unmodified lines | |||
| 350 | } | 355 | } |
| 351 | spin_unlock_irqrestore(&dwc->lock, flags); | 356 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 352 | 357 | ||
| 358 | pm_runtime_put_sync(dwc->dev); | ||
| 359 | |||
| 353 | return 0; | 360 | return 0; |
| 354 | } | 361 | } |
| 355 | 362 | ||
| @@ -395,6 +402,11 @@ static int dwc3_mode_show(struct seq_file *s, void *unused) · 39 unmodified lines | |||
| 395 | struct dwc3 *dwc = s->private; | 402 | struct dwc3 *dwc = s->private; |
| 396 | unsigned long flags; | 403 | unsigned long flags; |
| 397 | u32 reg; | 404 | u32 reg; |
| 405 | int ret; | ||
| 406 | |||
| 407 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 408 | if (ret < 0) | ||
| 409 | return ret; | ||
| 398 | 410 | ||
| 399 | spin_lock_irqsave(&dwc->lock, flags); | 411 | spin_lock_irqsave(&dwc->lock, flags); |
| 400 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | 412 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
| @@ -414,6 +426,8 @@ static int dwc3_mode_show(struct seq_file *s, void *unused) · 13 unmodified lines | |||
| 414 | seq_printf(s, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg)); | 426 | seq_printf(s, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg)); |
| 415 | } | 427 | } |
| 416 | 428 | ||
| 429 | pm_runtime_put_sync(dwc->dev); | ||
| 430 | |||
| 417 | return 0; | 431 | return 0; |
| 418 | } | 432 | } |
| 419 | 433 | ||
| @@ -463,6 +477,11 @@ static int dwc3_testmode_show(struct seq_file *s, void *unused) · 43 unmodified lines | |||
| 463 | struct dwc3 *dwc = s->private; | 477 | struct dwc3 *dwc = s->private; |
| 464 | unsigned long flags; | 478 | unsigned long flags; |
| 465 | u32 reg; | 479 | u32 reg; |
| 480 | int ret; | ||
| 481 | |||
| 482 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 483 | if (ret < 0) | ||
| 484 | return ret; | ||
| 466 | 485 | ||
| 467 | spin_lock_irqsave(&dwc->lock, flags); | 486 | spin_lock_irqsave(&dwc->lock, flags); |
| 468 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 487 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
| @@ -493,6 +512,8 @@ static int dwc3_testmode_show(struct seq_file *s, void *unused) · 24 unmodified lines | |||
| 493 | seq_printf(s, "UNKNOWN %d\n", reg); | 512 | seq_printf(s, "UNKNOWN %d\n", reg); |
| 494 | } | 513 | } |
| 495 | 514 | ||
| 515 | pm_runtime_put_sync(dwc->dev); | ||
| 516 | |||
| 496 | return 0; | 517 | return 0; |
| 497 | } | 518 | } |
| 498 | 519 | ||
| @@ -509,6 +530,7 @@ static ssize_t dwc3_testmode_write(struct file *file, · 10 unmodified lines | |||
| 509 | unsigned long flags; | 530 | unsigned long flags; |
| 510 | u32 testmode = 0; | 531 | u32 testmode = 0; |
| 511 | char buf[32]; | 532 | char buf[32]; |
| 533 | int ret; | ||
| 512 | 534 | ||
| 513 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | 535 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
| 514 | return -EFAULT; | 536 | return -EFAULT; |
| @@ -526,10 +548,16 @@ static ssize_t dwc3_testmode_write(struct file *file, · 11 unmodified lines | |||
| 526 | else | 548 | else |
| 527 | testmode = 0; | 549 | testmode = 0; |
| 528 | 550 | ||
| 551 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 552 | if (ret < 0) | ||
| 553 | return ret; | ||
| 554 | |||
| 529 | spin_lock_irqsave(&dwc->lock, flags); | 555 | spin_lock_irqsave(&dwc->lock, flags); |
| 530 | dwc3_gadget_set_test_mode(dwc, testmode); | 556 | dwc3_gadget_set_test_mode(dwc, testmode); |
| 531 | spin_unlock_irqrestore(&dwc->lock, flags); | 557 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 532 | 558 | ||
| 559 | pm_runtime_put_sync(dwc->dev); | ||
| 560 | |||
| 533 | return count; | 561 | return count; |
| 534 | } | 562 | } |
| 535 | 563 | ||
| @@ -548,12 +576,18 @@ static int dwc3_link_state_show(struct seq_file *s, void *unused) · 12 unmodified lines | |||
| 548 | enum dwc3_link_state state; | 576 | enum dwc3_link_state state; |
| 549 | u32 reg; | 577 | u32 reg; |
| 550 | u8 speed; | 578 | u8 speed; |
| 579 | int ret; | ||
| 580 | |||
| 581 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 582 | if (ret < 0) | ||
| 583 | return ret; | ||
| 551 | 584 | ||
| 552 | spin_lock_irqsave(&dwc->lock, flags); | 585 | spin_lock_irqsave(&dwc->lock, flags); |
| 553 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); | 586 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); |
| 554 | if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { | 587 | if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { |
| 555 | seq_puts(s, "Not available\n"); | 588 | seq_puts(s, "Not available\n"); |
| 556 | spin_unlock_irqrestore(&dwc->lock, flags); | 589 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 590 | pm_runtime_put_sync(dwc->dev); | ||
| 557 | return 0; | 591 | return 0; |
| 558 | } | 592 | } |
| 559 | 593 | ||
| @@ -566,6 +600,8 @@ static int dwc3_link_state_show(struct seq_file *s, void *unused) · 6 unmodified lines | |||
| 566 | dwc3_gadget_hs_link_string(state)); | 600 | dwc3_gadget_hs_link_string(state)); |
| 567 | spin_unlock_irqrestore(&dwc->lock, flags); | 601 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 568 | 602 | ||
| 603 | pm_runtime_put_sync(dwc->dev); | ||
| 604 | |||
| 569 | return 0; | 605 | return 0; |
| 570 | } | 606 | } |
| 571 | 607 | ||
| @@ -584,6 +620,7 @@ static ssize_t dwc3_link_state_write(struct file *file, · 12 unmodified lines | |||
| 584 | char buf[32]; | 620 | char buf[32]; |
| 585 | u32 reg; | 621 | u32 reg; |
| 586 | u8 speed; | 622 | u8 speed; |
| 623 | int ret; | ||
| 587 | 624 | ||
| 588 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | 625 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
| 589 | return -EFAULT; | 626 | return -EFAULT; |
| @@ -603,10 +640,15 @@ static ssize_t dwc3_link_state_write(struct file *file, · 13 unmodified lines | |||
| 603 | else | 640 | else |
| 604 | return -EINVAL; | 641 | return -EINVAL; |
| 605 | 642 | ||
| 643 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 644 | if (ret < 0) | ||
| 645 | return ret; | ||
| 646 | |||
| 606 | spin_lock_irqsave(&dwc->lock, flags); | 647 | spin_lock_irqsave(&dwc->lock, flags); |
| 607 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); | 648 | reg = dwc3_readl(dwc->regs, DWC3_GSTS); |
| 608 | if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { | 649 | if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) { |
| 609 | spin_unlock_irqrestore(&dwc->lock, flags); | 650 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 651 | pm_runtime_put_sync(dwc->dev); | ||
| 610 | return -EINVAL; | 652 | return -EINVAL; |
| 611 | } | 653 | } |
| 612 | 654 | ||
| @@ -616,12 +658,15 @@ static ssize_t dwc3_link_state_write(struct file *file, · 3 unmodified lines | |||
| 616 | if (speed < DWC3_DSTS_SUPERSPEED && | 658 | if (speed < DWC3_DSTS_SUPERSPEED && |
| 617 | state != DWC3_LINK_STATE_RECOV) { | 659 | state != DWC3_LINK_STATE_RECOV) { |
| 618 | spin_unlock_irqrestore(&dwc->lock, flags); | 660 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 661 | pm_runtime_put_sync(dwc->dev); | ||
| 619 | return -EINVAL; | 662 | return -EINVAL; |
| 620 | } | 663 | } |
| 621 | 664 | ||
| 622 | dwc3_gadget_set_link_state(dwc, state); | 665 | dwc3_gadget_set_link_state(dwc, state); |
| 623 | spin_unlock_irqrestore(&dwc->lock, flags); | 666 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 624 | 667 | ||
| 668 | pm_runtime_put_sync(dwc->dev); | ||
| 669 | |||
| 625 | return count; | 670 | return count; |
| 626 | } | 671 | } |
| 627 | 672 | ||
| @@ -645,6 +690,11 @@ static int dwc3_tx_fifo_size_show(struct seq_file *s, void *unused) · 17 unmodified lines | |||
| 645 | unsigned long flags; | 690 | unsigned long flags; |
| 646 | u32 mdwidth; | 691 | u32 mdwidth; |
| 647 | u32 val; | 692 | u32 val; |
| 693 | int ret; | ||
| 694 | |||
| 695 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 696 | if (ret < 0) | ||
| 697 | return ret; | ||
| 648 | 698 | ||
| 649 | spin_lock_irqsave(&dwc->lock, flags); | 699 | spin_lock_irqsave(&dwc->lock, flags); |
| 650 | val = dwc3_core_fifo_space(dep, DWC3_TXFIFO); | 700 | val = dwc3_core_fifo_space(dep, DWC3_TXFIFO); |
| @@ -657,6 +707,8 @@ static int dwc3_tx_fifo_size_show(struct seq_file *s, void *unused) · 6 unmodified lines | |||
| 657 | seq_printf(s, "%u\n", val); | 707 | seq_printf(s, "%u\n", val); |
| 658 | spin_unlock_irqrestore(&dwc->lock, flags); | 708 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 659 | 709 | ||
| 710 | pm_runtime_put_sync(dwc->dev); | ||
| 711 | |||
| 660 | return 0; | 712 | return 0; |
| 661 | } | 713 | } |
| 662 | 714 | ||
| @@ -667,6 +719,11 @@ static int dwc3_rx_fifo_size_show(struct seq_file *s, void *unused) · 4 unmodified lines | |||
| 667 | unsigned long flags; | 719 | unsigned long flags; |
| 668 | u32 mdwidth; | 720 | u32 mdwidth; |
| 669 | u32 val; | 721 | u32 val; |
| 722 | int ret; | ||
| 723 | |||
| 724 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 725 | if (ret < 0) | ||
| 726 | return ret; | ||
| 670 | 727 | ||
| 671 | spin_lock_irqsave(&dwc->lock, flags); | 728 | spin_lock_irqsave(&dwc->lock, flags); |
| 672 | val = dwc3_core_fifo_space(dep, DWC3_RXFIFO); | 729 | val = dwc3_core_fifo_space(dep, DWC3_RXFIFO); |
| @@ -679,6 +736,8 @@ static int dwc3_rx_fifo_size_show(struct seq_file *s, void *unused) · 6 unmodified lines | |||
| 679 | seq_printf(s, "%u\n", val); | 736 | seq_printf(s, "%u\n", val); |
| 680 | spin_unlock_irqrestore(&dwc->lock, flags); | 737 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 681 | 738 | ||
| 739 | pm_runtime_put_sync(dwc->dev); | ||
| 740 | |||
| 682 | return 0; | 741 | return 0; |
| 683 | } | 742 | } |
| 684 | 743 | ||
| @@ -688,12 +747,19 @@ static int dwc3_tx_request_queue_show(struct seq_file *s, void *unused) · 3 unmodified lines | |||
| 688 | struct dwc3 *dwc = dep->dwc; | 747 | struct dwc3 *dwc = dep->dwc; |
| 689 | unsigned long flags; | 748 | unsigned long flags; |
| 690 | u32 val; | 749 | u32 val; |
| 750 | int ret; | ||
| 751 | |||
| 752 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 753 | if (ret < 0) | ||
| 754 | return ret; | ||
| 691 | 755 | ||
| 692 | spin_lock_irqsave(&dwc->lock, flags); | 756 | spin_lock_irqsave(&dwc->lock, flags); |
| 693 | val = dwc3_core_fifo_space(dep, DWC3_TXREQQ); | 757 | val = dwc3_core_fifo_space(dep, DWC3_TXREQQ); |
| 694 | seq_printf(s, "%u\n", val); | 758 | seq_printf(s, "%u\n", val); |
| 695 | spin_unlock_irqrestore(&dwc->lock, flags); | 759 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 696 | 760 | ||
| 761 | pm_runtime_put_sync(dwc->dev); | ||
| 762 | |||
| 697 | return 0; | 763 | return 0; |
| 698 | } | 764 | } |
| 699 | 765 | ||
| @@ -703,12 +769,19 @@ static int dwc3_rx_request_queue_show(struct seq_file *s, void *unused) · 3 unmodified lines | |||
| 703 | struct dwc3 *dwc = dep->dwc; | 769 | struct dwc3 *dwc = dep->dwc; |
| 704 | unsigned long flags; | 770 | unsigned long flags; |
| 705 | u32 val; | 771 | u32 val; |
| 772 | int ret; | ||
| 773 | |||
| 774 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 775 | if (ret < 0) | ||
| 776 | return ret; | ||
| 706 | 777 | ||
| 707 | spin_lock_irqsave(&dwc->lock, flags); | 778 | spin_lock_irqsave(&dwc->lock, flags); |
| 708 | val = dwc3_core_fifo_space(dep, DWC3_RXREQQ); | 779 | val = dwc3_core_fifo_space(dep, DWC3_RXREQQ); |
| 709 | seq_printf(s, "%u\n", val); | 780 | seq_printf(s, "%u\n", val); |
| 710 | spin_unlock_irqrestore(&dwc->lock, flags); | 781 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 711 | 782 | ||
| 783 | pm_runtime_put_sync(dwc->dev); | ||
| 784 | |||
| 712 | return 0; | 785 | return 0; |
| 713 | } | 786 | } |
| 714 | 787 | ||
| @@ -718,12 +791,19 @@ static int dwc3_rx_info_queue_show(struct seq_file *s, void *unused) · 3 unmodified lines | |||
| 718 | struct dwc3 *dwc = dep->dwc; | 791 | struct dwc3 *dwc = dep->dwc; |
| 719 | unsigned long flags; | 792 | unsigned long flags; |
| 720 | u32 val; | 793 | u32 val; |
| 794 | int ret; | ||
| 795 | |||
| 796 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 797 | if (ret < 0) | ||
| 798 | return ret; | ||
| 721 | 799 | ||
| 722 | spin_lock_irqsave(&dwc->lock, flags); | 800 | spin_lock_irqsave(&dwc->lock, flags); |
| 723 | val = dwc3_core_fifo_space(dep, DWC3_RXINFOQ); | 801 | val = dwc3_core_fifo_space(dep, DWC3_RXINFOQ); |
| 724 | seq_printf(s, "%u\n", val); | 802 | seq_printf(s, "%u\n", val); |
| 725 | spin_unlock_irqrestore(&dwc->lock, flags); | 803 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 726 | 804 | ||
| 805 | pm_runtime_put_sync(dwc->dev); | ||
| 806 | |||
| 727 | return 0; | 807 | return 0; |
| 728 | } | 808 | } |
| 729 | 809 | ||
| @@ -733,12 +813,19 @@ static int dwc3_descriptor_fetch_queue_show(struct seq_file *s, void *unused) · 3 unmodified lines | |||
| 733 | struct dwc3 *dwc = dep->dwc; | 813 | struct dwc3 *dwc = dep->dwc; |
| 734 | unsigned long flags; | 814 | unsigned long flags; |
| 735 | u32 val; | 815 | u32 val; |
| 816 | int ret; | ||
| 817 | |||
| 818 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 819 | if (ret < 0) | ||
| 820 | return ret; | ||
| 736 | 821 | ||
| 737 | spin_lock_irqsave(&dwc->lock, flags); | 822 | spin_lock_irqsave(&dwc->lock, flags); |
| 738 | val = dwc3_core_fifo_space(dep, DWC3_DESCFETCHQ); | 823 | val = dwc3_core_fifo_space(dep, DWC3_DESCFETCHQ); |
| 739 | seq_printf(s, "%u\n", val); | 824 | seq_printf(s, "%u\n", val); |
| 740 | spin_unlock_irqrestore(&dwc->lock, flags); | 825 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 741 | 826 | ||
| 827 | pm_runtime_put_sync(dwc->dev); | ||
| 828 | |||
| 742 | return 0; | 829 | return 0; |
| 743 | } | 830 | } |
| 744 | 831 | ||
| @@ -748,12 +835,19 @@ static int dwc3_event_queue_show(struct seq_file *s, void *unused) · 3 unmodified lines | |||
| 748 | struct dwc3 *dwc = dep->dwc; | 835 | struct dwc3 *dwc = dep->dwc; |
| 749 | unsigned long flags; | 836 | unsigned long flags; |
| 750 | u32 val; | 837 | u32 val; |
| 838 | int ret; | ||
| 839 | |||
| 840 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 841 | if (ret < 0) | ||
| 842 | return ret; | ||
| 751 | 843 | ||
| 752 | spin_lock_irqsave(&dwc->lock, flags); | 844 | spin_lock_irqsave(&dwc->lock, flags); |
| 753 | val = dwc3_core_fifo_space(dep, DWC3_EVENTQ); | 845 | val = dwc3_core_fifo_space(dep, DWC3_EVENTQ); |
| 754 | seq_printf(s, "%u\n", val); | 846 | seq_printf(s, "%u\n", val); |
| 755 | spin_unlock_irqrestore(&dwc->lock, flags); | 847 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 756 | 848 | ||
| 849 | pm_runtime_put_sync(dwc->dev); | ||
| 850 | |||
| 757 | return 0; | 851 | return 0; |
| 758 | } | 852 | } |
| 759 | 853 | ||
| @@ -798,6 +892,11 @@ static int dwc3_trb_ring_show(struct seq_file *s, void *unused) · 38 unmodified lines | |||
| 798 | struct dwc3 *dwc = dep->dwc; | 892 | struct dwc3 *dwc = dep->dwc; |
| 799 | unsigned long flags; | 893 | unsigned long flags; |
| 800 | int i; | 894 | int i; |
| 895 | int ret; | ||
| 896 | |||
| 897 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 898 | if (ret < 0) | ||
| 899 | return ret; | ||
| 801 | 900 | ||
| 802 | spin_lock_irqsave(&dwc->lock, flags); | 901 | spin_lock_irqsave(&dwc->lock, flags); |
| 803 | if (dep->number <= 1) { | 902 | if (dep->number <= 1) { |
| @@ -827,6 +926,8 @@ static int dwc3_trb_ring_show(struct seq_file *s, void *unused) · 23 unmodified lines | |||
| 827 | out: | 926 | out: |
| 828 | spin_unlock_irqrestore(&dwc->lock, flags); | 927 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 829 | 928 | ||
| 929 | pm_runtime_put_sync(dwc->dev); | ||
| 930 | |||
| 830 | return 0; | 931 | return 0; |
| 831 | } | 932 | } |
| 832 | 933 | ||
| @@ -839,6 +940,11 @@ static int dwc3_ep_info_register_show(struct seq_file *s, void *unused) · 6 unmodified lines | |||
| 839 | u32 lower_32_bits; | 940 | u32 lower_32_bits; |
| 840 | u32 upper_32_bits; | 941 | u32 upper_32_bits; |
| 841 | u32 reg; | 942 | u32 reg; |
| 943 | int ret; | ||
| 944 | |||
| 945 | ret = pm_runtime_resume_and_get(dwc->dev); | ||
| 946 | if (ret < 0) | ||
| 947 | return ret; | ||
| 842 | 948 | ||
| 843 | spin_lock_irqsave(&dwc->lock, flags); | 949 | spin_lock_irqsave(&dwc->lock, flags); |
| 844 | reg = DWC3_GDBGLSPMUX_EPSELECT(dep->number); | 950 | reg = DWC3_GDBGLSPMUX_EPSELECT(dep->number); |
| @@ -851,6 +957,8 @@ static int dwc3_ep_info_register_show(struct seq_file *s, void *unused) · 6 unmodified lines | |||
| 851 | seq_printf(s, "0x%016llx\n", ep_info); | 957 | seq_printf(s, "0x%016llx\n", ep_info); |
| 852 | spin_unlock_irqrestore(&dwc->lock, flags); | 958 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 853 | 959 | ||
| 960 | pm_runtime_put_sync(dwc->dev); | ||
| 961 | |||
| 854 | return 0; | 962 | return 0; |
| 855 | } | 963 | } |
| 856 | 964 | ||
| @@ -910,6 +1018,7 @@ void dwc3_debugfs_init(struct dwc3 *dwc) · 53 unmodified lines | |||
| 910 | dwc->regset->regs = dwc3_regs; | 1018 | dwc->regset->regs = dwc3_regs; |
| 911 | dwc->regset->nregs = ARRAY_SIZE(dwc3_regs); | 1019 | dwc->regset->nregs = ARRAY_SIZE(dwc3_regs); |
| 912 | dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START; | 1020 | dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START; |
| 1021 | dwc->regset->dev = dwc->dev; | ||
| 913 | 1022 | ||
| 914 | root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root); | 1023 | root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root); |
| 915 | dwc->debug_root = root; | 1024 | dwc->debug_root = root; |
| @@ -2440,6 +2440,7 @@ static int dwc3_gadget_func_wakeup(struct usb_gadget *g, int intf_id) · 2439 unmodified lines | |||
| 2440 | return -EINVAL; | 2440 | return -EINVAL; |
| 2441 | } | 2441 | } |
| 2442 | dwc3_resume_gadget(dwc); | 2442 | dwc3_resume_gadget(dwc); |
| 2443 | dwc->suspended = false; | ||
| 2443 | dwc->link_state = DWC3_LINK_STATE_U0; | 2444 | dwc->link_state = DWC3_LINK_STATE_U0; |
| 2444 | } | 2445 | } |
| 2445 | 2446 | ||
| @@ -2699,6 +2700,21 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) · 253 unmodified lines | |||
| 2699 | return ret; | 2700 | return ret; |
| 2700 | } | 2701 | } |
| 2701 | 2702 | ||
| 2703 | static int dwc3_gadget_soft_connect(struct dwc3 *dwc) | ||
| 2704 | { | ||
| 2705 | /* | ||
| 2706 | * In the Synopsys DWC_usb31 1.90a programming guide section | ||
| 2707 | * 4.1.9, it specifies that for a reconnect after a | ||
| 2708 | * device-initiated disconnect requires a core soft reset | ||
| 2709 | * (DCTL.CSftRst) before enabling the run/stop bit. | ||
| 2710 | */ | ||
| 2711 | dwc3_core_soft_reset(dwc); | ||
| 2712 | |||
| 2713 | dwc3_event_buffers_setup(dwc); | ||
| 2714 | __dwc3_gadget_start(dwc); | ||
| 2715 | return dwc3_gadget_run_stop(dwc, true); | ||
| 2716 | } | ||
| 2717 | |||
| 2702 | static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) | 2718 | static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) |
| 2703 | { | 2719 | { |
| 2704 | struct dwc3 *dwc = gadget_to_dwc(g); | 2720 | struct dwc3 *dwc = gadget_to_dwc(g); |
| @@ -2737,21 +2753,10 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) · 32 unmodified lines | |||
| 2737 | 2753 | ||
| 2738 | synchronize_irq(dwc->irq_gadget); | 2754 | synchronize_irq(dwc->irq_gadget); |
| 2739 | 2755 | ||
| 2740 | if (!is_on) { | 2756 | if (!is_on) |
| 2741 | ret = dwc3_gadget_soft_disconnect(dwc); | 2757 | ret = dwc3_gadget_soft_disconnect(dwc); |
| 2742 | } else { | 2758 | else |
| 2743 | /* | 2759 | ret = dwc3_gadget_soft_connect(dwc); |
| 2744 | * In the Synopsys DWC_usb31 1.90a programming guide section | ||
| 2745 | * 4.1.9, it specifies that for a reconnect after a | ||
| 2746 | * device-initiated disconnect requires a core soft reset | ||
| 2747 | * (DCTL.CSftRst) before enabling the run/stop bit. | ||
| 2748 | */ | ||
| 2749 | dwc3_core_soft_reset(dwc); | ||
| 2750 | |||
| 2751 | dwc3_event_buffers_setup(dwc); | ||
| 2752 | __dwc3_gadget_start(dwc); | ||
| 2753 | ret = dwc3_gadget_run_stop(dwc, true); | ||
| 2754 | } | ||
| 2755 | 2760 | ||
| 2756 | pm_runtime_put(dwc->dev); | 2761 | pm_runtime_put(dwc->dev); |
| 2757 | 2762 | ||
| @@ -3938,6 +3943,8 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) · 1180 unmodified lines | |||
| 3938 | { | 3943 | { |
| 3939 | int reg; | 3944 | int reg; |
| 3940 | 3945 | ||
| 3946 | dwc->suspended = false; | ||
| 3947 | |||
| 3941 | dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RX_DET); | 3948 | dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RX_DET); |
| 3942 | 3949 | ||
| 3943 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 3950 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
| @@ -3962,6 +3969,8 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) · 18 unmodified lines | |||
| 3962 | { | 3969 | { |
| 3963 | u32 reg; | 3970 | u32 reg; |
| 3964 | 3971 | ||
| 3972 | dwc->suspended = false; | ||
| 3973 | |||
| 3965 | /* | 3974 | /* |
| 3966 | * Ideally, dwc3_reset_gadget() would trigger the function | 3975 | * Ideally, dwc3_reset_gadget() would trigger the function |
| 3967 | * drivers to stop any active transfers through ep disable. | 3976 | * drivers to stop any active transfers through ep disable. |
| @@ -4180,6 +4189,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) · 212 unmodified lines | |||
| 4180 | 4189 | ||
| 4181 | static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, unsigned int evtinfo) | 4190 | static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, unsigned int evtinfo) |
| 4182 | { | 4191 | { |
| 4192 | dwc->suspended = false; | ||
| 4193 | |||
| 4183 | /* | 4194 | /* |
| 4184 | * TODO take core out of low power mode when that's | 4195 | * TODO take core out of low power mode when that's |
| 4185 | * implemented. | 4196 | * implemented. |
| @@ -4277,6 +4288,7 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, · 91 unmodified lines | |||
| 4277 | if (dwc->gadget->wakeup_armed) { | 4288 | if (dwc->gadget->wakeup_armed) { |
| 4278 | dwc3_gadget_enable_linksts_evts(dwc, false); | 4289 | dwc3_gadget_enable_linksts_evts(dwc, false); |
| 4279 | dwc3_resume_gadget(dwc); | 4290 | dwc3_resume_gadget(dwc); |
| 4291 | dwc->suspended = false; | ||
| 4280 | } | 4292 | } |
| 4281 | break; | 4293 | break; |
| 4282 | case DWC3_LINK_STATE_U1: | 4294 | case DWC3_LINK_STATE_U1: |
| @@ -4303,8 +4315,10 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc, · 20 unmodified lines | |||
| 4303 | { | 4315 | { |
| 4304 | enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK; | 4316 | enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK; |
| 4305 | 4317 | ||
| 4306 | if (dwc->link_state != next && next == DWC3_LINK_STATE_U3) | 4318 | if (!dwc->suspended && next == DWC3_LINK_STATE_U3) { |
| 4319 | dwc->suspended = true; | ||
| 4307 | dwc3_suspend_gadget(dwc); | 4320 | dwc3_suspend_gadget(dwc); |
| 4321 | } | ||
| 4308 | 4322 | ||
| 4309 | dwc->link_state = next; | 4323 | dwc->link_state = next; |
| 4310 | } | 4324 | } |
| @@ -4655,42 +4669,39 @@ void dwc3_gadget_exit(struct dwc3 *dwc) · 344 unmodified lines | |||
| 4655 | int dwc3_gadget_suspend(struct dwc3 *dwc) | 4669 | int dwc3_gadget_suspend(struct dwc3 *dwc) |
| 4656 | { | 4670 | { |
| 4657 | unsigned long flags; | 4671 | unsigned long flags; |
| 4672 | int ret; | ||
| 4658 | 4673 | ||
| 4659 | if (!dwc->gadget_driver) | 4674 | if (!dwc->gadget_driver) |
| 4660 | return 0; | 4675 | return 0; |
| 4661 | 4676 | ||
| 4662 | dwc3_gadget_run_stop(dwc, false); | 4677 | ret = dwc3_gadget_soft_disconnect(dwc); |
| 4678 | if (ret) | ||
| 4679 | goto err; | ||
| 4663 | 4680 | ||
| 4664 | spin_lock_irqsave(&dwc->lock, flags); | 4681 | spin_lock_irqsave(&dwc->lock, flags); |
| 4665 | dwc3_disconnect_gadget(dwc); | 4682 | dwc3_disconnect_gadget(dwc); |
| 4666 | __dwc3_gadget_stop(dwc); | ||
| 4667 | spin_unlock_irqrestore(&dwc->lock, flags); | 4683 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 4668 | 4684 | ||
| 4669 | return 0; | 4685 | return 0; |
| 4686 | |||
| 4687 | err: | ||
| 4688 | /* | ||
| 4689 | * Attempt to reset the controller's state. Likely no | ||
| 4690 | * communication can be established until the host | ||
| 4691 | * performs a port reset. | ||
| 4692 | */ | ||
| 4693 | if (dwc->softconnect) | ||
| 4694 | dwc3_gadget_soft_connect(dwc); | ||
| 4695 | |||
| 4696 | return ret; | ||
| 4670 | } | 4697 | } |
| 4671 | 4698 | ||
| 4672 | int dwc3_gadget_resume(struct dwc3 *dwc) | 4699 | int dwc3_gadget_resume(struct dwc3 *dwc) |
| 4673 | { | 4700 | { |
| 4674 | int ret; | ||
| 4675 | |||
| 4676 | if (!dwc->gadget_driver || !dwc->softconnect) | 4701 | if (!dwc->gadget_driver || !dwc->softconnect) |
| 4677 | return 0; | 4702 | return 0; |
| 4678 | 4703 | ||
| 4679 | ret = __dwc3_gadget_start(dwc); | 4704 | return dwc3_gadget_soft_connect(dwc); |
| 4680 | if (ret < 0) | ||
| 4681 | goto err0; | ||
| 4682 | |||
| 4683 | ret = dwc3_gadget_run_stop(dwc, true); | ||
| 4684 | if (ret < 0) | ||
| 4685 | goto err1; | ||
| 4686 | |||
| 4687 | return 0; | ||
| 4688 | |||
| 4689 | err1: | ||
| 4690 | __dwc3_gadget_stop(dwc); | ||
| 4691 | |||
| 4692 | err0: | ||
| 4693 | return ret; | ||
| 4694 | } | 4705 | } |
| 4695 | 4706 | ||
| 4696 | void dwc3_gadget_process_pending_events(struct dwc3 *dwc) | 4707 | void dwc3_gadget_process_pending_events(struct dwc3 *dwc) |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | |||
| 17 | #include <linux/etherdevice.h> | 17 | #include <linux/etherdevice.h> |
| 18 | #include <linux/ethtool.h> | 18 | #include <linux/ethtool.h> |
| 19 | #include <linux/if_vlan.h> | 19 | #include <linux/if_vlan.h> |
| 20 | #include <linux/string_helpers.h> | ||
| 20 | #include <linux/usb/composite.h> | 21 | #include <linux/usb/composite.h> |
| 21 | 22 | ||
| 22 | #include "u_ether.h" | 23 | #include "u_ether.h" |
| @@ -965,6 +966,8 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len) · 942 unmodified lines | |||
| 965 | dev = netdev_priv(net); | 966 | dev = netdev_priv(net); |
| 966 | snprintf(host_addr, len, "%pm", dev->host_mac); | 967 | snprintf(host_addr, len, "%pm", dev->host_mac); |
| 967 | 968 | ||
| 969 | string_upper(host_addr, host_addr); | ||
| 970 | |||
| 968 | return strlen(host_addr); | 971 | return strlen(host_addr); |
| 969 | } | 972 | } |
| 970 | EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc); | 973 | EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc); |
| @@ -37,10 +37,6 @@ static const struct bus_type gadget_bus_type; · 36 unmodified lines | |||
| 37 | * @vbus: for udcs who care about vbus status, this value is real vbus status; | 37 | * @vbus: for udcs who care about vbus status, this value is real vbus status; |
| 38 | * for udcs who do not care about vbus status, this value is always true | 38 | * for udcs who do not care about vbus status, this value is always true |
| 39 | * @started: the UDC's started state. True if the UDC had started. | 39 | * @started: the UDC's started state. True if the UDC had started. |
| 40 | * @connect_lock: protects udc->vbus, udc->started, gadget->connect, gadget->deactivate related | ||
| 41 | * functions. usb_gadget_connect_locked, usb_gadget_disconnect_locked, | ||
| 42 | * usb_udc_connect_control_locked, usb_gadget_udc_start_locked, usb_gadget_udc_stop_locked are | ||
| 43 | * called with this lock held. | ||
| 44 | * | 40 | * |
| 45 | * This represents the internal data structure which is used by the UDC-class | 41 | * This represents the internal data structure which is used by the UDC-class |
| 46 | * to hold information about udc driver and gadget together. | 42 | * to hold information about udc driver and gadget together. |
| @@ -52,7 +48,6 @@ struct usb_udc { · 5 unmodified lines | |||
| 52 | struct list_head list; | 48 | struct list_head list; |
| 53 | bool vbus; | 49 | bool vbus; |
| 54 | bool started; | 50 | bool started; |
| 55 | struct mutex connect_lock; | ||
| 56 | }; | 51 | }; |
| 57 | 52 | ||
| 58 | static struct class *udc_class; | 53 | static struct class *udc_class; |
| @@ -692,9 +687,17 @@ out: · 633 unmodified lines | |||
| 692 | } | 687 | } |
| 693 | EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect); | 688 | EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect); |
| 694 | 689 | ||
| 695 | /* Internal version of usb_gadget_connect needs to be called with connect_lock held. */ | 690 | /** |
| 696 | static int usb_gadget_connect_locked(struct usb_gadget *gadget) | 691 | * usb_gadget_connect - software-controlled connect to USB host |
| 697 | __must_hold(&gadget->udc->connect_lock) | 692 | * @gadget:the peripheral being connected |
| 693 | * | ||
| 694 | * Enables the D+ (or potentially D-) pullup. The host will start | ||
| 695 | * enumerating this gadget when the pullup is active and a VBUS session | ||
| 696 | * is active (the link is powered). | ||
| 697 | * | ||
| 698 | * Returns zero on success, else negative errno. | ||
| 699 | */ | ||
| 700 | int usb_gadget_connect(struct usb_gadget *gadget) | ||
| 698 | { | 701 | { |
| 699 | int ret = 0; | 702 | int ret = 0; |
| 700 | 703 | ||
| @@ -703,15 +706,10 @@ static int usb_gadget_connect_locked(struct usb_gadget *gadget) · 2 unmodified lines | |||
| 703 | goto out; | 706 | goto out; |
| 704 | } | 707 | } |
| 705 | 708 | ||
| 706 | if (gadget->connected) | 709 | if (gadget->deactivated) { |
| 707 | goto out; | ||
| 708 | |||
| 709 | if (gadget->deactivated || !gadget->udc->started) { | ||
| 710 | /* | 710 | /* |
| 711 | * If gadget is deactivated we only save new state. | 711 | * If gadget is deactivated we only save new state. |
| 712 | * Gadget will be connected automatically after activation. | 712 | * Gadget will be connected automatically after activation. |
| 713 | * | ||
| 714 | * udc first needs to be started before gadget can be pulled up. | ||
| 715 | */ | 713 | */ |
| 716 | gadget->connected = true; | 714 | gadget->connected = true; |
| 717 | goto out; | 715 | goto out; |
| @@ -726,32 +724,22 @@ out: · 8 unmodified lines | |||
| 726 | 724 | ||
| 727 | return ret; | 725 | return ret; |
| 728 | } | 726 | } |
| 727 | EXPORT_SYMBOL_GPL(usb_gadget_connect); | ||
| 729 | 728 | ||
| 730 | /** | 729 | /** |
| 731 | * usb_gadget_connect - software-controlled connect to USB host | 730 | * usb_gadget_disconnect - software-controlled disconnect from USB host |
| 732 | * @gadget:the peripheral being connected | 731 | * @gadget:the peripheral being disconnected |
| 733 | * | 732 | * |
| 734 | * Enables the D+ (or potentially D-) pullup. The host will start | 733 | * Disables the D+ (or potentially D-) pullup, which the host may see |
| 735 | * enumerating this gadget when the pullup is active and a VBUS session | 734 | * as a disconnect (when a VBUS session is active). Not all systems |
| 736 | * is active (the link is powered). | 735 | * support software pullup controls. |
| 736 | * | ||
| 737 | * Following a successful disconnect, invoke the ->disconnect() callback | ||
| 738 | * for the current gadget driver so that UDC drivers don't need to. | ||
| 737 | * | 739 | * |
| 738 | * Returns zero on success, else negative errno. | 740 | * Returns zero on success, else negative errno. |
| 739 | */ | 741 | */ |
| 740 | int usb_gadget_connect(struct usb_gadget *gadget) | 742 | int usb_gadget_disconnect(struct usb_gadget *gadget) |
| 741 | { | ||
| 742 | int ret; | ||
| 743 | |||
| 744 | mutex_lock(&gadget->udc->connect_lock); | ||
| 745 | ret = usb_gadget_connect_locked(gadget); | ||
| 746 | mutex_unlock(&gadget->udc->connect_lock); | ||
| 747 | |||
| 748 | return ret; | ||
| 749 | } | ||
| 750 | EXPORT_SYMBOL_GPL(usb_gadget_connect); | ||
| 751 | |||
| 752 | /* Internal version of usb_gadget_disconnect needs to be called with connect_lock held. */ | ||
| 753 | static int usb_gadget_disconnect_locked(struct usb_gadget *gadget) | ||
| 754 | __must_hold(&gadget->udc->connect_lock) | ||
| 755 | { | 743 | { |
| 756 | int ret = 0; | 744 | int ret = 0; |
| 757 | 745 | ||
| @@ -763,12 +751,10 @@ static int usb_gadget_disconnect_locked(struct usb_gadget *gadget) · 5 unmodified lines | |||
| 763 | if (!gadget->connected) | 751 | if (!gadget->connected) |
| 764 | goto out; | 752 | goto out; |
| 765 | 753 | ||
| 766 | if (gadget->deactivated || !gadget->udc->started) { | 754 | if (gadget->deactivated) { |
| 767 | /* | 755 | /* |
| 768 | * If gadget is deactivated we only save new state. | 756 | * If gadget is deactivated we only save new state. |
| 769 | * Gadget will stay disconnected after activation. | 757 | * Gadget will stay disconnected after activation. |
| 770 | * | ||
| 771 | * udc should have been started before gadget being pulled down. | ||
| 772 | */ | 758 | */ |
| 773 | gadget->connected = false; | 759 | gadget->connected = false; |
| 774 | goto out; | 760 | goto out; |
| @@ -788,30 +774,6 @@ out: · 13 unmodified lines | |||
| 788 | 774 | ||
| 789 | return ret; | 775 | return ret; |
| 790 | } | 776 | } |
| 791 | |||
| 792 | /** | ||
| 793 | * usb_gadget_disconnect - software-controlled disconnect from USB host | ||
| 794 | * @gadget:the peripheral being disconnected | ||
| 795 | * | ||
| 796 | * Disables the D+ (or potentially D-) pullup, which the host may see | ||
| 797 | * as a disconnect (when a VBUS session is active). Not all systems | ||
| 798 | * support software pullup controls. | ||
| 799 | * | ||
| 800 | * Following a successful disconnect, invoke the ->disconnect() callback | ||
| 801 | * for the current gadget driver so that UDC drivers don't need to. | ||
| 802 | * | ||
| 803 | * Returns zero on success, else negative errno. | ||
| 804 | */ | ||
| 805 | int usb_gadget_disconnect(struct usb_gadget *gadget) | ||
| 806 | { | ||
| 807 | int ret; | ||
| 808 | |||
| 809 | mutex_lock(&gadget->udc->connect_lock); | ||
| 810 | ret = usb_gadget_disconnect_locked(gadget); | ||
| 811 | mutex_unlock(&gadget->udc->connect_lock); | ||
| 812 | |||
| 813 | return ret; | ||
| 814 | } | ||
| 815 | EXPORT_SYMBOL_GPL(usb_gadget_disconnect); | 777 | EXPORT_SYMBOL_GPL(usb_gadget_disconnect); |
| 816 | 778 | ||
| 817 | /** | 779 | /** |
| @@ -832,11 +794,10 @@ int usb_gadget_deactivate(struct usb_gadget *gadget) · 14 unmodified lines | |||
| 832 | if (gadget->deactivated) | 794 | if (gadget->deactivated) |
| 833 | goto out; | 795 | goto out; |
| 834 | 796 | ||
| 835 | mutex_lock(&gadget->udc->connect_lock); | ||
| 836 | if (gadget->connected) { | 797 | if (gadget->connected) { |
| 837 | ret = usb_gadget_disconnect_locked(gadget); | 798 | ret = usb_gadget_disconnect(gadget); |
| 838 | if (ret) | 799 | if (ret) |
| 839 | goto unlock; | 800 | goto out; |
| 840 | 801 | ||
| 841 | /* | 802 | /* |
| 842 | * If gadget was being connected before deactivation, we want | 803 | * If gadget was being connected before deactivation, we want |
| @@ -846,8 +807,6 @@ int usb_gadget_deactivate(struct usb_gadget *gadget) · 3 unmodified lines | |||
| 846 | } | 807 | } |
| 847 | gadget->deactivated = true; | 808 | gadget->deactivated = true; |
| 848 | 809 | ||
| 849 | unlock: | ||
| 850 | mutex_unlock(&gadget->udc->connect_lock); | ||
| 851 | out: | 810 | out: |
| 852 | trace_usb_gadget_deactivate(gadget, ret); | 811 | trace_usb_gadget_deactivate(gadget, ret); |
| 853 | 812 | ||
| @@ -871,7 +830,6 @@ int usb_gadget_activate(struct usb_gadget *gadget) · 17 unmodified lines | |||
| 871 | if (!gadget->deactivated) | 830 | if (!gadget->deactivated) |
| 872 | goto out; | 831 | goto out; |
| 873 | 832 | ||
| 874 | mutex_lock(&gadget->udc->connect_lock); | ||
| 875 | gadget->deactivated = false; | 833 | gadget->deactivated = false; |
| 876 | 834 | ||
| 877 | /* | 835 | /* |
| @@ -879,8 +837,7 @@ int usb_gadget_activate(struct usb_gadget *gadget) · 1 unmodified line | |||
| 879 | * while it was being deactivated, we call usb_gadget_connect(). | 837 | * while it was being deactivated, we call usb_gadget_connect(). |
| 880 | */ | 838 | */ |
| 881 | if (gadget->connected) | 839 | if (gadget->connected) |
| 882 | ret = usb_gadget_connect_locked(gadget); | 840 | ret = usb_gadget_connect(gadget); |
| 883 | mutex_unlock(&gadget->udc->connect_lock); | ||
| 884 | 841 | ||
| 885 | out: | 842 | out: |
| 886 | trace_usb_gadget_activate(gadget, ret); | 843 | trace_usb_gadget_activate(gadget, ret); |
| @@ -1121,13 +1078,12 @@ EXPORT_SYMBOL_GPL(usb_gadget_set_state); · 234 unmodified lines | |||
| 1121 | 1078 | ||
| 1122 | /* ------------------------------------------------------------------------- */ | 1079 | /* ------------------------------------------------------------------------- */ |
| 1123 | 1080 | ||
| 1124 | /* Acquire connect_lock before calling this function. */ | 1081 | static void usb_udc_connect_control(struct usb_udc *udc) |
| 1125 | static void usb_udc_connect_control_locked(struct usb_udc *udc) __must_hold(&udc->connect_lock) | ||
| 1126 | { | 1082 | { |
| 1127 | if (udc->vbus && udc->started) | 1083 | if (udc->vbus) |
| 1128 | usb_gadget_connect_locked(udc->gadget); | 1084 | usb_gadget_connect(udc->gadget); |
| 1129 | else | 1085 | else |
| 1130 | usb_gadget_disconnect_locked(udc->gadget); | 1086 | usb_gadget_disconnect(udc->gadget); |
| 1131 | } | 1087 | } |
| 1132 | 1088 | ||
| 1133 | /** | 1089 | /** |
| @@ -1143,12 +1099,10 @@ void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status) · 9 unmodified lines | |||
| 1143 | { | 1099 | { |
| 1144 | struct usb_udc *udc = gadget->udc; | 1100 | struct usb_udc *udc = gadget->udc; |
| 1145 | 1101 | ||
| 1146 | mutex_lock(&udc->connect_lock); | ||
| 1147 | if (udc) { | 1102 | if (udc) { |
| 1148 | udc->vbus = status; | 1103 | udc->vbus = status; |
| 1149 | usb_udc_connect_control_locked(udc); | 1104 | usb_udc_connect_control(udc); |
| 1150 | } | 1105 | } |
| 1151 | mutex_unlock(&udc->connect_lock); | ||
| 1152 | } | 1106 | } |
| 1153 | EXPORT_SYMBOL_GPL(usb_udc_vbus_handler); | 1107 | EXPORT_SYMBOL_GPL(usb_udc_vbus_handler); |
| 1154 | 1108 | ||
| @@ -1170,7 +1124,7 @@ void usb_gadget_udc_reset(struct usb_gadget *gadget, · 15 unmodified lines | |||
| 1170 | EXPORT_SYMBOL_GPL(usb_gadget_udc_reset); | 1124 | EXPORT_SYMBOL_GPL(usb_gadget_udc_reset); |
| 1171 | 1125 | ||
| 1172 | /** | 1126 | /** |
| 1173 | * usb_gadget_udc_start_locked - tells usb device controller to start up | 1127 | * usb_gadget_udc_start - tells usb device controller to start up |
| 1174 | * @udc: The UDC to be started | 1128 | * @udc: The UDC to be started |
| 1175 | * | 1129 | * |
| 1176 | * This call is issued by the UDC Class driver when it's about | 1130 | * This call is issued by the UDC Class driver when it's about |
| @@ -1181,11 +1135,8 @@ EXPORT_SYMBOL_GPL(usb_gadget_udc_reset); · 4 unmodified lines | |||
| 1181 | * necessary to have it powered on. | 1135 | * necessary to have it powered on. |
| 1182 | * | 1136 | * |
| 1183 | * Returns zero on success, else negative errno. | 1137 | * Returns zero on success, else negative errno. |
| 1184 | * | ||
| 1185 | * Caller should acquire connect_lock before invoking this function. | ||
| 1186 | */ | 1138 | */ |
| 1187 | static inline int usb_gadget_udc_start_locked(struct usb_udc *udc) | 1139 | static inline int usb_gadget_udc_start(struct usb_udc *udc) |
| 1188 | __must_hold(&udc->connect_lock) | ||
| 1189 | { | 1140 | { |
| 1190 | int ret; | 1141 | int ret; |
| 1191 | 1142 | ||
| @@ -1202,7 +1153,7 @@ static inline int usb_gadget_udc_start_locked(struct usb_udc *udc) · 10 unmodified lines | |||
| 1202 | } | 1153 | } |
| 1203 | 1154 | ||
| 1204 | /** | 1155 | /** |
| 1205 | * usb_gadget_udc_stop_locked - tells usb device controller we don't need it anymore | 1156 | * usb_gadget_udc_stop - tells usb device controller we don't need it anymore |
| 1206 | * @udc: The UDC to be stopped | 1157 | * @udc: The UDC to be stopped |
| 1207 | * | 1158 | * |
| 1208 | * This call is issued by the UDC Class driver after calling | 1159 | * This call is issued by the UDC Class driver after calling |
| @@ -1211,11 +1162,8 @@ static inline int usb_gadget_udc_start_locked(struct usb_udc *udc) · 2 unmodified lines | |||
| 1211 | * The details are implementation specific, but it can go as | 1162 | * The details are implementation specific, but it can go as |
| 1212 | * far as powering off UDC completely and disable its data | 1163 | * far as powering off UDC completely and disable its data |
| 1213 | * line pullups. | 1164 | * line pullups. |
| 1214 | * | ||
| 1215 | * Caller should acquire connect lock before invoking this function. | ||
| 1216 | */ | 1165 | */ |
| 1217 | static inline void usb_gadget_udc_stop_locked(struct usb_udc *udc) | 1166 | static inline void usb_gadget_udc_stop(struct usb_udc *udc) |
| 1218 | __must_hold(&udc->connect_lock) | ||
| 1219 | { | 1167 | { |
| 1220 | if (!udc->started) { | 1168 | if (!udc->started) { |
| 1221 | dev_err(&udc->dev, "UDC had already stopped\n"); | 1169 | dev_err(&udc->dev, "UDC had already stopped\n"); |
| @@ -1374,7 +1322,6 @@ int usb_add_gadget(struct usb_gadget *gadget) · 152 unmodified lines | |||
| 1374 | 1322 | ||
| 1375 | udc->gadget = gadget; | 1323 | udc->gadget = gadget; |
| 1376 | gadget->udc = udc; | 1324 | gadget->udc = udc; |
| 1377 | mutex_init(&udc->connect_lock); | ||
| 1378 | 1325 | ||
| 1379 | udc->started = false; | 1326 | udc->started = false; |
| 1380 | 1327 | ||
| @@ -1576,15 +1523,11 @@ static int gadget_bind_driver(struct device *dev) · 195 unmodified lines | |||
| 1576 | if (ret) | 1523 | if (ret) |
| 1577 | goto err_bind; | 1524 | goto err_bind; |
| 1578 | 1525 | ||
| 1579 | mutex_lock(&udc->connect_lock); | 1526 | ret = usb_gadget_udc_start(udc); |
| 1580 | ret = usb_gadget_udc_start_locked(udc); | 1527 | if (ret) |
| 1581 | if (ret) { | ||
| 1582 | mutex_unlock(&udc->connect_lock); | ||
| 1583 | goto err_start; | 1528 | goto err_start; |
| 1584 | } | ||
| 1585 | usb_gadget_enable_async_callbacks(udc); | 1529 | usb_gadget_enable_async_callbacks(udc); |
| 1586 | usb_udc_connect_control_locked(udc); | 1530 | usb_udc_connect_control(udc); |
| 1587 | mutex_unlock(&udc->connect_lock); | ||
| 1588 | 1531 | ||
| 1589 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); | 1532 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); |
| 1590 | return 0; | 1533 | return 0; |
| @@ -1615,14 +1558,12 @@ static void gadget_unbind_driver(struct device *dev) · 24 unmodified lines | |||
| 1615 | 1558 | ||
| 1616 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); | 1559 | kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); |
| 1617 | 1560 | ||
| 1618 | mutex_lock(&udc->connect_lock); | 1561 | usb_gadget_disconnect(gadget); |
| 1619 | usb_gadget_disconnect_locked(gadget); | ||
| 1620 | usb_gadget_disable_async_callbacks(udc); | 1562 | usb_gadget_disable_async_callbacks(udc); |
| 1621 | if (gadget->irq) | 1563 | if (gadget->irq) |
| 1622 | synchronize_irq(gadget->irq); | 1564 | synchronize_irq(gadget->irq); |
| 1623 | udc->driver->unbind(gadget); | 1565 | udc->driver->unbind(gadget); |
| 1624 | usb_gadget_udc_stop_locked(udc); | 1566 | usb_gadget_udc_stop(udc); |
| 1625 | mutex_unlock(&udc->connect_lock); | ||
| 1626 | 1567 | ||
| 1627 | mutex_lock(&udc_lock); | 1568 | mutex_lock(&udc_lock); |
| 1628 | driver->is_bound = false; | 1569 | driver->is_bound = false; |
| @@ -1708,15 +1649,11 @@ static ssize_t soft_connect_store(struct device *dev, · 79 unmodified lines | |||
| 1708 | } | 1649 | } |
| 1709 | 1650 | ||
| 1710 | if (sysfs_streq(buf, "connect")) { | 1651 | if (sysfs_streq(buf, "connect")) { |
| 1711 | mutex_lock(&udc->connect_lock); | 1652 | usb_gadget_udc_start(udc); |
| 1712 | usb_gadget_udc_start_locked(udc); | 1653 | usb_gadget_connect(udc->gadget); |
| 1713 | usb_gadget_connect_locked(udc->gadget); | ||
| 1714 | mutex_unlock(&udc->connect_lock); | ||
| 1715 | } else if (sysfs_streq(buf, "disconnect")) { | 1654 | } else if (sysfs_streq(buf, "disconnect")) { |
| 1716 | mutex_lock(&udc->connect_lock); | 1655 | usb_gadget_disconnect(udc->gadget); |
| 1717 | usb_gadget_disconnect_locked(udc->gadget); | 1656 | usb_gadget_udc_stop(udc); |
| 1718 | usb_gadget_udc_stop_locked(udc); | ||
| 1719 | mutex_unlock(&udc->connect_lock); | ||
| 1720 | } else { | 1657 | } else { |
| 1721 | dev_err(dev, "unsupported command '%s'\n", buf); | 1658 | dev_err(dev, "unsupported command '%s'\n", buf); |
| 1722 | ret = -EINVAL; | 1659 | ret = -EINVAL; |
| @@ -119,11 +119,13 @@ static int uhci_pci_init(struct usb_hcd *hcd) · 118 unmodified lines | |||
| 119 | 119 | ||
| 120 | uhci->rh_numports = uhci_count_ports(hcd); | 120 | uhci->rh_numports = uhci_count_ports(hcd); |
| 121 | 121 | ||
| 122 | /* Intel controllers report the OverCurrent bit active on. | 122 | /* |
| 123 | * VIA controllers report it active off, so we'll adjust the | 123 | * Intel controllers report the OverCurrent bit active on. VIA |
| 124 | * bit value. (It's not standardized in the UHCI spec.) | 124 | * and ZHAOXIN controllers report it active off, so we'll adjust |
| 125 | * the bit value. (It's not standardized in the UHCI spec.) | ||
| 125 | */ | 126 | */ |
| 126 | if (to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_VIA) | 127 | if (to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_VIA || |
| 128 | to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_ZHAOXIN) | ||
| 127 | uhci->oc_low = 1; | 129 | uhci->oc_low = 1; |
| 128 | 130 | ||
| 129 | /* HP's server management chip requires a longer port reset delay. */ | 131 | /* HP's server management chip requires a longer port reset delay. */ |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
| 15 | #include <linux/reset.h> | 15 | #include <linux/reset.h> |
| 16 | #include <linux/suspend.h> | ||
| 16 | 17 | ||
| 17 | #include "xhci.h" | 18 | #include "xhci.h" |
| 18 | #include "xhci-trace.h" | 19 | #include "xhci-trace.h" |
| @@ -387,7 +388,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 368 unmodified lines | |||
| 387 | 388 | ||
| 388 | if (pdev->vendor == PCI_VENDOR_ID_AMD && | 389 | if (pdev->vendor == PCI_VENDOR_ID_AMD && |
| 389 | pdev->device == PCI_DEVICE_ID_AMD_RENOIR_XHCI) | 390 | pdev->device == PCI_DEVICE_ID_AMD_RENOIR_XHCI) |
| 390 | xhci->quirks |= XHCI_BROKEN_D3COLD; | 391 | xhci->quirks |= XHCI_BROKEN_D3COLD_S2I; |
| 391 | 392 | ||
| 392 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 393 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
| 393 | xhci->quirks |= XHCI_LPM_SUPPORT; | 394 | xhci->quirks |= XHCI_LPM_SUPPORT; |
| @@ -801,9 +802,16 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) · 407 unmodified lines | |||
| 801 | * Systems with the TI redriver that loses port status change events | 802 | * Systems with the TI redriver that loses port status change events |
| 802 | * need to have the registers polled during D3, so avoid D3cold. | 803 | * need to have the registers polled during D3, so avoid D3cold. |
| 803 | */ | 804 | */ |
| 804 | if (xhci->quirks & (XHCI_COMP_MODE_QUIRK | XHCI_BROKEN_D3COLD)) | 805 | if (xhci->quirks & XHCI_COMP_MODE_QUIRK) |
| 805 | pci_d3cold_disable(pdev); | 806 | pci_d3cold_disable(pdev); |
| 806 | 807 | ||
| 808 | #ifdef CONFIG_SUSPEND | ||
| 809 | /* d3cold is broken, but only when s2idle is used */ | ||
| 810 | if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE && | ||
| 811 | xhci->quirks & (XHCI_BROKEN_D3COLD_S2I)) | ||
| 812 | pci_d3cold_disable(pdev); | ||
| 813 | #endif | ||
| 814 | |||
| 807 | if (xhci->quirks & XHCI_PME_STUCK_QUIRK) | 815 | if (xhci->quirks & XHCI_PME_STUCK_QUIRK) |
| 808 | xhci_pme_quirk(hcd); | 816 | xhci_pme_quirk(hcd); |
| 809 | 817 | ||
| @@ -276,6 +276,26 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, · 275 unmodified lines | |||
| 276 | trace_xhci_inc_enq(ring); | 276 | trace_xhci_inc_enq(ring); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | static int xhci_num_trbs_to(struct xhci_segment *start_seg, union xhci_trb *start, | ||
| 280 | struct xhci_segment *end_seg, union xhci_trb *end, | ||
| 281 | unsigned int num_segs) | ||
| 282 | { | ||
| 283 | union xhci_trb *last_on_seg; | ||
| 284 | int num = 0; | ||
| 285 | int i = 0; | ||
| 286 | |||
| 287 | do { | ||
| 288 | if (start_seg == end_seg && end >= start) | ||
| 289 | return num + (end - start); | ||
| 290 | last_on_seg = &start_seg->trbs[TRBS_PER_SEGMENT - 1]; | ||
| 291 | num += last_on_seg - start; | ||
| 292 | start_seg = start_seg->next; | ||
| 293 | start = start_seg->trbs; | ||
| 294 | } while (i++ <= num_segs); | ||
| 295 | |||
| 296 | return -EINVAL; | ||
| 297 | } | ||
| 298 | |||
| 279 | /* | 299 | /* |
| 280 | * Check to see if there's room to enqueue num_trbs on the ring and make sure | 300 | * Check to see if there's room to enqueue num_trbs on the ring and make sure |
| 281 | * enqueue pointer will not advance into dequeue segment. See rules above. | 301 | * enqueue pointer will not advance into dequeue segment. See rules above. |
| @@ -2140,6 +2160,7 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, · 1858 unmodified lines | |||
| 2140 | u32 trb_comp_code) | 2160 | u32 trb_comp_code) |
| 2141 | { | 2161 | { |
| 2142 | struct xhci_ep_ctx *ep_ctx; | 2162 | struct xhci_ep_ctx *ep_ctx; |
| 2163 | int trbs_freed; | ||
| 2143 | 2164 | ||
| 2144 | ep_ctx = xhci_get_ep_ctx(xhci, ep->vdev->out_ctx, ep->ep_index); | 2165 | ep_ctx = xhci_get_ep_ctx(xhci, ep->vdev->out_ctx, ep->ep_index); |
| 2145 | 2166 | ||
| @@ -2209,9 +2230,15 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, · 63 unmodified lines | |||
| 2209 | } | 2230 | } |
| 2210 | 2231 | ||
| 2211 | /* Update ring dequeue pointer */ | 2232 | /* Update ring dequeue pointer */ |
| 2233 | trbs_freed = xhci_num_trbs_to(ep_ring->deq_seg, ep_ring->dequeue, | ||
| 2234 | td->last_trb_seg, td->last_trb, | ||
| 2235 | ep_ring->num_segs); | ||
| 2236 | if (trbs_freed < 0) | ||
| 2237 | xhci_dbg(xhci, "Failed to count freed trbs at TD finish\n"); | ||
| 2238 | else | ||
| 2239 | ep_ring->num_trbs_free += trbs_freed; | ||
| 2212 | ep_ring->dequeue = td->last_trb; | 2240 | ep_ring->dequeue = td->last_trb; |
| 2213 | ep_ring->deq_seg = td->last_trb_seg; | 2241 | ep_ring->deq_seg = td->last_trb_seg; |
| 2214 | ep_ring->num_trbs_free += td->num_trbs - 1; | ||
| 2215 | inc_deq(xhci, ep_ring); | 2242 | inc_deq(xhci, ep_ring); |
| 2216 | 2243 | ||
| 2217 | return xhci_td_cleanup(xhci, td, ep_ring, td->status); | 2244 | return xhci_td_cleanup(xhci, td, ep_ring, td->status); |
| @@ -1901,7 +1901,7 @@ struct xhci_hcd { · 1900 unmodified lines | |||
| 1901 | #define XHCI_DISABLE_SPARSE BIT_ULL(38) | 1901 | #define XHCI_DISABLE_SPARSE BIT_ULL(38) |
| 1902 | #define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39) | 1902 | #define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39) |
| 1903 | #define XHCI_NO_SOFT_RETRY BIT_ULL(40) | 1903 | #define XHCI_NO_SOFT_RETRY BIT_ULL(40) |
| 1904 | #define XHCI_BROKEN_D3COLD BIT_ULL(41) | 1904 | #define XHCI_BROKEN_D3COLD_S2I BIT_ULL(41) |
| 1905 | #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) | 1905 | #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) |
| 1906 | #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) | 1906 | #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) |
| 1907 | #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) | 1907 | #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) |
| @@ -406,22 +406,25 @@ static DEF_SCSI_QCMD(queuecommand) · 405 unmodified lines | |||
| 406 | ***********************************************************************/ | 406 | ***********************************************************************/ |
| 407 | 407 | ||
| 408 | /* Command timeout and abort */ | 408 | /* Command timeout and abort */ |
| 409 | static int command_abort(struct scsi_cmnd *srb) | 409 | static int command_abort_matching(struct us_data *us, struct scsi_cmnd *srb_match) |
| 410 | { | 410 | { |
| 411 | struct us_data *us = host_to_us(srb->device->host); | ||
| 412 | |||
| 413 | usb_stor_dbg(us, "%s called\n", __func__); | ||
| 414 | |||
| 415 | /* | 411 | /* |
| 416 | * us->srb together with the TIMED_OUT, RESETTING, and ABORTING | 412 | * us->srb together with the TIMED_OUT, RESETTING, and ABORTING |
| 417 | * bits are protected by the host lock. | 413 | * bits are protected by the host lock. |
| 418 | */ | 414 | */ |
| 419 | scsi_lock(us_to_host(us)); | 415 | scsi_lock(us_to_host(us)); |
| 420 | 416 | ||
| 421 | /* Is this command still active? */ | 417 | /* is there any active pending command to abort ? */ |
| 422 | if (us->srb != srb) { | 418 | if (!us->srb) { |
| 423 | scsi_unlock(us_to_host(us)); | 419 | scsi_unlock(us_to_host(us)); |
| 424 | usb_stor_dbg(us, "-- nothing to abort\n"); | 420 | usb_stor_dbg(us, "-- nothing to abort\n"); |
| 421 | return SUCCESS; | ||
| 422 | } | ||
| 423 | |||
| 424 | /* Does the command match the passed srb if any ? */ | ||
| 425 | if (srb_match && us->srb != srb_match) { | ||
| 426 | scsi_unlock(us_to_host(us)); | ||
| 427 | usb_stor_dbg(us, "-- pending command mismatch\n"); | ||
| 425 | return FAILED; | 428 | return FAILED; |
| 426 | } | 429 | } |
| 427 | 430 | ||
| @@ -444,6 +447,14 @@ static int command_abort(struct scsi_cmnd *srb) · 16 unmodified lines | |||
| 444 | return SUCCESS; | 447 | return SUCCESS; |
| 445 | } | 448 | } |
| 446 | 449 | ||
| 450 | static int command_abort(struct scsi_cmnd *srb) | ||
| 451 | { | ||
| 452 | struct us_data *us = host_to_us(srb->device->host); | ||
| 453 | |||
| 454 | usb_stor_dbg(us, "%s called\n", __func__); | ||
| 455 | return command_abort_matching(us, srb); | ||
| 456 | } | ||
| 457 | |||
| 447 | /* | 458 | /* |
| 448 | * This invokes the transport reset mechanism to reset the state of the | 459 | * This invokes the transport reset mechanism to reset the state of the |
| 449 | * device | 460 | * device |
| @@ -455,6 +466,9 @@ static int device_reset(struct scsi_cmnd *srb) · 5 unmodified lines | |||
| 455 | 466 | ||
| 456 | usb_stor_dbg(us, "%s called\n", __func__); | 467 | usb_stor_dbg(us, "%s called\n", __func__); |
| 457 | 468 | ||
| 469 | /* abort any pending command before reset */ | ||
| 470 | command_abort_matching(us, NULL); | ||
| 471 | |||
| 458 | /* lock the device pointers and do the reset */ | 472 | /* lock the device pointers and do the reset */ |
| 459 | mutex_lock(&(us->dev_mutex)); | 473 | mutex_lock(&(us->dev_mutex)); |
| 460 | result = us->transport_reset(us); | 474 | result = us->transport_reset(us); |
| @@ -516,6 +516,10 @@ static ssize_t pin_assignment_show(struct device *dev, · 515 unmodified lines | |||
| 516 | 516 | ||
| 517 | mutex_unlock(&dp->lock); | 517 | mutex_unlock(&dp->lock); |
| 518 | 518 | ||
| 519 | /* get_current_pin_assignments can return 0 when no matching pin assignments are found */ | ||
| 520 | if (len == 0) | ||
| 521 | len++; | ||
| 522 | |||
| 519 | buf[len - 1] = '\n'; | 523 | buf[len - 1] = '\n'; |
| 520 | return len; | 524 | return len; |
| 521 | } | 525 | } |
| @@ -886,6 +886,9 @@ static void tps6598x_remove(struct i2c_client *client) · 885 unmodified lines | |||
| 886 | { | 886 | { |
| 887 | struct tps6598x *tps = i2c_get_clientdata(client); | 887 | struct tps6598x *tps = i2c_get_clientdata(client); |
| 888 | 888 | ||
| 889 | if (!client->irq) | ||
| 890 | cancel_delayed_work_sync(&tps->wq_poll); | ||
| 891 | |||
| 889 | tps6598x_disconnect(tps, 0); | 892 | tps6598x_disconnect(tps, 0); |
| 890 | typec_unregister_port(tps->port); | 893 | typec_unregister_port(tps->port); |
| 891 | usb_role_switch_put(tps->role_sw); | 894 | usb_role_switch_put(tps->role_sw); |
| @@ -74,6 +74,7 @@ struct class { · 73 unmodified lines | |||
| 74 | struct class_dev_iter { | 74 | struct class_dev_iter { |
| 75 | struct klist_iter ki; | 75 | struct klist_iter ki; |
| 76 | const struct device_type *type; | 76 | const struct device_type *type; |
| 77 | struct subsys_private *sp; | ||
| 77 | }; | 78 | }; |
| 78 | 79 | ||
| 79 | int __must_check class_register(const struct class *class); | 80 | int __must_check class_register(const struct class *class); |
| @@ -443,7 +443,7 @@ static inline struct usb_composite_driver *to_cdriver( · 442 unmodified lines | |||
| 443 | * @bcd_webusb_version: 0x0100 by default, WebUSB specification version | 443 | * @bcd_webusb_version: 0x0100 by default, WebUSB specification version |
| 444 | * @b_webusb_vendor_code: 0x0 by default, vendor code for WebUSB | 444 | * @b_webusb_vendor_code: 0x0 by default, vendor code for WebUSB |
| 445 | * @landing_page: empty by default, landing page to announce in WebUSB | 445 | * @landing_page: empty by default, landing page to announce in WebUSB |
| 446 | * @use_webusb:: false by default, interested gadgets set it | 446 | * @use_webusb: false by default, interested gadgets set it |
| 447 | * @os_desc_config: the configuration to be used with OS descriptors | 447 | * @os_desc_config: the configuration to be used with OS descriptors |
| 448 | * @setup_pending: true when setup request is queued but not completed | 448 | * @setup_pending: true when setup request is queued but not completed |
| 449 | * @os_desc_pending: true when os_desc request is queued but not completed | 449 | * @os_desc_pending: true when os_desc request is queued but not completed |