From patchwork Tue Apr 20 12:27:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Cree X-Patchwork-Id: 425052 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 599A8C433ED for ; Tue, 20 Apr 2021 12:27:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B901611F2 for ; Tue, 20 Apr 2021 12:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbhDTM15 (ORCPT ); Tue, 20 Apr 2021 08:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbhDTM14 (ORCPT ); Tue, 20 Apr 2021 08:27:56 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 292BAC06174A for ; Tue, 20 Apr 2021 05:27:25 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id p10-20020a1c544a0000b02901387e17700fso958496wmi.2 for ; Tue, 20 Apr 2021 05:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=XoeIRb0eHe4jsIbV771Ps2kfvlWkmrvexCN/09xmdRg=; b=OUlETLIbze08UFiFmolckV0gz8pZXUmgDoaedMuU8i409mNQ2SBZm67EqPYYxCrSsT rhSYXMxLU8sMEyWZk4j4hnaSKGOpMXew6q8kIH45AUHsFv18zh9MLhrDBhRvMfO3BdIv WfDbWnOy0B2tOfIGgvc+2mvrwp4U92COMIsIE0ORSbHurMErzjSeC+DornLE9uF1O1+j vT8KYj1rhGDu+xBegMuyq3ZYzXz5ggl+pR6D1aMuAQyYN+yZZl4c8Rf3aXeBxnddKPh1 INLyj9RvTTHVmVozXbYpZ3n6I0gLBO2F/lgIPfD5iUZcglcTWGqkdIjIr/eWI+56Ig2p d99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=XoeIRb0eHe4jsIbV771Ps2kfvlWkmrvexCN/09xmdRg=; b=bHvvZWcBEHTkMyZA50i1gFbBGWUEqBUeRtd/RC7J6Rnnl15ShTKh/Xj2/f8hay6aWN W/Vek0KDZoL+iqevXopde4P3EQsfAAnc9WGxTyhuRlA5PnVME6L9Icqli+0wokl7XjU3 k3cJfkWzcfViQv74XbznwUvr8+iOhgzJKs87dNYc89aalbD1v2NU1ljtCQ5XKtjmhS53 wa3RLO0FYNWVVIcO8rsgAT3n0JmfTfDdPuEHCrnS7zWEiLPMUtvunuYmgu3lbFe/tYPQ p59p8UaXVU/WR6WLHzQkn+3ZEn98lHXjOZcX6O5/QSn1B5HE5AtWTljacVBtUwlnVjfh dLYg== X-Gm-Message-State: AOAM532j30Tbw1jN5DfTh1Skqml1f1Qx1j+nO+6KrYrIsKnM5tzwIuVV gM0GT+L97wIg64XsOmc2nfDxdk9a12aIwA== X-Google-Smtp-Source: ABdhPJxX5FY3R1Qh9PnNPbecdhi/s/Keko4Jy2sOXJHAU/QPA5k76AMJ+eEc/Xuhg5HJ6FbAF5fkMg== X-Received: by 2002:a1c:4482:: with SMTP id r124mr4272038wma.42.1618921643980; Tue, 20 Apr 2021 05:27:23 -0700 (PDT) Received: from [10.108.8.69] ([149.199.80.129]) by smtp.gmail.com with ESMTPSA id e9sm28083181wrs.84.2021.04.20.05.27.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Apr 2021 05:27:23 -0700 (PDT) Subject: [PATCH net 1/3] sfc: farch: fix TX queue lookup in TX flush done handling From: Edward Cree To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, themsley@voiceflex.com References: <6b97b589-91fe-d71e-a7d0-5662a4f7a91c@gmail.com> Message-ID: <62859b67-9de0-55bc-f5d3-9ceba902ce08@gmail.com> Date: Tue, 20 Apr 2021 13:27:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <6b97b589-91fe-d71e-a7d0-5662a4f7a91c@gmail.com> Content-Language: en-GB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We're starting from a TXQ instance number ('qid'), not a TXQ type, so efx_get_tx_queue() is inappropriate (and could return NULL, leading to panics). Fixes: 12804793b17c ("sfc: decouple TXQ type from label") Reported-by: Trevor Hemsley Cc: stable@vger.kernel.org Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/farch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c index d75cf5ff5686..f89ebe0073dd 100644 --- a/drivers/net/ethernet/sfc/farch.c +++ b/drivers/net/ethernet/sfc/farch.c @@ -1081,16 +1081,16 @@ static u16 efx_farch_handle_rx_not_ok(struct efx_rx_queue *rx_queue, efx_farch_handle_tx_flush_done(struct efx_nic *efx, efx_qword_t *event) { struct efx_tx_queue *tx_queue; + struct efx_channel *channel; int qid; qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA); if (qid < EFX_MAX_TXQ_PER_CHANNEL * (efx->n_tx_channels + efx->n_extra_tx_channels)) { - tx_queue = efx_get_tx_queue(efx, qid / EFX_MAX_TXQ_PER_CHANNEL, - qid % EFX_MAX_TXQ_PER_CHANNEL); - if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0)) { + channel = efx_get_tx_channel(efx, qid / EFX_MAX_TXQ_PER_CHANNEL); + tx_queue = channel->tx_queue + (qid % EFX_MAX_TXQ_PER_CHANNEL); + if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0)) efx_farch_magic_event(tx_queue->channel, EFX_CHANNEL_MAGIC_TX_DRAIN(tx_queue)); - } } } From patchwork Tue Apr 20 12:28:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Cree X-Patchwork-Id: 425051 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 B3679C433B4 for ; Tue, 20 Apr 2021 12:28:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DBA3613C3 for ; Tue, 20 Apr 2021 12:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbhDTM3E (ORCPT ); Tue, 20 Apr 2021 08:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbhDTM3D (ORCPT ); Tue, 20 Apr 2021 08:29:03 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7900FC06174A for ; Tue, 20 Apr 2021 05:28:32 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id n127so8255538wmb.5 for ; Tue, 20 Apr 2021 05:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=GsyGKufi5wHCisc4G59o/96x9Xn+H/DMjNSI77b5beU=; b=l3Ji/ViW/UOhE9jP9CoFr1WNOlWh7mSk3O2btmRwJ3fDCjDpuVEO8p8eNI4TdFrVoE YW4QyiO0Sk/8ryul8Q9/K5jvun/fCPeYDS6ADqUq0nRsXFc4S3iO78iqOYI55ybtLhNP TNMB9oI3OVeLXOVW8kgeVFdPJb43WR9YC0lrGnrFSKAZQInLDRQKQBNP3EY1wnG7rv7f SBZYECbuF6PTt5hl1Mfi/nLaKU2w3KghxQIg0s0lN+xRrI/ado2pyKaLVgWT6HxHM/pe eT2n709B5KOTJzSCNOPlXgSH1njo+K2TCQBxssxnNxU2xGWirq2zqJVjN9pTP00nqiG/ TfrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GsyGKufi5wHCisc4G59o/96x9Xn+H/DMjNSI77b5beU=; b=EwaW7E5e2oFLM8SKCU4hRmKAYAayf8SCMU8bUix0HcWU52BBYz3l/X9o1bDihZqIqP 0jpQKs4Idlf4oPW2K/kSEfmHTM9+Ey73KVXF+0p9LT02Jaq5qJ3+CLLqDxl5DoFUn6AT 4ynGvAaCl8u+GnA/FpElmZkMBEMAQpp5z8zYi+9yqxooZdx//R2TjDTpYsik6wNJJwBG vrS9iWnA/kdMQsOSEhL/n335KCWsAlfJa+z9Y7+ADXP5fPc7gu0hlADzbrTk3E058Zny 4l+bnKF97hypxtpXCp45JsqB8Wy5Ff5PZLpU6ZN9Mo39cfaIQjN+5iFy20FvDVXugV8C xFzg== X-Gm-Message-State: AOAM530hPteO0y/xJahYuiNu8b6P0FkIiI9Zrn2Fdr2vqjWOk99jm5g+ Qf9HzUd+AfpJtVD8huvF6wgC7vPPcy48rw== X-Google-Smtp-Source: ABdhPJz9NE4uS9qljtgwbrfwTo2CsfXSIWCPqYpycCFHJ988VobvRMRxFlp+dtdN2GiIa/eaM2viPA== X-Received: by 2002:a7b:cd04:: with SMTP id f4mr4412297wmj.84.1618921710351; Tue, 20 Apr 2021 05:28:30 -0700 (PDT) Received: from [10.108.8.69] ([149.199.80.129]) by smtp.gmail.com with ESMTPSA id s16sm3133716wmh.11.2021.04.20.05.28.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Apr 2021 05:28:30 -0700 (PDT) Subject: [PATCH net 2/3] sfc: farch: fix TX queue lookup in TX event handling From: Edward Cree To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, themsley@voiceflex.com References: <6b97b589-91fe-d71e-a7d0-5662a4f7a91c@gmail.com> Message-ID: <6f8dc43a-4693-3f2e-51d9-c941e2256a2c@gmail.com> Date: Tue, 20 Apr 2021 13:28:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <6b97b589-91fe-d71e-a7d0-5662a4f7a91c@gmail.com> Content-Language: en-GB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We're starting from a TXQ label, not a TXQ type, so efx_channel_get_tx_queue() is inappropriate (and could return NULL, leading to panics). Fixes: 12804793b17c ("sfc: decouple TXQ type from label") Cc: stable@vger.kernel.org Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/farch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c index f89ebe0073dd..49df02ecee91 100644 --- a/drivers/net/ethernet/sfc/farch.c +++ b/drivers/net/ethernet/sfc/farch.c @@ -835,14 +835,14 @@ static void efx_farch_magic_event(struct efx_channel *channel, u32 magic) /* Transmit completion */ tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_DESC_PTR); tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL); - tx_queue = efx_channel_get_tx_queue( - channel, tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL); + tx_queue = channel->tx_queue + + (tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL); efx_xmit_done(tx_queue, tx_ev_desc_ptr); } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) { /* Rewrite the FIFO write pointer */ tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL); - tx_queue = efx_channel_get_tx_queue( - channel, tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL); + tx_queue = channel->tx_queue + + (tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL); netif_tx_lock(efx->net_dev); efx_farch_notify_tx_desc(tx_queue);