From nobody Mon Jun 29 19:37:39 2026 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 EB028C433F5 for ; Thu, 3 Feb 2022 17:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352577AbiBCRJr (ORCPT ); Thu, 3 Feb 2022 12:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352518AbiBCRJe (ORCPT ); Thu, 3 Feb 2022 12:09:34 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBFD6C06173B for ; Thu, 3 Feb 2022 09:09:34 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id x6so2629364ilg.9 for ; Thu, 03 Feb 2022 09:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HDx7zrECt0lRbn6ErTR+Jkn99RQBQ9k/kBc416RdGfc=; b=TjhIqGFUReCXhgyjJ7DYcxUGbwXOKufhBPP/MOfmOvCSCBciZLnMwUeQ96hHaYkQPb lmcXyk96hPRDuWXI0U4tfltE2PTFy94slEmLlUkMikgjc2mX4NaIZdMbsYi3vVgXUtLf 3YqeDO5DObZCYFaZNU/k77u71LZnlgWBREW3JkuyIMXxbEBYiraQH9uwOApbxT+f0HHq IPZRTRGXrykjXtyqoMdbZjTS3TX+C0VomNYjfidqyKVA5tM7R4+/TtMd269gBnGqYPJk 0tDgyYuigex5iJggC8A1l+9B81XV3rbvr+YEspMGTts3br3ZINHht2U2/qVM9ejsz5bG WndQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HDx7zrECt0lRbn6ErTR+Jkn99RQBQ9k/kBc416RdGfc=; b=oFpSaRNAiVPzNZ117AgXmax1Ch7+JNnQB787HR1zU8dXvgI8eqhfYIHOhFPPNDjtMc t107EjfQ7XBA6ahty2ebOncIOnuI4EztgqSnzf3eI/Gpgl+AAMgGelGmtOtrVXqd0z0d 47oTA913OoH+QC2tBg8nUYiRQ+VkKsuMAPFGEBKJPZLVJWHFgIe2H00bGLedJqoMbOtM wIZYzgW+Dp6AKNN5UDH0whWMlbExTdds3pgRDUh/n5vLAvl/0iqJ2pfDBFgKZGYlSQLI n0fi1gff/J7JE/8aakpqqBjrN0v236CalUUZ9mMjgDdBLSFK4KFE9c4xJdaMhaJ8V8ra M01A== X-Gm-Message-State: AOAM5319zM/8Hd+/FVrt16kfPmgU48syQJiX8U2wxZlXt2j3E8GgyxgT F3xjClZkHHhMHyuGRoIVDG5DCg== X-Google-Smtp-Source: ABdhPJz5StQMD32VXFnbCoQKHcybhlADU8uiE5tXhUIqC5kLooVjU+SY5inGUl/6NJ8w5o3T44lFmw== X-Received: by 2002:a92:d4ce:: with SMTP id o14mr20659791ilm.218.1643908174073; Thu, 03 Feb 2022 09:09:34 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:33 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 01/10] net: ipa: kill replenish_saved Date: Thu, 3 Feb 2022 11:09:18 -0600 Message-Id: <20220203170927.770572-2-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The replenish_saved field keeps track of the number of times a new buffer is added to the backlog when replenishing is disabled. We don't really use it though, so there's no need for us to track it separately. Whether replenishing is enabled or not, we can simply increment the backlog. Get rid of replenish_saved, and initialize and increment the backlog where it would have otherwise been used. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 17 ++++------------- drivers/net/ipa/ipa_endpoint.h | 2 -- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index fffd0a784ef2c..a9f6d4083f869 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1090,9 +1090,8 @@ static int ipa_endpoint_replenish_one(struct ipa_endp= oint *endpoint) * endpoint, based on the number of entries in the underlying channel ring * buffer. If an endpoint's "backlog" is non-zero, it indicates how many * more receive buffers can be supplied to the hardware. Replenishing for - * an endpoint can be disabled, in which case requests to replenish a - * buffer are "saved", and transferred to the backlog once it is re-enabled - * again. + * an endpoint can be disabled, in which case buffers are not queued to + * the hardware. */ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add= _one) { @@ -1102,7 +1101,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoin= t *endpoint, bool add_one) =20 if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) { if (add_one) - atomic_inc(&endpoint->replenish_saved); + atomic_inc(&endpoint->replenish_backlog); return; } =20 @@ -1147,11 +1146,8 @@ static void ipa_endpoint_replenish_enable(struct ipa= _endpoint *endpoint) { struct gsi *gsi =3D &endpoint->ipa->gsi; u32 max_backlog; - u32 saved; =20 set_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); - while ((saved =3D atomic_xchg(&endpoint->replenish_saved, 0))) - atomic_add(saved, &endpoint->replenish_backlog); =20 /* Start replenishing if hardware currently has no buffers */ max_backlog =3D gsi_channel_tre_max(gsi, endpoint->channel_id); @@ -1161,11 +1157,7 @@ static void ipa_endpoint_replenish_enable(struct ipa= _endpoint *endpoint) =20 static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) { - u32 backlog; - clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); - while ((backlog =3D atomic_xchg(&endpoint->replenish_backlog, 0))) - atomic_add(backlog, &endpoint->replenish_saved); } =20 static void ipa_endpoint_replenish_work(struct work_struct *work) @@ -1727,9 +1719,8 @@ static void ipa_endpoint_setup_one(struct ipa_endpoin= t *endpoint) */ clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); - atomic_set(&endpoint->replenish_saved, + atomic_set(&endpoint->replenish_backlog, gsi_channel_tre_max(gsi, endpoint->channel_id)); - atomic_set(&endpoint->replenish_backlog, 0); INIT_DELAYED_WORK(&endpoint->replenish_work, ipa_endpoint_replenish_work); } diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h index 0313cdc607de3..c95816d882a74 100644 --- a/drivers/net/ipa/ipa_endpoint.h +++ b/drivers/net/ipa/ipa_endpoint.h @@ -66,7 +66,6 @@ enum ipa_replenish_flag { * @netdev: Network device pointer, if endpoint uses one * @replenish_flags: Replenishing state flags * @replenish_ready: Number of replenish transactions without doorbell - * @replenish_saved: Replenish requests held while disabled * @replenish_backlog: Number of buffers needed to fill hardware queue * @replenish_work: Work item used for repeated replenish failures */ @@ -87,7 +86,6 @@ struct ipa_endpoint { /* Receive buffer replenishing for RX endpoints */ DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT); u32 replenish_ready; - atomic_t replenish_saved; atomic_t replenish_backlog; struct delayed_work replenish_work; /* global wq */ }; --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 39BFBC433F5 for ; Thu, 3 Feb 2022 17:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352515AbiBCRJu (ORCPT ); Thu, 3 Feb 2022 12:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352525AbiBCRJg (ORCPT ); Thu, 3 Feb 2022 12:09:36 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02962C061714 for ; Thu, 3 Feb 2022 09:09:36 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id o10so2697896ilh.0 for ; Thu, 03 Feb 2022 09:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S9Js8VpK5v34d/SHjXYqifp26sYx/3WFpJFibcc3jAA=; b=Dn5ffHOFIO+yxvEZJhMhn0TK54JUtSJ2/L9VR8EWcm2GiNI9xyomj0/XMucFfjR+Tg fhpqJKugfueNgWmfNR7AqjlAvAjpZyNz7nO1q7RWCnDNaQZxROARuFoWEXYxwZczrnPp luJ3+P4mfLGnSQ5BzdktgImcQ1HiNIfw4RAqTiVjsh5YbN9jyJcnjpxHspVIdp3dzkXl qUNxvbTwW6VrLRl/Hz/MiBaq0Un1xdjSUnyNRkUpZLvEuc6SWvl224SUPQ9HFrnck56v s6Xr4S501o1zb8Q2F79tjsRE9OtN9e/BtkkH5FabZ/QvqxO6OMKDrwk9vCNszyBSEFSN A2Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S9Js8VpK5v34d/SHjXYqifp26sYx/3WFpJFibcc3jAA=; b=ymraGvUh6QTCoQOKc7YNNx+75V3SIqFwVzV7gl5kGzCHRdR3KmV79ovC4/dICKlxue Skgrs5TDHefwgU3VocX/Njkw8yn3QbD18LvZWS7Q4K7EvHZBWoJm9OTEmCXWEt7Mdsc6 2WmKvDsWupacr0Fm5ci6srmLkg3yQUbvm85KENAOWynruygYiGV6hEFiiNryVrnDlnb/ elkqUVe1R1LfrXwyMwux8FoBSRBbZcHhCAhdufhe6HiixtaIUtBigONrPvQvkzV0PAyV 2+0bRCyWwPpbsTNJdpnyJXawT58NyT56VIxMhxH8Mq0WrhHqsd7ge2jthPSwjufEaFTx GApQ== X-Gm-Message-State: AOAM531xQpAPgRKLHmdmIlYBHu9U8d5AUPiaB/MiOFaGef+dYvujWBVd f4M2h51Zq3engrKNUvMNS565r5k0vJvrXCwo X-Google-Smtp-Source: ABdhPJysyug1E35eI4H34ILFMbMQbJPCwvEOSw1CqL4sKLek2Gd8fXdvo80lPbU6RyGAS50+Bn3uEw== X-Received: by 2002:a05:6e02:1a05:: with SMTP id s5mr14464952ild.231.1643908175442; Thu, 03 Feb 2022 09:09:35 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:34 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 02/10] net: ipa: allocate transaction before pages when replenishing Date: Thu, 3 Feb 2022 11:09:19 -0600 Message-Id: <20220203170927.770572-3-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A transaction failure only occurs if no more transactions are available for an endpoint. It's a very cheap test. When replenishing an RX endpoint buffer, there's no point in allocating pages if transactions are exhausted. So don't bother doing so unless the transaction allocation succeeds. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index a9f6d4083f869..f8dbd43949e16 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1046,14 +1046,14 @@ static int ipa_endpoint_replenish_one(struct ipa_en= dpoint *endpoint) u32 len; int ret; =20 + trans =3D ipa_endpoint_trans_alloc(endpoint, 1); + if (!trans) + return -ENOMEM; + buffer_size =3D endpoint->data->rx.buffer_size; page =3D dev_alloc_pages(get_order(buffer_size)); if (!page) - return -ENOMEM; - - trans =3D ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - goto err_free_pages; + goto err_trans_free; =20 /* Offset the buffer to make space for skb headroom */ offset =3D NET_SKB_PAD; @@ -1061,7 +1061,7 @@ static int ipa_endpoint_replenish_one(struct ipa_endp= oint *endpoint) =20 ret =3D gsi_trans_page_add(trans, page, len, offset); if (ret) - goto err_trans_free; + goto err_free_pages; trans->data =3D page; /* transaction owns page now */ =20 if (++endpoint->replenish_ready =3D=3D IPA_REPLENISH_BATCH) { @@ -1073,10 +1073,10 @@ static int ipa_endpoint_replenish_one(struct ipa_en= dpoint *endpoint) =20 return 0; =20 -err_trans_free: - gsi_trans_free(trans); err_free_pages: __free_pages(page, get_order(buffer_size)); +err_trans_free: + gsi_trans_free(trans); =20 return -ENOMEM; } --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 3F027C433FE for ; Thu, 3 Feb 2022 17:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352608AbiBCRJy (ORCPT ); Thu, 3 Feb 2022 12:09:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242220AbiBCRJn (ORCPT ); Thu, 3 Feb 2022 12:09:43 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AE0C061741 for ; Thu, 3 Feb 2022 09:09:37 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id r144so4047687iod.9 for ; Thu, 03 Feb 2022 09:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xl48elVtzdvJ/g20NXNECeobi1xogdrDqiancn7eDUY=; b=U+FRSTLhO8mv9K7+OqQpUKavuTqHUH23ppB7lEYSWgSmZEFzlvgloHdoSwAlrwAr9L a4AWeGKv1MyTq/ZSOo+LRgWDrySNDTtucHLZYW+NaHzdxnwmht4GO0xUdm1T1TnusRS0 /4NhgQbIdv4dFVWXXuvgZbp/rnxIaKyF8Au4GJ5qnZf069Dgx5YkI419tN7cOjbU7fyp lbogSwjz1tBePgY69Ui2uRN3K7eqbAClKdNQNBzSkQZM9AG7zLpErL8jkJzHNGj5TGwt 44iQyfrJwBRwWnjIEThSVm301yfZryebgKKDvKZMeALrGv7Eumt3CakBxuRWiRJpHgBl d7oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xl48elVtzdvJ/g20NXNECeobi1xogdrDqiancn7eDUY=; b=l44OYvQ9dRJ1vsWuQ7vTn/wtY4oV+oht9HCYy8jcwBHq4W8ZLQ/3aRLZ59Z7cSLJXP g69E4AKuMdRjpjZXkQ1Ks40/yJgVvGRf9sHAWWOTWMbuzWtM1nskG/iRudF0CmrKc+HT Fykf0FfXPcCu3bE0IiiCW1TcLRi3xqP2/5Ujmpl+pRBFRAXfEDqlMjd99cLp/0ZW57UO xFzM4JkuT7iYduWP9RjXTTPdHHiIYj0u1YyXlwItJu7Rinc6kGojBgH2V7vr78xu+heA W64FO0YwA/garP7btw1XgnP7ARJRUxFlOp1g0I+aTgTEwntH3f2eSP59FWZJtG9bCbRM MeMw== X-Gm-Message-State: AOAM533BVQvj0jMs79zMP26XxLtPudM9WUvkT6kPWEA0rnW3ZntbqCVn PJoUpbFaXR/8ihM5ysEHKfB7Dw== X-Google-Smtp-Source: ABdhPJzS6Tz0bFFNqMgE95uK21ifG3uUZr+k0LR8EqBX+XSLVF2jB35xfAjRzp1HetpD5mkTuczwvg== X-Received: by 2002:a05:6602:1512:: with SMTP id g18mr11947586iow.121.1643908176951; Thu, 03 Feb 2022 09:09:36 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:36 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 03/10] net: ipa: increment backlog in replenish caller Date: Thu, 3 Feb 2022 11:09:20 -0600 Message-Id: <20220203170927.770572-4-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Three spots call ipa_endpoint_replenish(), and just one of those requests that the backlog be incremented after completing the replenish operation. Instead, have the caller increment the backlog, and get rid of the add_one argument to ipa_endpoint_replenish(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index f8dbd43949e16..060a025d70ec6 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1084,7 +1084,6 @@ static int ipa_endpoint_replenish_one(struct ipa_endp= oint *endpoint) /** * ipa_endpoint_replenish() - Replenish endpoint receive buffers * @endpoint: Endpoint to be replenished - * @add_one: Whether this is replacing a just-consumed buffer * * The IPA hardware can hold a fixed number of receive buffers for an RX * endpoint, based on the number of entries in the underlying channel ring @@ -1093,24 +1092,17 @@ static int ipa_endpoint_replenish_one(struct ipa_en= dpoint *endpoint) * an endpoint can be disabled, in which case buffers are not queued to * the hardware. */ -static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add= _one) +static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) { struct gsi *gsi; u32 backlog; - int delta; =20 - if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) { - if (add_one) - atomic_inc(&endpoint->replenish_backlog); + if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) return; - } =20 - /* If already active, just update the backlog */ - if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) { - if (add_one) - atomic_inc(&endpoint->replenish_backlog); + /* Skip it if it's already active */ + if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) return; - } =20 while (atomic_dec_not_zero(&endpoint->replenish_backlog)) if (ipa_endpoint_replenish_one(endpoint)) @@ -1118,17 +1110,13 @@ static void ipa_endpoint_replenish(struct ipa_endpo= int *endpoint, bool add_one) =20 clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 - if (add_one) - atomic_inc(&endpoint->replenish_backlog); - return; =20 try_again_later: clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 /* The last one didn't succeed, so fix the backlog */ - delta =3D add_one ? 2 : 1; - backlog =3D atomic_add_return(delta, &endpoint->replenish_backlog); + backlog =3D atomic_inc_return(&endpoint->replenish_backlog); =20 /* Whenever a receive buffer transaction completes we'll try to * replenish again. It's unlikely, but if we fail to supply even @@ -1152,7 +1140,7 @@ static void ipa_endpoint_replenish_enable(struct ipa_= endpoint *endpoint) /* Start replenishing if hardware currently has no buffers */ max_backlog =3D gsi_channel_tre_max(gsi, endpoint->channel_id); if (atomic_read(&endpoint->replenish_backlog) =3D=3D max_backlog) - ipa_endpoint_replenish(endpoint, false); + ipa_endpoint_replenish(endpoint); } =20 static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) @@ -1167,7 +1155,7 @@ static void ipa_endpoint_replenish_work(struct work_s= truct *work) =20 endpoint =3D container_of(dwork, struct ipa_endpoint, replenish_work); =20 - ipa_endpoint_replenish(endpoint, false); + ipa_endpoint_replenish(endpoint); } =20 static void ipa_endpoint_skb_copy(struct ipa_endpoint *endpoint, @@ -1372,7 +1360,8 @@ static void ipa_endpoint_rx_complete(struct ipa_endpo= int *endpoint, { struct page *page; =20 - ipa_endpoint_replenish(endpoint, true); + ipa_endpoint_replenish(endpoint); + atomic_inc(&endpoint->replenish_backlog); =20 if (trans->cancelled) return; --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 D3F33C433EF for ; Thu, 3 Feb 2022 17:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352721AbiBCRK2 (ORCPT ); Thu, 3 Feb 2022 12:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352545AbiBCRJo (ORCPT ); Thu, 3 Feb 2022 12:09:44 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4227C06174E for ; Thu, 3 Feb 2022 09:09:38 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id i1so2658607ils.5 for ; Thu, 03 Feb 2022 09:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1KdZcajVjZgu+pEXQdk/RqI6U+J/OtZyImbF73oIsC8=; b=KVWM6AxxBaFX120lVv/FXvzsCdVidVZoQu+22yzFauzaZQF1Pg1OdEpW31fiL681Sr A7xzZzpI+hh5O7jcnoPyIu8eSkZVNzCheS42OQ7v/WIYCyjv9ykLe6r0JIvgxyOETkol DTDRgTu4YPvUcs7/Jpg73VQobIfJxuDpVLmL4Pgmi3F46B8OWBUm3VUrZnNRlkWI6TUq +cXGeiEFgxq2V4E1kxeh+cH/ePUL8FHRjMOcwJRUD4PndHvTZMctDK8L2lDVavCIhl52 jWOyACDSFQJjZu/0ZwJ2XBd5pUxyICq2teLbH7zwRk0jjrg2kI2jWsUo/q6KiP91FZEX YhdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1KdZcajVjZgu+pEXQdk/RqI6U+J/OtZyImbF73oIsC8=; b=d40cvTBjXd/rQaKIfQZ6rInflibw6ejhfzInV39fGnGCU6I0UyNxUJ6xybPRt4b3K7 yo9r//ASGfx1Oots0drNoYqHHVrFjNK3qjEZnbz83BT3f1x2g25TvSovdYfZNClrSZyh 0A/GWK3S0i2jarYtomQqx14bRm+90mKefLvce8kMB0ASz8Jz9uwNK6Sqtl9toZPzsRxT eNPsEZtz4GnPTYUHWtabbT+cBxHx6sHdvV3g6wT7+yMdXQoxkOcvNTnbo1tm/i4mSYbU LSSpP8CgHn1sgYPiNZ2kTsswA1cQjwxlRV99Hg8LuMalwe29fnaBa7AQp1LSCUrGmdUL Gp5A== X-Gm-Message-State: AOAM533mlNG+26QTVdVz/OjlSVTI24VuuNgir4NkxoTLwpFH9A1CojJE ruXAq1gAe+G647qFkCkZMr4alA== X-Google-Smtp-Source: ABdhPJyZ6j2FHUvUiFHZhhEM1xkxbWU88BM9dMz889OeLePYeoqwj8yUiVMMWjVT1AuBOM0Y7HVQoA== X-Received: by 2002:a05:6e02:2185:: with SMTP id j5mr4789378ila.298.1643908178290; Thu, 03 Feb 2022 09:09:38 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:37 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 04/10] net: ipa: decide on doorbell in replenish loop Date: Thu, 3 Feb 2022 11:09:21 -0600 Message-Id: <20220203170927.770572-5-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Decide whether the doorbell should be signaled when committing a replenish transaction in the main replenish loop, rather than in ipa_endpoint_replenish_one(). This is a step to facilitate the next patch. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 060a025d70ec6..274cf1c30b593 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1036,10 +1036,10 @@ static void ipa_endpoint_status(struct ipa_endpoint= *endpoint) iowrite32(val, ipa->reg_virt + offset); } =20 -static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) +static int +ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint, bool doorbell) { struct gsi_trans *trans; - bool doorbell =3D false; struct page *page; u32 buffer_size; u32 offset; @@ -1064,11 +1064,6 @@ static int ipa_endpoint_replenish_one(struct ipa_end= point *endpoint) goto err_free_pages; trans->data =3D page; /* transaction owns page now */ =20 - if (++endpoint->replenish_ready =3D=3D IPA_REPLENISH_BATCH) { - doorbell =3D true; - endpoint->replenish_ready =3D 0; - } - gsi_trans_commit(trans, doorbell); =20 return 0; @@ -1104,9 +1099,17 @@ static void ipa_endpoint_replenish(struct ipa_endpoi= nt *endpoint) if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) return; =20 - while (atomic_dec_not_zero(&endpoint->replenish_backlog)) - if (ipa_endpoint_replenish_one(endpoint)) + while (atomic_dec_not_zero(&endpoint->replenish_backlog)) { + bool doorbell; + + if (++endpoint->replenish_ready =3D=3D IPA_REPLENISH_BATCH) + endpoint->replenish_ready =3D 0; + + /* Ring the doorbell if we've got a full batch */ + doorbell =3D !endpoint->replenish_ready; + if (ipa_endpoint_replenish_one(endpoint, doorbell)) goto try_again_later; + } =20 clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 BC4A9C433F5 for ; Thu, 3 Feb 2022 17:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352682AbiBCRKV (ORCPT ); Thu, 3 Feb 2022 12:10:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352550AbiBCRJo (ORCPT ); Thu, 3 Feb 2022 12:09:44 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489EDC061756 for ; Thu, 3 Feb 2022 09:09:40 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id y84so4139795iof.0 for ; Thu, 03 Feb 2022 09:09:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mXk6/jklZ0AYGAuxmfmw3LNYpU5JINoBQKXGEs/0Dho=; b=EefgkxqQKQHG4WYyEScxAiis4foYHb61WzvZjo2f5v0DG/JRMQWY2zr68+cuogzJVf XEsaQs1Op9xOiOTzQugXWOcqNBWig8cY0shQQmpiz4tprv7COJERf6r4JBaN3myo11y6 QKH2k77gLUeBKGmaodl6ZRgvkPxbGp0ekZiRjdwGILD2YNzFVbuQI0y7rzrW7ZjejH4y OTn9mRT7HlradYtEr9ArcsGuNkDD1RPrK/+/t6PbbBrKr4/OCRzX9xxcAPMqsD6qzt6j Nv/BUtntiLDNhzhe/XVTwz+8EGoH1jdrZEvzqwCkv3taEsRB0BvylUS3Pxt6/rKW4Lf9 HhIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mXk6/jklZ0AYGAuxmfmw3LNYpU5JINoBQKXGEs/0Dho=; b=troF1AOEVeIxoyojwvLwdlwdC0zFQGSGQfGJ4d7lIxg6d59JRoBlQ0vPUWcyH/B79e SQwN4tam/Lm+lqJt/aYEDsrRgHLpWYOugoCnzp1QBWWR84bi7GpcEKQhdHViMDkZmNOV KRTubb/4BeiKKYmjkmkQtpTaCX9VhtAkHMlIHEffA07MIRmUK+vd053UzqIQQevslNTL WJehzCd1vj4mKpnQe4WSzsxxxDo2XgVuR3+X+h5+iqRqwqVlTu1IlZ/kv9MUZWzmzCiK gIEB3vnJj0Eb4OkePUy0OBrsPToTUbMPvGnCrQGQzUqioHAuOPWdJVlAL9SvLUOiWcI3 J0kw== X-Gm-Message-State: AOAM530uSvjZbVcUzkpNTznE36Ed9Fuk/E2uk2OzkX62gtw5m/k88/T6 OHSrKTWdalz80lc0mTGzQjCqRQ== X-Google-Smtp-Source: ABdhPJxXK062Agk9lwAVE0WtsAmkZa/PY1YW9Q/CwQlOV+ymoLZp3RIzIk6m1kR1w3/YcJYuVxyLFQ== X-Received: by 2002:a02:cc97:: with SMTP id s23mr12490030jap.31.1643908179655; Thu, 03 Feb 2022 09:09:39 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:39 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 05/10] net: ipa: allocate transaction in replenish loop Date: Thu, 3 Feb 2022 11:09:22 -0600 Message-Id: <20220203170927.770572-6-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When replenishing, have ipa_endpoint_replenish() allocate a transaction, and pass that to ipa_endpoint_replenish_one() to fill. Then, if that produces no error, commit the transaction within the replenish loop as well. In this way we can distinguish between transaction failures and buffer allocation/mapping failures. Failure to allocate a transaction simply means the hardware already has as many receive buffers as it can hold. In that case we can break out of the replenish loop because there's nothing more to do. If we fail to allocate or map pages for the receive buffer, just try again later. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 40 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 274cf1c30b593..f5367b902c27c 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1036,24 +1036,19 @@ static void ipa_endpoint_status(struct ipa_endpoint= *endpoint) iowrite32(val, ipa->reg_virt + offset); } =20 -static int -ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint, bool doorbell) +static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint, + struct gsi_trans *trans) { - struct gsi_trans *trans; struct page *page; u32 buffer_size; u32 offset; u32 len; int ret; =20 - trans =3D ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - return -ENOMEM; - buffer_size =3D endpoint->data->rx.buffer_size; page =3D dev_alloc_pages(get_order(buffer_size)); if (!page) - goto err_trans_free; + return -ENOMEM; =20 /* Offset the buffer to make space for skb headroom */ offset =3D NET_SKB_PAD; @@ -1061,19 +1056,11 @@ ipa_endpoint_replenish_one(struct ipa_endpoint *end= point, bool doorbell) =20 ret =3D gsi_trans_page_add(trans, page, len, offset); if (ret) - goto err_free_pages; - trans->data =3D page; /* transaction owns page now */ + __free_pages(page, get_order(buffer_size)); + else + trans->data =3D page; /* transaction owns page now */ =20 - gsi_trans_commit(trans, doorbell); - - return 0; - -err_free_pages: - __free_pages(page, get_order(buffer_size)); -err_trans_free: - gsi_trans_free(trans); - - return -ENOMEM; + return ret; } =20 /** @@ -1089,6 +1076,7 @@ ipa_endpoint_replenish_one(struct ipa_endpoint *endpo= int, bool doorbell) */ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) { + struct gsi_trans *trans; struct gsi *gsi; u32 backlog; =20 @@ -1100,15 +1088,18 @@ static void ipa_endpoint_replenish(struct ipa_endpo= int *endpoint) return; =20 while (atomic_dec_not_zero(&endpoint->replenish_backlog)) { - bool doorbell; + trans =3D ipa_endpoint_trans_alloc(endpoint, 1); + if (!trans) + break; + + if (ipa_endpoint_replenish_one(endpoint, trans)) + goto try_again_later; =20 if (++endpoint->replenish_ready =3D=3D IPA_REPLENISH_BATCH) endpoint->replenish_ready =3D 0; =20 /* Ring the doorbell if we've got a full batch */ - doorbell =3D !endpoint->replenish_ready; - if (ipa_endpoint_replenish_one(endpoint, doorbell)) - goto try_again_later; + gsi_trans_commit(trans, !endpoint->replenish_ready); } =20 clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); @@ -1116,6 +1107,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoin= t *endpoint) return; =20 try_again_later: + gsi_trans_free(trans); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 /* The last one didn't succeed, so fix the backlog */ --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 440F1C4321E for ; Thu, 3 Feb 2022 17:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352589AbiBCRKE (ORCPT ); Thu, 3 Feb 2022 12:10:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352553AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81134C061757 for ; Thu, 3 Feb 2022 09:09:41 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id m2so2625135ilg.11 for ; Thu, 03 Feb 2022 09:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lgsdnCvj6CM3pv7GIi7Q7qxhb/rwEQOt/gAxMz7ESwo=; b=CV9xhfZ4p0xRwN3tI5jIW7vkfasMn89uQPYfbgfEIRzmhSKWGFDIibcLrUd/XAE3LZ 9lFBSDFl0HyFQ+r4NXc0NEMLC5cCgKDBQGtn3cM5IOwKhQuc2JSmeKxGagNlE4aB3u2T PrhktKmmbfJVOJAVYd2p8dyo9PwwgWdtRq5T7KFMFaFotAiOlBySMnyG7pMF0Nku1WtA 4aKtoEYGT3s49glN2KXpPDtnWNe5E0+B0h/lripFYoNBWssVkWBZjwfYUmTdDvquEsKe PDqu8waRlxXthYp99P9TfH+I350rX0bJujYbjqOjnysdEcf6CaKeKAzBqMvD34eohO94 RGWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lgsdnCvj6CM3pv7GIi7Q7qxhb/rwEQOt/gAxMz7ESwo=; b=HOX3X5Aaingih6ZSyCtVeUT6hBROWWJvH1tHAkHHk7cjUIIgX13cRY8NGfvm5osOXr hJrM8cSnDqiY2yc0Mj83XLMIFrbNlmc20+Wt7uOoi7R5WN/NpKE4+mbAzhCymsJ0Gcrh zdRyF7W4d93sNMojOosCMnrr40uq+86TusRzs0/753k2oJ7ZLJkhPN4Gr+jVppYS63hh JgUPcBmAsBE4kc0hCxuHFJ1pKd39ntXnN5Y1pXj2AWPjzebFIoP3/V/NBMqQbKO4/Rar V2e/vcTfYsAEwP6sPEe7V3Bbrj4qu9B14yaI0pOUkHRp3XAyge4H8j2/bCByuUZ6bCze UpOA== X-Gm-Message-State: AOAM530CH6mx+lVSp5BKvhANOQiNqSaQqyojbG6Q/ncYgy3mErvaWnuV J7JpF2Jetk0PgHxs80ysv8gI+w== X-Google-Smtp-Source: ABdhPJwPNHidFImaNmF7P2maK7ImXz0odBg3rq1AugQJbNWk9HprTIkONp3Cqhoc/6JALaNpiRutLw== X-Received: by 2002:a05:6e02:1946:: with SMTP id x6mr5642505ilu.236.1643908180968; Thu, 03 Feb 2022 09:09:40 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:40 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 06/10] net: ipa: don't use replenish_backlog Date: Thu, 3 Feb 2022 11:09:23 -0600 Message-Id: <20220203170927.770572-7-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Rather than determining when to stop replenishing using the replenish backlog, just stop when we have exhausted all available transactions. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index f5367b902c27c..fba8728ce12e3 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1087,11 +1087,8 @@ static void ipa_endpoint_replenish(struct ipa_endpoi= nt *endpoint) if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) return; =20 - while (atomic_dec_not_zero(&endpoint->replenish_backlog)) { - trans =3D ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - break; - + while ((trans =3D ipa_endpoint_trans_alloc(endpoint, 1))) { + WARN_ON(!atomic_dec_not_zero(&endpoint->replenish_backlog)); if (ipa_endpoint_replenish_one(endpoint, trans)) goto try_again_later; =20 --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 C0078C433EF for ; Thu, 3 Feb 2022 17:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352707AbiBCRKY (ORCPT ); Thu, 3 Feb 2022 12:10:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242770AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5601C06175C for ; Thu, 3 Feb 2022 09:09:42 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id z18so2661108ilp.3 for ; Thu, 03 Feb 2022 09:09:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UTD/8NZGtGtHN6WTCBTC3xofep8IAMari0myuecKnYQ=; b=OYR8oTnqEhUdLucBWHO5TUpvftUwNm40eg0joHmIB1RFw06B4Khq67KtL9nRUj0dFI VbuyDsFNOO7JA2DqdkcLnfmfDgQFFrpKdFqBfheY9A8hImWYM/rXDM0OTdDmYQY4eVSE e3puryseN9tyXPExl8zcRyQhQpB7eTbL+v3QXj5v+L590JphWD4hTyNba4O8CEC5dpJz 1jTwbW7U1gKG6Kz9TfO/sKxikrcZZ3K19sJ8r+ddCH/U7FomyYj8Fdxhm9VuatCt+nrI FopJHVkK9BVscMPzVfRWoRVHT6gmz5XYNEnR1MYLH1688qseSI6TG5aggtXsIEMeNQQM K+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UTD/8NZGtGtHN6WTCBTC3xofep8IAMari0myuecKnYQ=; b=ZbsjFbLVxOZGJLyKSNBVjj5NV4k4xj6JZQE1Trz8y8sku14531E/sbcYuXUMxqKykh jcGx/mWYscNQC1E30sSJ9MW81oQMXes0HfjNUbvhI5ksnUeLuQxaCyIGoAklBzLdihSM 6I4ySrS9N+/Fv1GaSJ8WRCBAlujQcNZwqV9uXJb5wK2H69i0HvTp1i+MpyOGm3mhUT8r eDm2e56hPer6bDDtfF+mIh4n8Te34YoGmktt5BFJGGpDab+pN6DTmNgKNyPL6W40b1rX uPYX2gBRsFsAA9J9u3S0Vvo1vnp5ACh1tQpjesJhOtA2+q18r1tyOIDv4E4+iVvJLofR P4jA== X-Gm-Message-State: AOAM5322R9ls9eLtos3yaPETLANXKVyy/mVU9uBqQ2TNLvJ8ZjYTSOsX Zhlc4asuN+GvuUBlMsLHzuIOhg== X-Google-Smtp-Source: ABdhPJwhKCVVa3GlNNcFDuFJ0nVbvWnU46D74FgYnJqaUyx0SvYPrC9nNwh4YU8fl0EIhGBWYAx9wQ== X-Received: by 2002:a92:c548:: with SMTP id a8mr21026692ilj.51.1643908182246; Thu, 03 Feb 2022 09:09:42 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:41 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 07/10] net: ipa: introduce gsi_channel_trans_idle() Date: Thu, 3 Feb 2022 11:09:24 -0600 Message-Id: <20220203170927.770572-8-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a new function that returns true if all transactions for a channel are available for use. Use it in ipa_endpoint_replenish_enable() to see whether to start replenishing, and in ipa_endpoint_replenish() to determine whether it's necessary after a failure to schedule delayed work to ensure a future replenish attempt occurs. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi_trans.c | 11 +++++++++++ drivers/net/ipa/gsi_trans.h | 10 ++++++++++ drivers/net/ipa/ipa_endpoint.c | 17 +++++------------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 1544564bc2835..87e1d43c118c1 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -320,6 +320,17 @@ gsi_trans_tre_release(struct gsi_trans_info *trans_inf= o, u32 tre_count) atomic_add(tre_count, &trans_info->tre_avail); } =20 +/* Return true if no transactions are allocated, false otherwise */ +bool gsi_channel_trans_idle(struct gsi *gsi, u32 channel_id) +{ + u32 tre_max =3D gsi_channel_tre_max(gsi, channel_id); + struct gsi_trans_info *trans_info; + + trans_info =3D &gsi->channel[channel_id].trans_info; + + return atomic_read(&trans_info->tre_avail) =3D=3D tre_max; +} + /* Allocate a GSI transaction on a channel */ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, u32 tre_count, diff --git a/drivers/net/ipa/gsi_trans.h b/drivers/net/ipa/gsi_trans.h index 17fd1822d8a9f..af379b49299ee 100644 --- a/drivers/net/ipa/gsi_trans.h +++ b/drivers/net/ipa/gsi_trans.h @@ -129,6 +129,16 @@ void *gsi_trans_pool_alloc_dma(struct gsi_trans_pool *= pool, dma_addr_t *addr); */ void gsi_trans_pool_exit_dma(struct device *dev, struct gsi_trans_pool *po= ol); =20 +/** + * gsi_channel_trans_idle() - Return whether no transactions are allocated + * @gsi: GSI pointer + * @channel_id: Channel the transaction is associated with + * + * Return: True if no transactions are allocated, false otherwise + * + */ +bool gsi_channel_trans_idle(struct gsi *gsi, u32 channel_id); + /** * gsi_channel_trans_alloc() - Allocate a GSI transaction on a channel * @gsi: GSI pointer diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index fba8728ce12e3..b854a39c69925 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1077,8 +1077,6 @@ static int ipa_endpoint_replenish_one(struct ipa_endp= oint *endpoint, static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) { struct gsi_trans *trans; - struct gsi *gsi; - u32 backlog; =20 if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) return; @@ -1108,30 +1106,25 @@ static void ipa_endpoint_replenish(struct ipa_endpo= int *endpoint) clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 /* The last one didn't succeed, so fix the backlog */ - backlog =3D atomic_inc_return(&endpoint->replenish_backlog); + atomic_inc(&endpoint->replenish_backlog); =20 /* Whenever a receive buffer transaction completes we'll try to * replenish again. It's unlikely, but if we fail to supply even * one buffer, nothing will trigger another replenish attempt. - * Receive buffer transactions use one TRE, so schedule work to - * try replenishing again if our backlog is *all* available TREs. + * If the hardware has no receive buffers queued, schedule work to + * try replenishing again. */ - gsi =3D &endpoint->ipa->gsi; - if (backlog =3D=3D gsi_channel_tre_max(gsi, endpoint->channel_id)) + if (gsi_channel_trans_idle(&endpoint->ipa->gsi, endpoint->channel_id)) schedule_delayed_work(&endpoint->replenish_work, msecs_to_jiffies(1)); } =20 static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) { - struct gsi *gsi =3D &endpoint->ipa->gsi; - u32 max_backlog; - set_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); =20 /* Start replenishing if hardware currently has no buffers */ - max_backlog =3D gsi_channel_tre_max(gsi, endpoint->channel_id); - if (atomic_read(&endpoint->replenish_backlog) =3D=3D max_backlog) + if (gsi_channel_trans_idle(&endpoint->ipa->gsi, endpoint->channel_id)) ipa_endpoint_replenish(endpoint); } =20 --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 7DCB5C433F5 for ; Thu, 3 Feb 2022 17:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234378AbiBCRKL (ORCPT ); Thu, 3 Feb 2022 12:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352557AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66DCEC061714 for ; Thu, 3 Feb 2022 09:09:44 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id z4so2654565ilz.4 for ; Thu, 03 Feb 2022 09:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TIZyuqBufxAitJOiYAoUO6ML7BGyW72LuYL7A9Zd06I=; b=l0cNK/ZoNnrcd1AYeAyM4hvz0Xi7q+a9VciorTZrJw/NQUe/pu0lWzj2GADHrJT/G8 L8mxRxQ4zJDPW3+Jrl6QFjLJFUlBQtFwDTI/HqZdN8Hm9CKwLYQL5sRCNQsRoF9KNYet Yw35Zk988oetFskQSyg2D6XV8d+TeHry9855Rq4qWIUZOcpgjqCT1XFJFvlwYOLQEevY aYMmaJHb44yUKpY1rRBqc75CtGitB/ayOiXx5SjGgYkloywhg7mSgLRHRMg6n7yd375G 5dlrxRdCEeb75z8OiBmGTz4GqsbsU+IuuO8vAw6Fc8K2GMP4skS8H15oOFxouzHteLTP xbRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TIZyuqBufxAitJOiYAoUO6ML7BGyW72LuYL7A9Zd06I=; b=LUvoOqIrREg2rBovVCO7o/eZ3Rvjv94V71TwqbuQ++rS6ISmH+Aq2yU6FFticZ9bKe L2/Lo+U9Ha6iJBvXEw2AekSplSWD24LGgnzH5/p8Q8tVEWfjT68td5a/r+A5fTrf5DFE kVsSIMDmE/WxOJYrpbyWpyJk6JBtrW4xQQfUSAaD/9MQYvBFbX+SP5Gxhoa/ENycloNn MoyagMHCGjET9YFc//GqLdiLV0OdWEFIX/UZYrguqfmiVfoU4Q3Z1i43GBgInS5hsw90 o0oDmBoVTMAslQUwiphOE81leHIJqyNg21GJIW8qeDOvZ9EqfqWWOGIkdyDfPpQMg7BN 7WXg== X-Gm-Message-State: AOAM531ez164NyD5g4Hd2+agePIAACV9zkqvHWNrS27+DRCknWF7T8Z5 8bItzcGTtddVzpdwD0STDiR7nw== X-Google-Smtp-Source: ABdhPJyk0r+iDfI5LvKb3rFl035/2uwyP9pIu2kHmets5AjQAqhM+87VIbldc+yqFQkHFsIgl4i4pw== X-Received: by 2002:a05:6e02:2163:: with SMTP id s3mr19853641ilv.244.1643908183577; Thu, 03 Feb 2022 09:09:43 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:43 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 08/10] net: ipa: kill replenish_backlog Date: Thu, 3 Feb 2022 11:09:25 -0600 Message-Id: <20220203170927.770572-9-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We no longer use the replenish_backlog atomic variable to decide when we've got work to do providing receive buffers to hardware. Basically, we try to keep the hardware as full as possible, all the time. We keep supplying buffers until the hardware has no more space for them. As a result, we can get rid of the replenish_backlog field and the atomic operations performed on it. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 7 ------- drivers/net/ipa/ipa_endpoint.h | 2 -- 2 files changed, 9 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index b854a39c69925..9d875126a360e 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1086,7 +1086,6 @@ static void ipa_endpoint_replenish(struct ipa_endpoin= t *endpoint) return; =20 while ((trans =3D ipa_endpoint_trans_alloc(endpoint, 1))) { - WARN_ON(!atomic_dec_not_zero(&endpoint->replenish_backlog)); if (ipa_endpoint_replenish_one(endpoint, trans)) goto try_again_later; =20 @@ -1105,9 +1104,6 @@ static void ipa_endpoint_replenish(struct ipa_endpoin= t *endpoint) gsi_trans_free(trans); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); =20 - /* The last one didn't succeed, so fix the backlog */ - atomic_inc(&endpoint->replenish_backlog); - /* Whenever a receive buffer transaction completes we'll try to * replenish again. It's unlikely, but if we fail to supply even * one buffer, nothing will trigger another replenish attempt. @@ -1346,7 +1342,6 @@ static void ipa_endpoint_rx_complete(struct ipa_endpo= int *endpoint, struct page *page; =20 ipa_endpoint_replenish(endpoint); - atomic_inc(&endpoint->replenish_backlog); =20 if (trans->cancelled) return; @@ -1693,8 +1688,6 @@ static void ipa_endpoint_setup_one(struct ipa_endpoin= t *endpoint) */ clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); - atomic_set(&endpoint->replenish_backlog, - gsi_channel_tre_max(gsi, endpoint->channel_id)); INIT_DELAYED_WORK(&endpoint->replenish_work, ipa_endpoint_replenish_work); } diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h index c95816d882a74..9a37f9387f011 100644 --- a/drivers/net/ipa/ipa_endpoint.h +++ b/drivers/net/ipa/ipa_endpoint.h @@ -66,7 +66,6 @@ enum ipa_replenish_flag { * @netdev: Network device pointer, if endpoint uses one * @replenish_flags: Replenishing state flags * @replenish_ready: Number of replenish transactions without doorbell - * @replenish_backlog: Number of buffers needed to fill hardware queue * @replenish_work: Work item used for repeated replenish failures */ struct ipa_endpoint { @@ -86,7 +85,6 @@ struct ipa_endpoint { /* Receive buffer replenishing for RX endpoints */ DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT); u32 replenish_ready; - atomic_t replenish_backlog; struct delayed_work replenish_work; /* global wq */ }; =20 --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 36FF7C433F5 for ; Thu, 3 Feb 2022 17:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352625AbiBCRKR (ORCPT ); Thu, 3 Feb 2022 12:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344834AbiBCRJq (ORCPT ); Thu, 3 Feb 2022 12:09:46 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96126C061401 for ; Thu, 3 Feb 2022 09:09:45 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id e79so4011699iof.13 for ; Thu, 03 Feb 2022 09:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tAfEVLznrjK0PtYMLtCgziZc4mTACQEXidJQ/KE2jWY=; b=yZXqiS+hm8Gx5qlSKY/A/sgA85RRPqOyySx9Zj/R3KCPmp6dflOWos+SEuayk2GODs gdOKNDI+EaJFQ1EHQ0l65g/3YAFZtQ2eYHhvcTKqgo0kgcxlxT3AJhvCuRGxLkXrqgNb CeT0N8fx3mScLoWIEePe6bBzzHRmCyEjLflzV3l7Cu+FACOFzxXDJS2x+1i9sSuZVSof b0NT+dH7N4ftYE3FMORiF6H2QlfUQ0G5cQL0sNR9QQ62vbkX5i5lsEc0IwLItG2+3Xr3 Qw1F0GkzpMp12qMTm8xNDg8uAQO0KJXb2n4qhMleKoTKM1mZTH1WhNEgLZuHFyq5ta/0 4BXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tAfEVLznrjK0PtYMLtCgziZc4mTACQEXidJQ/KE2jWY=; b=RwTrXT0J8R4EsP4Y8C+ApysAlWG3eykU3RudSccnJqG0csZKVeB3RZc9uHLHVb4eHH AyqJ3Nj21P3LVcvGzmjfaSMwvm5g8ttm/EnmioisOfIKybrllRa0j5ekL0mQ1uZLGqCG gROq7nLiR7Iz7T6kNfQmNjYlQMLKl4oeWjYFsMO4EoPTKUbMAB+QpEiq5CncFTn3QeG3 gYY7Zxy0L4NSto8D5x7d7B93H/xpAKd3ut4eK+Z9OXt9jGRyVnn8PhyDggc6fqZAI207 +IEYQLaAHKTiUir6/VNHvfoFQaMCuR8xCLap1DZftNJpHJ+cvwpWs2HGiPXQBdU08A16 9mCQ== X-Gm-Message-State: AOAM530UuO222g6EFzuOA8K2qH1PJxblgkrPHrf56REvFnKRu0yz4HTH hQbqcXG8wQrY5IchiKuRR0mdtQ== X-Google-Smtp-Source: ABdhPJwJNPGh91oli2FBotsMWPYmloSMBeib+F2xqeaNrurxsViPy4ZuXVtrNPHOWQtjmzIbfkQDCA== X-Received: by 2002:a02:6303:: with SMTP id j3mr18506808jac.292.1643908184957; Thu, 03 Feb 2022 09:09:44 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:44 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 09/10] net: ipa: replenish after delivering payload Date: Thu, 3 Feb 2022 11:09:26 -0600 Message-Id: <20220203170927.770572-10-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replenishing is now solely driven by whether transactions are available for a channel, and it doesn't really matter whether we replenish before or after we deliver received packets to the network stack. Replenishing before delivering the payload adds a little latency. Eliminate that by requesting a replenish after the payload is delivered. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 9d875126a360e..a236edf5bf068 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1341,10 +1341,8 @@ static void ipa_endpoint_rx_complete(struct ipa_endp= oint *endpoint, { struct page *page; =20 - ipa_endpoint_replenish(endpoint); - if (trans->cancelled) - return; + goto done; =20 /* Parse or build a socket buffer using the actual received length */ page =3D trans->data; @@ -1352,6 +1350,8 @@ static void ipa_endpoint_rx_complete(struct ipa_endpo= int *endpoint, ipa_endpoint_status_parse(endpoint, page, trans->len); else if (ipa_endpoint_skb_build(endpoint, page, trans->len)) trans->data =3D NULL; /* Pages have been consumed */ +done: + ipa_endpoint_replenish(endpoint); } =20 void ipa_endpoint_trans_complete(struct ipa_endpoint *endpoint, --=20 2.32.0 From nobody Mon Jun 29 19:37:39 2026 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 97E55C433F5 for ; Thu, 3 Feb 2022 17:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352735AbiBCRKd (ORCPT ); Thu, 3 Feb 2022 12:10:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352572AbiBCRJr (ORCPT ); Thu, 3 Feb 2022 12:09:47 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F7DC06173D for ; Thu, 3 Feb 2022 09:09:46 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id y17so2674833ilm.1 for ; Thu, 03 Feb 2022 09:09:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YVeOmvrDZv3hJhW6Jsr2R6/Y4bCLC3bv8VO35vQkvl0=; b=Sb4qc8l3d6fQWal2+nYncDQdeid9w3iJdshg8xNvNmQ4F//S3vBoRXD26En58ipbPo flL859XADrQx9pKN8Fb/GpOOZUfnf9NU5/iRRCma9rMXw994X/c3opxOJd3evH47XII3 T3iBsCsTcP3WZeKrU87xqe+D4lxJgFmfL2TTABvTsj+RpgSbxKEcmRZhb+zuneWMluLw Xv2MXEL2Gp6uAsjYiZFmegoeXMHlura4ysUAl5wpYogmlxq0SWOf0pw0c5CxCrq7rb9j w0hbl3o3FJU+/NPDtukSpF/nXxZf3ACDksHVonvoJnjhuCdXjwVlkYo2Pdapl2FJZECj FORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YVeOmvrDZv3hJhW6Jsr2R6/Y4bCLC3bv8VO35vQkvl0=; b=ELRNEuGeX5kHIZfpddFLyhDg7MDk79uWTtZUuy2fIK26PPLd74iaRSEuw+M+jRC9Hz aZmfG/chNyss8fBZ+/OMMLYKtjS8SlOI/pgTa95pL8g+uWiIaXOJ5FXJ6iGdkFSBoijh 8Slr4t1kCg/y1zhspOok0S+aV/JZe47OpoOHCAkzZskNws/O3yQKCQIjCieCoaWQAR/x 5r1cDpCxslMzjZsGH4BQdKLjOQ00jUpNhg1mIJxvpC90QkbYiByANRsBIL5LZvXimNsh 17B3rDJowjP4cSEnoZaQOnsCVN0DUlRskX+7RfX+l5pKhIp58TilyUM3Mg+gy+gCF8/J i45g== X-Gm-Message-State: AOAM5319tYPQ/M6vVlpVffxD0blIgiyLnYB6kObBQ+iHlAxrtRVJVxNy 8W2QK2FAzBGzNM2UtHa0aTXWgA== X-Google-Smtp-Source: ABdhPJzhqZlmD4YUH2TSGjEPaJJqyZwSZV111h2PXgaPokJLksR9esJgPnzvFD5Bx9/RrLdLwBGoeQ== X-Received: by 2002:a05:6e02:15c8:: with SMTP id q8mr21128743ilu.19.1643908186272; Thu, 03 Feb 2022 09:09:46 -0800 (PST) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id m12sm21869671iow.54.2022.02.03.09.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:09:45 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, mka@chromium.org, evgreen@chromium.org, cpratapa@codeaurora.org, avuyyuru@codeaurora.org, jponduru@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 10/10] net: ipa: determine replenish doorbell differently Date: Thu, 3 Feb 2022 11:09:27 -0600 Message-Id: <20220203170927.770572-11-elder@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203170927.770572-1-elder@linaro.org> References: <20220203170927.770572-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Rather than tracking the number of receive buffer transactions that have been submitted without a doorbell, just track the total number of transactions that have been issued. Then ring the doorbell when that number modulo the replenish batch size is 0. The effect is roughly the same, but the new count is slightly more interesting, and this approach will someday allow the replenish batch size to be tuned at runtime. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 12 ++++++++---- drivers/net/ipa/ipa_endpoint.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index a236edf5bf068..888e94278a84f 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -25,7 +25,8 @@ =20 #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) =20 -#define IPA_REPLENISH_BATCH 16 +/* Hardware is told about receive buffers once a "batch" has been queued */ +#define IPA_REPLENISH_BATCH 16 /* Must be non-zero */ =20 /* The amount of RX buffer space consumed by standard skb overhead */ #define IPA_RX_BUFFER_OVERHEAD (PAGE_SIZE - SKB_MAX_ORDER(NET_SKB_PAD, 0)) @@ -1086,14 +1087,15 @@ static void ipa_endpoint_replenish(struct ipa_endpo= int *endpoint) return; =20 while ((trans =3D ipa_endpoint_trans_alloc(endpoint, 1))) { + bool doorbell; + if (ipa_endpoint_replenish_one(endpoint, trans)) goto try_again_later; =20 - if (++endpoint->replenish_ready =3D=3D IPA_REPLENISH_BATCH) - endpoint->replenish_ready =3D 0; =20 /* Ring the doorbell if we've got a full batch */ - gsi_trans_commit(trans, !endpoint->replenish_ready); + doorbell =3D !(++endpoint->replenish_count % IPA_REPLENISH_BATCH); + gsi_trans_commit(trans, doorbell); } =20 clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); @@ -1863,6 +1865,8 @@ u32 ipa_endpoint_init(struct ipa *ipa, u32 count, enum ipa_endpoint_name name; u32 filter_map; =20 + BUILD_BUG_ON(!IPA_REPLENISH_BATCH); + if (!ipa_endpoint_data_valid(ipa, count, data)) return 0; /* Error */ =20 diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h index 9a37f9387f011..12fd5b16c18eb 100644 --- a/drivers/net/ipa/ipa_endpoint.h +++ b/drivers/net/ipa/ipa_endpoint.h @@ -65,7 +65,7 @@ enum ipa_replenish_flag { * @evt_ring_id: GSI event ring used by the endpoint * @netdev: Network device pointer, if endpoint uses one * @replenish_flags: Replenishing state flags - * @replenish_ready: Number of replenish transactions without doorbell + * @replenish_count: Total number of replenish transactions committed * @replenish_work: Work item used for repeated replenish failures */ struct ipa_endpoint { @@ -84,7 +84,7 @@ struct ipa_endpoint { =20 /* Receive buffer replenishing for RX endpoints */ DECLARE_BITMAP(replenish_flags, IPA_REPLENISH_COUNT); - u32 replenish_ready; + u64 replenish_count; struct delayed_work replenish_work; /* global wq */ }; =20 --=20 2.32.0