Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jason-ch Chen <jason-ch.chen@mediatek.com>
To: Hayes Wang <hayeswang@realtek.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Project_Global_Chrome_Upstream_Group@mediatek.com"
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"hsinyi@google.com" <hsinyi@google.com>,
	nic_swsd <nic_swsd@realtek.com>
Subject: Re: [PATCH] r8152: stop submitting rx for -EPROTO
Date: Fri, 1 Oct 2021 09:36:54 +0800	[thread overview]
Message-ID: <a891e733157ca7e631ca120ebae15557a6f05738.camel@mediatek.com> (raw)
In-Reply-To: <7dc4198f05784b6686973500150faca7@realtek.com>

On Thu, 2021-09-30 at 02:41 +0000, Hayes Wang wrote:
> Jason-ch Chen <jason-ch.chen@mediatek.com>
> > Sent: Wednesday, September 29, 2021 5:53 PM
> 
> [...]
> > Hi Hayes,
> > 
> > Sometimes Rx submits rapidly and the USB kernel driver of
> > opensource
> > cannot receive any disconnect event due to CPU heavy loading, which
> > finally causes a system crash.
> > Do you have any suggestions to modify the r8152 driver to prevent
> > this
> > situation happened?
> 
> Do you mind to try the following patch?
> It avoids to re-submit RX immediately.
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 60ba9b734055..bfe00af8283f 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -767,6 +767,7 @@ enum rtl8152_flags {
>  	PHY_RESET,
>  	SCHEDULE_TASKLET,
>  	GREEN_ETHERNET,
> +	SCHEDULE_NAPI,
>  };
>  
>  #define DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2	0x3082
> @@ -1770,6 +1771,14 @@ static void read_bulk_callback(struct urb
> *urb)
>  		rtl_set_unplug(tp);
>  		netif_device_detach(tp->netdev);
>  		return;
> +	case -EPROTO:
> +		urb->actual_length = 0;
> +		spin_lock_irqsave(&tp->rx_lock, flags);
> +		list_add_tail(&agg->list, &tp->rx_done);
> +		spin_unlock_irqrestore(&tp->rx_lock, flags);
> +		set_bit(SCHEDULE_NAPI, &tp->flags);
> +		schedule_delayed_work(&tp->schedule, 1);
> +		return;
>  	case -ENOENT:
>  		return;	/* the urb is in unlink state */
>  	case -ETIME:
> @@ -2425,6 +2434,7 @@ static int rx_bottom(struct r8152 *tp, int
> budget)
>  	if (list_empty(&tp->rx_done))
>  		goto out1;
>  
> +	clear_bit(SCHEDULE_NAPI, &tp->flags);
>  	INIT_LIST_HEAD(&rx_queue);
>  	spin_lock_irqsave(&tp->rx_lock, flags);
>  	list_splice_init(&tp->rx_done, &rx_queue);
> @@ -2441,7 +2451,7 @@ static int rx_bottom(struct r8152 *tp, int
> budget)
>  
>  		agg = list_entry(cursor, struct rx_agg, list);
>  		urb = agg->urb;
> -		if (urb->actual_length < ETH_ZLEN)
> +		if (urb->status != 0 || urb->actual_length < ETH_ZLEN)
>  			goto submit;
>  
>  		agg_free = rtl_get_free_rx(tp, GFP_ATOMIC);
> @@ -6643,6 +6653,10 @@ static void rtl_work_func_t(struct work_struct
> *work)
>  	    netif_carrier_ok(tp->netdev))
>  		tasklet_schedule(&tp->tx_tl);
>  
> +	if (test_and_clear_bit(SCHEDULE_NAPI, &tp->flags) &&
> +	    !list_empty(&tp->rx_done))
> +		napi_schedule(&tp->napi);
> +
>  	mutex_unlock(&tp->control);
>  
>  out1:
> 
> 
> Best Regards,
> Hayes

Hi,

This patch has been verified.
It did avoid Rx re-submit immediately.

Thanks,
Jason


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  reply	other threads:[~2021-10-01  1:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29  5:18 [PATCH] r8152: stop submitting rx for -EPROTO Jason-ch Chen
2021-09-29  8:14 ` Hayes Wang
2021-09-29  9:52   ` Jason-ch Chen
2021-09-30  2:41     ` Hayes Wang
2021-10-01  1:36       ` Jason-ch Chen [this message]
2021-09-30  9:30     ` Oliver Neukum
2021-09-30 15:18       ` Alan Stern
2021-10-01  2:40         ` Hayes Wang
2021-10-01  3:26           ` Hayes Wang
2021-10-01 15:22             ` Alan Stern
2021-10-04  2:15               ` Hayes Wang
2021-10-04 11:44               ` Oliver Neukum
2021-10-04 14:33                 ` Alan Stern
2021-09-30 16:13       ` Hayes Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a891e733157ca7e631ca120ebae15557a6f05738.camel@mediatek.com \
    --to=jason-ch.chen@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=hayeswang@realtek.com \
    --cc=hsinyi@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox