Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2857957pxb; Thu, 3 Feb 2022 16:37:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4EbgaVFSFzis448kyHBuTi0cuc+POV9WidaDmuFCbmWvA4iRG0gMXuZJ9ed8AcNd3HQgo X-Received: by 2002:a05:6402:270a:: with SMTP id y10mr700540edd.413.1643935060465; Thu, 03 Feb 2022 16:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643935060; cv=none; d=google.com; s=arc-20160816; b=mcBH5K67ftxTZ5N7JwyLchNlED1kyzV7nKZZ6rim6Xcsl+yuTrKJ52cNt6T37eVsR7 UtEyK9Jvd3PXrsCgXxwdvSiQ8Ol9qN1AHNbt4TB7aEToW0XALt+czeXyZkSZO8CWMebr kk7XrmrvzLVXlAZMFEf0jy4BW3kHqzO0fE2b8E2n5Ji2kvuy6Roreg61VZKSY1K4+g9W GlnGeCQ2Z2rHGeOPrToIxuto8LeQakgUZurBc/rtugJ5beVqptT3cw2i1fjWjBXTs8GM C7XrlEIwLe0zmf0LrZgL9+rf9M9LpbQ3ifJ49LvbW5drNT/xhlBnfFdzTOCcO3vAShIT EDhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UTD/8NZGtGtHN6WTCBTC3xofep8IAMari0myuecKnYQ=; b=1BTTsi7Hcyahaybju1ongSZjWq8Pe7sB1EmRHetlQxcBtSGJByKtskot86bsFmYQ9/ gJ2rUSxwZsmSsBOMkEWKdaLPPcANey9A/zz65xD9868PxwVRyIy6Do/JXwghDwnD6lXL Y6QFgBKdeXfKoRgmlf19ibhymk6wOnWmh12I1oT8oi1trw7PlkUNdSnbuyqc7Izgqrdy ZfQxnrWVKnLKKyRZRFI+8j89/XYHPIi4b+B0g1cBZyrXeeD9Ben6Cgycok2kY6MbunDx FbBh28jKYmxue8veQ3gwD5AIRmtp3MWzj8ItJgvgxIR4yvXXMGAXUTfgIVVx5R1H6/rT Wjzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYR8oTnq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg39si209341ejc.709.2022.02.03.16.37.15; Thu, 03 Feb 2022 16:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYR8oTnq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352703AbiBCRKY (ORCPT + 99 others); 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-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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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); } -- 2.32.0