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] [day] [month] [year] [list]
Message-ID: <CAJxxZ0MU3D3ZdMoyzzO=3OAMzvmtm=M9gYHNQKvzoKome8UzpQ@mail.gmail.com>
Date:	Thu, 24 Jul 2014 16:28:35 +0800
From:	Sonic Zhang <sonic.adi@...il.com>
To:	Francois Romieu <romieu@...zoreil.com>
Cc:	"David S. Miller" <davem@...emloft.net>,
	netdev <netdev@...r.kernel.org>,
	adi-buildroot-devel@...ts.sourceforge.net,
	Sonic Zhang <sonic.zhang@...log.com>,
	Eric Dumazet <eric.dumazet@...il.com>,
	David Laight <David.Laight@...lab.com>
Subject: Re: [PATCH v7] bfin_mac: convert bfin Ethernet driver to NAPI framework

Hi Francois,

On Wed, Jul 23, 2014 at 6:16 AM, Francois Romieu <romieu@...zoreil.com> wrote:
> Sonic Zhang <sonic.adi@...il.com> :
> [...]
>> diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
>> index 7ae74d4..8924802 100644
>> --- a/drivers/net/ethernet/adi/bfin_mac.c
>> +++ b/drivers/net/ethernet/adi/bfin_mac.c
> [...]
>> @@ -1302,41 +1303,53 @@ out:
>>       current_rx_ptr = current_rx_ptr->next;
>>  }
>>
>> +static int bfin_mac_poll(struct napi_struct *napi, int budget)
>> +{
>> +     int i = 0;
>> +     struct bfin_mac_local *lp = container_of(napi,
>> +                                              struct bfin_mac_local,
>> +                                              napi);
>> +
>> +     while (current_rx_ptr->status.status_word != 0 && i < budget) {
>> +             bfin_mac_rx(lp, budget);
>> +             i++;
>> +     }
>> +
>> +     if (i < budget) {
>> +             napi_complete(napi);
>> +             if (lp->rx_irq_disabled--)
>> +                     if (!lp->rx_irq_disabled)
>> +                             enable_irq(IRQ_MAC_RX);
>> +     }
> [...]
>>  static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
>>  {
>> +     struct bfin_mac_local *lp = netdev_priv(dev_id);
>> +     u32 status;
>> +
>> +     status = bfin_read_DMA1_IRQ_STATUS();
>> +
>> +     bfin_write_DMA1_IRQ_STATUS(status | DMA_DONE | DMA_ERR);
>> +     if ((status & DMA_DONE) && napi_schedule_prep(&lp->napi)) {
>> +             if (!lp->rx_irq_disabled++)
>> +                     disable_irq_nosync(IRQ_MAC_RX);
>> +             __napi_schedule(&lp->napi);
>
> If netpoll scavenges between napi_schedule_prep and lp->rx_irq_disabled++
> on a different CPU, bfin_mac_interrupt may later __napi_schedule while
> already napi_completed in netpoll...bfin_mac_poll(): bfin_mac_poll won't
> be run in net_rx_action and IRQ_MAC_RX will stay disabled.
>
> I don't know if something on the blackfin arch prevents the window to
> widen and makes it moot.
>
> As the bfin_mac driver requests the single non shared IRQ_MAC_RX irq,
> couldn't we instead:
>
> static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
> [...]
>         if (status & DMA_DONE) {
>                 disable_irq_nosync(IRQ_MAC_RX);
>                 /* Code won't return here until a scheduled poll enables irq. */
>                 set_bit(BFIN_IRQ_DISABLED, &lp->flags);
>                 napi_schedule(&lp->napi);
>         }
>
> static int bfin_mac_poll(struct napi_struct *napi, int budget)
> [...]
>         if (i < budget) {
>                 napi_complete(napi);
>                 if (test_and_clear_bit(BFIN_IRQ_DISABLED, &lp->flags))
>                         enable_irq(IRQ_MAC_RX);
>         }
>
> Comments ?

Yes, you suggestion can make sure both the balanced operations of the
MAC RX IRQ and the NAPI poll is always called with MAC RX IRQ
disabled. I just tested your suggestion on Blackfin with and without
netpoll loop. Both work well.

Thanks,

Sonic Zhang
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ