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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241024-marvellous-brainy-anteater-f61302-mkl@pengutronix.de>
Date: Thu, 24 Oct 2024 17:28:15 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Ming Yu <a0282524688@...il.com>
Cc: tmyu0@...oton.com, lee@...nel.org, linus.walleij@...aro.org, 
	brgl@...ev.pl, andi.shyti@...nel.org, mailhol.vincent@...adoo.fr, 
	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, 
	jic23@...nel.org, lars@...afoo.de, ukleinek@...nel.org, 
	alexandre.belloni@...tlin.com, 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-iio@...r.kernel.org, 
	linux-pwm@...r.kernel.org, linux-rtc@...r.kernel.org
Subject: Re: [PATCH v1 4/9] can: Add Nuvoton NCT6694 CAN support

On 24.10.2024 14:12:44, Marc Kleine-Budde wrote:
> Hello,
> 
> thanks for your contribution. It seems to me that there is no proper
> TX-flow control and I have some questions.
> 
> On 24.10.2024 16:59:17, Ming Yu wrote:
> 
> [...]
> 
> > +static netdev_tx_t nct6694_canfd_start_xmit(struct sk_buff *skb,
> > +					    struct net_device *ndev)
> > +{
> > +	struct nct6694_canfd_priv *priv = netdev_priv(ndev);
> > +	struct nct6694 *nct6694 = priv->nct6694;
> > +	struct canfd_frame *cf = (struct canfd_frame *)skb->data;
> > +	struct net_device_stats *stats = &ndev->stats;
> > +	int can_idx = priv->can_idx;
> > +	u32 txid = 0;
> > +	int i;
> > +	unsigned int echo_byte;
> > +	u8 data_buf[REQUEST_CAN_CMD10_LEN] = {0};
> > +
> > +	if (can_dropped_invalid_skb(ndev, skb))
> > +		return NETDEV_TX_OK;
> > +
> > +	/*
> > +	 * No check for NCT66794 because the TX bit is read-clear
> > +	 * and may be read-cleared by other function
> > +	 * Just check the result of tx command.
> > +	 */
> 
> Where do you check the result of the TX command?
> 
> > +	/* Check if the TX buffer is full */
> 
> Where's the check if the TX buffer is full?
> 
> > +	netif_stop_queue(ndev);
> > +
> > +	if (can_idx == 0)
> > +		data_buf[CAN_TAG_IDX] = CAN_TAG_CAN0;
> > +	else
> > +		data_buf[CAN_TAG_IDX] = CAN_TAG_CAN1;
> > +
> > +	if (cf->can_id & CAN_EFF_FLAG) {
> > +		txid = cf->can_id & CAN_EFF_MASK;
> > +		/*
> > +		 * In case the Extended ID frame is transmitted, the
> > +		 * standard and extended part of the ID are swapped
> > +		 * in the register, so swap them back to send the
> > +		 * correct ID.
> > +		 */
> > +		data_buf[CAN_FLAG_IDX] |= CAN_FLAG_EFF;
> > +	} else {
> > +		txid = cf->can_id & CAN_SFF_MASK;
> > +	}
> > +
> > +	set_buf32(&data_buf[CAN_ID_IDX], txid);
> > +
> > +	data_buf[CAN_DLC_IDX] = cf->len;
> > +
> > +	if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
> > +		data_buf[CAN_FLAG_IDX] |= CAN_FLAG_FD;
> > +		if (cf->flags & CANFD_BRS)
> > +			data_buf[CAN_FLAG_IDX] |= CAN_FLAG_BRS;
> > +	}
> > +
> > +	if (cf->can_id & CAN_RTR_FLAG)
> > +		data_buf[CAN_FLAG_IDX] |= CAN_FLAG_RTR;
> > +
> > +	/* set data to buf */
> > +	for (i = 0; i < cf->len; i++)
> > +		data_buf[CAN_DATA_IDX + i] = *(u8 *)(cf->data + i);
> > +
> > +	can_put_echo_skb(skb, ndev, 0, 0);
> > +
> > +	memcpy(priv->data_buf, data_buf, REQUEST_CAN_CMD10_LEN);
> > +	queue_work(nct6694->async_workqueue, &priv->tx_work);
> > +
> > +	stats->tx_bytes += cf->len;
> > +	stats->tx_packets++;
> > +	echo_byte = can_get_echo_skb(ndev, 0, NULL);
> > +
> > +	netif_wake_queue(ndev);
> 
> How do you make sure that the tx_work has finished?
> Once you wake the queue, the xmit function can be called again. If your
> tx_work has not finished, you'll overwrite the priv->data_buf.

Do you get a CAN TX complete message/IRQ from your device?

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ