Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp49049rwe; Wed, 31 Aug 2022 16:10:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wTjww8/YlBXDQsFVtVjuFcT8sv29egefMY546MLAQJJr6CT3jtNvMDfcUEmE8HruenKFc X-Received: by 2002:a63:110:0:b0:430:77e1:9284 with SMTP id 16-20020a630110000000b0043077e19284mr443292pgb.410.1661987441997; Wed, 31 Aug 2022 16:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661987441; cv=none; d=google.com; s=arc-20160816; b=QTBEnjNYOrWYh3aQ5+ojuwoAypjFRZE9wl+ZT5TZIQtoiFtJbzcVBPWW88TVRy3hkC cCqldOto5CqavKEYX8+BD8mEhW3sPXKlVQQad8Wl9RX3wVFukSajVxM5f7i3V9795ax7 m9IMml6Ck45yPuF32ZAxKzD9P3M+IeIehXo33t6OJa6dv7xe2qQf/+Cr9/6VNPL5VJ7N 37KOY5CMdt7eTvisuRj0AeIjmqFJ41cJRdpbSY2gR51CV8DM0k5ptvWj9NUWKfPo7dza 79M5kwZuQLcsKllk1VCwW8DY6naZCNMqGFzEZXqmg6EXh0sGI44Pl8gz+HVMYgqrcjvj nlWQ== 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=xr5LlJafNYPtsRXFWcggz2TXxTu5qcopLJfaNmU/uX0=; b=fd3n9V2aliO3pAulJseLU9zm7UZBlY6EbhxPct+giFYp6/gTWvqwE3kAiTwzw2Tk4E 1LWe4bT7/pTj4TpbHM6qf/JRObGzN5lP4wFVIJ6tbxx0Yidgz7pUe/5MJwWHke1PRR9z p4HtuXCWpWJ260lpYTSxR3Y40Mo5tKJL60C4//ilUfRx+IBmqkn3bCjmDjag2H5865ux lCjLWjV5a+m4gAUgTE9fl4/d6nZgiJCD8Z3S06OZH9GokS6zKyVINePq7jU65SmdbYJ/ eR66EAYdzWKEDP4KIclAp5EqgeRlYyjhV05MCwR3BI9FWon1XAg53AfLcvk01STXlp+p 7rZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s5uW3vqC; 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 w4-20020a656944000000b0042a020bd06bsi6713659pgq.781.2022.08.31.16.10.31; Wed, 31 Aug 2022 16:10:41 -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=s5uW3vqC; 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 S232625AbiHaWke (ORCPT + 99 others); Wed, 31 Aug 2022 18:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbiHaWk0 (ORCPT ); Wed, 31 Aug 2022 18:40:26 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9020286702 for ; Wed, 31 Aug 2022 15:40:24 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id l6so6934755ilk.13 for ; Wed, 31 Aug 2022 15:40:24 -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=xr5LlJafNYPtsRXFWcggz2TXxTu5qcopLJfaNmU/uX0=; b=s5uW3vqCPy4yTk5IW2Fzx7gJsfZQyEFZxK0exzAZA4rr/GN7/oM04jx09bxOWq6rPM MmnLYMmvUcMVxBMU4w4hHGXFHZkFj0eICzQfoMFgBuWFYhwoQFu1xqX8eA8fh07lsoy9 YVI75RZE0OOsMYAhuW9efX3MOcQH7wjVMAJfoLYCYVTJnhgMMwKRRYold39anoFMeihO FBw9BCWi9+IpwONUswMcjcb6FLe1WSyBvBntdMQZtRiJ5Ac2/eH9VGJlyMRT0c1zrjie 4i0atnTa0l0g9AnrgiF1HsEwB30RHyqIte9kpk8TmKj3VF6nt9IHwfcPk4fYEeXOa4n1 GrQw== 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=xr5LlJafNYPtsRXFWcggz2TXxTu5qcopLJfaNmU/uX0=; b=wRokdeKjvNjbVGyHoCLR6E3h3PqKQVDnLnARZ/fjEV4C5ODsHjlB5QjuuAhA+6xVFg HVUzWreJgqg8jpcXEI5iYJOnOi6OJcvbWKhhyVgo5nD5Vags65lIWynds9TF2S0d70bq LvwnP/6gO1eMLRsmO9KhLfRDkdEHuK4iamLtFXv5WtbTIHlamNZHoMz0G332RBHlfaoO ehVdLJAic+2+DWqxaCwMzlDOP6BFp8f/UjAmeak3co6WotvDlK/AisUCWfttNfc0ffXO ha2lgCd50RfCEwX5o+MytyNuTDVTkjw/b9l2xxzFbGEaKa9CHyPRHs/fWVR5GbPn+i3V rDbw== X-Gm-Message-State: ACgBeo0tyxdxtRbE2b2oaUcJo+Aj0zhF0XI88tAfhffSqXP4quX/t6rB ihyQsgU4NM4RWr3jWRsghP5bxg== X-Received: by 2002:a92:c265:0:b0:2ea:8f5b:f759 with SMTP id h5-20020a92c265000000b002ea8f5bf759mr13095686ild.73.1661985623886; Wed, 31 Aug 2022 15:40:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 15:40:23 -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 2/6] net: ipa: track allocated transactions with an ID Date: Wed, 31 Aug 2022 17:40:13 -0500 Message-Id: <20220831224017.377745-3-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=unavailable 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 Transactions for a channel are now managed in an array, with a free transaction ID indicating which is the next one free. Add another transaction ID field to track the first element in the array that has been allocated. Advance it when a transaction is committed (because that is when that transaction leaves allocated state). Temporarily add warnings that verify that the first allocated transaction tracked by the ID matches the first element on the allocated list, both when allocating and committing a transaction. Signed-off-by: Alex Elder --- NOTE: I find these temporary WARN_ON() calls helpful in proving the new index refers to the same transaction as the first element of an "old" list. I'll gladly remove these if requested. (This comment applies throughout this series.) drivers/net/ipa/gsi.h | 1 + drivers/net/ipa/gsi_trans.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 4a88aec7e7d92..6bbbda6f27eae 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -84,6 +84,7 @@ struct gsi_trans_info { atomic_t tre_avail; /* TREs available for allocation */ u16 free_id; /* first free trans in array */ + u16 allocated_id; /* first allocated 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 9775e50d0423f..d84400e13487f 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -246,12 +246,26 @@ static void gsi_trans_move_committed(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->committed); + trans = list_first_entry_or_null(&trans_info->alloc, + struct gsi_trans, links); + spin_unlock_bh(&trans_info->spinlock); + + /* This allocated transaction is now committed */ + trans_info->allocated_id++; + + if (trans) { + trans_index = trans_info->allocated_id % channel->tre_count; + WARN_ON(trans != &trans_info->trans[trans_index]); + } else { + WARN_ON(trans_info->allocated_id != trans_info->free_id); + } } /* Move transactions from the committed list to the pending list */ @@ -378,8 +392,14 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, list_add_tail(&trans->links, &trans_info->alloc); + trans = list_first_entry(&trans_info->alloc, struct gsi_trans, links); + spin_unlock_bh(&trans_info->spinlock); + WARN_ON(trans_info->allocated_id == trans_info->free_id); + trans_index = trans_info->allocated_id % channel->tre_count; + WARN_ON(trans != &trans_info->trans[trans_index]); + return trans; } @@ -408,7 +428,10 @@ void gsi_trans_free(struct gsi_trans *trans) if (!last) return; - if (trans->used_count) + /* Unused transactions are allocated but never committed */ + if (!trans->used_count) + trans_info->allocated_id++; + else ipa_gsi_trans_release(trans); /* Releasing the reserved TREs implicitly frees the sgl[] and @@ -744,7 +767,8 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) GFP_KERNEL); if (!trans_info->trans) return -ENOMEM; - trans_info->free_id = 0; /* modulo channel->tre_count */ + trans_info->free_id = 0; /* all modulo channel->tre_count */ + trans_info->allocated_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