From patchwork Tue Sep 6 17:19:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12967936 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 C4DF1ECAAA1 for ; Tue, 6 Sep 2022 17:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbiIFR2h (ORCPT ); Tue, 6 Sep 2022 13:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbiIFR2D (ORCPT ); Tue, 6 Sep 2022 13:28:03 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB6FA21811 for ; Tue, 6 Sep 2022 10:19:48 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id i77so9466946ioa.7 for ; Tue, 06 Sep 2022 10:19:48 -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=SsJOWqNx8N+KalhLrOerr5OsTlnBZPakmw9e8MRgY0g=; b=vx/kh62Ife6c+24oArxDVg8MLRZ+fIlND7Px2yBWCn0y49bs13cZky6OvL66p1RuuF IdI+D6I/5ejj8lLBgUg/O+COgCc3PUHkQUFdOiqb3ho831UEUwb4jrbIo7Ok9FLpY6iG Db7BtivIRzxYAsSvYvHqion/mU5HThu1+ELuq6zeT2ULCLnEexWMYK2cP2+XVXy6pQKT BKgKR47VTpA3LAEwxKpR2vjzD00DdyKnDbJpgeNkDwlJbtFGe0x1qwmSPpZi65WauS7p f/R/frSx33ZvT5B6KxNB1QL3vzGViwwuSvDN6oMxxTSkS5vtkHnZVlPGwAVVejX3Yl83 j45A== 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=SsJOWqNx8N+KalhLrOerr5OsTlnBZPakmw9e8MRgY0g=; b=Sg7VpnVbDDsdMDdwnJmCLsgZ9WURSOh/aLeF2Cz+Ha8GP8dzwgRg0GvRV9kB2dY69b tNTneLZosjB+7jnCIqkrl/SKUOHFlraTcPMytrQnYVGxPRicpfGvYVNk+8t8kDCgu97X fYZkKtQX6LMVGO50FlL3vAMNAeZFHAhTKhwtkBbr6FV5vccPhJ7qqw4wG0xPMw7YFw9P eXoc2CyM6Ti04sOGM/vCaBhN+2UJdJ6CJNkAryqv3XkAK2ydjCSF3jg43QtnA8ZRiIub rOD+ZNLH1Ysw91Mn00EV6uBvx+qp27RVcxzA4KKvIAA6MR2bSKA3Nz1G2k9NV81gSm66 GKlA== X-Gm-Message-State: ACgBeo3wC0Ea04hkbuVhQB+K0ABpeRHirjWNhqLOlXlkS0urSdRdBC3z AUBQgq2TPWeRX9RaRdmZwstdZw== X-Google-Smtp-Source: AA6agR5Ls+KS2KaQXrYHynxqMo7Jc06iL1OoIgqwOs+7lEPkYc9ibsgoqmXwY9Bl7WvR42wfIgZnRw== X-Received: by 2002:a05:6638:3e90:b0:34c:f1b5:d600 with SMTP id ch16-20020a0566383e9000b0034cf1b5d600mr13635084jab.166.1662484787455; Tue, 06 Sep 2022 10:19:47 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id q10-20020a056e020c2a00b002eb3f5fc4easm5292204ilg.27.2022.09.06.10.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:19:46 -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 1/5] net: ipa: always use transaction IDs instead of lists Date: Tue, 6 Sep 2022 12:19:38 -0500 Message-Id: <20220906171942.957704-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906171942.957704-1-elder@linaro.org> References: <20220906171942.957704-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In gsi_channel_trans_complete(), use the completed and pending IDs to determine whether there are any transactions in completed state. Similarly, in gsi_channel_trans_cancel_pending(), use the pending and committed IDs to mark pending transactions cancelled. Rearrange the logic a bit there for a simpler result. This removes the only user of list_last_entry_or_null(), so get rid of that macro. Remove the temporary warnings added by the previous commit. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi_private.h | 14 --------- drivers/net/ipa/gsi_trans.c | 58 ++++++++++------------------------- 2 files changed, 16 insertions(+), 56 deletions(-) diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index 51bbc7a40dc2d..0b2516fa21b5d 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -16,20 +16,6 @@ struct gsi_channel; #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ -/** - * list_last_entry_or_null - get the last element from a list - * @ptr: the list head to take the element from. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_head within the struct. - * - * Note that if the list is empty, it returns NULL. - */ -#define list_last_entry_or_null(ptr, type, member) ({ \ - struct list_head *head__ = (ptr); \ - struct list_head *pos__ = READ_ONCE(head__->prev); \ - pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ -}) - /** * gsi_trans_move_complete() - Mark a GSI transaction completed * @trans: Transaction to commit diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 05ab4d052c68b..a131a4fbb53fc 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -239,22 +239,11 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel) { struct gsi_trans_info *trans_info = &channel->trans_info; u16 trans_id = trans_info->completed_id; - struct gsi_trans *trans; - trans = list_first_entry_or_null(&trans_info->complete, - struct gsi_trans, links); - - if (!trans) { - WARN_ON(trans_id != trans_info->pending_id); + if (trans_id == trans_info->pending_id) return NULL; - } - if (!WARN_ON(trans_id == trans_info->pending_id)) { - trans_id %= channel->tre_count; - WARN_ON(trans != &trans_info->trans[trans_id]); - } - - return trans; + return &trans_info->trans[trans_id %= channel->tre_count]; } /* Move a transaction from the allocated list to the committed list */ @@ -705,47 +694,32 @@ void gsi_trans_complete(struct gsi_trans *trans) void gsi_channel_trans_cancel_pending(struct gsi_channel *channel) { struct gsi_trans_info *trans_info = &channel->trans_info; - struct gsi_trans *trans; - struct gsi_trans *first; - struct gsi_trans *last; - bool cancelled; + u16 trans_id = trans_info->pending_id; /* channel->gsi->mutex is held by caller */ spin_lock_bh(&trans_info->spinlock); - cancelled = !list_empty(&trans_info->pending); - list_for_each_entry(trans, &trans_info->pending, links) - trans->cancelled = true; - list_splice_tail_init(&trans_info->pending, &trans_info->complete); - first = list_first_entry_or_null(&trans_info->complete, - struct gsi_trans, links); - last = list_last_entry_or_null(&trans_info->complete, - struct gsi_trans, links); - spin_unlock_bh(&trans_info->spinlock); + /* If there are no pending transactions, we're done */ + if (trans_id == trans_info->committed_id) + return; + + /* Mark all pending transactions cancelled */ + do { + struct gsi_trans *trans; + + trans = &trans_info->trans[trans_id % channel->tre_count]; + trans->cancelled = true; + } while (++trans_id != trans_info->committed_id); + /* All pending transactions are now completed */ - WARN_ON(cancelled != (trans_info->pending_id != - trans_info->committed_id)); - trans_info->pending_id = trans_info->committed_id; /* Schedule NAPI polling to complete the cancelled transactions */ - if (cancelled) { - u16 trans_id; - - napi_schedule(&channel->napi); - - trans_id = trans_info->completed_id; - trans = &trans_info->trans[trans_id % channel->tre_count]; - WARN_ON(trans != first); - - trans_id = trans_info->pending_id - 1; - trans = &trans_info->trans[trans_id % channel->tre_count]; - WARN_ON(trans != last); - } + napi_schedule(&channel->napi); } /* Issue a command to read a single byte from a channel */ From patchwork Tue Sep 6 17:19:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12967941 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 8A480C6FA86 for ; Tue, 6 Sep 2022 17:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbiIFR3c (ORCPT ); Tue, 6 Sep 2022 13:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233834AbiIFR2D (ORCPT ); Tue, 6 Sep 2022 13:28:03 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F3762253C for ; Tue, 6 Sep 2022 10:19:49 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id b142so9450682iof.10 for ; Tue, 06 Sep 2022 10:19:49 -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=CjoWo3+k+FJefuKDmYvTvnT+WX8ScIS7BJ8NLr7fgUk=; b=JPpBQZyb3MFCnoBO52mQbvRvFK1bzbdI+2/0tSQ5oAtPjJEdcY29K3sXpZD8LW583o rMaIFEo+9v2fgMfra5ZEmTVqfrlU4Kx3Z6vtoPQ7oMklEmD0m9CqzMKCWQrsQ7qnAeuA llGVacas3XKjxS7jF3f6w4fBsE1GCEFRkNSstvF/6wFP4jpQBwmadDv6B8YNQBWZHOT1 9dww/OZOZmcaE+5h9DAzKvfyrGEpSo6KDqsxbrm47GwywxTPcK5jaYyt07JisfArbRX5 pp+eePKsh8cRKOPl8iPWW7OoU7Ub4KQkR2KpO8Jtcb0qaNZ98j7eR2UGIUwAozFi/R2V 4aDw== 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=CjoWo3+k+FJefuKDmYvTvnT+WX8ScIS7BJ8NLr7fgUk=; b=ps9NV7UrFFWVowEkolFVSmabgkF6FN6mbMejy9IE6T2B9wRsx7ZvGc3OuSlYb6BdKf vqVYk4L6oaWzr5BcsaJ4TuYRG4v6hhvqHkw7KAgrKN/AZweG3fdzcokoFHotibZYiKTg NtD6ZrL0VqEGBZPY2LE5uYNPmRL4LqZbcZFx6J43uME4mtXq/WEEeOrVuR9tH0F2UzNU 5v8GbzmZXC9JShBjAkLKEY3nfWFXV1mfpwCelxQ01icM/TOGllZLACLYWj9VSGpN6MV2 Cn0JtbfHs2sf8JbFJ0jgxrDbOcETIo4ljTuUROSV6Do/HSGEeo+b5gs7t/zXzcNjGBiK Dxvg== X-Gm-Message-State: ACgBeo0r9zK6W9r5FmR6vjD/VMl3GpVbQqG1l67Tebn3mySuf5kBJIVg hSUs+IW/Ao6GjQb6N8mED3T8ig== X-Google-Smtp-Source: AA6agR7rTi9SxdHgk5lyHtTRB5WdZqlUMnmRfR0A29gUrSbu1B0otTK52IVfZET3qDkjamMOw66CPw== X-Received: by 2002:a05:6638:4811:b0:349:d619:a9d9 with SMTP id cp17-20020a056638481100b00349d619a9d9mr29500805jab.240.1662484788720; Tue, 06 Sep 2022 10:19:48 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id q10-20020a056e020c2a00b002eb3f5fc4easm5292204ilg.27.2022.09.06.10.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:19:48 -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/5] net: ipa: kill the allocated transaction list Date: Tue, 6 Sep 2022 12:19:39 -0500 Message-Id: <20220906171942.957704-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906171942.957704-1-elder@linaro.org> References: <20220906171942.957704-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The only place the trans_info->alloc list is used is when initializing it, when adding a transaction to it when allocation finishes, and when moving a transaction from that list to the committed list. We can just skip putting a transaction on the allocated list, and add it (rather than move it) to the committed list when it is committed. On additional caveat is that an allocated transaction that's committed without any TREs added will be immediately freed. Because we aren't adding allocated transactions to a list any more, the list links need to be initialized to ensure they're valid at the time list_del() is called for the transaction. Then we can safely eliminate the allocated transaction list. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.h | 1 - drivers/net/ipa/gsi_trans.c | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 13468704c4000..a3f2d27a7e4b3 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -96,7 +96,6 @@ struct gsi_trans_info { struct gsi_trans_pool cmd_pool; /* command payload DMA pool */ spinlock_t spinlock; /* protects updates to the lists */ - struct list_head alloc; /* allocated, not committed */ struct list_head committed; /* committed, awaiting doorbell */ struct list_head pending; /* pending, awaiting completion */ struct list_head complete; /* completed, awaiting poll */ diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index a131a4fbb53fc..254c09824004c 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -246,7 +246,7 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel) return &trans_info->trans[trans_id %= channel->tre_count]; } -/* Move a transaction from the allocated list to the committed list */ +/* Move a transaction from allocated to committed state */ static void gsi_trans_move_committed(struct gsi_trans *trans) { struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id]; @@ -254,7 +254,7 @@ static void gsi_trans_move_committed(struct gsi_trans *trans) spin_lock_bh(&trans_info->spinlock); - list_move_tail(&trans->links, &trans_info->committed); + list_add_tail(&trans->links, &trans_info->committed); spin_unlock_bh(&trans_info->spinlock); @@ -383,6 +383,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, memset(trans, 0, sizeof(*trans)); /* Initialize non-zero fields in the transaction */ + INIT_LIST_HEAD(&trans->links); trans->gsi = gsi; trans->channel_id = channel_id; trans->rsvd_count = tre_count; @@ -398,12 +399,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, /* This free transaction will now be allocated */ trans_info->free_id++; - spin_lock_bh(&trans_info->spinlock); - - list_add_tail(&trans->links, &trans_info->alloc); - - spin_unlock_bh(&trans_info->spinlock); - return trans; } @@ -821,7 +816,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) goto err_map_free; spin_lock_init(&trans_info->spinlock); - INIT_LIST_HEAD(&trans_info->alloc); INIT_LIST_HEAD(&trans_info->committed); INIT_LIST_HEAD(&trans_info->pending); INIT_LIST_HEAD(&trans_info->complete); From patchwork Tue Sep 6 17:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12967937 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 8B84FC38145 for ; Tue, 6 Sep 2022 17:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232909AbiIFR2i (ORCPT ); Tue, 6 Sep 2022 13:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234722AbiIFR2G (ORCPT ); Tue, 6 Sep 2022 13:28:06 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5687F286EB for ; Tue, 6 Sep 2022 10:19:50 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id e195so9491970iof.1 for ; Tue, 06 Sep 2022 10:19:50 -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=vGV0LErzUVZ+oH6Ahl3yaA3wsEhujDLPCmZWellXY2E=; b=fhyOsKBoGlfGVT9fE6T//G3it4Qv/vOjcLFmHO38ILsRfLiLXvp+ayam+rsB5VpbKt ZptduDSgOvMw+UEBpcwMDtsCtDWKmWC4/MD6cvmdqkb3bTctUQhE3bgxudC/6/3ZROIu 5R02jOk0zW/rxhOx1lXDYdmB6FTOwuJtQ3n9a4M/fQw84OENtySHrft/h3xiiTdh+nB3 HKrnR3/1BKgXTstaqmMufCPCQpZQ73BKYwUzGWEvOia4zugtnGurXldHke/ZpoGvn5gB WlR2UuYN2D/lpJgtJOCEX5p6uZEjtCcfF18nsnG4hNdyfOz4Iqw3i4yjBx1mf/ebXsN7 /Wrg== 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=vGV0LErzUVZ+oH6Ahl3yaA3wsEhujDLPCmZWellXY2E=; b=VWI5KCf8FLv+mdjnpddRrXhZx+Hr3PTB8tPlMYHSTVejyzeexV+CpW/jO/wTRvaRhW o2Dlb1Z8pdAEDfMAyTuWAL8hMwo2aWzr9lX8lDFLILGVjgld1D6dKpvgYXwvytQ4rqlk D7uPuxmya6OkGa/WSELexZ+KmtwVexeW/OXxakJVnc/1e30/6CXxy9f0MNoAw4PrwMh5 w3CfUjKM6ByVn84Bt48rtjuujzeiP0ic+G8IRi4AUXFWd0mDRPyVVnEQ2hUeQInPfZiO tp0KnFiIohM/3MA+6vqUWKCwwVMCbOcdIlFuATFnyNS+vZP7Ejy8/5YbBOqxjbAl/Xu1 kxaA== X-Gm-Message-State: ACgBeo19mtFdo6fHAbm0VQMgcndFbEP5b4M9b21JPFd3I8KQ9C763PTd d7WE4d22zgEZwxfdYdPq3v7OGw== X-Google-Smtp-Source: AA6agR4n1LTlHdCfl+Mih055iDKJd42eGpUqbhFXFSCI+CzoZ+ZKWIDBkHhj882oa/5RuGb1q1s2Iw== X-Received: by 2002:a05:6602:490:b0:678:d781:446d with SMTP id y16-20020a056602049000b00678d781446dmr26173445iov.115.1662484789865; Tue, 06 Sep 2022 10:19:49 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id q10-20020a056e020c2a00b002eb3f5fc4easm5292204ilg.27.2022.09.06.10.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:19:49 -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 3/5] net: ipa: kill all other transaction lists Date: Tue, 6 Sep 2022 12:19:40 -0500 Message-Id: <20220906171942.957704-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906171942.957704-1-elder@linaro.org> References: <20220906171942.957704-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org None of the transaction lists are actually needed any more, because transaction IDs (which have been shown to be equivalent) are used instead. So we can remove all of them, as well as the spinlock that protects updates to them. Not requiring a lock simplifies gsi_trans_free() as well; we only need to check the reference count once to decide whether we've hit the last reference. This makes the links field in the gsi_trans structure unused, so get rid of that as well. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.h | 6 ---- drivers/net/ipa/gsi_trans.c | 71 ++++--------------------------------- drivers/net/ipa/gsi_trans.h | 3 -- 3 files changed, 6 insertions(+), 74 deletions(-) diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index a3f2d27a7e4b3..84d178a1a7d22 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -94,12 +94,6 @@ struct gsi_trans_info { struct gsi_trans_pool sg_pool; /* scatterlist pool */ struct gsi_trans_pool cmd_pool; /* command payload DMA pool */ - - spinlock_t spinlock; /* protects updates to the lists */ - struct list_head committed; /* committed, awaiting doorbell */ - struct list_head pending; /* pending, awaiting completion */ - struct list_head complete; /* completed, awaiting poll */ - struct list_head polled; /* returned by gsi_channel_poll_one() */ }; /* Hardware values signifying the state of a channel */ diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 254c09824004c..a3ae0ca4813c6 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -252,75 +252,43 @@ 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; - spin_lock_bh(&trans_info->spinlock); - - list_add_tail(&trans->links, &trans_info->committed); - - spin_unlock_bh(&trans_info->spinlock); - /* This allocated transaction is now committed */ trans_info->allocated_id++; } -/* Move transactions from the committed list to the pending list */ +/* Move committed transactions to pending state */ static void gsi_trans_move_pending(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 = trans - &trans_info->trans[0]; - struct list_head list; u16 delta; - spin_lock_bh(&trans_info->spinlock); - - /* Move this transaction and all predecessors to the pending list */ - list_cut_position(&list, &trans_info->committed, &trans->links); - list_splice_tail(&list, &trans_info->pending); - - 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; } -/* Move a transaction and all of its predecessors from the pending list - * to the completed list. - */ +/* Move pending transactions to completed state */ void gsi_trans_move_complete(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 = trans - trans_info->trans; - struct list_head list; u16 delta; - spin_lock_bh(&trans_info->spinlock); - - /* Move this transaction and all predecessors to completed list */ - list_cut_position(&list, &trans_info->pending, &trans->links); - list_splice_tail(&list, &trans_info->complete); - - spin_unlock_bh(&trans_info->spinlock); - /* These pending transactions are now completed */ delta = trans_index - trans_info->pending_id + 1; delta %= channel->tre_count; trans_info->pending_id += delta; } -/* Move a transaction from the completed list to the polled list */ +/* Move a transaction from completed to polled state */ 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; - spin_lock_bh(&trans_info->spinlock); - - list_move_tail(&trans->links, &trans_info->polled); - - spin_unlock_bh(&trans_info->spinlock); - /* This completed transaction is now polled */ trans_info->completed_id++; } @@ -383,7 +351,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, memset(trans, 0, sizeof(*trans)); /* Initialize non-zero fields in the transaction */ - INIT_LIST_HEAD(&trans->links); trans->gsi = gsi; trans->channel_id = channel_id; trans->rsvd_count = tre_count; @@ -396,7 +363,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, trans->direction = direction; refcount_set(&trans->refcount, 1); - /* This free transaction will now be allocated */ + /* This free transaction is now allocated */ trans_info->free_id++; return trans; @@ -405,31 +372,15 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, /* Free a previously-allocated transaction */ void gsi_trans_free(struct gsi_trans *trans) { - refcount_t *refcount = &trans->refcount; struct gsi_trans_info *trans_info; - bool last; - /* We must hold the lock to release the last reference */ - if (refcount_dec_not_one(refcount)) - return; - - trans_info = &trans->gsi->channel[trans->channel_id].trans_info; - - spin_lock_bh(&trans_info->spinlock); - - /* Reference might have been added before we got the lock */ - last = refcount_dec_and_test(refcount); - if (last) - list_del(&trans->links); - - spin_unlock_bh(&trans_info->spinlock); - - if (!last) + if (!refcount_dec_and_test(&trans->refcount)) return; /* Unused transactions are allocated but never committed, pending, * completed, or polled. */ + trans_info = &trans->gsi->channel[trans->channel_id].trans_info; if (!trans->used_count) { trans_info->allocated_id++; trans_info->committed_id++; @@ -692,11 +643,6 @@ void gsi_channel_trans_cancel_pending(struct gsi_channel *channel) u16 trans_id = trans_info->pending_id; /* channel->gsi->mutex is held by caller */ - spin_lock_bh(&trans_info->spinlock); - - list_splice_tail_init(&trans_info->pending, &trans_info->complete); - - spin_unlock_bh(&trans_info->spinlock); /* If there are no pending transactions, we're done */ if (trans_id == trans_info->committed_id) @@ -815,11 +761,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) if (ret) goto err_map_free; - spin_lock_init(&trans_info->spinlock); - INIT_LIST_HEAD(&trans_info->committed); - INIT_LIST_HEAD(&trans_info->pending); - INIT_LIST_HEAD(&trans_info->complete); - INIT_LIST_HEAD(&trans_info->polled); return 0; diff --git a/drivers/net/ipa/gsi_trans.h b/drivers/net/ipa/gsi_trans.h index 7084507830c21..af8c4c6719d11 100644 --- a/drivers/net/ipa/gsi_trans.h +++ b/drivers/net/ipa/gsi_trans.h @@ -29,7 +29,6 @@ struct gsi_trans_pool; * struct gsi_trans - a GSI transaction * * Most fields in this structure for internal use by the transaction core code: - * @links: Links for channel transaction lists by state * @gsi: GSI pointer * @channel_id: Channel number transaction is associated with * @cancelled: If set by the core code, transaction was cancelled @@ -50,8 +49,6 @@ struct gsi_trans_pool; * received. */ struct gsi_trans { - struct list_head links; /* gsi_channel lists */ - struct gsi *gsi; u8 channel_id; From patchwork Tue Sep 6 17:19:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12967938 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 88494ECAAA1 for ; Tue, 6 Sep 2022 17:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233280AbiIFR2j (ORCPT ); Tue, 6 Sep 2022 13:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234895AbiIFR2G (ORCPT ); Tue, 6 Sep 2022 13:28:06 -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 B04852982A for ; Tue, 6 Sep 2022 10:19:51 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id h14so6308307ilh.10 for ; Tue, 06 Sep 2022 10:19:51 -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=zZbEcuX0tdGW7P2MaUSSUsEhwbNAXlnJUrhgFzH+WmQ=; b=I0njSX+tXOi0JgBd1TyTJqM9z+wnQ1XLkog8MwTlzh2ydkCBZMPz/yUwAhOX2G7qiw bWh33JM8bI7MWixDFomd9+Py89DNjn9W/8GB39vf09N3gM/0fhG8TGiu9DCJoOKZdVun kG0YZB6ONQoDZrzjGoIXIFhRaQh8cqaVfjNjD9e+7qyb89hs0LkSK8tysKGpo8zSTqb4 Tt1n/N3nW5aFaEIxf+0I43/PY61PcZE3kIuqK+bQhN8s48dTBcOhG5slGSKSaffeSZMo TNbF53ZwrxaELtt/9SMWOsZfrlfGe4rTfkW0R2eqePgH/TmnmCr4zbQk29kfHw2H23Q3 3VGQ== 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=zZbEcuX0tdGW7P2MaUSSUsEhwbNAXlnJUrhgFzH+WmQ=; b=GlTp8jzTTotVI4H7/eBTMOfyyZsNStB87jzSJQC3MVH3nEsNDG9uwKnkdj974vYwA7 3xm9Cq37bnMOJVX+A5St+8Bb2noUgC25JNTJ/3H5EHO2riVsbAKK3QJd3YWo302tqZ8z WjxEFWkTjrBuqoqdEl5hd2saxpvzIKRaRVyeVXW/CDWZ9il8ztrHZo0ZAs74vA6IPXjO 5Fb/v0bw8FSUdSMNC6g1oMJeqNt/zWTXzpgse2BF7sUN/XilKGCY95n8fFLDLmADKbRN dmbG7Qfh8oT2Al+MZE0TNDZqkKiqRNLxD9vgbPqMxSOfPhCvQA7EZ9UJcN2z/ANZshCK S7Gw== X-Gm-Message-State: ACgBeo3uxtHvm5191acyAnI6Zz4DhFeRcUi8OFb6Xo3id6wWNwaVpnJi OPjuap50dnDltNqTvc2OUYE1Lw== X-Google-Smtp-Source: AA6agR7XdHZspGzRaTMyCUViyeFlimDqc98GcZ+u5jnNk0/i4g7QUV6klrH8oqlC3vAYFZYZ4k5ZFA== X-Received: by 2002:a05:6e02:19cb:b0:2eb:3cd1:105e with SMTP id r11-20020a056e0219cb00b002eb3cd1105emr17590197ill.235.1662484791034; Tue, 06 Sep 2022 10:19:51 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id q10-20020a056e020c2a00b002eb3f5fc4easm5292204ilg.27.2022.09.06.10.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:19:50 -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 4/5] net: ipa: update channel in gsi_channel_trans_complete() Date: Tue, 6 Sep 2022 12:19:41 -0500 Message-Id: <20220906171942.957704-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906171942.957704-1-elder@linaro.org> References: <20220906171942.957704-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Have gsi_channel_trans_complete() update the known state from hardware rather than doing so in gsi_channel_poll_one(). Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 5 +---- drivers/net/ipa/gsi_private.h | 8 ++++++++ drivers/net/ipa/gsi_trans.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 16df699009a86..5471843b665fc 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1475,7 +1475,7 @@ void gsi_channel_doorbell(struct gsi_channel *channel) } /* Consult hardware, move any newly completed transactions to completed list */ -static struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) +struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) { u32 evt_ring_id = channel->evt_ring_id; struct gsi *gsi = channel->gsi; @@ -1529,9 +1529,6 @@ static struct gsi_trans *gsi_channel_poll_one(struct gsi_channel *channel) /* Get the first transaction from the completed list */ trans = gsi_channel_trans_complete(channel); - if (!trans) /* List is empty; see if there's more to do */ - trans = gsi_channel_update(channel); - if (trans) gsi_trans_move_polled(trans); diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index 0b2516fa21b5d..a937811bb1bb7 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -94,6 +94,14 @@ void gsi_channel_trans_exit(struct gsi_channel *channel); */ void gsi_channel_doorbell(struct gsi_channel *channel); +/* gsi_channel_update() - Update knowledge of channel hardware state + * @channel: Channel whose doorbell should be rung + * + * Consult hardware, move any newly completed transactions to a + * channel's completed list + */ +struct gsi_trans *gsi_channel_update(struct gsi_channel *channel); + /** * gsi_ring_virt() - Return virtual address for a ring entry * @ring: Ring whose address is to be translated diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index a3ae0ca4813c6..0b78ae904bacf 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -241,7 +241,7 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel) u16 trans_id = trans_info->completed_id; if (trans_id == trans_info->pending_id) - return NULL; + return gsi_channel_update(channel); return &trans_info->trans[trans_id %= channel->tre_count]; } From patchwork Tue Sep 6 17:19:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 12967939 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 0E005C38145 for ; Tue, 6 Sep 2022 17:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236695AbiIFR2p (ORCPT ); Tue, 6 Sep 2022 13:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238547AbiIFR2J (ORCPT ); Tue, 6 Sep 2022 13:28:09 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE17B2AE36 for ; Tue, 6 Sep 2022 10:19:52 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id z72so9439859iof.12 for ; Tue, 06 Sep 2022 10:19:52 -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=iyM6dtbNFzdJQR32hgHiDgJSwSi9j8lAYdcvFPMbXJQ=; b=JuA28ed5jfpBvyjkILaIrZc370JCraCfaVZn0DwL/4XC41roAyCqdnFq6wu5ilJPe8 eoWcn+CF5cnYMI+CZsOPAmW8Cm6SOsL0uoXmlXjgd0G933yf2HdAEPZATZgyeKG3643P wo8AEnhlzk4tT0kl7vimXVaDzY/I+Hc4FNG6Z4344k7fu+oXyf7Td6Nfs/+hXL0dKpRf twpDyDuurRHgnOt8Er1gujlyEHl4hi658FnSs0YYAMzlP47tpPxNwniaDiBsNltPXKti 8xswIFw9fL1e/NMq7A3wgMkrlIf7zYb3dQ1avCH+hoVmPaNcfEFCa6Fx4lif9SfuupIP 2RJA== 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=iyM6dtbNFzdJQR32hgHiDgJSwSi9j8lAYdcvFPMbXJQ=; b=b9O4CXPrxNj+hiSl2JOBgfEawXShXAYCDORjofKExC2lUtsXniT+rEvt56DH2bTCw9 I1CfHAuOTccREP3C5mxOFNd48S2ioX73VApQcf99XFCReXxEPu63OGiF1wtg8B/qbAXR KaFcfdqei1wJ3QyuQZfYSkrN5VcX6Ot7f/VjOuqW4UiJUV8u5S6F6bsNvSGD2Y0Csi+h XL9lCh9NJ6OzWinRTmJfGy7V3JC1nMECxtwFdcsqzqNXjlvyA9yp8scoKRaTke08cOiM NeUQ1drPyT1z7m34Sv0p9UidM83k1hmo4f/XnYSXJ8KYiU9f8KkP9E9Qd42oSh2XL39u LiOw== X-Gm-Message-State: ACgBeo3ShmZirpyvxtx8XaTXXXwxVUbYkgv8R86sdau6+IRPr3A7YCTb wIjqW2n8iB1jOsRfh/FZ/cZysg== X-Google-Smtp-Source: AA6agR6w7W/TozARn63hxlzaI23dFAQKaWq+NONJ95SyRshkKGSZ8QqS4uF3yMhJkXqBdv4i/6+TWA== X-Received: by 2002:a05:6602:2d41:b0:688:e962:2b53 with SMTP id d1-20020a0566022d4100b00688e9622b53mr25867027iow.79.1662484792111; Tue, 06 Sep 2022 10:19:52 -0700 (PDT) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id q10-20020a056e020c2a00b002eb3f5fc4easm5292204ilg.27.2022.09.06.10.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:19:51 -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/5] net: ipa: don't have gsi_channel_update() return a value Date: Tue, 6 Sep 2022 12:19:42 -0500 Message-Id: <20220906171942.957704-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906171942.957704-1-elder@linaro.org> References: <20220906171942.957704-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If it finds no completed transactions, gsi_channel_trans_complete() calls gsi_channel_update() to check hardware. If new transactions have completed, gsi_channel_update() records that, then calls gsi_channel_trans_complete() to return the first of those found. This recursion won't go any further, but can be avoided if we have gsi_channel_update() only be responsible for updating state after accessing hardware. Change gsi_channel_update() so it simply checks for and handles new completions, without returning a value. If it needs to call that function, have gsi_channel_trans_complete() determine whether there are new transactions available after the update. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 8 +++----- drivers/net/ipa/gsi_private.h | 6 +++--- drivers/net/ipa/gsi_trans.c | 7 +++++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 5471843b665fc..3f97653450bb9 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1475,7 +1475,7 @@ void gsi_channel_doorbell(struct gsi_channel *channel) } /* Consult hardware, move any newly completed transactions to completed list */ -struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) +void gsi_channel_update(struct gsi_channel *channel) { u32 evt_ring_id = channel->evt_ring_id; struct gsi *gsi = channel->gsi; @@ -1494,12 +1494,12 @@ struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) offset = GSI_EV_CH_E_CNTXT_4_OFFSET(evt_ring_id); index = gsi_ring_index(ring, ioread32(gsi->virt + offset)); if (index == ring->index % ring->count) - return NULL; + return; /* Get the transaction for the latest completed event. */ trans = gsi_event_trans(gsi, gsi_ring_virt(ring, index - 1)); if (!trans) - return NULL; + return; /* For RX channels, update each completed transaction with the number * of bytes that were actually received. For TX channels, report @@ -1507,8 +1507,6 @@ struct gsi_trans *gsi_channel_update(struct gsi_channel *channel) * up the network stack. */ gsi_evt_ring_update(gsi, evt_ring_id, index); - - return gsi_channel_trans_complete(channel); } /** diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index a937811bb1bb7..af4cc13864e21 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -95,12 +95,12 @@ void gsi_channel_trans_exit(struct gsi_channel *channel); void gsi_channel_doorbell(struct gsi_channel *channel); /* gsi_channel_update() - Update knowledge of channel hardware state - * @channel: Channel whose doorbell should be rung + * @channel: Channel to be updated * * Consult hardware, move any newly completed transactions to a - * channel's completed list + * channel's completed list. */ -struct gsi_trans *gsi_channel_update(struct gsi_channel *channel); +void gsi_channel_update(struct gsi_channel *channel); /** * gsi_ring_virt() - Return virtual address for a ring entry diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 0b78ae904bacf..03e54fc4376a6 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -240,8 +240,11 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel) struct gsi_trans_info *trans_info = &channel->trans_info; u16 trans_id = trans_info->completed_id; - if (trans_id == trans_info->pending_id) - return gsi_channel_update(channel); + if (trans_id == trans_info->pending_id) { + gsi_channel_update(channel); + if (trans_id == trans_info->pending_id) + return NULL; + } return &trans_info->trans[trans_id %= channel->tre_count]; }