From patchwork Thu Feb 3 17:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734365 X-Patchwork-Delegate: kuba@kernel.org 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 922E7C433F5 for ; Thu, 3 Feb 2022 17:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352528AbiBCRJg (ORCPT ); Thu, 3 Feb 2022 12:09:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352517AbiBCRJf (ORCPT ); Thu, 3 Feb 2022 12:09:35 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0A9C06173D for ; Thu, 3 Feb 2022 09:09:34 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id z18so2660788ilp.3 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=27pa651mpa+DkIJwHdztX2dQBo7FqyOGNbGT0Gi0yYaRSKfBEkbqQ5EF06Jaze1dBf 5GlBDHanNIlsNwJhKuebUJ9O0YstVGRsJdvdSHD7Ii7XKNidb+b9ynxzf4JyGgFKmYyp 6SAHNt+OIQP1SLxBEfPCl3c3bwlqWHWkPw8JOsOWuun4H2Apriz41kCrjnNmIFN7QZ16 Z8PODNIozKBwnHvGLIS+lKnUn6DZGAyYGnCXgZPnehxO8mfePW2Wos9n3QY86b+4J2EM +ENSyhUZVQ8YBuvkQm0fT7Ultl0ulgCzOYgVsafJ/6ffbmk+RQJFOMUrSlyviYUe0xuq 5yoA== X-Gm-Message-State: AOAM533MtuDs7oQB1Wnv0j/CSssoepqjwmmHJyyK7BEt5T3HEAwpZu1G mkgMH4rVs7jT5LrDMN46E4ABnw== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *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_endpoint *endpoint, bool add_one) if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) { if (add_one) - atomic_inc(&endpoint->replenish_saved); + atomic_inc(&endpoint->replenish_backlog); return; } @@ -1147,11 +1146,8 @@ static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) { struct gsi *gsi = &endpoint->ipa->gsi; u32 max_backlog; - u32 saved; set_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); - while ((saved = atomic_xchg(&endpoint->replenish_saved, 0))) - atomic_add(saved, &endpoint->replenish_backlog); /* Start replenishing if hardware currently has no buffers */ max_backlog = gsi_channel_tre_max(gsi, endpoint->channel_id); @@ -1161,11 +1157,7 @@ static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) { - u32 backlog; - clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); - while ((backlog = atomic_xchg(&endpoint->replenish_backlog, 0))) - atomic_add(backlog, &endpoint->replenish_saved); } static void ipa_endpoint_replenish_work(struct work_struct *work) @@ -1727,9 +1719,8 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *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 */ }; From patchwork Thu Feb 3 17:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734366 X-Patchwork-Delegate: kuba@kernel.org 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 7960AC433FE for ; Thu, 3 Feb 2022 17:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352551AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352526AbiBCRJg (ORCPT ); Thu, 3 Feb 2022 12:09:36 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029B2C06173B for ; Thu, 3 Feb 2022 09:09:36 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id s1so2641858ilj.7 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=UEvzPIsfrL8gIF3uwtueQXXB7sDuVXOuS6/5cRt+LQTjuf+4G/47/2zj1OrstXMFuj u2vHH/Cq+c0E2bPPbf6dZZnF+GjHVEql7o3Pjt/d2XC9kFAT5+YWCEmR55zMBc9V+/2V RcouEmRJoiCWImOIe2t03avbRdorC/tKwDbF38LO3/vkcJUFLvD1cg+MwSJ8zJhlufJu 39w7RWnqEnblMFL0nnA0y4bVmVBay82ip4aUid/7t1G5u/E72wOI1IyDGrG9pNBneVkC sBp6I/B/iRQKFBbyoMW8c8uaLtatS6EDWvFN+ErMm4+oZRU2FeqLUcxg02urzxEjsy6Y r2eA== X-Gm-Message-State: AOAM530vI6I2CKHeH5MKkxm0/dhV+PvHkRy8rm9HsU4ABBxGJyJTW6x4 zstbdKyODMN+jXpZd1wrt7wS/A== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *endpoint) u32 len; int ret; + trans = ipa_endpoint_trans_alloc(endpoint, 1); + if (!trans) + return -ENOMEM; + buffer_size = endpoint->data->rx.buffer_size; page = dev_alloc_pages(get_order(buffer_size)); if (!page) - return -ENOMEM; - - trans = ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - goto err_free_pages; + goto err_trans_free; /* Offset the buffer to make space for skb headroom */ offset = NET_SKB_PAD; @@ -1061,7 +1061,7 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) ret = gsi_trans_page_add(trans, page, len, offset); if (ret) - goto err_trans_free; + goto err_free_pages; trans->data = page; /* transaction owns page now */ if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) { @@ -1073,10 +1073,10 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) return 0; -err_trans_free: - gsi_trans_free(trans); err_free_pages: __free_pages(page, get_order(buffer_size)); +err_trans_free: + gsi_trans_free(trans); return -ENOMEM; } From patchwork Thu Feb 3 17:09:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734370 X-Patchwork-Delegate: kuba@kernel.org 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 91895C4321E for ; Thu, 3 Feb 2022 17:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352566AbiBCRJq (ORCPT ); Thu, 3 Feb 2022 12:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352536AbiBCRJn (ORCPT ); Thu, 3 Feb 2022 12:09:43 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C503C061744 for ; Thu, 3 Feb 2022 09:09:37 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id y84so4139590iof.0 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=UaaNWTpgFfpnEKRxpTKCC3hSvO+9bWNBbKx3rWPGpwMEbrAnnADQuAZPza/Q2EJGQa IeiFj2QXx5gZyE++x7QwpRECh7lm1pXzT18VwAZXG/72Sz1qDKzhlEbSkF/NWpE2EUJA hMknBshGFCaNCrpQTxpypCX/+wyAgjL2kHej7g5C/euPgeDt9ZhXnz+XT+g0nZNyH7Bu iiy9LH/dnkCobbRQDNpd9MIKgmd8WwRcn7zzcL1TvEEI5qqmlbMxIA026dpQOYr+Rnpv j7oyPJDRctT5kJA4n6nnlTVqjUJDryDCljERDaieyVA8Id/gBwQpp9z8dwhDzg8feZmC /g/w== X-Gm-Message-State: AOAM533/OlzwTW9BWuVsXoPXZAOF8cl6OMae4SEWpzXS8+oxCoplscQm iwwG1deN6efcKfDXoteAowBguQ== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *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_endpoint *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; - 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; - } - /* 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; - } 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_endpoint *endpoint, bool add_one) clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); - if (add_one) - atomic_inc(&endpoint->replenish_backlog); - return; try_again_later: clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); /* The last one didn't succeed, so fix the backlog */ - delta = add_one ? 2 : 1; - backlog = atomic_add_return(delta, &endpoint->replenish_backlog); + backlog = atomic_inc_return(&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 @@ -1152,7 +1140,7 @@ static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) /* Start replenishing if hardware currently has no buffers */ max_backlog = gsi_channel_tre_max(gsi, endpoint->channel_id); if (atomic_read(&endpoint->replenish_backlog) == max_backlog) - ipa_endpoint_replenish(endpoint, false); + ipa_endpoint_replenish(endpoint); } static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) @@ -1167,7 +1155,7 @@ static void ipa_endpoint_replenish_work(struct work_struct *work) endpoint = container_of(dwork, struct ipa_endpoint, replenish_work); - ipa_endpoint_replenish(endpoint, false); + ipa_endpoint_replenish(endpoint); } static void ipa_endpoint_skb_copy(struct ipa_endpoint *endpoint, @@ -1372,7 +1360,8 @@ static void ipa_endpoint_rx_complete(struct ipa_endpoint *endpoint, { struct page *page; - ipa_endpoint_replenish(endpoint, true); + ipa_endpoint_replenish(endpoint); + atomic_inc(&endpoint->replenish_backlog); if (trans->cancelled) return; From patchwork Thu Feb 3 17:09:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734367 X-Patchwork-Delegate: kuba@kernel.org 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 90338C4167D for ; Thu, 3 Feb 2022 17:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352576AbiBCRJr (ORCPT ); Thu, 3 Feb 2022 12:09:47 -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 S236960AbiBCRJo (ORCPT ); Thu, 3 Feb 2022 12:09:44 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4D2EC061751 for ; Thu, 3 Feb 2022 09:09:38 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id o10so2698019ilh.0 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=qeADizNc4H/rk2g/5ZPQnE/sIevIEYRxgYNt3zYzosyKvrWAbPQdIAlNB0QmAKleq+ 6ezHezJFDGwQAGd01cURca+Ya88FtB0/OHXzPbNMNSXOZvdxsXhBdsOQf1RVUBW8qUCa ddB2iTsQEvGb89Wlh+5yXuHhBmifeR8EZZgRGsi4Kx41hRGlEx0XMzc6bGlojm0y28Lk SjC9sYEO+TsOn1seHGeacyIrq/wxthpMvDR9RdEvRT9I4yW6IgL1vjGHV+5s+niE/vgH bnEkEIx1Vs+PFhp/Ly/gBgbw7UsjVIkfWFNGEztM6Pix0WAjcPQXdMvdP6yGaAG4Keil wz9A== X-Gm-Message-State: AOAM531sfyeWox28JYSGZtkYugrJGTD74VjS/0Lrnn+vrlcRZ4CeJTLf pg0XeclE29OgP6FGa3Lq3zaWig== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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); } -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 = false; struct page *page; u32 buffer_size; u32 offset; @@ -1064,11 +1064,6 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) goto err_free_pages; trans->data = page; /* transaction owns page now */ - if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) { - doorbell = true; - endpoint->replenish_ready = 0; - } - gsi_trans_commit(trans, doorbell); return 0; @@ -1104,9 +1099,17 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) return; - 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 == IPA_REPLENISH_BATCH) + endpoint->replenish_ready = 0; + + /* Ring the doorbell if we've got a full batch */ + doorbell = !endpoint->replenish_ready; + if (ipa_endpoint_replenish_one(endpoint, doorbell)) goto try_again_later; + } clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); From patchwork Thu Feb 3 17:09:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734373 X-Patchwork-Delegate: kuba@kernel.org 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 6F5D1C433F5 for ; Thu, 3 Feb 2022 17:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234690AbiBCRJ4 (ORCPT ); Thu, 3 Feb 2022 12:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352549AbiBCRJo (ORCPT ); Thu, 3 Feb 2022 12:09:44 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486AAC061755 for ; Thu, 3 Feb 2022 09:09:40 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id e79so4011350iof.13 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=v2LSvVCps3oOgfgwpdMOZHg7sOOVgdvKfmjFH9r9lRWPZrVh8UMN4QPqOylMszgWXb 1MVrXJ3H3XcjlPUGRI8xTKH5n/fXS/0SkG4w/VnZlvf548TbPLZ9tpJBnMP0tesw9j6O /nX+dU9DDl46/BqkJ/Yv0GD2V0ansqnzJIb4BUajdA3uMiv+C24qWjOKgQEzLobGVWjq THwt8+jVRiGwDSEWaOTxkrUwF8Mi0GnvfIYAtUr5d+glaOev6fOd1Geyltb14p3TLCwv xHZV+o+yQTWzhs4a+LyIm/zfYU1EeNBW6Q2uQdiGSf93OlBaeXopTFyDUDPNQVrF9omp SnMg== X-Gm-Message-State: AOAM5333Cw1wtg84kT2bs/UCg3XqM2vXxcHtcA5asbRivS+50JwYDtxB bVJTeLsvo4F91980BFZbKRkBFA== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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); } -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; - trans = ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - return -ENOMEM; - buffer_size = endpoint->data->rx.buffer_size; page = dev_alloc_pages(get_order(buffer_size)); if (!page) - goto err_trans_free; + return -ENOMEM; /* Offset the buffer to make space for skb headroom */ offset = NET_SKB_PAD; @@ -1061,19 +1056,11 @@ ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint, bool doorbell) ret = gsi_trans_page_add(trans, page, len, offset); if (ret) - goto err_free_pages; - trans->data = page; /* transaction owns page now */ + __free_pages(page, get_order(buffer_size)); + else + trans->data = page; /* transaction owns page now */ - 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; } /** @@ -1089,6 +1076,7 @@ ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint, bool doorbell) */ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) { + struct gsi_trans *trans; struct gsi *gsi; u32 backlog; @@ -1100,15 +1088,18 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) return; while (atomic_dec_not_zero(&endpoint->replenish_backlog)) { - bool doorbell; + trans = ipa_endpoint_trans_alloc(endpoint, 1); + if (!trans) + break; + + if (ipa_endpoint_replenish_one(endpoint, trans)) + goto try_again_later; if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) endpoint->replenish_ready = 0; /* Ring the doorbell if we've got a full batch */ - doorbell = !endpoint->replenish_ready; - if (ipa_endpoint_replenish_one(endpoint, doorbell)) - goto try_again_later; + gsi_trans_commit(trans, !endpoint->replenish_ready); } clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); @@ -1116,6 +1107,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) return; try_again_later: + gsi_trans_free(trans); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); /* The last one didn't succeed, so fix the backlog */ From patchwork Thu Feb 3 17:09:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734368 X-Patchwork-Delegate: kuba@kernel.org 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 4106AC43217 for ; Thu, 3 Feb 2022 17:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352583AbiBCRJr (ORCPT ); Thu, 3 Feb 2022 12:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352554AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84DDCC061759 for ; Thu, 3 Feb 2022 09:09:41 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id m17so2617860ilj.12 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=Ofnx9Frqjq3qZjSfLDYm6ZvKEROplXIX5XOFFFEFmJ9sikRP5dAMeQGADsFIzmDvYR A2wDD15NlzKpvlza+l3guMedhd+j+/eRKMhr83ICQ6qRj/jUkVXH0r48RBBd2XTcAMBG ZmEW7w8kk/+2T6ylWuCHsw6urR69FilxHPC3xaLDi1cGCyRJHLGeBB3eAWDoUsfOO/Ce g1zZQ5d6CLr8Zu9wgeM0CG2XncNk6scpQ/YjSG3f85Sj9pJBh4jvEVq54m90U9sVwRI0 k7rjw8xqWM4GeGx3/Qc3+bVit+EgeLh2MVyg/98o/RF2pM2g/yk7UppHuTi9P55SKsRQ TJXA== X-Gm-Message-State: AOAM531faP/lRmjOWfIrij8Z5EMuD9eImakh2O5NlPAcZQsgK7RsakFv eJLos4KU1OirFkB1+TgiDszV1w== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *endpoint) if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) return; - while (atomic_dec_not_zero(&endpoint->replenish_backlog)) { - trans = ipa_endpoint_trans_alloc(endpoint, 1); - if (!trans) - break; - + while ((trans = 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; From patchwork Thu Feb 3 17:09:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734372 X-Patchwork-Delegate: kuba@kernel.org 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 52F56C4321E for ; Thu, 3 Feb 2022 17:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352607AbiBCRJy (ORCPT ); Thu, 3 Feb 2022 12:09:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352556AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E007BC06175A for ; Thu, 3 Feb 2022 09:09:42 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id z18so2661107ilp.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=reLn5vmOYxChsr6DBcUKQiPCQwuu1UIUWMqwhQEa8ZC8qFWgdEeAQpnt17MssS3qAQ v1rCqC06ECQ0dVL2AI0QQWA4iLKzSLncT6nI44C2M6UkbaX5S+4n8wbwjiCnwmWejYun LrESPLXSl+kjC2f76Q/dvunrkAuoGjnkaQ8++Ht747JxnsiD2Y+fC+wlwscN5cWqV1f4 tFxqOfOJmpKUqIBEUV5ovzMRNMsTZGo7zTNSBu0+rQCwzSADKSE8xalFQkQVLbuTmB8j pBEiIS3c3huW+Yw1eY7m2GFotXRE720CUOtd7fdP8Qvf5Y7rAe6DBIgwwjQsCi6fq8uz hkEQ== X-Gm-Message-State: AOAM531u3OMDvRa9IH60XUWdTklfvdalxExDmhF3Z5Wp0OQhlX9tSRv5 YtYl1apPV8OORQrdJNcwNCCbVg== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_info, u32 tre_count) atomic_add(tre_count, &trans_info->tre_avail); } +/* Return true if no transactions are allocated, false otherwise */ +bool gsi_channel_trans_idle(struct gsi *gsi, u32 channel_id) +{ + u32 tre_max = gsi_channel_tre_max(gsi, channel_id); + struct gsi_trans_info *trans_info; + + trans_info = &gsi->channel[channel_id].trans_info; + + return atomic_read(&trans_info->tre_avail) == 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 *pool); +/** + * 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_endpoint *endpoint, static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) { struct gsi_trans *trans; - struct gsi *gsi; - u32 backlog; if (!test_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags)) return; @@ -1108,30 +1106,25 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); /* The last one didn't succeed, so fix the backlog */ - backlog = atomic_inc_return(&endpoint->replenish_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. - * 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 = &endpoint->ipa->gsi; - if (backlog == 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)); } static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) { - struct gsi *gsi = &endpoint->ipa->gsi; - u32 max_backlog; - set_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags); /* Start replenishing if hardware currently has no buffers */ - max_backlog = gsi_channel_tre_max(gsi, endpoint->channel_id); - if (atomic_read(&endpoint->replenish_backlog) == max_backlog) + if (gsi_channel_trans_idle(&endpoint->ipa->gsi, endpoint->channel_id)) ipa_endpoint_replenish(endpoint); } From patchwork Thu Feb 3 17:09:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734371 X-Patchwork-Delegate: kuba@kernel.org 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 872A5C43217 for ; Thu, 3 Feb 2022 17:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352526AbiBCRJx (ORCPT ); Thu, 3 Feb 2022 12:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352560AbiBCRJp (ORCPT ); Thu, 3 Feb 2022 12:09:45 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681B3C06175D for ; Thu, 3 Feb 2022 09:09:44 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id i1so2658834ils.5 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=Hyb+3MfDVjPy7iyQhO240VMlkWKnjYrOIk709/jrOFdhkdDqmJpe57P5ZcmuLkJ8Yz sJOfepAvPkDa85thjwKi1BzxOjCUUaDtTfTha5NrF/hoYvjQUBllt28iApiskm4WPi6q IiC0RfuSCxziRLODOg4kvlios5pkosSysXxO/QshRCcpfBzqMWevJrQrfVfldqd5TSf0 9Wl/DLU1HXWEDwqCAIljqKtsw36k88GTcIuHjZAnPPT/Kjtenfegppuf0hGroC9WBJdM FX1QAdrnUP7K52YPh79KvK0cJW4MveW88prpslVQvCPVQsYFIy06dgpbVzyHWDf8/Z0Q 280A== X-Gm-Message-State: AOAM532pevUir2yKP21xYDiKtlN7I78C5kbjMa0ZAkfIi3XFz1TzgIx6 putf59TeUz/bOHK8FAf5wOhRgw== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *endpoint) return; while ((trans = 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; @@ -1105,9 +1104,6 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint) gsi_trans_free(trans); clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags); - /* 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_endpoint *endpoint, struct page *page; ipa_endpoint_replenish(endpoint); - atomic_inc(&endpoint->replenish_backlog); if (trans->cancelled) return; @@ -1693,8 +1688,6 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *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 */ }; From patchwork Thu Feb 3 17:09:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734369 X-Patchwork-Delegate: kuba@kernel.org 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 8270AC4332F for ; Thu, 3 Feb 2022 17:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352590AbiBCRJt (ORCPT ); Thu, 3 Feb 2022 12:09:49 -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 S1352532AbiBCRJq (ORCPT ); Thu, 3 Feb 2022 12:09:46 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99C5AC061741 for ; Thu, 3 Feb 2022 09:09:45 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id q204so4051082iod.8 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=W7kwwqN+g/nbPSyOn/p0yo92Ti9WFFEHw6RjmIpibljcQPhuTAmDeMT8KfktnU112a slD/RSkPNyEdBajpzqpyUA78ub5l0L1OoqX1MgM/fQsKWqMTx173ibCtFp3pJxAoJJfa x+yMU38WLwAbLxzxyBuPJhiRFxwdSYBw+4WhDTRH2Gu/JV55yieNYxfzAl8aUSGUyjxZ 6vLDiAsZh/roNk4zPJFJ2D4bqAzFYb8ERQbF0ORSPagNkbDnXtgDQss98okp3A3J+O87 6wwXNjq5MHnJrZ7eWpQWgwN4aIRaOQ2xcdOppzlC0TVpERuEeo5nDxPi5ONbz0MrDeVa yR5g== X-Gm-Message-State: AOAM532gtEvc/Bqv0yG593OWjJxAG8pdpFROVkqLXAKgkA70Iuwgw36h EX94w5b/oX4B8r0ZVYh5yXcXLA== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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_endpoint *endpoint, { struct page *page; - ipa_endpoint_replenish(endpoint); - if (trans->cancelled) - return; + goto done; /* Parse or build a socket buffer using the actual received length */ page = trans->data; @@ -1352,6 +1350,8 @@ static void ipa_endpoint_rx_complete(struct ipa_endpoint *endpoint, ipa_endpoint_status_parse(endpoint, page, trans->len); else if (ipa_endpoint_skb_build(endpoint, page, trans->len)) trans->data = NULL; /* Pages have been consumed */ +done: + ipa_endpoint_replenish(endpoint); } void ipa_endpoint_trans_complete(struct ipa_endpoint *endpoint, From patchwork Thu Feb 3 17:09:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12734374 X-Patchwork-Delegate: kuba@kernel.org 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 5E45AC433EF for ; Thu, 3 Feb 2022 17:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352657AbiBCRKA (ORCPT ); Thu, 3 Feb 2022 12:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352571AbiBCRJr (ORCPT ); Thu, 3 Feb 2022 12:09:47 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0810C06173B for ; Thu, 3 Feb 2022 09:09:46 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id o10so2698332ilh.0 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=2rOnFDIZMtrHtPrlgFXT/2Hgshj7ZzseV9aXWWByzHcR7KdHOTUucy74OHA8cMc4rw GRpLIYmWBWgSosY+lGZkFmacqX2gKqCeY4thN40WIgIPqlXiVy2zeRFDcAJlAQstvqUC EXqduW2CXAANYVqlDTUSbmdqjx3UsOb3bIHEzpS5f8S5A59YXi9/YsXvqzXBP48qyTxF 3FhFdLV4xRKcwjRMluzeMKmg2ywk/cJZM87RLGwjyAeGIS/+pcA3ireVTReZ+y0ms1CO /RaYiy1437SsCvRilkA1dq0d0XVfsT5L7C45OeAkBi6yi0e21/Gv7xfAzGfmS3IphcUC mv8g== X-Gm-Message-State: AOAM532GKGJ69rOtZjLnqLHHb7DGzNI0+5u8vU8rb+kIWKSSHs24BI6H 1T0MlCoMw0hvKT3e5+Q7fgeXMQ== 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 @@ #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) -#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 */ /* 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_endpoint *endpoint) return; while ((trans = ipa_endpoint_trans_alloc(endpoint, 1))) { + bool doorbell; + if (ipa_endpoint_replenish_one(endpoint, trans)) goto try_again_later; - if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) - endpoint->replenish_ready = 0; /* Ring the doorbell if we've got a full batch */ - gsi_trans_commit(trans, !endpoint->replenish_ready); + doorbell = !(++endpoint->replenish_count % IPA_REPLENISH_BATCH); + gsi_trans_commit(trans, doorbell); } 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; + BUILD_BUG_ON(!IPA_REPLENISH_BATCH); + if (!ipa_endpoint_data_valid(ipa, count, data)) return 0; /* Error */ 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 { /* 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 */ };