wil6210: make sure Rx ring sizes are correlated
authorDedy Lansky <dlansky@codeaurora.org>
Wed, 31 Oct 2018 08:52:12 +0000 (10:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Apr 2020 07:03:13 +0000 (09:03 +0200)
commit 61e5ec044748486f06dec760a19dce78247b3ad8 upstream.

When enlarging rx_ring_order module param, wil6210 fails to load
because there are not enough Rx buffers.
Fix this by enlarging number of Rx buffers at startup, if needed based
on rx_ring_order.

Signed-off-by: Dedy Lansky <dlansky@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/txrx.c
drivers/net/wireless/ath/wil6210/txrx_edma.c
drivers/net/wireless/ath/wil6210/wil6210.h

index 28d2bfd0fde79de5236a57e114926af9276637a1..fe91db3478dc8446fb139ac158bafc7e758f199b 100644 (file)
@@ -1687,7 +1687,7 @@ int __wil_up(struct wil6210_priv *wil)
                return rc;
 
        /* Rx RING. After MAC and beacon */
-       rc = wil->txrx_ops.rx_init(wil, 1 << rx_ring_order);
+       rc = wil->txrx_ops.rx_init(wil, rx_ring_order);
        if (rc)
                return rc;
 
index 73cdf54521f9bb8dad9c7506acc9df70b121ca05..236dcb6f5e84da7e3a440f8168809632ac30af47 100644 (file)
@@ -881,7 +881,7 @@ static void wil_rx_buf_len_init(struct wil6210_priv *wil)
        }
 }
 
-static int wil_rx_init(struct wil6210_priv *wil, u16 size)
+static int wil_rx_init(struct wil6210_priv *wil, uint order)
 {
        struct wil_ring *vring = &wil->ring_rx;
        int rc;
@@ -895,7 +895,7 @@ static int wil_rx_init(struct wil6210_priv *wil, u16 size)
 
        wil_rx_buf_len_init(wil);
 
-       vring->size = size;
+       vring->size = 1 << order;
        vring->is_rx = true;
        rc = wil_vring_alloc(wil, vring);
        if (rc)
index 03d0e6c550b98ed865e1bf424b7ea644e2d6e8a0..fe666a3583c105063b3e4cbac64eb59effc5688f 100644 (file)
@@ -593,9 +593,9 @@ static void wil_rx_buf_len_init_edma(struct wil6210_priv *wil)
                WIL_MAX_ETH_MTU : WIL_EDMA_RX_BUF_LEN_DEFAULT;
 }
 
-static int wil_rx_init_edma(struct wil6210_priv *wil, u16 desc_ring_size)
+static int wil_rx_init_edma(struct wil6210_priv *wil, uint desc_ring_order)
 {
-       u16 status_ring_size;
+       u16 status_ring_size, desc_ring_size = 1 << desc_ring_order;
        struct wil_ring *ring = &wil->ring_rx;
        int rc;
        size_t elem_size = wil->use_compressed_rx_status ?
@@ -610,7 +610,12 @@ static int wil_rx_init_edma(struct wil6210_priv *wil, u16 desc_ring_size)
                        "compressed RX status cannot be used with SW reorder\n");
                return -EINVAL;
        }
-
+       if (wil->rx_status_ring_order <= desc_ring_order)
+               /* make sure sring is larger than desc ring */
+               wil->rx_status_ring_order = desc_ring_order + 1;
+       if (wil->rx_buff_id_count <= desc_ring_size)
+               /* make sure we will not run out of buff_ids */
+               wil->rx_buff_id_count = desc_ring_size + 512;
        if (wil->rx_status_ring_order < WIL_SRING_SIZE_ORDER_MIN ||
            wil->rx_status_ring_order > WIL_SRING_SIZE_ORDER_MAX)
                wil->rx_status_ring_order = WIL_RX_SRING_SIZE_ORDER_DEFAULT;
index 6a05f59ee58e9347e273e6ee20e3a29556cf2a55..bc89044d0b66e520b8eedd47b45a46b74bba32f1 100644 (file)
@@ -602,7 +602,7 @@ struct wil_txrx_ops {
                           struct wil_ring *ring, struct sk_buff *skb);
        irqreturn_t (*irq_tx)(int irq, void *cookie);
        /* RX ops */
-       int (*rx_init)(struct wil6210_priv *wil, u16 ring_size);
+       int (*rx_init)(struct wil6210_priv *wil, uint ring_order);
        void (*rx_fini)(struct wil6210_priv *wil);
        int (*wmi_addba_rx_resp)(struct wil6210_priv *wil, u8 mid, u8 cid,
                                 u8 tid, u8 token, u16 status, bool amsdu,