Merge remote-tracking branch 'stable/linux-4.19.y' into rpi-4.19.y
authorpopcornmix <popcornmix@gmail.com>
Mon, 11 Nov 2019 15:58:41 +0000 (15:58 +0000)
committerpopcornmix <popcornmix@gmail.com>
Mon, 11 Nov 2019 15:58:41 +0000 (15:58 +0000)
1  2 
arch/arm64/kernel/armv8_deprecated.c
drivers/hid/hid-ids.h
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/usb/lan78xx.c
drivers/rtc/rtc-pcf8523.c
drivers/usb/core/hub.c

@@@ -177,20 -177,18 +177,23 @@@ static void __init register_insn_emulat
        struct insn_emulation *insn;
  
        insn = kzalloc(sizeof(*insn), GFP_KERNEL);
+       if (!insn)
+               return;
        insn->ops = ops;
        insn->min = INSN_UNDEF;
  
        switch (ops->status) {
        case INSN_DEPRECATED:
 +#if 0
                insn->current_mode = INSN_EMULATE;
                /* Disable the HW mode if it was turned on at early boot time */
                run_all_cpu_set_hw_mode(insn, false);
 +#else
 +              insn->current_mode = INSN_HW;
 +              run_all_cpu_set_hw_mode(insn, true);
                insn->max = INSN_HW;
 +#endif
                break;
        case INSN_OBSOLETE:
                insn->current_mode = INSN_UNDEF;
@@@ -241,6 -239,8 +244,8 @@@ static void __init register_insn_emulat
  
        insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
                               GFP_KERNEL);
+       if (!insns_sysctl)
+               return;
  
        raw_spin_lock_irqsave(&insn_emulation_lock, flags);
        list_for_each_entry(insn, &insn_emulation, node) {
diff --combined drivers/hid/hid-ids.h
  #define USB_VENDOR_ID_BAANTO          0x2453
  #define USB_DEVICE_ID_BAANTO_MT_190W2 0x0100
  
 +#define USB_VENDOR_ID_BEKEN           0x25a7
 +#define USB_DEVICE_ID_AIRMOUSE_T3     0x2402
 +
  #define USB_VENDOR_ID_BELKIN          0x050d
  #define USB_DEVICE_ID_FLIP_KVM                0x3201
  
  #define USB_VENDOR_ID_BETOP_2185V2PC  0x8380
  #define USB_VENDOR_ID_BETOP_2185V2BFM 0x20bc
  
 +#define USB_VENDOR_ID_BIGBEN  0x146b
 +#define USB_DEVICE_ID_BIGBEN_PS3OFMINIPAD     0x0902
 +
  #define USB_VENDOR_ID_BTC             0x046e
  #define USB_DEVICE_ID_BTC_EMPREX_REMOTE       0x5578
  #define USB_DEVICE_ID_BTC_EMPREX_REMOTE_2     0x5577
  #define USB_VENDOR_ID_LG              0x1fd2
  #define USB_DEVICE_ID_LG_MULTITOUCH   0x0064
  #define USB_DEVICE_ID_LG_MELFAS_MT    0x6007
+ #define I2C_DEVICE_ID_LG_8001         0x8001
  
  #define USB_VENDOR_ID_LOGITECH                0x046d
  #define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
  #define USB_VENDOR_ID_XAT     0x2505
  #define USB_DEVICE_ID_XAT_CSR 0x0220
  
 +#define USB_VENDOR_ID_XENTA                   0x1d57
 +#define USB_DEVICE_ID_AIRMOUSE_MX3            0xad03
 +
  #define USB_VENDOR_ID_XIN_MO                  0x16c0
  #define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE      0x05e1
  #define USB_DEVICE_ID_THT_2P_ARCADE           0x75e1
  #define GENET_RDMA_REG_OFF    (priv->hw_params->rdma_offset + \
                                TOTAL_DESC * DMA_DESC_SIZE)
  
 +static bool skip_umac_reset = true;
 +module_param(skip_umac_reset, bool, 0444);
 +MODULE_PARM_DESC(skip_umac_reset, "Skip UMAC reset step");
 +
  static inline void bcmgenet_writel(u32 value, void __iomem *offset)
  {
        /* MIPS chips strapped for BE will automagically configure the
@@@ -1997,11 -1993,6 +1997,11 @@@ static void reset_umac(struct bcmgenet_
        bcmgenet_rbuf_ctrl_set(priv, 0);
        udelay(10);
  
 +      if (skip_umac_reset) {
 +              pr_warn("Skipping UMAC reset\n");
 +              return;
 +      }
 +
        /* disable MAC while updating its registers */
        bcmgenet_umac_writel(priv, 0, UMAC_CMD);
  
@@@ -2029,6 -2020,8 +2029,8 @@@ static void bcmgenet_link_intr_enable(s
         */
        if (priv->internal_phy) {
                int0_enable |= UMAC_IRQ_LINK_EVENT;
+               if (GENET_IS_V1(priv) || GENET_IS_V2(priv) || GENET_IS_V3(priv))
+                       int0_enable |= UMAC_IRQ_PHY_DET_R;
        } else if (priv->ext_phy) {
                int0_enable |= UMAC_IRQ_LINK_EVENT;
        } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
@@@ -2156,7 -2149,7 +2158,7 @@@ static void bcmgenet_init_tx_ring(struc
  
        bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_PROD_INDEX);
        bcmgenet_tdma_ring_writel(priv, index, 0, TDMA_CONS_INDEX);
 -      bcmgenet_tdma_ring_writel(priv, index, 1, DMA_MBUF_DONE_THRESH);
 +      bcmgenet_tdma_ring_writel(priv, index, 10, DMA_MBUF_DONE_THRESH);
        /* Disable rate control for now */
        bcmgenet_tdma_ring_writel(priv, index, flow_period_val,
                                  TDMA_FLOW_PERIOD);
@@@ -2627,11 -2620,14 +2629,14 @@@ static void bcmgenet_irq_task(struct wo
        priv->irq0_stat = 0;
        spin_unlock_irq(&priv->lock);
  
+       if (status & UMAC_IRQ_PHY_DET_R &&
+           priv->dev->phydev->autoneg != AUTONEG_ENABLE)
+               phy_init_hw(priv->dev->phydev);
        /* Link UP/DOWN event */
-       if (status & UMAC_IRQ_LINK_EVENT) {
-               priv->dev->phydev->link = !!(status & UMAC_IRQ_LINK_UP);
+       if (status & UMAC_IRQ_LINK_EVENT)
                phy_mac_interrupt(priv->dev->phydev);
-       }
  }
  
  /* bcmgenet_isr1: handle Rx and Tx priority queues */
@@@ -2726,7 -2722,7 +2731,7 @@@ static irqreturn_t bcmgenet_isr0(int ir
        }
  
        /* all other interested interrupts handled in bottom half */
-       status &= UMAC_IRQ_LINK_EVENT;
+       status &= (UMAC_IRQ_LINK_EVENT | UMAC_IRQ_PHY_DET_R);
        if (status) {
                /* Save irq status for bottom-half processing. */
                spin_lock_irqsave(&priv->lock, flags);
@@@ -3580,12 -3576,9 +3585,12 @@@ static int bcmgenet_probe(struct platfo
        netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1);
  
        /* Set default coalescing parameters */
 -      for (i = 0; i < priv->hw_params->rx_queues; i++)
 +      for (i = 0; i < priv->hw_params->rx_queues; i++) {
                priv->rx_rings[i].rx_max_coalesced_frames = 1;
 +              priv->rx_rings[i].rx_coalesce_usecs = 50;
 +      }
        priv->rx_rings[DESC_INDEX].rx_max_coalesced_frames = 1;
 +      priv->rx_rings[DESC_INDEX].rx_coalesce_usecs = 50;
  
        /* libphy will determine the link state */
        netif_carrier_off(dev);
@@@ -439,20 -439,6 +439,20 @@@ static int msg_level = -1
  module_param(msg_level, int, 0);
  MODULE_PARM_DESC(msg_level, "Override default message level");
  
 +/* TSO seems to be having some issue with Selective Acknowledge (SACK) that
 + * results in lost data never being retransmitted.
 + * Disable it by default now, but adds a module parameter to enable it for
 + * debug purposes (the full cause is not currently understood).
 + */
 +static bool enable_tso;
 +module_param(enable_tso, bool, 0644);
 +MODULE_PARM_DESC(enable_tso, "Enables TCP segmentation offload");
 +
 +#define INT_URB_MICROFRAMES_PER_MS    8
 +static int int_urb_interval_ms = 8;
 +module_param(int_urb_interval_ms, int, 0);
 +MODULE_PARM_DESC(int_urb_interval_ms, "Override usb interrupt urb interval");
 +
  static int lan78xx_read_reg(struct lan78xx_net *dev, u32 index, u32 *data)
  {
        u32 *buf = kmalloc(sizeof(u32), GFP_KERNEL);
@@@ -1292,8 -1278,11 +1292,11 @@@ static void lan78xx_status(struct lan78
                netif_dbg(dev, link, dev->net, "PHY INTR: 0x%08x\n", intdata);
                lan78xx_defer_kevent(dev, EVENT_LINK_RESET);
  
-               if (dev->domain_data.phyirq > 0)
+               if (dev->domain_data.phyirq > 0) {
+                       local_irq_disable();
                        generic_handle_irq(dev->domain_data.phyirq);
+                       local_irq_enable();
+               }
        } else
                netdev_warn(dev->net,
                            "unexpected interrupt: 0x%08x\n", intdata);
@@@ -2191,22 -2180,6 +2194,22 @@@ static int lan78xx_phy_init(struct lan7
        mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control);
        phydev->advertising |= mii_adv_to_ethtool_adv_t(mii_adv);
  
 +      if (of_property_read_bool(phydev->mdio.dev.of_node,
 +                                "microchip,eee-enabled")) {
 +              struct ethtool_eee edata;
 +              memset(&edata, 0, sizeof(edata));
 +              edata.cmd = ETHTOOL_SEEE;
 +              edata.advertised = ADVERTISED_1000baseT_Full |
 +                                 ADVERTISED_100baseT_Full;
 +              edata.eee_enabled = true;
 +              edata.tx_lpi_enabled = true;
 +              if (of_property_read_u32(dev->udev->dev.of_node,
 +                                       "microchip,tx-lpi-timer",
 +                                       &edata.tx_lpi_timer))
 +                      edata.tx_lpi_timer = 600; /* non-aggressive */
 +              (void)lan78xx_set_eee(dev->net, &edata);
 +      }
 +
        if (phydev->mdio.dev.of_node) {
                u32 reg;
                int len;
@@@ -2502,11 -2475,6 +2505,11 @@@ static int lan78xx_reset(struct lan78xx
        int ret = 0;
        unsigned long timeout;
        u8 sig;
 +      bool has_eeprom;
 +      bool has_otp;
 +
 +      has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
 +      has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
  
        ret = lan78xx_read_reg(dev, HW_CFG, &buf);
        buf |= HW_CFG_LRST_;
  
        ret = lan78xx_read_reg(dev, HW_CFG, &buf);
        buf |= HW_CFG_MEF_;
 +      /* If no valid EEPROM and no valid OTP, enable the LEDs by default */
 +      if (!has_eeprom && !has_otp)
 +          buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
        ret = lan78xx_write_reg(dev, HW_CFG, buf);
  
        ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
                        buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
                }
        }
 +      /* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
 +      if (!has_eeprom && !has_otp)
 +          buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
        ret = lan78xx_write_reg(dev, MAC_CR, buf);
  
        ret = lan78xx_read_reg(dev, MAC_TX, &buf);
@@@ -3017,14 -2979,8 +3020,14 @@@ static int lan78xx_bind(struct lan78xx_
        if (DEFAULT_RX_CSUM_ENABLE)
                dev->net->features |= NETIF_F_RXCSUM;
  
 -      if (DEFAULT_TSO_CSUM_ENABLE)
 -              dev->net->features |= NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_SG;
 +      if (DEFAULT_TSO_CSUM_ENABLE) {
 +              dev->net->features |= NETIF_F_SG;
 +              /* Use module parameter to control TCP segmentation offload as
 +               * it appears to cause issues.
 +               */
 +              if (enable_tso)
 +                      dev->net->features |= NETIF_F_TSO | NETIF_F_TSO6;
 +      }
  
        if (DEFAULT_VLAN_RX_OFFLOAD)
                dev->net->features |= NETIF_F_HW_VLAN_CTAG_RX;
@@@ -3250,7 -3206,7 +3253,7 @@@ static int rx_submit(struct lan78xx_ne
        size_t size = dev->rx_urb_size;
        int ret = 0;
  
 -      skb = netdev_alloc_skb_ip_align(dev->net, size);
 +      skb = netdev_alloc_skb(dev->net, size);
        if (!skb) {
                usb_free_urb(urb);
                return -ENOMEM;
@@@ -3821,12 -3777,7 +3824,12 @@@ static int lan78xx_probe(struct usb_int
        dev->pipe_intr = usb_rcvintpipe(dev->udev,
                                        dev->ep_intr->desc.bEndpointAddress &
                                        USB_ENDPOINT_NUMBER_MASK);
 -      period = dev->ep_intr->desc.bInterval;
 +      if (int_urb_interval_ms <= 0)
 +              period = dev->ep_intr->desc.bInterval;
 +      else
 +              period = int_urb_interval_ms * INT_URB_MICROFRAMES_PER_MS;
 +
 +      netif_notice(dev, probe, netdev, "int urb period %d\n", period);
  
        maxp = usb_maxpacket(dev->udev, dev->pipe_intr, 0);
        buf = kmalloc(maxp, GFP_KERNEL);
        /* driver requires remote-wakeup capability during autosuspend. */
        intf->needs_remote_wakeup = 1;
  
+       ret = lan78xx_phy_init(dev);
+       if (ret < 0)
+               goto out4;
        ret = register_netdev(netdev);
        if (ret != 0) {
                netif_err(dev, probe, netdev, "couldn't register the device\n");
-               goto out4;
+               goto out5;
        }
  
        usb_set_intfdata(intf, dev);
        pm_runtime_set_autosuspend_delay(&udev->dev,
                                         DEFAULT_AUTOSUSPEND_DELAY);
  
-       ret = lan78xx_phy_init(dev);
-       if (ret < 0)
-               goto out5;
        return 0;
  
  out5:
-       unregister_netdev(netdev);
+       phy_disconnect(netdev->phydev);
  out4:
        usb_free_urb(dev->urb_intr);
  out3:
@@@ -97,8 -97,9 +97,9 @@@ static int pcf8523_voltage_low(struct i
        return !!(value & REG_CONTROL3_BLF);
  }
  
- static int pcf8523_select_capacitance(struct i2c_client *client, bool high)
+ static int pcf8523_load_capacitance(struct i2c_client *client)
  {
+       u32 load;
        u8 value;
        int err;
  
        if (err < 0)
                return err;
  
-       if (!high)
-               value &= ~REG_CONTROL1_CAP_SEL;
-       else
+       load = 12500;
+       of_property_read_u32(client->dev.of_node, "quartz-load-femtofarads",
+                            &load);
+       switch (load) {
+       default:
+               dev_warn(&client->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 12500",
+                        load);
+               /* fall through */
+       case 12500:
                value |= REG_CONTROL1_CAP_SEL;
+               break;
+       case 7000:
+               value &= ~REG_CONTROL1_CAP_SEL;
+               break;
+       }
  
        err = pcf8523_write(client, REG_CONTROL1, value);
-       if (err < 0)
-               return err;
  
        return err;
  }
@@@ -201,28 -212,8 +212,28 @@@ static int pcf8523_rtc_read_time(struc
        if (err < 0)
                return err;
  
 -      if (regs[0] & REG_SECONDS_OS)
 -              return -EINVAL;
 +      if (regs[0] & REG_SECONDS_OS) {
 +              /*
 +               * If the oscillator was stopped, try to clear the flag. Upon
 +               * power-up the flag is always set, but if we cannot clear it
 +               * the oscillator isn't running properly for some reason. The
 +               * sensible thing therefore is to return an error, signalling
 +               * that the clock cannot be assumed to be correct.
 +               */
 +
 +              regs[0] &= ~REG_SECONDS_OS;
 +
 +              err = pcf8523_write(client, REG_SECONDS, regs[0]);
 +              if (err < 0)
 +                      return err;
 +
 +              err = pcf8523_read(client, REG_SECONDS, &regs[0]);
 +              if (err < 0)
 +                      return err;
 +
 +              if (regs[0] & REG_SECONDS_OS)
 +                      return -EAGAIN;
 +      }
  
        tm->tm_sec = bcd2bin(regs[0] & 0x7f);
        tm->tm_min = bcd2bin(regs[1] & 0x7f);
@@@ -258,6 -249,7 +269,6 @@@ static int pcf8523_rtc_set_time(struct 
                return err;
  
        regs[0] = REG_SECONDS;
 -      /* This will purposely overwrite REG_SECONDS_OS */
        regs[1] = bin2bcd(tm->tm_sec);
        regs[2] = bin2bcd(tm->tm_min);
        regs[3] = bin2bcd(tm->tm_hour);
@@@ -366,9 -358,10 +377,10 @@@ static int pcf8523_probe(struct i2c_cli
        if (!pcf)
                return -ENOMEM;
  
-       err = pcf8523_select_capacitance(client, true);
+       err = pcf8523_load_capacitance(client);
        if (err < 0)
-               return err;
+               dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
+                        err);
  
        err = pcf8523_set_pm(client, 0);
        if (err < 0)
diff --combined drivers/usb/core/hub.c
@@@ -107,6 -107,8 +107,8 @@@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rw
  static void hub_release(struct kref *kref);
  static int usb_reset_and_verify_device(struct usb_device *udev);
  static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
+ static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
+               u16 portstatus);
  
  static inline char *portspeed(struct usb_hub *hub, int portstatus)
  {
@@@ -1111,6 -1113,11 +1113,11 @@@ static void hub_activate(struct usb_hu
                                                   USB_PORT_FEAT_ENABLE);
                }
  
+               /* Make sure a warm-reset request is handled by port_event */
+               if (type == HUB_RESUME &&
+                   hub_port_warm_reset_required(hub, port1, portstatus))
+                       set_bit(port1, hub->event_bits);
                /*
                 * Add debounce if USB3 link is in polling/link training state.
                 * Link will automatically transition to Enabled state after
@@@ -5214,7 -5221,7 +5221,7 @@@ static void port_event(struct usb_hub *
                u16 status = 0, unused;
                port_dev->over_current_count++;
  
 -              dev_dbg(&port_dev->dev, "over-current change #%u\n",
 +              dev_notice(&port_dev->dev, "over-current change #%u\n",
                        port_dev->over_current_count);
                usb_clear_port_feature(hdev, port1,
                                USB_PORT_FEAT_C_OVER_CURRENT);