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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C62EC433F5 for ; Sun, 13 Mar 2022 20:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235573AbiCMUpO (ORCPT ); Sun, 13 Mar 2022 16:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbiCMUpO (ORCPT ); Sun, 13 Mar 2022 16:45:14 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A301A17061; Sun, 13 Mar 2022 13:44:05 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id h14so23809126lfk.11; Sun, 13 Mar 2022 13:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=10NJX5WEPZhAbw38QlaBhRLwrw0zlgt8u1rSp6vim3c=; b=hIqFsjMZ7GAYY0cKldKhaMwlr68shtyELE9Nw15HAcr4D9wW3B3CzCVtx/FHBLG1DZ Cx+4pyV7tXqH/46vP7wzOWut2JP9PvA0DvmhZ0q5kxkjgCD8jXQeq1EPGtybntQeuRgz MPqGzo1gvQiWcLd3gqfzFGdym4v4EiUwX20liLDkRAoQKxMfhOzw8M2ysODuE/gIMPPj +oJUEP6hwaXDLO3TSUDZSgAQj0jPMT7IDsH/5MrLtMjGpcKy6pGADCNsFSv1xiioNtBM C8dT+V/kVAP8AuMOSxfenuRSXvhAez8FMQZIVbUoiFg2akPaSfJRhtTvdVGgJW0C1vG8 Y3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=10NJX5WEPZhAbw38QlaBhRLwrw0zlgt8u1rSp6vim3c=; b=potcgTD2X1KFhTEfh/QWP2r0QDZFzk1UJ6N/Jo4gvKM65W3a24SMInRZmTDztVdvLX nQ0Sl4ly99smXmb3t6i3ZzALKcnz9EAqRzHH4hT/PZV9UsS9klk7n8e1/rYk3jdDus04 64yBdpjSc//ZzQtAc8SmMPodaleVfcivDuzXZ3QgaNsyps6BgWffhBiMwDr/92/qfp/v QxRg9NHqH92yepIoLp5Xa3fjhtviNaoMK+qi6yIuHm+FKofb9BQ03loZp1XyPItKajPC Ah3gL2/azv2DLhBSnijPYG5BhVrsm80MtaTyWGnna1U6+E8Me+5Q7+R6XVAp8ztRg3Kq p5aQ== X-Gm-Message-State: AOAM530jP40yePjxgUqKK7gM5ptx6JPGn9XRlOURPZbWfFecadDFD3FV ZOz0XSJHzc4ZA+eHGpwbzMY0TmWgYjk2qd78tnk= X-Google-Smtp-Source: ABdhPJz3f4DsSflyf7bXBTZPpPzDvIkAx9i2kIjmDti/zE3sTnArKFPU4uBfwp8C9/kMPcSZ7WsSiw+4IQi/YdD1FPs= X-Received: by 2002:ac2:4241:0:b0:448:4b83:8372 with SMTP id m1-20020ac24241000000b004484b838372mr11558232lfl.463.1647204243861; Sun, 13 Mar 2022 13:44:03 -0700 (PDT) MIME-Version: 1.0 References: <20220207144804.708118-1-miquel.raynal@bootlin.com> <20220207144804.708118-14-miquel.raynal@bootlin.com> <20220303191723.39b87766@xps13> <20220304115432.7913f2ef@xps13> In-Reply-To: <20220304115432.7913f2ef@xps13> From: Alexander Aring Date: Sun, 13 Mar 2022 16:43:52 -0400 Message-ID: Subject: Re: [PATCH wpan-next v2 13/14] net: mac802154: Introduce a tx queue flushing mechanism To: Miquel Raynal Cc: Stefan Schmidt , linux-wpan - ML , "David S. Miller" , Jakub Kicinski , "open list:NETWORKING [GENERAL]" , David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Hi, On Fri, Mar 4, 2022 at 5:54 AM Miquel Raynal wrote: > I had a second look at it and it appears to me that the issue was > already there and is structural. We just did not really cared about it > because we didn't bother with synchronization issues. > I am not sure if I understand correctly. We stop the queue at some specific moment and we need to make sure that xmit_do() is not called or can't be called anymore. I was thinking about: void ieee802154_disable_queue(struct ieee802154_hw *hw) { struct ieee802154_local *local = hw_to_local(hw); struct ieee802154_sub_if_data *sdata; rcu_read_lock(); list_for_each_entry_rcu(sdata, &local->interfaces, list) { if (!sdata->dev) continue; netif_tx_disable(sdata->dev); } rcu_read_unlock(); } EXPORT_SYMBOL(ieee802154_stop_queue); >From my quick view is that "netif_tx_disable()" ensures by holding locks and other things and doing netif_tx_stop_queue() it we can be sure there will be no xmit_do() going on while it's called and afterwards. It can be that there are still transmissions on the transceiver that are on the way, but then your atomic counter and wait_event() will come in place. We need to be sure there will be nothing queued anymore for transmission what (in my opinion) tx_disable() does. from any context. We might need to review some netif callbacks... I have in my mind for example stop(), maybe netif_tx_stop_queue() is enough (because the context is like netif_tx_disable(), helding similar locks, etc.) but we might want to be sure that nothing is going on anymore by using your wait_event() with counter. Is there any problem which I don't see? - Alex