From patchwork Fri Feb 5 22:10:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377640 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2817269jah; Fri, 5 Feb 2021 18:48:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeFgTAQzAnNfzIY11XEh6FzlHPmRuk4ffvKuqwzwep5zBisPyAJUpRZJ5Q4IPKyCcYJmxM X-Received: by 2002:a17:906:3656:: with SMTP id r22mr6800668ejb.14.1612579737649; Fri, 05 Feb 2021 18:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612579737; cv=none; d=google.com; s=arc-20160816; b=RSzG9RwfVqy7PosA2meEBn6E+BjSDrOg5CpQTS8rlQK9KcOnKEDqYhbAkUQWBzCV5m wW7P9xrvg3SV9B/zl/S41Vo9MB2bWpI5dWZFK6I5b0KES1ITZ2AEXTO9WC//x7mKGxO8 H8O+Zd3G4dH62f64VXLxAPPNfstUTiI1zXpCoy5+/qUOjLjI1KHODtJKIATdz2+Pq/5N TYCFhPqJeu0Ii/9ibJbLRnkcfoLZY3+xk/My7NOngDvTS+rJSgEIlWdzULtALT8bjhhD efqpjRqbWEDB8SE+k6vNN4iIHA0AmYqt6zOqmTiiqIXFtN0M1Q0CnZRPGr8odnOKE6yS nBqA== 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=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=dPIgTKV3vFIGMdH9cdj9Q+ZsA6hTUlQCI6WF+DBawuVuaaxm41zRqhJkfXsLrgayno kDlISb8OQu0McjgqWqV4obyucfKnEQMIQ6vhumYXkbcMtaGIfLWUSku3D2jAsx2jcbtE I2JvgCou2jh2o8nRo8h6dewQJpGGvZTT4Eq6aa+hNB6ANAwRNRt2hwxKcG1uZJI4410h rTt4iKLQtIoG8f4vsIvsmRVJwU33S3mk9pp7rJGSkb5ehkHNVhJ+44QGGO/OUmwzAVbY 9kgnQtHKAkHx/X+0xgeF3ZkyBGZrLcYzbQiQHf7MRDii6ArsjtipYQa5NBnUoNodaPQa WWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTEuxbCC; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 96si2069033edr.333.2021.02.05.18.48.57; Fri, 05 Feb 2021 18:48:57 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTEuxbCC; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231526AbhBFCsH (ORCPT + 7 others); Fri, 5 Feb 2021 21:48:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbhBFCcA (ORCPT ); Fri, 5 Feb 2021 21:32:00 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB24C0611BE for ; Fri, 5 Feb 2021 14:11:08 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id n14so8803557iog.3 for ; Fri, 05 Feb 2021 14:11:08 -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=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=BTEuxbCCuEIbEh3Xb6lKeZylFVq79zCpfoq3Qe9xk58lEmVUp3XxdGh6Gid63VWwoR VNA6pAn08IVlLt16Vm9+/RguhOrnxo/92jgQgGsA1+CyhGy7kQw8Y1CihWcub4RdNZSd vx3e1tX/pLnSAZecxcvoRFg/4KI6kJB1pY+Tm6tiDn4SzyhfcgjFWsIa4at4898aWki/ SbeythTF4biNSWniAe5g/58y6PozXVQ2MxYSY33HCXxZ1x1s4sBRPVBVhquKJFON8XxF m2YGyyCmbc0Jp7QyjQULVnL37y6gcvDELTLeXNKPL8BzfXnDViqjTtUbdjcRpdSFXx4V jNnw== 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=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=bEUSPVGvnZNnB0M2tLZSjCB1K7ujGtQwaUW//JPjtoqCDBpe8ns8oX4QWSp0fVr/fR x9nveWCagcjWW7B9WXshbuX2x+z7MG7RxOWfKZV5+P1A2t1sY0q0QdoHlBroL7vrl6Ak 7fxMOEVIPTkWQAnleZYZa/FvwWeMXoCfzXVs8ldAZWGbWlXkYL3dYZlkR9KLpUsH8ScI lHlQvNVXcdLN7BBHpQOhS9/vjZn4/2nkvLBhjnwoUtrSISeal59sFjOBOzkOJnyRwU+i RWol+lIXSoqQtQka6Bt36WYd36ihn9KPpfYXOmLgszXiU5HbS1YPSe6UIViHtHCrxS1g 6LVQ== X-Gm-Message-State: AOAM532wXWvFj63VGnWQcqbfSmUuOL7b1NTYKiq7xve2qWrYwUxeI5JS yfOZ08kh8D5pNU8TeFtmhHX3jA== X-Received: by 2002:a05:6602:8f:: with SMTP id h15mr5769771iob.29.1612563068102; Fri, 05 Feb 2021 14:11:08 -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 m15sm4647171ilh.6.2021.02.05.14.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:07 -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 1/7] net: ipa: move mutex calls into __gsi_channel_stop() Date: Fri, 5 Feb 2021 16:10:54 -0600 Message-Id: <20210205221100.1738-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the mutex calls out of gsi_channel_stop_retry() and into __gsi_channel_stop(), to make the latter more semantically similar to to __gsi_channel_start(). Signed-off-by: Alex Elder --- v2: - Return early in some cases, to avoid blocks of indented code - Update description, to better reflect the updated patch - Fix v1 bug in gsi_channel_stop(); disable things on *success* drivers/net/ipa/gsi.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 53640447bf123..f0432c965168c 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -910,11 +910,8 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id) static int gsi_channel_stop_retry(struct gsi_channel *channel) { u32 retries = GSI_CHANNEL_STOP_RETRIES; - struct gsi *gsi = channel->gsi; int ret; - mutex_lock(&gsi->mutex); - do { ret = gsi_channel_stop_command(channel); if (ret != -EAGAIN) @@ -922,24 +919,33 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel) usleep_range(3 * USEC_PER_MSEC, 5 * USEC_PER_MSEC); } while (retries--); - mutex_unlock(&gsi->mutex); - return ret; } static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) { + struct gsi *gsi = channel->gsi; int ret; /* Wait for any underway transactions to complete before stopping. */ gsi_channel_trans_quiesce(channel); - ret = stop ? gsi_channel_stop_retry(channel) : 0; - /* Finally, ensure NAPI polling has finished. */ - if (!ret) - napi_synchronize(&channel->napi); + if (!stop) + return 0; - return ret; + mutex_lock(&gsi->mutex); + + ret = gsi_channel_stop_retry(channel); + + mutex_unlock(&gsi->mutex); + + if (ret) + return ret; + + /* Ensure NAPI polling has finished. */ + napi_synchronize(&channel->napi); + + return 0; } /* Stop a started channel */ @@ -948,11 +954,11 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) struct gsi_channel *channel = &gsi->channel[channel_id]; int ret; - /* Only disable the completion interrupt if stop is successful */ ret = __gsi_channel_stop(channel, true); if (ret) return ret; + /* Disable the completion interrupt and NAPI if successful */ gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); napi_disable(&channel->napi); From patchwork Fri Feb 5 22:10:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377639 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2813369jah; Fri, 5 Feb 2021 18:40:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwK8Qs/XXUMWgx2qkmcVH4IvkejIuuYrv89KMux5piw0bx2NuMKVrFJSiODG50INesZjkBW X-Received: by 2002:a17:906:c1c1:: with SMTP id bw1mr7011921ejb.86.1612579226019; Fri, 05 Feb 2021 18:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612579226; cv=none; d=google.com; s=arc-20160816; b=ovOnk3R2hLzTwzyLNV0t8R1Zy1zJb0Q4jLlBc8aBunv7+Axp4DO7CtoNICz78knQGm 1CAEgQCenbGBdRDTHj4ELDeYoHYV72f8fdYpGCchYv2HCixa0uQFFYYvp38mS3Wb4FFB /uO+yFmArIaWipPDTknPrHr/p+SpyqME8ZawipYVqqM8xLEWRWlLmn99mBdajVIInOiN hT8hlsPMY6+WLqv9q5jhQZJ72xAZ2sNEw0s5FKE0vHKfcMvkn3Dah0rNsYl0gy0VSn7h WKLc2QeVVT1xegV7zIJBW86TVe8t/nBi9TP35Dc3nAo6E0+7NxHGczWlAXNsjEZnfH5N g/zw== 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=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=KZZzaNbSbUYWmhspYK7E00mcMBNYTyMXfY0Hc+o2KS1qGJdLVGXdc3CgebgNaIH0ba SIqAMOsFo5t3IngI7Nrqra39grPjO6ai+BP0VFo60RrdWGAF4qcH1rZlhDyIIqx4RuYN P5nDzu7CLXaB7Am9hKMD+gMzfPWeLE7Ijx5WqKt/tILaRQ69A46shMg5gH8wTxfo2g// CUXwyq+VHJ29ZVrtO9xkg0l6sTrlx7w0gIjzITZPNad366CMnwAwLiE7kojB4AXxwGDY 4O3JVnLzz9x0ccECklQH2ammgSrZ4blvtfX+rGS2JzChHILYPd4yz57tdfqjN2931VP4 Q4rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HPiOVeky; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si6346472ejy.529.2021.02.05.18.40.25; Fri, 05 Feb 2021 18:40:26 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HPiOVeky; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231440AbhBFCj1 (ORCPT + 7 others); Fri, 5 Feb 2021 21:39:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbhBFCgR (ORCPT ); Fri, 5 Feb 2021 21:36:17 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF291C061A2B for ; Fri, 5 Feb 2021 14:11:09 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id z18so7232256ile.9 for ; Fri, 05 Feb 2021 14:11:09 -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=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=HPiOVeky7a2Uf27cS5sPHL8+U0ndFwwub2ApiF9duyiJFjOaYTOYAEfwtIqRWLKw1K 43B0TJDKV4K6tNuG+VpwSBmicQOi1SjnL671emiWlarpWVgpHIdjWuFxsSHvoc2qw/GW fNd7Bgr05JZpnJMECyfDjpVecPFohd0ZTMzOgwAozoX/rKoOAYaYDmwHMYw2z/k4X9yi PK8173e+xuPO2hoKz8ZUdl0WKl+M0ff2SLbEflw2T3bI7htu0dSzMxWCzaQAhkfON8Ie HpcLG4AL4/9eemfMGqs5rbEAk23SCgkftpyupT2D3y8I9WP2jocHyfKk2eX4EOl+fLvZ 2EWg== 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=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=KSeunPhkhDptD/iDHnUUzoheMly+7qKAb2bYct1VLldTBjeI1IKrgO70dvQps5T8+7 ygCQJx8GdjXx2Eg36bclXpZyixSgnFxR/NrW11dduZKze06sdFpslOzkIPJ241EAvl7a G2aLdgW/F4JrL2NpNzN9Lrp0CTj7TQYmIaHuXsdqWhlWyeDcrBbtJ0q3MZFox63/trpw 5++l4tn4UkB/k27AWQgfEzkVglJ/hOo6dQNushCw+lRd9O1ulTwZufspQcKVWERy1C9i 4W5dBWe4Yr0hQ6L606EGv8oqv/P1zsHCRa6RHF+DkCBquMPnH+B1HMrSkB0wBuhry+HP Dl6g== X-Gm-Message-State: AOAM533NQaLB8LJ1JA3vj6Ptape9fKPxYe7fshJpT9hbfejk5nF8onN/ mBznA/O2yzE1FZWR5vJA8wIUrw== X-Received: by 2002:a05:6e02:20e8:: with SMTP id q8mr5572337ilv.205.1612563069287; Fri, 05 Feb 2021 14:11:09 -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 m15sm4647171ilh.6.2021.02.05.14.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:08 -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 2/7] net: ipa: synchronize NAPI only for suspend Date: Fri, 5 Feb 2021 16:10:55 -0600 Message-Id: <20210205221100.1738-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When stopping a channel, gsi_channel_stop() will ensure NAPI polling is complete when it calls napi_disable(). So there is no need to call napi_synchronize() in that case. Move the call to napi_synchronize() out of __gsi_channel_stop() and into gsi_channel_suspend(), so it's only used where needed. Signed-off-by: Alex Elder --- v2: - Return early to avoid blocks of indented code drivers/net/ipa/gsi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index f0432c965168c..60eb765c53647 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -939,13 +939,7 @@ static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) mutex_unlock(&gsi->mutex); - if (ret) - return ret; - - /* Ensure NAPI polling has finished. */ - napi_synchronize(&channel->napi); - - return 0; + return ret; } /* Stop a started channel */ @@ -987,8 +981,16 @@ void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool doorbell) int gsi_channel_suspend(struct gsi *gsi, u32 channel_id, bool stop) { struct gsi_channel *channel = &gsi->channel[channel_id]; + int ret; - return __gsi_channel_stop(channel, stop); + ret = __gsi_channel_stop(channel, stop); + if (ret) + return ret; + + /* Ensure NAPI polling has finished. */ + napi_synchronize(&channel->napi); + + return 0; } /* Resume a suspended channel (starting will be requested if STOPPED) */ From patchwork Fri Feb 5 22:10:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377635 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2809946jah; Fri, 5 Feb 2021 18:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlu95/PvCAxe+ux73mbNrlthmZbsY+RyuOsyGU9/O8sH8XDwu7NyUdLHwhySIwkIe+Hr8t X-Received: by 2002:a17:907:2bef:: with SMTP id gv47mr1559527ejc.457.1612578778516; Fri, 05 Feb 2021 18:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612578778; cv=none; d=google.com; s=arc-20160816; b=0K5DX09YCIJrYuIvf+tufrh3u48bJra2jJJ8gUyrN71jDKguqkZp9lqMNhDVNWMfSL f5sEOnpgn9bo4SR0B9gdWkxf4AqFcuNJpOrjYf8ob789WB407xDVTUof4KjwJe+zPuOp yYEmNt5EhEeRS0SWsU9NJXMTA3s68uT6LKaMvA5trOGpeylgoEbasageE1HuLsVOrGNT DIjMCi0NMpLDqMsajTM1TkyOZ5e3kH1qLbLNGhmdBldNTJkuABtZw7QfWulnfmmW3Avu pBegjT4ng0MMg6D+ng8Rzt2XnP/Wodb3CWC1MxhR3cymp7cJedPJnMGSyQ5tYNWnR7T6 EFAg== 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=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=D6K/fA00dtZdDuKrThx/t1XIua0pUQuvm+N44pfaKJUWKtkr5b7jiXNt2qvMVLSNXs 4W16RNByG4VMcWWaCl0JvJ5h220/KfLbbEEd4mvVyU0CCYaK4jPnCvZlTN8exvRt4De7 b9IXM7CAcpY8Bc3Is49/Ndf2FUPtYdFrz/f/BNN9JdYP2xZi9sawZ696TjXmEszXUUaI 0gURMH2oCqiUOhQbiaoy+PsgVJL52j4FCH610ACLKglnsqMR5l+b59C4N8X+5Ayy/eJp llNBJLmHshL9qv32EJI389tvZctN8019OiWhY3/XNSB1PbEcU01V0IpckZ0djecRJoQY Q18A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qYlnn/0g"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a73si6553558edf.23.2021.02.05.18.32.57; Fri, 05 Feb 2021 18:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qYlnn/0g"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S229636AbhBFCbP (ORCPT + 7 others); Fri, 5 Feb 2021 21:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhBFCa6 (ORCPT ); Fri, 5 Feb 2021 21:30:58 -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 E8BBBC061A2D for ; Fri, 5 Feb 2021 14:11:10 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id z18so7232294ile.9 for ; Fri, 05 Feb 2021 14:11:10 -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=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=qYlnn/0gDE4AziyGSnRNwSemRdlcmPQOUMcgwj00lGUzkE7soR0Dh0tlyjLMn7bOis 7TomvR/IkRo4l0NZVl8Vsj7v3UUPIEND5VQeocLx59p8hgiEyv2QvuDrffQ/J+EWRXci JdnCeyD716YZkXXIpkSfur5rhAn5cQSO8xFhUzTmkNpFm2+8bm8enaj+bnTtV4fSbD35 Zyxb+ohCKRbgs/tadu8A8zX1mGy7pZftHp5mwQq9Y/bHnnl1y8EMhwICETiANQT1VJWR pyu2R/LE7eh3oHpRL/DXx5FXsiuKCIvfogA4UpH7FHg18S4v6V5Lcbz2Q5KZf32HI6KL ub+A== 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=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=dt2qwW36UFwIuKlNuD23PCvjtsRt7pi7GDJpMp2IE4Ne7tfNya87/4bbj6Ko3KZnzY AdiSArx1JNrYLIvkk6XjrPYmIYJdq/Uo/+TA+QR5fCRaF7Pc6mN5H89EEhmFW89RU2O3 v5bz+tPKdke3Pof1zXF7TnPvRnb2PCjUUP8HgovN9/6+yunew0dZP1dbZ+GcYY7B3m6D TAQLZJaQIbUrr1KgRGE6M3k2odxpbMaQSEaXPebOt4KRt+aa83WP3sAg+TE2DoU766kv EeM8n5bWapEZAwxGMGdCXIFgIs+I9YppjWOBIu4LcxCsxE7K2BPgUT6MaX036hVi/tA4 xXfA== X-Gm-Message-State: AOAM530bh2XPLsNbR7EhQSoWCly1q4v06zgx8RGtYDMdkNiSM0VQHGcg YIFute2cqMQ37jLVuJ5LQE9xVQ== X-Received: by 2002:a05:6e02:1d85:: with SMTP id h5mr6027520ila.246.1612563070459; Fri, 05 Feb 2021 14:11:10 -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 m15sm4647171ilh.6.2021.02.05.14.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:09 -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 3/7] net: ipa: do not cache event ring state Date: Fri, 5 Feb 2021 16:10:56 -0600 Message-Id: <20210205221100.1738-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An event ring's state only needs to be known when it is allocated, reset, or deallocated. We check an event ring's state both before and after performing an event ring control command that changes its state. These are only issued at startup and shutdown, so there is very little value in caching the state. Stop recording a copy of the channel's last known state, and instead fetch the true state from hardware whenever it's needed. In such cases, *do* record the state in a local variable, in case an error message reports it (so the value reported is the value seen). Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 39 +++++++++++++++++++++------------------ drivers/net/ipa/gsi.h | 1 - 2 files changed, 21 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 60eb765c53647..511c94f66036c 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -408,30 +408,31 @@ static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, return; dev_err(dev, "GSI command %u for event ring %u timed out, state %u\n", - opcode, evt_ring_id, evt_ring->state); + opcode, evt_ring_id, gsi_evt_ring_state(gsi, evt_ring_id)); } /* Allocate an event ring in NOT_ALLOCATED state */ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; + enum gsi_evt_ring_state state; /* Get initial event ring state */ - evt_ring->state = gsi_evt_ring_state(gsi, evt_ring_id); - if (evt_ring->state != GSI_EVT_RING_STATE_NOT_ALLOCATED) { + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state != GSI_EVT_RING_STATE_NOT_ALLOCATED) { dev_err(gsi->dev, "event ring %u bad state %u before alloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return -EINVAL; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_ALLOCATE); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_ALLOCATED) return 0; dev_err(gsi->dev, "event ring %u bad state %u after alloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return -EIO; } @@ -439,45 +440,48 @@ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) /* Reset a GSI event ring in ALLOCATED or ERROR state. */ static void gsi_evt_ring_reset_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; - enum gsi_evt_ring_state state = evt_ring->state; + enum gsi_evt_ring_state state; + state = gsi_evt_ring_state(gsi, evt_ring_id); if (state != GSI_EVT_RING_STATE_ALLOCATED && state != GSI_EVT_RING_STATE_ERROR) { dev_err(gsi->dev, "event ring %u bad state %u before reset\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_RESET); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_ALLOCATED) return; dev_err(gsi->dev, "event ring %u bad state %u after reset\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); } /* Issue a hardware de-allocation request for an allocated event ring */ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; + enum gsi_evt_ring_state state; - if (evt_ring->state != GSI_EVT_RING_STATE_ALLOCATED) { + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state != GSI_EVT_RING_STATE_ALLOCATED) { dev_err(gsi->dev, "event ring %u state %u before dealloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_DE_ALLOC); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_NOT_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_NOT_ALLOCATED) return; dev_err(gsi->dev, "event ring %u bad state %u after dealloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); } /* Fetch the current state of a channel from hardware */ @@ -1107,7 +1111,6 @@ static void gsi_isr_evt_ctrl(struct gsi *gsi) event_mask ^= BIT(evt_ring_id); evt_ring = &gsi->evt_ring[evt_ring_id]; - evt_ring->state = gsi_evt_ring_state(gsi, evt_ring_id); complete(&evt_ring->completion); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 96c9aed397aad..d674db0ba4eb0 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -142,7 +142,6 @@ enum gsi_evt_ring_state { struct gsi_evt_ring { struct gsi_channel *channel; struct completion completion; /* signals event ring state changes */ - enum gsi_evt_ring_state state; struct gsi_ring ring; }; From patchwork Fri Feb 5 22:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377638 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2812575jah; Fri, 5 Feb 2021 18:38:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw27SvL7P585Pn2lVKiHK9yi0kkQrpoxNZ27R2KqdhYjnPfIDvCp3SWRvYgh2VEkKDM3mud X-Received: by 2002:aa7:dd4b:: with SMTP id o11mr6482841edw.303.1612579108794; Fri, 05 Feb 2021 18:38:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612579108; cv=none; d=google.com; s=arc-20160816; b=Z3Nr0vN44hWY71Q836fUm8BJ6hKgqaJiKcTQxHoQBL/YkOsgLpuQStqqVU3K8wvUVg RRlGn7bGUkWh76+41KKEnLCcDqdJw2qIOv5kd8Pn/8JRRp2TfUOvjV+MnMIauUUhhRCd yXxDtJeVsiwrn6TUs13iuV732xjKoFngb1iQXpLptvmQ7X3RO3LVXhsGTl1y0Tu5vE0C gOhIY6ZECsW2tC7RfUmxj9lp3VAimRyCDDQHFygXblBsbzAKShA6OP4PlJkob3bMhwZH ZnWmRgXALAEaUrblmjbVRS4kAMtzVzLLKTL2WYU3F0rrCFZBsNo+NfqJeTFoEO527gx0 Y8JQ== 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=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=qwLhhn3iv95LFX+XRRGxahqGg59BekN5gI5GWxkjoDuZ7F9ZiMH+x9yoBL+C2hH7kW 5aRE2e8CVc6iaU7oX2GDQDUb7yKLyAb7QV+8kpaK99tQlaMmHJSKA6hc07XTmTJobiJG J/IlleVS9l9KjayJRMSWRBWgbdTdknQZZvK4nDB3ycipSsEZ5lu1aAovDyqgiRPu02qv gxAD+h9uRkb/wmtVneVGIVpOnr4DN7sKu2Qqd59EdINyTI2PyFroD5frQOdR7Jxt7UGy FJkYObN82qsWsPXYytagMZlk0WVg1m82rSJ+r3xaXNH4DbaNZYPGB5i4bU0VccJdfSGC wDWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/EGLZiT"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx15si6246257ejc.300.2021.02.05.18.38.28; Fri, 05 Feb 2021 18:38:28 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/EGLZiT"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231336AbhBFChW (ORCPT + 7 others); Fri, 5 Feb 2021 21:37:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbhBFCdj (ORCPT ); Fri, 5 Feb 2021 21:33:39 -0500 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 09DEBC061A30 for ; Fri, 5 Feb 2021 14:11:12 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id q9so7272630ilo.1 for ; Fri, 05 Feb 2021 14:11:12 -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=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=a/EGLZiT4ynqoWW1KvNwfvuiT5usb63C9ZVCnNxL2lz0b+PYz6gj8PsP7D+x78hPop CqC+9iRL80c2q/RQ+8wotrshRmRtgGH8kBjIddcEWqBxm+KSEJB32GtubSsL/g2TGBI8 cuI2wfmoamucduV0RqSqaady5XE65BJ7PR0Cnq1chXpn+JLvbdA+tSXyqRIXxLqWtlwc WBO1RTlav3lIEWSH9HSY8w8wXCk0WpqT0b2hbd81GA1eTkiQCBLBRNu91Jf8Lgdkb9Fv SJp4xIqAx/4UeU7OitYrQlH2s/dOTYR/3s8td4LERYlIoK403sh4/UFHnm53GktyZ+1b 4zPA== 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=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=QNCVnmSb0uFJsk7HtjPd1h0ZLIQb14DDYgexd+eDzYK08zWkghhR6Sk5jFghTL0Fvt eb2aWk25R3AFv1cser6aLbA16brccutztLsLnsbCCJTkYk3ik+jMpXi7MXW3uhL4Cw62 22sX754Ec+f46kvBHocufhzVaLkzQcNjQIOnyy1tJ0acV791KurkBZHuFe3bzaydhJEs +u9f6oJH6WeTbPfh8o9vUdxwGcF/bpb+20r/Jxi/nOfZJmUqa6hnrbRjV/o52rlY7IFp GEH9DKrBVvwPyo01+a9ZQ1QqniCElMECG9KAPiBJw2t44J5P401WptlHj5FDH2ZiJcPB Or4g== X-Gm-Message-State: AOAM530a5e7gFO6x76z58FRBTZcChuPmnWQAy+47lbrpaiFhhey2pEp5 EsyyOYfYA6G02lj8wSoBtjAeBA== X-Received: by 2002:a05:6e02:188d:: with SMTP id o13mr5609957ilu.223.1612563071546; Fri, 05 Feb 2021 14:11:11 -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 m15sm4647171ilh.6.2021.02.05.14.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:10 -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 4/7] net: ipa: remove two unused register definitions Date: Fri, 5 Feb 2021 16:10:57 -0600 Message-Id: <20210205221100.1738-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We do not support inter-EE channel or event ring commands. Inter-EE interrupts are disabled (and never re-enabled) for all channels and event rings, so we have no need for the GSI registers that clear those interrupt conditions. So remove their definitions. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi_reg.h | 10 ---------- 1 file changed, 10 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi_reg.h b/drivers/net/ipa/gsi_reg.h index 0e138bbd82053..299456e70f286 100644 --- a/drivers/net/ipa/gsi_reg.h +++ b/drivers/net/ipa/gsi_reg.h @@ -59,16 +59,6 @@ #define GSI_INTER_EE_N_SRC_EV_CH_IRQ_OFFSET(ee) \ (0x0000c01c + 0x1000 * (ee)) -#define GSI_INTER_EE_SRC_CH_IRQ_CLR_OFFSET \ - GSI_INTER_EE_N_SRC_CH_IRQ_CLR_OFFSET(GSI_EE_AP) -#define GSI_INTER_EE_N_SRC_CH_IRQ_CLR_OFFSET(ee) \ - (0x0000c028 + 0x1000 * (ee)) - -#define GSI_INTER_EE_SRC_EV_CH_IRQ_CLR_OFFSET \ - GSI_INTER_EE_N_SRC_EV_CH_IRQ_CLR_OFFSET(GSI_EE_AP) -#define GSI_INTER_EE_N_SRC_EV_CH_IRQ_CLR_OFFSET(ee) \ - (0x0000c02c + 0x1000 * (ee)) - #define GSI_CH_C_CNTXT_0_OFFSET(ch) \ GSI_EE_N_CH_C_CNTXT_0_OFFSET((ch), GSI_EE_AP) #define GSI_EE_N_CH_C_CNTXT_0_OFFSET(ch, ee) \ From patchwork Fri Feb 5 22:10:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377636 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2810816jah; Fri, 5 Feb 2021 18:34:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyfbpK0W+FSRLw2QgkTNgz5bWtlz1QcS7TvnCKV5Qo6HJd5P/rA0MFKo2GLHl4W88LN77u X-Received: by 2002:a05:6402:4252:: with SMTP id g18mr6586129edb.231.1612578889733; Fri, 05 Feb 2021 18:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612578889; cv=none; d=google.com; s=arc-20160816; b=UA5TvZDJAh1ptue1MMcdDCwH0Ls2gqAY8bygrwELUprnA3hFuYAhMn85XzF5T9BPp8 hja6v+jlCIQzAzwCYFNhTNWSP0BD+ThbhqMNwCwde/SGwtT31OWRQ8OUNprXWiWv8hGX qJxBxqf/p57/QKp+UOkZK7QuqHYCDD2j0BwE/Hh601gdjwhO24QgrL4h37QWDvY07k06 IN4NL1kVLgxyo/i6/reXaKeGP7bf+qBXWb/+YGc7ia6RBUV9GMTkoo6dG6aLhP0uU9Dr j+9NCkOPeVxcxuqsPzZwM1xxh5gZ0XTyZcbTvhucfvDcCSyqCGl1Pe7e4cf4cG4TNqf8 co7g== 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=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=m1EzQEYenBtyMVzSKK+b9FT7n5SZCvw3sa7OMqODyFupo0vVOaazG8rgkhoXJhTdCF lSDzL/kdWkgnrnxX+rv3c0SFK0IZETdgqVXSZ6QoU35Dt3991zgDVJU5LrE/33GyTNAA 8DfGqcP382c2eJglM+aymRuCONxrerWgMwf5kqLw2nOcQgOT3BZon4Sd+9F9b4LKvoCY 5/QszJiqRQL9i8X1ykDwA0fgwYOdEZAMZSolRqOaVjhAbHkAI+cnEIS3rSOU9yz07VQA ZaXBEFkMUEdgisvedw77lHERQw8y0n/DVOXQdC9ECGCWsb7l6hya5VWkd+QlGjo03jAX l2Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hTPgVLNS; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si6701642eds.433.2021.02.05.18.34.49; Fri, 05 Feb 2021 18:34:49 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hTPgVLNS; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S230382AbhBFCdp (ORCPT + 7 others); Fri, 5 Feb 2021 21:33:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbhBFCcX (ORCPT ); Fri, 5 Feb 2021 21:32:23 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DFCC061A86 for ; Fri, 5 Feb 2021 14:11:13 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id y17so7199909ili.12 for ; Fri, 05 Feb 2021 14:11:13 -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=hTPgVLNSODjoqc0f730U8vWV6C1asXWCeoeebQj6gmhDd8uSqKl34FprhHSqFK7U8F /CjjYvFGEyvpnzroIhG4B/OMmGP2DAVJzu2moXWhrShwr3Z4WVzoj9mGBFpGFCOOI4AT XX1C9Q56mUd9ODIanu0zKNcFPEetMHD0zZtTsFh8k9DRP1LuCPqRrl0q1Zm7wbIQVjHS Rv78RTBj38saLCFEPQne/ksBqXlscyHglmBf1gbr3yVE4MH85zI57tOdJdEK0LJXVuHv qmhaLQsHaNh4aTmR7QCjVhc9SZOsuHRAcHym+FuTzy+dKCwuRo88j/VHXXe96E1KyyEr 7NNA== 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=PKD1Z1bgStX/7oaEji5KYXK+FWTp5iF5iHmiPv2caRvs7eDprNX7yp6/mATkvG6sYA d6tKd7Y2PL2gNRoNISmYnoO40Uv9XvE5PcGxfjJTQT4BxV/FKiD0tOYqvpFnrNcYei/R rVZSSGOO7jcL1zLXpNQqshdWxOW920DBVDE8/f5rucAF1b4mzvpI168pxkJNFwOcE05+ 5Dlb6SKDbwtNSfdHQe69OUCHavJ0VvrcHEbPZ7OxnRvQt7ypzRpvAx9uwZJXEKg/kJz2 SrDpLpHSzDoUVn5j0BhNx1hxlNfA/2DhFg6kKIMUX5GKVlle4v3g9DAN55eYW48ORrHH n/gw== X-Gm-Message-State: AOAM5334I81po2e34smovLZEWseNMyzbmm7LSPsWJ/UOL9/v6/57YT/3 JNmk6RK+YQLpZic96xgEAto5AQ== X-Received: by 2002:a92:8e42:: with SMTP id k2mr6121493ilh.250.1612563072586; Fri, 05 Feb 2021 14:11:12 -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 m15sm4647171ilh.6.2021.02.05.14.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:12 -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 16:10:58 -0600 Message-Id: <20210205221100.1738-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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(-) -- 2.20.1 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; From patchwork Fri Feb 5 22:10:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377637 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2811601jah; Fri, 5 Feb 2021 18:36:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsmitIJHCaPYR8cg9s5BFGTxdh25DOMXYx4phZScllzQzOOhG17KNzH8Bi6UpNY9bvsGl8 X-Received: by 2002:a17:906:24ca:: with SMTP id f10mr6658464ejb.96.1612578990647; Fri, 05 Feb 2021 18:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612578990; cv=none; d=google.com; s=arc-20160816; b=B7QiYChJOeKUJW1I66DEphpYg3Vt6N0/ChV+JZ5Zt8bRjFoAQCtuuguXm5K4Exf3Y+ xuWtvdZGySQXrBH/HqJy55FH9MMm+5yBcRrx6DURopMXzZJ+TyBFqyg2ab0i34HT3IAV yHFFWMJ/kqHE6O6CGp4iO4Kpm9RMmG6qQfyzMjZL+yymIL0mnzQU4EF+gyT8wurN7mds JBGCuOD75Ki1pfnkm4JJ80YVNmHgYO/kHaFGivChdKwWetJmvwpOrGj8Sql2ptA0Zm+c w01npklb0NByWb6SgSv5Vwgv4Pq/JIZVpQszY4B/WNz+C/9FfQeYNAhl0khxCdctp1mO 51Ng== 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=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=zGbsEzOtJ1q5BY2H+h2cnZ9sWfqVfASjGUtwzfF4UGo/XXuW248OR+5I2JxJLZVTpJ DlrVQDY0OMALAQyzuqSl3MMh5jFSwP1OInahzFknRdKHeGzghn7ERqyFF+GXaSKftBOi kBFDuqtovm5I8qu0he3+qTRuPzE5pa7DctHc5uTe4qlBTrWg2gOBd4Bx8zaXrEqSnLqW KQQreu74S6is9tNxMT4RznEyDDF/kD8F88h9JQwWWwm6yMhBrbi9AH34EK5mGeXkyYL2 xXycOaxsXEgxX9ris9C8aDfhwIKOBcj8fJkpb4G7+VoISt2IbSm4jiHfjrG1poJ4hoSR AzVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ozvSvOes; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hj12si6844632ejb.577.2021.02.05.18.36.30; Fri, 05 Feb 2021 18:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ozvSvOes; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S231168AbhBFCfN (ORCPT + 7 others); Fri, 5 Feb 2021 21:35:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhBFCcb (ORCPT ); Fri, 5 Feb 2021 21:32:31 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FEA9C061BC3 for ; Fri, 5 Feb 2021 14:11:14 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id e1so7282808ilu.0 for ; Fri, 05 Feb 2021 14:11:14 -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=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=ozvSvOes+inyPBHz80LRvVrFcsrJMzQcACU5LKGFx08VpOGwelVCRaOGmPRhfUgQCf N5rqnPRhUMvCvkCVIkkyaPXJ6xaVQ/AoMuGpi6zk8CwVLjaQ8KbMscdkjSWapEY8O8EQ vTLjdqs+t2mXJMIP4Npaiv16vWRmN36xVdMJ4i2sw+Z7elNhC6x42O+YvahqLGUDv4MG ZgH5Tvs3PWP03HWf/1e1H5C2npvac6I6W8e3OFf/HvHaDiP5UVgRq7nf46JLwL0C9bA2 DmaKbWBsP/apTInIRbWEwjExMmiDJ7MFjsv85P9AJ/Z2bNfoC3UqxoxSbfNrFgd34dD4 uExQ== 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=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=T8H0r0+LEtD7F3v9pWsw2dZ/fHLDJImnGrPAmPtX/MGX4eBUpoZ0ySXGVVQyhmcD9K V5b3c+y2NwPshyO/1khIuw1CD9cq7MieiGrc1FSuCwtz799jA35O3jm+xuBXUignAXT4 hCVSj/3p0GecRiq4nx7rHHZo7/hc8c687iksK1BAvjF/OUCPBIxyKIkjuXMiiRapY61x B924oT9uQ0qn5/tvr+OuUgrvPEnnD4CCSvT1QSCskCHp8jlMLmHvRVj0rzGke8QNRyCp flDqy9/VdXoJpHNIt/CZlha7lyhHUXN1yMRSkfeXVznm9F/vgYVsMGoCwjOPjj34dCAr E2+A== X-Gm-Message-State: AOAM530LuhbHusoTAuGrIZ2Z7/JWYvtRd19KBckzhuGepLM1hNdfXuSt qjCJ6fFCxm1r66nMZHxpLraAXg== X-Received: by 2002:a92:2e05:: with SMTP id v5mr6146744ile.241.1612563073683; Fri, 05 Feb 2021 14:11:13 -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 m15sm4647171ilh.6.2021.02.05.14.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:13 -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 6/7] net: ipa: get rid of status size constraint Date: Fri, 5 Feb 2021 16:10:59 -0600 Message-Id: <20210205221100.1738-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is a build-time check that the packet status structure is a multiple of 4 bytes in size. It's not clear where that constraint comes from, but the structure defines what hardware provides so its definition won't change. Get rid of the check; it adds no value. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 3 --- 1 file changed, 3 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index bff5d6ffd1186..7209ee3c31244 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -174,9 +174,6 @@ static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count, enum ipa_endpoint_name name; u32 limit; - /* Not sure where this constraint come from... */ - BUILD_BUG_ON(sizeof(struct ipa_status) % 4); - if (count > IPA_ENDPOINT_COUNT) { dev_err(dev, "too many endpoints specified (%u > %u)\n", count, IPA_ENDPOINT_COUNT); From patchwork Fri Feb 5 22:11:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 377641 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2818904jah; Fri, 5 Feb 2021 18:52:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZIggjv2DQaFAdjNR7jFBMJ6ENaRVrbgl4cSDZ5IGzrkiqI2BwQ1BeCpfzbGo2ld7k88Nt X-Received: by 2002:a17:906:ca04:: with SMTP id jt4mr7005645ejb.548.1612579944534; Fri, 05 Feb 2021 18:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612579944; cv=none; d=google.com; s=arc-20160816; b=nBMheaYuP4irwE1fD2yKjWmwiYEMkxzlvYlFiy+RN6qwdfM6XtQvZ6JcMVeMjZnKTl wRtYf6udUyHNWLwTFx4Q0rwMfCMu26CrywHef26JUh2dYz+1jshaSL2+BApH/WQNQEYA 54oj5lTMT6erqQajAg09bJnBWzhnjAiF5Y6n7+SsB7hXEV+e4uCbC4h04k0H6C6O5sr0 arLwpyE0yW/JbJBAuMmFHLr/1oUaiA74R99AgvTP3wpaKjAtLIc5M9u1B/VGbeZrEJnM omQAgUlUEgI0ClgRA+vM8gclg3+52mUXJAKtNJVFNROque279JxPCxH7dgdrNhL6qCf4 AgVA== 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=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=GtPieFxrSxvinT1zsxB+q5SwKGYpd+vXQDF+KFbtCZa5qaVm514dJiTVWfxhRbYRpT /e/3fwR7Yi+T0v3BgPBXV+ZyNnETf93ApY76BeMfgNK+4yWpu0fc1YwxIGW695S1Jx54 PIQ5oETF3CE0oBqc1XItJJSC86tiD5zdjhHO4+nV8NoYWh+jmKVYiup7HEwQprhO4NBV jkO+cD2qKbgdM3mQKhLPKoB614BX1SckIGJT3AhbmskZOcQmo1/XeNn+8xEVyJrUM1Qm ej1FEyyWji0HvtXi+YFWDLLz43l3IXSs2a8vQvrLdhMMTt9JKpM5Jmny1LvdVCCr4sSz SI/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dTeI9ZXk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si6382472edb.227.2021.02.05.18.52.24; Fri, 05 Feb 2021 18:52:24 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dTeI9ZXk; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S232145AbhBFCv2 (ORCPT + 7 others); Fri, 5 Feb 2021 21:51:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbhBFClG (ORCPT ); Fri, 5 Feb 2021 21:41:06 -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 48C5DC061D73 for ; Fri, 5 Feb 2021 14:11:15 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id y17so7199976ili.12 for ; Fri, 05 Feb 2021 14:11:15 -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=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=dTeI9ZXkMLEbDbqLDCD7wS977KZA+JfdY7T42waiRpAhSo2UF3a0My9aGY88c5II62 1b0jcGZ7xE/D3islRRXJeTMWaX8YY1aj/OX5I/sIjX1JRkzXqwtpOodMmXJuxsRFxXoz U/86TNwxQdyatpc7p8CtGglxhKg5UdGjfeAx9bUHmPyt6ijWBWUdys9aKMa5MELwq4So wG5pl+gWqc3mR+YdOebDL38YB4NaAHBpQpXrd4AXI66bnNUxrq9gneEy8/jybvupbXwB ZSG2+arMRCiWCwEin2IVFuyzh093iXsN0KJId6yfdp+4M5HB2y++kiYXIGt1aflTtvx+ YSgQ== 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=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=CRtcXMx0Cs+IgYBFgU9OxnXuQWuc0ZgkxriYF6KoVlWvUEiDE/Pu4QzN/d2sDaqKnn 2k7JmnlRYTc4iNbJYo0cb2nlE66GS/4n+M6DjR4hS2BbdaRYyOV9f6H5XeDu4K50rM+P kbQAgxDoCQIySsZlC4LZ60BX0MG1Y2v4taVusbiyBw651FpywcKQNbyCvUTOcDIELeYG mq8gVjTaX+nRu1+qrPl9ndK0nm8/92xUOy8VVneNZpuXRwKr60S/fPX/PPzf9252TUiT h6PsDtfnR9KVmMS4XrlUvWkFyJ5m7sDQwNCf6AEMCkSyiQlvTlxZ4SgYghNkiR4Rhpqo jLGQ== X-Gm-Message-State: AOAM5337p3iDXMEVLR9xKqUO122RgHx1JtdcGhhsC9P5bw+y3rcO58a4 yTWKKl9Gk+1DDxMZ7ZmINUC7Yw== X-Received: by 2002:a92:cbce:: with SMTP id s14mr6093470ilq.306.1612563074789; Fri, 05 Feb 2021 14:11:14 -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 m15sm4647171ilh.6.2021.02.05.14.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 14:11:14 -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 7/7] net: ipa: avoid field overflow Date: Fri, 5 Feb 2021 16:11:00 -0600 Message-Id: <20210205221100.1738-8-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205221100.1738-1-elder@linaro.org> References: <20210205221100.1738-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org It's possible that the length passed to ipa_header_size_encoded() is larger than what can be represented by the HDR_LEN field alone (starting with IPA v4.5). If we attempted that, u32_encode_bits() would trigger a build-time error. Avoid this problem by masking off high-order bits of the value encoded as the lower portion of the header length. The same sort of problem exists in ipa_metadata_offset_encoded(), so implement the same fix there. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_reg.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index e6b0827a244ec..732e691e9aa62 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -408,15 +408,18 @@ enum ipa_cs_offload_en { static inline u32 ipa_header_size_encoded(enum ipa_version version, u32 header_size) { + u32 size = header_size & field_mask(HDR_LEN_FMASK); u32 val; - val = u32_encode_bits(header_size, HDR_LEN_FMASK); - if (version < IPA_VERSION_4_5) + val = u32_encode_bits(size, HDR_LEN_FMASK); + if (version < IPA_VERSION_4_5) { + /* ipa_assert(header_size == size); */ return val; + } /* IPA v4.5 adds a few more most-significant bits */ - header_size >>= hweight32(HDR_LEN_FMASK); - val |= u32_encode_bits(header_size, HDR_LEN_MSB_FMASK); + size = header_size >> hweight32(HDR_LEN_FMASK); + val |= u32_encode_bits(size, HDR_LEN_MSB_FMASK); return val; } @@ -425,15 +428,18 @@ static inline u32 ipa_header_size_encoded(enum ipa_version version, static inline u32 ipa_metadata_offset_encoded(enum ipa_version version, u32 offset) { + u32 off = offset & field_mask(HDR_OFST_METADATA_FMASK); u32 val; - val = u32_encode_bits(offset, HDR_OFST_METADATA_FMASK); - if (version < IPA_VERSION_4_5) + val = u32_encode_bits(off, HDR_OFST_METADATA_FMASK); + if (version < IPA_VERSION_4_5) { + /* ipa_assert(offset == off); */ return val; + } /* IPA v4.5 adds a few more most-significant bits */ - offset >>= hweight32(HDR_OFST_METADATA_FMASK); - val |= u32_encode_bits(offset, HDR_OFST_METADATA_MSB_FMASK); + off = offset >> hweight32(HDR_OFST_METADATA_FMASK); + val |= u32_encode_bits(off, HDR_OFST_METADATA_MSB_FMASK); return val; }