lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cef1b9bf-59f6-484d-861e-82b405653ca1@wanadoo.fr>
Date: Thu, 16 Jan 2025 01:45:02 +0900
From: Vincent Mailhol <mailhol.vincent@...adoo.fr>
To: Ming Yu <a0282524688@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
 linux-i2c@...r.kernel.org, linux-can@...r.kernel.org,
 netdev@...r.kernel.org, linux-watchdog@...r.kernel.org,
 linux-hwmon@...r.kernel.org, linux-rtc@...r.kernel.org,
 linux-usb@...r.kernel.org, tmyu0@...oton.com, lee@...nel.org,
 linus.walleij@...aro.org, brgl@...ev.pl, andi.shyti@...nel.org,
 mkl@...gutronix.de, andrew+netdev@...n.ch, davem@...emloft.net,
 edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
 wim@...ux-watchdog.org, linux@...ck-us.net, jdelvare@...e.com,
 alexandre.belloni@...tlin.com
Subject: Re: [PATCH v5 4/7] can: Add Nuvoton NCT6694 CAN support

On 14/01/2025 at 12:30, Ming Yu wrote:

(...)

> +static void nct6694_can_clean(struct net_device *ndev)
> +{
> +	struct nct6694_can_priv *priv = netdev_priv(ndev);
> +
> +	if (priv->tx_skb || netif_queue_stopped(ndev))
> +		ndev->stats.tx_errors++;
> +	dev_kfree_skb(priv->tx_skb);

Use:

  	can_flush_echo_skb(ndev);

(related to the following comments).

> +	priv->tx_skb = NULL;
> +}

(...)

> +static void nct6694_can_tx_work(struct work_struct *work)
> +{
> +	struct nct6694_can_priv *priv = container_of(work,
> +						     struct nct6694_can_priv,
> +						     tx_work);
> +	struct net_device *ndev = priv->ndev;
> +
> +	guard(mutex)(&priv->lock);
> +
> +	if (priv->tx_skb) {
> +		if (priv->can.state == CAN_STATE_BUS_OFF) {

Just stop the queue when the can bus is off so that you do not have do
check the bus status each time a frame is sent.

> +			nct6694_can_clean(ndev);
> +		} else {
> +			nct6694_can_tx(ndev);
> +			can_put_echo_skb(priv->tx_skb, ndev, 0, 0);
> +			priv->tx_skb = NULL;
> +		}
> +	}
> +}
> +
> +static netdev_tx_t nct6694_can_start_xmit(struct sk_buff *skb,
> +					  struct net_device *ndev)
> +{
> +	struct nct6694_can_priv *priv = netdev_priv(ndev);
> +
> +	if (can_dev_dropped_skb(ndev, skb))
> +		return NETDEV_TX_OK;
> +
> +	if (priv->tx_skb) {
> +		netdev_err(ndev, "hard_xmit called while tx busy\n");
> +		return NETDEV_TX_BUSY;
> +	}
> +
> +	netif_stop_queue(ndev);
> +	priv->tx_skb = skb;

Here, you can directly do:

  	can_put_echo_skb(skb, ndev, 0, 0);

The skb remains accessible under priv->can.echo_skb[0]. With this, you
can remove the priv->tx_skb field.

> +	queue_work(priv->wq, &priv->tx_work);
> +
> +	return NETDEV_TX_OK;
> +}


Yours sincerely,
Vincent Mailhol


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ