From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BEA0C433E6 for ; Fri, 5 Feb 2021 22:06:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBFC764E16 for ; Fri, 5 Feb 2021 22:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbhBEWFH (ORCPT ); Fri, 5 Feb 2021 17:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbhBEO5z (ORCPT ); Fri, 5 Feb 2021 09:57:55 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 325F2C061226 for ; Fri, 5 Feb 2021 08:29:04 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id g15so4879245pgu.9 for ; Fri, 05 Feb 2021 08:29:04 -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=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=juD/+IMQSeopqjDcUewqw+7th0LzGiueKxRWyZJfLMy15zCeq9KpHi2i7WwRhQweGZ 0EHXyU+ekxL1FAX+isehGEYN7baPZiUVvYqbqiHPmEyE58s7Rxp4iMWqN3hS8twxRHix trsFwYsZ4bUpTsm0asNTic0agw1ba9BaCNKnAGSmU4/FXXW11bVRgT1MLZGBIeiJCjUE KAJJBovvbq73wbN8U99W/VgQXRZfchctJ3noW6nJTja3rsHMVFL1xxeQDv8tuUFO/s/X W5p44YExl3mB28Ig93OGJO/uAEL30YLbdBvaMZV/PoOYbpyEsCr4hVgxLx9E/JMvgJiB AcfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=Op3ZdOTO9LmMpvoNsAMXF8b6DDZRZet3+DXVJ/mctfoNxmo8fhOhsGs7deGLinUWP8 PHMRHlOUS0TFVSg3RmgXUtGFGPFaYWsyyoMiXVF6KKuj6O0kXnl+seBvLNvh8YGmoOkY cHg35BvGbqjnKwM/HsCIFEgBNfw3G6S1to3vM5C9C/MxwlVyGjKrv6P1Yx5aafQrDqp1 twRVNF0yp3HDSC6k368bOekdw7INlt8rH7ALRVMOtwKDktp822Lwixf/CKmJp00pgLCp cBweG5nMldbHkvO6ySLDfv2sLyBV5+QcOlHVfBBMAYFY8EIHfZLu+JaS4Xhx+rFV8KDN KN5Q== X-Gm-Message-State: AOAM533UjVfX8pGk0ZWO4UePti9M4fh4ohOy+NxTbK42i9vLnI6yJOT0 J00CLT9iUnqqnV1x7ShUlRgykpvM4UGrxA== X-Google-Smtp-Source: ABdhPJzpmVPq4i70R7apOVIic6mAVRpo/eJuY86d/TMT4Ty9BlpLtBuDaaVFPlH4FCh+VE9eepNsAA== X-Received: by 2002:a92:4447:: with SMTP id a7mr4396967ilm.240.1612535918922; Fri, 05 Feb 2021 06:38:38 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:38 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 5/7] net: ipa: use a Boolean rather than count when replenishing Date: Fri, 5 Feb 2021 08:38:27 -0600 Message-Id: <20210205143829.16271-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The count argument to ipa_endpoint_replenish() is only ever 0 or 1, and always will be (because we always handle each receive buffer in a single transaction). Rename the argument to be add_one and change it to be Boolean. Update the function description to reflect the current code. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 7a46c790afbef..bff5d6ffd1186 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1020,31 +1020,34 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) } /** - * ipa_endpoint_replenish() - Replenish the Rx packets cache. + * ipa_endpoint_replenish() - Replenish endpoint receive buffers * @endpoint: Endpoint to be replenished - * @count: Number of buffers to send to hardware + * @add_one: Whether this is replacing a just-consumed buffer * - * Allocate RX packet wrapper structures with maximal socket buffers - * for an endpoint. These are supplied to the hardware, which fills - * them with incoming data. + * 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 + * 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. */ -static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, u32 count) +static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one) { struct gsi *gsi; u32 backlog; if (!endpoint->replenish_enabled) { - if (count) - atomic_add(count, &endpoint->replenish_saved); + if (add_one) + atomic_inc(&endpoint->replenish_saved); return; } - while (atomic_dec_not_zero(&endpoint->replenish_backlog)) if (ipa_endpoint_replenish_one(endpoint)) goto try_again_later; - if (count) - atomic_add(count, &endpoint->replenish_backlog); + if (add_one) + atomic_inc(&endpoint->replenish_backlog); return; @@ -1052,8 +1055,8 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, u32 count) /* The last one didn't succeed, so fix the backlog */ backlog = atomic_inc_return(&endpoint->replenish_backlog); - if (count) - atomic_add(count, &endpoint->replenish_backlog); + if (add_one) + 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 @@ -1080,7 +1083,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, 0); + ipa_endpoint_replenish(endpoint, false); } static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) @@ -1099,7 +1102,7 @@ static void ipa_endpoint_replenish_work(struct work_struct *work) endpoint = container_of(dwork, struct ipa_endpoint, replenish_work); - ipa_endpoint_replenish(endpoint, 0); + ipa_endpoint_replenish(endpoint, false); } static void ipa_endpoint_skb_copy(struct ipa_endpoint *endpoint, @@ -1300,7 +1303,7 @@ static void ipa_endpoint_rx_complete(struct ipa_endpoint *endpoint, { struct page *page; - ipa_endpoint_replenish(endpoint, 1); + ipa_endpoint_replenish(endpoint, true); if (trans->cancelled) return; -- 2.20.1