From: Havard Skinnemoen <havard@skinnemoen.net>
To: David Miller <davem@davemloft.net>
Cc: nicolas.ferre@atmel.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, plagnioj@jcrosoft.com,
jamie@jamieiles.com, linux-kernel@vger.kernel.org,
patrice.vilchez@atmel.com
Subject: Re: [PATCH 04/10] net/macb: Fix a race in macb_start_xmit()
Date: Thu, 6 Sep 2012 17:49:11 +0200 [thread overview]
Message-ID: <CACiLriTSddM-5pnpii9c+4dA++OrsKovGLabegdwSRLchuSnAA@mail.gmail.com> (raw)
In-Reply-To: <20120905.173023.2235590074897156746.davem@davemloft.net>
On Wed, Sep 5, 2012 at 11:30 PM, David Miller <davem@davemloft.net> wrote:
> From: Nicolas Ferre <nicolas.ferre@atmel.com>
> Date: Wed, 5 Sep 2012 10:19:11 +0200
>
>> From: Havard Skinnemoen <havard@skinnemoen.net>
>>
>> Fix a race in macb_start_xmit() where we unconditionally set the TSTART bit.
>> If an underrun just happened (we do this with interrupts disabled, so it might
>> not have been handled yet), the controller starts transmitting from the first
>> entry in the ring, which is usually wrong.
>> Restart the controller after error handling.
>>
>> Signed-off-by: Havard Skinnemoen <havard@skinnemoen.net>
>> [nicolas.ferre@atmel.com: split patch in topics]
>> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
>
> Accumulating special case code and checks into the hot path of TX packet
> processing is extremely unwise.
>
> Instead, when you handle the TX error conditions and reset the chip you
> should first ensure that there are no flows of control in the transmit
> function of your driver by using the appropriate locking et al. facilities.
IIRC, the hardware resets the ring pointers when an error happens, and
if we set TSTART right after that happens, the hardware will happily
transmit whatever is sitting in the beginning of the ring. This is
what I was trying to avoid.
The details are a bit hazy as it's been a while since I looked at
this, so it could be that simply letting it happen and using a bigger
hammer during reset processing might work just as well. Just want to
make sure y'all understand that we're talking about a race against
hardware, not against interrupt handlers, threads or anything that can
be solved by locking :)
Havard
next prev parent reply other threads:[~2012-09-06 15:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:19 [PATCH 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup Nicolas Ferre
2012-09-05 8:19 ` [PATCH 01/10] net/macb: Add support for Gigabit Ethernet mode Nicolas Ferre
2012-09-05 8:19 ` [PATCH 02/10] net/macb: memory barriers cleanup Nicolas Ferre
2012-09-05 8:19 ` [PATCH 03/10] net/macb: change debugging messages Nicolas Ferre
2012-09-05 8:19 ` [PATCH 04/10] net/macb: Fix a race in macb_start_xmit() Nicolas Ferre
2012-09-05 21:30 ` David Miller
2012-09-06 14:52 ` Nicolas Ferre
2012-09-06 15:49 ` Havard Skinnemoen [this message]
2012-09-07 16:34 ` Nicolas Ferre
2012-09-05 9:00 ` [PATCH 05/10] net/macb: clean up ring buffer logic Nicolas Ferre
2012-09-05 9:00 ` [PATCH 06/10] net/macb: better manage tx errors Nicolas Ferre
2012-09-05 9:00 ` [PATCH 07/10] net/macb: tx status is more than 8 bits now Nicolas Ferre
2012-09-05 9:00 ` [PATCH 08/10] net/macb: macb_get_drvinfo: add GEM/MACB suffix to differentiate revision Nicolas Ferre
2012-09-05 21:31 ` David Miller
2012-09-05 23:27 ` Ben Hutchings
2012-09-06 14:01 ` Nicolas Ferre
2012-09-06 17:42 ` David Miller
2012-09-05 9:00 ` [PATCH 09/10] net/macb: ethtool interface: add register dump feature Nicolas Ferre
2012-09-05 21:32 ` David Miller
2012-09-05 23:36 ` Ben Hutchings
2012-09-06 14:20 ` [PATCH v2 " Nicolas Ferre
2012-09-06 14:34 ` Ben Hutchings
2012-09-05 9:04 ` [PATCH 10/10] net/macb: Offset first RX buffer by two bytes Nicolas Ferre
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=CACiLriTSddM-5pnpii9c+4dA++OrsKovGLabegdwSRLchuSnAA@mail.gmail.com \
--to=havard@skinnemoen.net \
--cc=davem@davemloft.net \
--cc=jamie@jamieiles.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
--cc=patrice.vilchez@atmel.com \
--cc=plagnioj@jcrosoft.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;
as well as URLs for NNTP newsgroup(s).