Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp30296rwe; Wed, 31 Aug 2022 15:46:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6vqJa0RhBqr7vsb6nRX28eAZYng+KKsNxRUwyxy1FfJqXqsNFbFIpZsTOT20GmB0dTLLoZ X-Received: by 2002:a05:6402:501d:b0:443:1c7:ccb9 with SMTP id p29-20020a056402501d00b0044301c7ccb9mr26599776eda.101.1661985999711; Wed, 31 Aug 2022 15:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661985999; cv=none; d=google.com; s=arc-20160816; b=vQ88VixBU+comYMM2ujQWTMy+eeFtlnluCHqX8v5CHXh+mnR+Vbhh8eDdYo1AhqbNT 3pWq/WAyt728Akh6GGIYg41lm0vSZxAmtMRqnBgHO64Ho3YfpUC+h2nnbVuN2Bq7oqlR qVgjf6KgwZx4C3b4tAccykNxOAADthlT34c4IgAPxBDWdwp0t/HO/37n2SSLOlfOjiQ1 LHdtsBSiGNx1S7T1/Hqpnbq2gHIUZXud4pPYYUbBR6beOX9IXN9en475Sr5CCUIR5fLe Kyf9UHOriM5to6dP3eGdxgCySZO5d4FJypYhETrlSMmZ0Ax+Muw8YlxwXWFQpEkx2BMO JbwQ== 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=Yc6ZsFPyEM3kFhmeyp2pTQv8n95urKP/xL3I5LxZcU8=; b=h51A7tlMS4q5i4y/YLpQvz0uSvFQbj/QIrYZeTuMiyqwArnklo7sVW/sPry1uqv9kp HRrNVYz5uOZykKqoxEEeD+rwBZocJW3jWQPZMe2IvP2BlQoNtY/XWAtpJmL4bvDsmIzv AdGeaEhrR1nvT7klR/rqccCzI0GphVouHAnzkBwkD2siG6tmAHKlNKAtjMly94f36Nv3 NTL/9hoWpfKR4SyBgxMNFuphDG7wGFfXf+U+fsVJBtR35dhfan8L9mDsEAE0KaG3MaKJ cKl3t6KbhYYtZysTUEqkIWrEDiQKrYAZkzhyso1JENxZutnce925WNiYlxd4nMzrKAYT d20g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xtGGtkYd; 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 xf11-20020a17090731cb00b0073d7ba692b3si12480279ejb.375.2022.08.31.15.45.58; Wed, 31 Aug 2022 15:46:39 -0700 (PDT) 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=xtGGtkYd; 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 S232666AbiHaWkt (ORCPT + 99 others); Wed, 31 Aug 2022 18:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232594AbiHaWk3 (ORCPT ); Wed, 31 Aug 2022 18:40:29 -0400 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 B857D86702 for ; Wed, 31 Aug 2022 15:40:27 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id t11so5561192ilf.3 for ; Wed, 31 Aug 2022 15:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Yc6ZsFPyEM3kFhmeyp2pTQv8n95urKP/xL3I5LxZcU8=; b=xtGGtkYdxXLUjN/j9lTbb1UmdHhBXQtjzhw3Zu73Z7MRb+Q92408zHAPe/wq8VP7F2 rcwFiITymzXNJ1OsJ/Mcy6tThqkCIdUP4k7erRx87ugJurqYnjF8s1+fb8ZZmuyAcKey hwz3dZQXxuuBoBGVz9Twq1C4EnoNE3YmF0tfoP2hXLjiFmQq9H7Zx/ySqnOQ26RfLLdu fUhKuSlNxxGl4CokHFxaJvI0Ox2i7GOikGCI31A6kZ3SQAh7BhTAqdOxAAGKiPH/cqRB ThhAyOMm8593l9SnquJbe5o6k8d5fqHiBWCvdlV7z5LRN94Er5KdB2DJAhGfFe12k1Et YMFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Yc6ZsFPyEM3kFhmeyp2pTQv8n95urKP/xL3I5LxZcU8=; b=STMGMbUhTDlwhTJ8kMRb2O82Lu9TdxKy1QAlb+qtU7Vz5gyXRlzy/XgaE7V6M9cWuW 5HDVXnLzD13K3rQhGp3/F77b2RlCGegP1FNnWOKvyVHinpHDaML7QcySQszS97kna0Ml Mtv9RwdOaea14yB9Io/Bul5EKOjU11+mHYvJJum/91/3m0CCt1h18KJAtMb7b65NDWH7 JDr6QqNUvdulsITCMfsn1IppwRlILOyRpJEp8U8ZI6KL8Es6nY2lnLpQSwba7VEhKuMW QqZ3YfvdhAQo7NVUMGeOLiKHIHFbuJUS4twSmbjR06jIOYxOxOpA5XHsj6dRHZYcnSxl RuRA== X-Gm-Message-State: ACgBeo1AQdVF98Lhu3ertQnL43PbbJfmnUU8AKXhxrz1CxhS4LZr1FhW i0QEmdtWe65FD+71fMKNeWVGzA== X-Received: by 2002:a05:6e02:1ca9:b0:2e5:fa2a:6345 with SMTP id x9-20020a056e021ca900b002e5fa2a6345mr15057998ill.5.1661985627071; Wed, 31 Aug 2022 15:40:27 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id n30-20020a02a19e000000b0034c0db05629sm1392005jah.161.2022.08.31.15.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 15:40:26 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, bjorn.andersson@linaro.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/6] net: ipa: track completed transactions with an ID Date: Wed, 31 Aug 2022 17:40:16 -0500 Message-Id: <20220831224017.377745-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220831224017.377745-1-elder@linaro.org> References: <20220831224017.377745-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a transaction ID field to track the first element in the transaction array that has completed but has not yet been polled. Advance the ID when we are processing a transaction in the NAPI polling loop (where completed transactions become polled). Temporarily add warnings that verify that the first completed transaction tracked by the ID matches the first element on the completed list, both when pending and completing. Remove the temporary warnings added by the previous commit. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.h | 1 + drivers/net/ipa/gsi_trans.c | 40 +++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index f23e7e562585e..987f9f5f35d36 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -87,6 +87,7 @@ struct gsi_trans_info { u16 allocated_id; /* first allocated transaction */ u16 committed_id; /* first committed transaction */ u16 pending_id; /* first pending transaction */ + u16 completed_id; /* first completed transaction */ struct gsi_trans *trans; /* transaction array */ struct gsi_trans **map; /* TRE -> transaction map */ diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 5e3b4f673d9fb..40852b1dd5b98 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -272,18 +272,11 @@ static void gsi_trans_move_pending(struct gsi_trans *trans) list_cut_position(&list, &trans_info->committed, &trans->links); list_splice_tail(&list, &trans_info->pending); - trans = list_first_entry(&trans_info->pending, - struct gsi_trans, links); - spin_unlock_bh(&trans_info->spinlock); /* These committed transactions are now pending */ delta = trans_index - trans_info->committed_id + 1; trans_info->committed_id += delta % channel->tre_count; - - WARN_ON(trans_info->pending_id == trans_info->committed_id); - trans_index = trans_info->pending_id % channel->tre_count; - WARN_ON(trans != &trans_info->trans[trans_index]); } /* Move a transaction and all of its predecessors from the pending list @@ -303,8 +296,8 @@ void gsi_trans_move_complete(struct gsi_trans *trans) list_cut_position(&list, &trans_info->pending, &trans->links); list_splice_tail(&list, &trans_info->complete); - trans = list_first_entry_or_null(&trans_info->pending, - struct gsi_trans, links); + trans = list_first_entry(&trans_info->complete, + struct gsi_trans, links); spin_unlock_bh(&trans_info->spinlock); @@ -313,13 +306,9 @@ void gsi_trans_move_complete(struct gsi_trans *trans) delta %= channel->tre_count; trans_info->pending_id += delta; - if (trans) { - trans_index = trans_info->pending_id % channel->tre_count; - WARN_ON(trans != &trans_info->trans[trans_index]); - } else { - WARN_ON(trans_info->pending_id != - trans_info->committed_id); - } + WARN_ON(trans_info->completed_id == trans_info->pending_id); + trans_index = trans_info->completed_id % channel->tre_count; + WARN_ON(trans != &trans_info->trans[trans_index]); } /* Move a transaction from the completed list to the polled list */ @@ -327,12 +316,27 @@ void gsi_trans_move_polled(struct gsi_trans *trans) { struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id]; struct gsi_trans_info *trans_info = &channel->trans_info; + u16 trans_index; spin_lock_bh(&trans_info->spinlock); list_move_tail(&trans->links, &trans_info->polled); + trans = list_first_entry_or_null(&trans_info->complete, + struct gsi_trans, links); + spin_unlock_bh(&trans_info->spinlock); + + /* This completed transaction is now polled */ + trans_info->completed_id++; + + if (trans) { + trans_index = trans_info->completed_id % channel->tre_count; + WARN_ON(trans != &trans_info->trans[trans_index]); + } else { + WARN_ON(trans_info->completed_id != + trans_info->pending_id); + } } /* Reserve some number of TREs on a channel. Returns true if successful */ @@ -443,12 +447,13 @@ void gsi_trans_free(struct gsi_trans *trans) return; /* Unused transactions are allocated but never committed, pending, - * or completed. + * completed, or polled. */ if (!trans->used_count) { trans_info->allocated_id++; trans_info->committed_id++; trans_info->pending_id++; + trans_info->completed_id++; } else { ipa_gsi_trans_release(trans); } @@ -790,6 +795,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) trans_info->allocated_id = 0; trans_info->committed_id = 0; trans_info->pending_id = 0; + trans_info->completed_id = 0; /* A completion event contains a pointer to the TRE that caused * the event (which will be the last one used by the transaction). -- 2.34.1