[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANEJEGsDwvUQZsowJwVkE9qHSoYt3x26bN4yo0y7C-zheY3zsw@mail.gmail.com>
Date: Mon, 20 Nov 2023 19:26:09 -0800
From: Grant Grundler <grundler@...omium.org>
To: Douglas Anderson <dianders@...omium.org>
Cc: Jakub Kicinski <kuba@...nel.org>,
Hayes Wang <hayeswang@...ltek.com>,
"David S . Miller" <davem@...emloft.net>,
Grant Grundler <grundler@...omium.org>,
Simon Horman <horms@...nel.org>,
Edward Hill <ecgh@...omium.org>, linux-usb@...r.kernel.org,
Laura Nao <laura.nao@...labora.com>,
Alan Stern <stern@...land.harvard.edu>,
Bjørn Mork <bjorn@...k.no>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH 2/2] r8152: Add RTL8152_INACCESSIBLE checks to more loops
On Fri, Nov 17, 2023 at 1:10 PM Douglas Anderson <dianders@...omium.org> wrote:
>
> Previous commits added checks for RTL8152_INACCESSIBLE in the loops in
> the driver. There are still a few more that keep tripping the driver
> up in error cases and make things take longer than they should. Add
> those in.
>
> Signed-off-by: Douglas Anderson <dianders@...omium.org>
Reviewed-by: Grant Grundler <grundler@...omium.org>
I've checked all the return paths and believe these changes don't
break any of them.
cheers,
grant
> ---
>
> drivers/net/usb/r8152.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index d6edf0254599..aca7dd7b4090 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -3000,6 +3000,8 @@ static void rtl8152_nic_reset(struct r8152 *tp)
> ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, CR_RST);
>
> for (i = 0; i < 1000; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> if (!(ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR) & CR_RST))
> break;
> usleep_range(100, 400);
> @@ -3329,6 +3331,8 @@ static void rtl_disable(struct r8152 *tp)
> rxdy_gated_en(tp, true);
>
> for (i = 0; i < 1000; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
> if ((ocp_data & FIFO_EMPTY) == FIFO_EMPTY)
> break;
> @@ -3336,6 +3340,8 @@ static void rtl_disable(struct r8152 *tp)
> }
>
> for (i = 0; i < 1000; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0) & TCR0_TX_EMPTY)
> break;
> usleep_range(1000, 2000);
> @@ -5499,6 +5505,8 @@ static void wait_oob_link_list_ready(struct r8152 *tp)
> int i;
>
> for (i = 0; i < 1000; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
> if (ocp_data & LINK_LIST_READY)
> break;
> @@ -5513,6 +5521,8 @@ static void r8156b_wait_loading_flash(struct r8152 *tp)
> int i;
>
> for (i = 0; i < 100; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> if (ocp_read_word(tp, MCU_TYPE_USB, USB_GPHY_CTRL) & GPHY_PATCH_DONE)
> break;
> usleep_range(1000, 2000);
> @@ -5635,6 +5645,8 @@ static int r8153_pre_firmware_1(struct r8152 *tp)
> for (i = 0; i < 104; i++) {
> u32 ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_WDT1_CTRL);
>
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return -ENODEV;
> if (!(ocp_data & WTD1_EN))
> break;
> usleep_range(1000, 2000);
> @@ -5791,6 +5803,8 @@ static void r8153_aldps_en(struct r8152 *tp, bool enable)
> data &= ~EN_ALDPS;
> ocp_reg_write(tp, OCP_POWER_CFG, data);
> for (i = 0; i < 20; i++) {
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> usleep_range(1000, 2000);
> if (ocp_read_word(tp, MCU_TYPE_PLA, 0xe000) & 0x0100)
> break;
> --
> 2.43.0.rc0.421.g78406f8d94-goog
>
Powered by blists - more mailing lists