]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
r8169: add check for invalid parameter combination in rtl_set_coalesce
authorHeiner Kallweit <hkallweit1@gmail.com>
Thu, 30 Apr 2020 19:59:48 +0000 (21:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2020 00:39:15 +0000 (17:39 -0700)
Realtek provided information about a HW constraint that time limit must
not be set to 0 if the frame limit is >0. Add a check for this and
reject invalid parameter combinations.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/realtek/r8169_main.c

index 4fe8b1d35b696eda860d868a6b318db8f8615e83..aa3e63e031dac54d01f834d3a0cb88edf79b5311 100644 (file)
@@ -1908,6 +1908,11 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
        if (tx_fr == 1)
                tx_fr = 0;
 
+       /* HW requires time limit to be set if frame limit is set */
+       if ((tx_fr && !ec->tx_coalesce_usecs) ||
+           (rx_fr && !ec->rx_coalesce_usecs))
+               return -EINVAL;
+
        w |= FIELD_PREP(RTL_COALESCE_TX_FRAMES, DIV_ROUND_UP(tx_fr, 4));
        w |= FIELD_PREP(RTL_COALESCE_RX_FRAMES, DIV_ROUND_UP(rx_fr, 4));