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

USB: r8a66597-hcd: fix usb device connection timing

Fix the problem that enumeration of a USB device was slow.

Signed-off-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Yoshihiro Shimoda and committed by
Greg Kroah-Hartman
29fab0cd 6d879107

+34 -25
+32 -24
drivers/usb/host/r8a66597-hcd.c
··· 900 900 } 901 901 902 902 /* this function must be called with interrupt disabled */ 903 - static void r8a66597_usb_preconnect(struct r8a66597 *r8a66597, int port) 903 + static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port, 904 + u16 syssts) 904 905 { 905 - r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) 906 - | (1 << USB_PORT_FEAT_C_CONNECTION); 906 + if (syssts == SE0) { 907 + r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); 908 + return; 909 + } 910 + 911 + if (syssts == FS_JSTS) 912 + r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); 913 + else if (syssts == LS_JSTS) 914 + r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); 915 + 907 916 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); 908 917 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); 909 918 } ··· 1487 1478 } 1488 1479 } 1489 1480 1481 + static void r8a66597_root_hub_start_polling(struct r8a66597 *r8a66597) 1482 + { 1483 + mod_timer(&r8a66597->rh_timer, 1484 + jiffies + msecs_to_jiffies(R8A66597_RH_POLL_TIME)); 1485 + } 1486 + 1490 1487 static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port) 1491 1488 { 1492 1489 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; 1493 1490 1494 1491 rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; 1495 1492 rh->scount = R8A66597_MAX_SAMPLING; 1496 - mod_timer(&r8a66597->rh_timer, jiffies + msecs_to_jiffies(50)); 1493 + r8a66597->root_hub[port].port |= (1 << USB_PORT_FEAT_CONNECTION) 1494 + | (1 << USB_PORT_FEAT_C_CONNECTION); 1495 + r8a66597_root_hub_start_polling(r8a66597); 1497 1496 } 1498 1497 1499 1498 static irqreturn_t r8a66597_irq(struct usb_hcd *hcd) ··· 1588 1571 if ((tmp & USBRST) == USBRST) { 1589 1572 r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, 1590 1573 dvstctr_reg); 1591 - mod_timer(&r8a66597->rh_timer, 1592 - jiffies + msecs_to_jiffies(50)); 1574 + r8a66597_root_hub_start_polling(r8a66597); 1593 1575 } else 1594 1576 r8a66597_usb_connect(r8a66597, port); 1577 + } 1578 + 1579 + if (!(rh->port & (1 << USB_PORT_FEAT_CONNECTION))) { 1580 + r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port)); 1581 + r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); 1595 1582 } 1596 1583 1597 1584 if (rh->scount > 0) { 1598 1585 tmp = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; 1599 1586 if (tmp == rh->old_syssts) { 1600 1587 rh->scount--; 1601 - if (rh->scount == 0) { 1602 - if (tmp == FS_JSTS) { 1603 - r8a66597_bset(r8a66597, HSE, 1604 - get_syscfg_reg(port)); 1605 - r8a66597_usb_preconnect(r8a66597, port); 1606 - } else if (tmp == LS_JSTS) { 1607 - r8a66597_bclr(r8a66597, HSE, 1608 - get_syscfg_reg(port)); 1609 - r8a66597_usb_preconnect(r8a66597, port); 1610 - } else if (tmp == SE0) 1611 - r8a66597_bset(r8a66597, ATTCHE, 1612 - get_intenb_reg(port)); 1613 - } else { 1614 - mod_timer(&r8a66597->rh_timer, 1615 - jiffies + msecs_to_jiffies(50)); 1616 - } 1588 + if (rh->scount == 0) 1589 + r8a66597_check_syssts(r8a66597, port, tmp); 1590 + else 1591 + r8a66597_root_hub_start_polling(r8a66597); 1617 1592 } else { 1618 1593 rh->scount = R8A66597_MAX_SAMPLING; 1619 1594 rh->old_syssts = tmp; 1620 - mod_timer(&r8a66597->rh_timer, 1621 - jiffies + msecs_to_jiffies(50)); 1595 + r8a66597_root_hub_start_polling(r8a66597); 1622 1596 } 1623 1597 } 1624 1598 }
+2 -1
drivers/usb/host/r8a66597.h
··· 396 396 #define R8A66597_BUF_BSIZE 8 397 397 #define R8A66597_MAX_DEVICE 10 398 398 #define R8A66597_MAX_ROOT_HUB 2 399 - #define R8A66597_MAX_SAMPLING 10 399 + #define R8A66597_MAX_SAMPLING 5 400 + #define R8A66597_RH_POLL_TIME 10 400 401 #define R8A66597_MAX_DMA_CHANNEL 2 401 402 #define R8A66597_PIPE_NO_DMA R8A66597_MAX_DMA_CHANNEL 402 403 #define check_bulk_or_isoc(pipenum) ((pipenum >= 1 && pipenum <= 5))