]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
net: ena: fix incorrect update of intr_delay_resolution
authorArthur Kiyanovski <akiyano@amazon.com>
Mon, 16 Sep 2019 11:31:36 +0000 (14:31 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 4 Dec 2019 09:29:26 +0000 (10:29 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853180
ena_dev->intr_moder_rx/tx_interval save the intervals received from the
user after dividing them by ena_dev->intr_delay_resolution. Therefore
when intr_delay_resolution changes, the code needs to first mutiply
intr_moder_rx/tx_interval by the previous intr_delay_resolution to get
the value originally given by the user, and only then divide it by the
new intr_delay_resolution.

Current code does not first multiply intr_moder_rx/tx_interval by the old
intr_delay_resolution. This commit fixes it.

Also initialize ena_dev->intr_delay_resolution to be 1.

Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 79226cea4a5ebbd84a4eee1762526f664c7beb62)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Khaled Elmously <khalid.elmously@canonical.com>
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/amazon/ena/ena_com.c
drivers/net/ethernet/amazon/ena/ena_com.h
drivers/net/ethernet/amazon/ena/ena_netdev.c

index 621b747f062b7172c52cdbaf3eb4c266f38e53df..ea62604fdf8ca7b0dc647b986ac5ea998f7bc414 100644 (file)
@@ -1281,17 +1281,30 @@ static int ena_com_ind_tbl_convert_from_device(struct ena_com_dev *ena_dev)
 static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
                                                 u16 intr_delay_resolution)
 {
+       /* Initial value of intr_delay_resolution might be 0 */
+       u16 prev_intr_delay_resolution =
+               ena_dev->intr_delay_resolution ?
+               ena_dev->intr_delay_resolution :
+               ENA_DEFAULT_INTR_DELAY_RESOLUTION;
+
        if (!intr_delay_resolution) {
                pr_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
-               intr_delay_resolution = 1;
+               intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
        }
-       ena_dev->intr_delay_resolution = intr_delay_resolution;
 
        /* update Rx */
-       ena_dev->intr_moder_rx_interval /= intr_delay_resolution;
+       ena_dev->intr_moder_rx_interval =
+               ena_dev->intr_moder_rx_interval *
+               prev_intr_delay_resolution /
+               intr_delay_resolution;
 
        /* update Tx */
-       ena_dev->intr_moder_tx_interval /= intr_delay_resolution;
+       ena_dev->intr_moder_tx_interval =
+               ena_dev->intr_moder_tx_interval *
+               prev_intr_delay_resolution /
+               intr_delay_resolution;
+
+       ena_dev->intr_delay_resolution = intr_delay_resolution;
 }
 
 /*****************************************************************************/
index ddc2a8c5033334819d57ea173fa249805303b939..7c941eba0bc9b30b373ab77d9f6b3bb4667a90ae 100644 (file)
@@ -74,6 +74,7 @@
 
 #define ENA_INTR_INITIAL_TX_INTERVAL_USECS             196
 #define ENA_INTR_INITIAL_RX_INTERVAL_USECS             0
+#define ENA_DEFAULT_INTR_DELAY_RESOLUTION              1
 
 #define ENA_HW_HINTS_NO_TIMEOUT                                0xFFFF
 
index 3396c85bcab0899ded92905e43dc2f9e8551d0ab..c487d2a7d6dd04cfcc0c5693a6f0692a00753cd9 100644 (file)
@@ -3501,6 +3501,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        */
        ena_dev->intr_moder_tx_interval = ENA_INTR_INITIAL_TX_INTERVAL_USECS;
        ena_dev->intr_moder_rx_interval = ENA_INTR_INITIAL_RX_INTERVAL_USECS;
+       ena_dev->intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
        io_queue_num = ena_calc_io_queue_num(pdev, ena_dev, &get_feat_ctx);
        rc = ena_calc_queue_size(&calc_queue_ctx);
        if (rc || io_queue_num <= 0) {