Skip to contentSkip to conversation

mctp serial minor fixes

PATCH Superseded Jeremy Kerr 2 participants 9 messages Nov 23, 2021 – Nov 25, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeremy Kerr

author maintainer
#0 lore raw

cover mctp serial minor fixes

We had a few minor fixes queued for a v4 of the original series, so they're sent here as separate changes.

Cheers,

Jeremy

Jeremy Kerr (3):
mctp: serial: cancel tx work on ldisc close
mctp: serial: enforce fixed MTU
mctp: serial: remove unnecessary ldisc data check

 drivers/net/mctp/mctp-serial.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH 1/3 mctp: serial: cancel tx work on ldisc close

We want to ensure that the tx work has finished before returning from the ldisc close op, so do a synchronous cancel.

---
 drivers/net/mctp/mctp-serial.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mctp/mctp-serial.c +1 -0
index 9ac0e187f36e..c958d773a82a 100644
@@ -478,6 +478,7 @@ static void mctp_serial_close(struct tty_struct *tty)
 	struct mctp_serial *dev = tty->disc_data;
 	int idx = dev->idx;
 
+	cancel_work_sync(&dev->tx_work);
 	unregister_netdev(dev->netdev);
 	ida_free(&mctp_serial_ida, idx);
 }
Signature · 1 line
2.33.0
author maintainer
#7 lore raw

PATCH 2/3 mctp: serial: enforce fixed MTU

In reply to Jeremy Kerr

The current serial driver requires a maximum MTU of 68, and it doesn't make sense to set a MTU below the MCTP-required baseline (of 68) either.

This change sets the min_mtu & max_mtu of the mctp netdev, essentially disallowing changes. By using these instead of a ndo_change_mtu op, we get the netlink extacks reported too.

---
 drivers/net/mctp/mctp-serial.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mctp/mctp-serial.c +7 -0
index c958d773a82a..5687ad3220cd 100644
@@ -410,7 +410,14 @@ static const struct net_device_ops mctp_serial_netdev_ops = {
 static void mctp_serial_setup(struct net_device *ndev)
 {
 	ndev->type = ARPHRD_MCTP;
+
+	/* we limit at the fixed MTU, which is also the MCTP-standard
+	 * baseline MTU, so is also our minimum
+	 */
 	ndev->mtu = MCTP_SERIAL_MTU;
+	ndev->max_mtu = MCTP_SERIAL_MTU;
+	ndev->min_mtu = MCTP_SERIAL_MTU;
+
 	ndev->hard_header_len = 0;
 	ndev->addr_len = 0;
 	ndev->tx_queue_len = DEFAULT_TX_QUEUE_LEN;
Signature · 1 line
2.33.0
author maintainer
#8 lore raw

PATCH 3/3 mctp: serial: remove unnecessary ldisc data check

In reply to Jeremy Kerr

Jiri assures me that a ldisc->open with tty->disc_data set should never happen, so this check doesn't do anything.

---
 drivers/net/mctp/mctp-serial.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/mctp/mctp-serial.c +0 -3
index 5687ad3220cd..9919a4734ed9 100644
@@ -439,9 +439,6 @@ static int mctp_serial_open(struct tty_struct *tty)
 	if (!tty->ops->write)
 		return -EOPNOTSUPP;
 
-	if (tty->disc_data)
-		return -EEXIST;
-
 	idx = ida_alloc(&mctp_serial_ida, GFP_KERNEL);
 	if (idx < 0)
 		return idx;
Signature · 1 line
2.33.0
#2 lore raw

Re: [PATCH net-next 1/3] mctp: serial: cancel tx work on ldisc close

In reply to Jeremy Kerr
Quoted 14 lines · Jeremy Kerr

We want to ensure that the tx work has finished before returning from the ldisc close op, so do a synchronous cancel.

---
  drivers/net/mctp/mctp-serial.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/mctp/mctp-serial.c +0 -0
index 9ac0e187f36e..c958d773a82a 100644

drivers/net/mctp/mctp-serial.c static void mctp_serial_close(struct tty_struct *tty) · line 481

Quoted 4 lines
drivers/net/mctp/mctp-serial.c +1 -0
@@ -478,6 +478,7 @@ static void mctp_serial_close(struct tty_struct *tty)
  	struct mctp_serial *dev = tty->disc_data;
  	int idx = dev->idx;
 
+	cancel_work_sync(&dev->tx_work);

But the work still can be queued after the cancel (and before the unregister), right?

drivers/net/mctp/mctp-serial.c static void mctp_serial_close(struct tty_struct *tty) · line 484

Quoted 4 lines
drivers/net/mctp/mctp-serial.c +0 -0
  	unregister_netdev(dev->netdev);
  	ida_free(&mctp_serial_ida, idx);
  }

thanks,

Signature · 2 lines
js
suse labs
#3 lore raw

Re: [PATCH net-next 1/3] mctp: serial: cancel tx work on ldisc close

Quoted 10 lines · Jiri Slaby
Quoted 9 lines · Jeremy Kerr

We want to ensure that the tx work has finished before returning from the ldisc close op, so do a synchronous cancel.

---
  drivers/net/mctp/mctp-serial.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/mctp/mctp-serial.c static void mctp_serial_close(struct tty_struct *tty) · line 480

Quoted 8 lines
drivers/net/mctp/mctp-serial.c +1 -0
index 9ac0e187f36e..c958d773a82a 100644
@@ -478,6 +478,7 @@ static void mctp_serial_close(struct tty_struct *tty)
       struct mctp_serial *dev = tty->disc_data;
       int idx = dev->idx;
+    cancel_work_sync(&dev->tx_work);

But the work still can be queued after the cancel (and before the unregister), right?

Maybe do it in ->ndo_uninit()?

Quoted 6 lines

drivers/net/mctp/mctp-serial.c static void mctp_serial_close(struct tty_struct *tty)

Quoted 4 lines
drivers/net/mctp/mctp-serial.c +0 -0
       unregister_netdev(dev->netdev);
       ida_free(&mctp_serial_ida, idx);
   }
 

thanks,

Signature · 2 lines
js
suse labs
author maintainer
#4 lore raw

Re: [PATCH net-next 1/3] mctp: serial: cancel tx work on ldisc close

In reply to Jiri Slaby

Hi Jiri,

Quoted 4 lines
Quoted 1 line

+       cancel_work_sync(&dev->tx_work);

But the work still can be queued after the cancel (and before the unregister), right?

Yes. Yes it can.

I should be cancelling after the unregister, not before, so this'll need a v2.

On the ldisc side: is there any case where we'd get a write wakeup during (or after) the ->close()?

Cheers,

Jeremy

#5 lore raw

Re: [PATCH net-next 1/3] mctp: serial: cancel tx work on ldisc close

Hi,

Quoted 2 lines · Jeremy Kerr

On the ldisc side: is there any case where we'd get a write wakeup during (or after) the ->close()?

there should be no invocation of ldisc after close(). If there is, it's a bug as this is even documented:

* @close: [TTY] ``void ()(struct tty_struct *tty)`` *
* This function is called when the line discipline is being shutdown,
* either because the @tty is being closed or because the @tty is
being
* changed to use a new line discipline. At the point of execution no
* further users will enter the ldisc code for this tty.
*
* Can sleep.

Should be the same also for the "during" case.

regards,

Signature · 1 line
js
author maintainer
#6 lore raw

Re: [PATCH net-next 1/3] mctp: serial: cancel tx work on ldisc close

Hi Jiri,

Quoted 2 lines

there should be no invocation of ldisc after close(). If there is, it's a bug as this is even documented:

Excellent thanks for that (and the doc pointer), I'll get a v2 done now.

Cheers,

Jeremy