public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Oliver Neukum <oneukum@suse.com>,
	Matt Johnston <matt@codeconstruct.com.au>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	Santosh Puranik <spuranik@nvidia.com>
Subject: Re: [PATCH net-next 2/2] net: mctp: Add MCTP USB transport driver
Date: Fri, 07 Feb 2025 15:45:02 +0800	[thread overview]
Message-ID: <16ff513ac43a23fb0abfeaf9ff139115d87dbf3a.camel@codeconstruct.com.au> (raw)
In-Reply-To: <b78d0e25-f8cc-43af-90d8-2c7344895d55@suse.com>

Hi Oliver,

Thanks for taking a look. Some responses too.

> > +               hdr = skb_pull_data(skb, sizeof(*hdr));
> > +               if (!hdr)
> > +                       break;
> > +
> > +               if (be16_to_cpu(hdr->id) != MCTP_USB_DMTF_ID) {
> 
> It would be more efficient to do the conversion on the constant

Compiler should be clever enough for that not to make a difference:

  $ diff -u \
    <(arm-linux-gnueabihf-objdump -d obj/drivers/net/mctp/mctp-usb.o.orig) \
    <(arm-linux-gnueabihf-objdump -d obj/drivers/net/mctp/mctp-usb.o)
  --- /dev/fd/63	2025-02-07 15:32:53.813084894 +0800
  +++ /dev/fd/62	2025-02-07 15:32:53.809084826 +0800
  @@ -1,5 +1,5 @@
   
  -obj/drivers/net/mctp/mctp-usb.o.orig:     file format elf32-littlearm
  +obj/drivers/net/mctp/mctp-usb.o:     file format elf32-littlearm

  Disassembly of section .text:
  $

And endian-converting the header field (rather than the const) seems
more readable to me.

> > +               if (pkt_len < skb->len) {
> > +                       /* more packets may follow - clone to a new
> > +                        * skb to use on the next iteration
> > +                        */
> > +                       skb2 = skb_clone(skb, GFP_ATOMIC);
> > +                       if (skb2) {
> > +                               if (!skb_pull(skb2, pkt_len)) {
> > +                                       kfree_skb(skb2);
> > +                                       skb2 = NULL;
> > +                               }
> > +                       }
> > +                       skb_trim(skb, pkt_len);
> 
> This is functional. Though in terms of algorithm you are copying
> the same data multiple times.

There should be no copy here; they're shared clones of the same buffer.
Or am I missing some situation where they would get unshared?

> > +static int mctp_usb_open(struct net_device *dev)
> > +{
> > +       struct mctp_usb *mctp_usb = netdev_priv(dev);
> > +
> > +       return mctp_usb_rx_queue(mctp_usb);
> 
> This will needlessly use GFP_ATOMIC

It's only the one (first) skb and urb submission, but fair enough. I'll
add a gfp_t argument in a v2.

> > +       SET_NETDEV_DEV(netdev, &intf->dev);
> > +       dev = netdev_priv(netdev);
> > +       dev->netdev = netdev;
> > +       dev->usbdev = usb_get_dev(interface_to_usbdev(intf));
> 
> Taking a reference.
> Where is the corresponding put?

Good catch - we should have one in disconnect(). Coming up in v2 too.

Cheers,


Jeremy

  reply	other threads:[~2025-02-07  7:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  6:48 [PATCH net-next 0/2] mctp: Add MCTP-over-USB hardware transport binding Jeremy Kerr
2025-02-06  6:48 ` [PATCH net-next 1/2] usb: Add base USB MCTP definitions Jeremy Kerr
2025-02-06  7:03   ` Greg Kroah-Hartman
2025-02-06  7:11     ` Jeremy Kerr
2025-02-06  7:22       ` Greg Kroah-Hartman
2025-02-06  7:36         ` Jeremy Kerr
2025-02-06  8:14           ` Greg Kroah-Hartman
2025-02-06  6:48 ` [PATCH net-next 2/2] net: mctp: Add MCTP USB transport driver Jeremy Kerr
2025-02-06  7:07   ` Greg Kroah-Hartman
2025-02-07  8:49     ` Jeremy Kerr
2025-02-07  9:10       ` Greg Kroah-Hartman
2025-02-07  9:45         ` Jeremy Kerr
2025-02-07 12:18           ` Greg Kroah-Hartman
2025-02-06 11:12   ` Oliver Neukum
2025-02-07  7:45     ` Jeremy Kerr [this message]
2025-02-07 15:26   ` Simon Horman
2025-02-10  1:57     ` Jeremy Kerr
2025-02-20 18:13   ` Jeff Johnson

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=16ff513ac43a23fb0abfeaf9ff139115d87dbf3a.camel@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=pabeni@redhat.com \
    --cc=spuranik@nvidia.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