From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAF41C07E99 for ; Fri, 9 Jul 2021 07:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C24426139A for ; Fri, 9 Jul 2021 07:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbhGIHee (ORCPT ); Fri, 9 Jul 2021 03:34:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:40736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbhGIHee (ORCPT ); Fri, 9 Jul 2021 03:34:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 622806139A for ; Fri, 9 Jul 2021 07:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625815911; bh=gO6fe7uu30K1aRnJxP7G3No2PQGO/1V5QqwZY5CeLI8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lYUm+j8upcUL50Az08+EBU0dwWZU56oomKlMVyUoaxM97H4AamGMy2RrkkfudXlIE cqJ2gLkAvGoZbEO90NOsfbu67/NjDxKqOH069tyq1nAm30PYCSlpMWWf1uho50HScs rQjiYB0/AfoYcZXnZk7dGWxaoJNoBZPUSIvVeZF6xiL0bU8IRfoiTKh7/LTFF4q85v taW8B2ZI2mgqfq974OwdagK8U5g1zmXzGzhDuYblIiREYvXrBpjyIrczTZRPYPpRfk lBaOsQDgaYKq1dQ7Ok83R/zVXHZFQyfA25pUkugVP4jfKhXgH1MjTGc1tb7lvyH/sw nQVOmCs7xc4GQ== Received: by mail-wr1-f43.google.com with SMTP id l7so9880775wrv.7 for ; Fri, 09 Jul 2021 00:31:51 -0700 (PDT) X-Gm-Message-State: AOAM531N8rkW+pm17OuC/VfAAxyawLduHBWocF+hm/TpSApkGslZW/tM KRPP+VZ5hLEyuJiQ7KmfLY8Wnq3UtKjf62VUJgo= X-Google-Smtp-Source: ABdhPJx+nO3v98cdGJnkOaQvoqTOXfH9nxd97AciSeiPNXpBfrmrt3WRl7pX/ZHJgpMDpo0uCU+jHrC4WYwrKpwfMp4= X-Received: by 2002:adf:b318:: with SMTP id j24mr15695932wrd.361.1625815909957; Fri, 09 Jul 2021 00:31:49 -0700 (PDT) MIME-Version: 1.0 References: <60B24AC2.9050505@gmail.com> <60B611C6.2000801@gmail.com> <60B65BBB.2040507@gmail.com> <877dipgyrb.ffs@nanos.tec.linutronix.de> <60D1DAC1.9060200@gmail.com> <60D22F1D.1000205@gmail.com> <60D361FF.70905@gmail.com> <60DF62DA.6030508@gmail.com> <60E75057.60706@gmail.com> In-Reply-To: <60E75057.60706@gmail.com> From: Arnd Bergmann Date: Fri, 9 Jul 2021 09:31:34 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Realtek 8139 problem on 486. To: Nikolai Zhubr Cc: "Maciej W. Rozycki" , Thomas Gleixner , Heiner Kallweit , netdev , "the arch/x86 maintainers" , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jul 8, 2021 at 9:21 PM Nikolai Zhubr wrote: > > Hello Arnd, > > 03.07.2021 12:10, Arnd Bergmann: > > The simplest workaround would be to just move the > > "spin_lock_irqsave(&tp->lock, flags);" a few lines down, below the rx > > processing. This keeps the locking rules exactly how they were before > > Indeed, moving spin_lock_irqsave below rtl8139_rx eliminated the warn_on > message apparently, here is a new log: > > https://pastebin.com/dVFNVEu4 > > and here is my resulting diff: > > https://pastebin.com/CzNzsUPu Ok, great, the patch looks good to me, and I think we should just merge that, in addition to Maciej's bugfix for the platform. > My usual tests run fine. However I still see 2 issues: > > 1. I do not understand all this locking thing enough to do a good > cleanup myself, and it looks like it needs one; A lot of drivers need one. With your latest patch, I'm confident enough that it's not getting worse here and given the age of this device I don't think the cleanup is required. It's probably possible to squeeze out a little more performance from this device on SMP systems by improving it, but this would still be hopeless to compete against a $5 gigabit ethernet card. > 2. It looks like in case of incorrect (edge) triggering mode, the "poll > approach" with no loop added in the poll function would still allow a > race window, as explained in following outline (from some previous mails): > > 22.06.2021 14:12, David Laight: > > Typically you need to: > > 1) stop the chip driving IRQ low. > > 2) process all the completed RX and TX entries. > > 3) clear the chip's interrupt pending bits (often write to clear). > > 4) check for completed RX/TX entries, back to 2 if found. > > 5) enable driving IRQ. > > > > The loop (4) is needed because of the timing window between > > (2) and (3). > > You can swap (2) and (3) over - but then you get an additional > > interrupt if packets arrive during processing - which is common. > > So in terms of such outline, the "poll approach" now implements 1, 2, 3, > 5 but still misses 4, and my understanding is that it is therefore still > not a complete solution for the broken triggering case (Although > practically, the time window might be too small for the race effect to > be ever observable) From my previous testing I know that such a loop > does not affect the perfomance too much anyway, so it seems quite safe > to add it. Maybe I've missunderstood something though. The latest version of your patch already does what David explained as the alternative: the 'ack' (step 3) happens before processing the interrupts (2), so you don't need step 4 for correctness. You had that in the previous version of the patch that had the loop, and since you have experimentally shown that it makes no significant difference to performance, I'd rather leave it out for simplicity. If another event becomes pending after the Ack but before the napi_complete_done(), then we get an interrupt and call napi_schedule() again. For some reason, the TxErr bit is only cleared after tx processing, so we could miss an error event, but that seems fine as the tx errors are not handled in any way other than counting them, which is already unreliable if multiple transmits fail before the interrupt comes. Arnd