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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 16 Oct 2020 10:27:16 +0200
From:   Loic Poulain <loic.poulain@...aro.org>
To:     Eric Dumazet <eric.dumazet@...il.com>
Cc:     davem@...emloft.net, Jakub Kicinski <kuba@...nel.org>,
        netdev@...r.kernel.org, Hemant Kumar <hemantk@...eaurora.org>,
        Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
Subject: Re: [PATCH v4 1/2] net: Add mhi-net driver

Hi Eric,

On Thu, 15 Oct 2020 at 20:56, Eric Dumazet <eric.dumazet@...il.com> wrote:
>
>
>
> On 10/15/20 3:29 PM, Loic Poulain wrote:
> > On Thu, 15 Oct 2020 at 14:41, Eric Dumazet <eric.dumazet@...il.com> wrote:
> >>
> >>
> >>
> >> On 10/15/20 12:31 PM, Loic Poulain wrote:
> >>> This patch adds a new network driver implementing MHI transport for
> >>> network packets. Packets can be in any format, though QMAP (rmnet)
> >>> is the usual protocol (flow control + PDN mux).
> >>>
> >>> It support two MHI devices, IP_HW0 which is, the path to the IPA
> >>> (IP accelerator) on qcom modem, And IP_SW0 which is the software
> >>> driven IP path (to modem CPU).
> >>>
> >>>
> >>> +static int mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev)
> >>> +{
> >>> +     struct mhi_net_dev *mhi_netdev = netdev_priv(ndev);
> >>> +     struct mhi_device *mdev = mhi_netdev->mdev;
> >>> +     int err;
> >>> +
> >>> +     skb_tx_timestamp(skb);
> >>> +
> >>> +     /* mhi_queue_skb is not thread-safe, but xmit is serialized by the
> >>> +      * network core. Once MHI core will be thread save, migrate to
> >>> +      * NETIF_F_LLTX support.
> >>> +      */
> >>> +     err = mhi_queue_skb(mdev, DMA_TO_DEVICE, skb, skb->len, MHI_EOT);
> >>> +     if (err == -ENOMEM) {
> >>> +             netif_stop_queue(ndev);
> >>
> >> If you return NETDEV_TX_BUSY, this means this skb will be requeues,
> >> then sent again right away, and this will potentially loop forever.
> >
> > The TX queue is stopped in that case, so the net core will not loop, right?
>
> -ENOMEM suggests a memory allocation failed.
>
> What is going to restart the queue when memory is available ?

The queue is restarted as soon as new ring elements are available, in
the tx complete callback (mhi_net_ul_callback).

>
> -ENOMEM seems weird if used for queue being full.

Regarding MHI core, that means no element is available in the ring to
push the buffer, so maybe -ENOSPC would be more suitable? This change
could be done in a subsequent series since it would request to modify
MHI core and other MHI drivers.

I'm not sure this is the right way, but this 'stop-queue and return
busy' is a pattern used in various other network drivers. However, I
understand that a better solution would be to stop the queue earlier,
as soon as ring is full and prevent this abnormal situation.

>
> >
> >>
> >> Also skb_tx_timestamp() would be called multiple times.
> >
> > OK so I'm going to remove that, maybe the MHI layer should mark
> > timestamp instead.
>
> Yes, probably.
>

Powered by blists - more mailing lists