From patchwork Wed Feb 3 15:28:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 375435 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp442791jah; Wed, 3 Feb 2021 07:34:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWQBUCGUAlRJeBquDVihgT5S9c05EsvaAEALGcWDautkWoksXFDhilQfYwZX6iJbBD7kd2 X-Received: by 2002:aa7:da8d:: with SMTP id q13mr2873764eds.263.1612366488727; Wed, 03 Feb 2021 07:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366488; cv=none; d=google.com; s=arc-20160816; b=b3a4aJwFdSBUH8n+m270Jl8G8lUbWM1ChGOtcGHMKcmJu8uR3Uwi4TWcgmJYKgNHV8 HVIU+6uVNR9p5mjXHO9m99SIaf7JIS8kxgz67Zc6I1EanvHe+UOIye7MVm6yVJmEQIks dxw8OgCe+8VoxImquv2oEYfxVs/mIVgIcIBoBx8D/ki6GGXcFPH6WeB99Qf4NUhn5OOy WAACw1q50h6EWpwMxsbat0d33ozW71K5xfk1bz2nYK5of9Fo1nTYdiM1WmS+IHfhe6iF du4G427g/C5hvW8/oaDXYSbI3bIer0WRWNg/FEmnMSLcKfyzDOhWKZklFsMXgJIYAe6W gjrA== 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=NnJicAfg3Ex9JmXfJakNzYykElqGIVAtmZeJOEX7nY8=; b=fw5A3jsPmIm9BP0sex8c0OsxDs4+eGPC/5/Q0hKrE/FzdmngrZE40JXNMjaJK1mWAL F+upOfjgpSsT+JbNyH7UN4CPnOjggUWNVfphBa8YueaF/cTCThSgMn4NTyt+DfdXv7iE M8dW2j/gr08urGgD07MoXKZJGaQgJ0ssfEyVsMW1s7ZgZCY2pr/CJ67b2sudJSaPnls+ HQE5VCZ5R4mIsx/ztnwnV/OoKZT2QXElE4HULOfmg73rJbADTNSpyebNMRjXfjC4Mu76 2m2iSIlz61+JYWeGVkbm0aKx6rUZ4xff7X4j9k1S3avnm/hNTFroiaS+AOlSISnPzSqw 76KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WeiQpgik; 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 p12si1491051ejx.70.2021.02.03.07.34.47; Wed, 03 Feb 2021 07:34:48 -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=WeiQpgik; 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 S234438AbhBCPd7 (ORCPT + 7 others); Wed, 3 Feb 2021 10:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233487AbhBCP3l (ORCPT ); Wed, 3 Feb 2021 10:29:41 -0500 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 AFC49C06178A for ; Wed, 3 Feb 2021 07:29:01 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id f6so5467096ioz.5 for ; Wed, 03 Feb 2021 07:29:01 -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=NnJicAfg3Ex9JmXfJakNzYykElqGIVAtmZeJOEX7nY8=; b=WeiQpgikcJrLCIIRrvoKT+fJ4jY6Z0RQYttsgwlaiWDhb9Nyi0QULctbbmad4xFQms iVWrDuSwV0HSSWcKHn9bfTEFAxLshr+xynfgxfupmdxLL5G5O6jK+cEufE94WUgzx9rg xyIiEXeJKPE8dgR15z4EeaCUwr/Ipo7tI3w3m2YKY63tMYEyNnOhQcqjAUIFnszB3aiB MT4bat6Z0dtRAwKlpIxY2EU6dOIFwrg3EWcLDcToJQ3AOo6zAQYp1pHyvF5xM5NLnyYi KOo4z5hk89tRTMoLFYcgH1CpQkSE+ryN+aQjlbgYruWhZLhl2E24IK26tLwLYxg1swyR Z1Eg== 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=NnJicAfg3Ex9JmXfJakNzYykElqGIVAtmZeJOEX7nY8=; b=BgxGNn8IZO1lW5GYNtynUpO++5k1+IDKwTgYNd+3Dz0os2/GIwZINKRz1LMOA8hHO4 UVdhFiZMuQLqeUsnwKHbyWWKCEDFIJQboOaXPk5EsU+CnGKkReVdkVJbp6jIrl8b7ewg EiAz1G7rPZdbH6vpK2Wf8ogYfSke08ipxMG4KGovOkVO9pjsReuRVKwUuLXpnYfLVYfT OE1Fn4F27dTFEWeBA2BrNUM9S5eWdGA1fkiIrcvzTQVKI2fwlvOB/NogkifZv8W+elEO BIZNV+LsL//i1cNLwtIxbIaupzYhQjFwQxwPdccsQq4VlKwEfayigmr8O7SiXJmo2fO4 2wXA== X-Gm-Message-State: AOAM533nqcYyo0a/350R3jKZ+nm9luKjKPVb6+p99Ws9irGLwH8tmvoi vJkyx1TTP2do6s8K8AlYb6rWOw== X-Received: by 2002:a05:6602:1243:: with SMTP id o3mr1622255iou.47.1612366141181; Wed, 03 Feb 2021 07:29:01 -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 a15sm1119774ilb.11.2021.02.03.07.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:00 -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 1/7] net: ipa: restructure a few functions Date: Wed, 3 Feb 2021 09:28:49 -0600 Message-Id: <20210203152855.11866-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make __gsi_channel_start() and __gsi_channel_stop() more structurally and semantically similar to each other: - Restructure __gsi_channel_start() to always return at the end of the function, similar to the way __gsi_channel_stop() does. - Move the mutex calls out of gsi_channel_stop_retry() and into __gsi_channel_stop(). Restructure gsi_channel_stop() to always return at the end of the function, like gsi_channel_start() does. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 53640447bf123..2671b76ebcfe3 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -873,17 +873,17 @@ static void gsi_channel_deprogram(struct gsi_channel *channel) static int __gsi_channel_start(struct gsi_channel *channel, bool start) { - struct gsi *gsi = channel->gsi; - int ret; + int ret = 0; - if (!start) - return 0; + if (start) { + struct gsi *gsi = channel->gsi; - mutex_lock(&gsi->mutex); + mutex_lock(&gsi->mutex); - ret = gsi_channel_start_command(channel); + ret = gsi_channel_start_command(channel); - mutex_unlock(&gsi->mutex); + mutex_unlock(&gsi->mutex); + } return ret; } @@ -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,19 +919,26 @@ 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) { - int ret; + int ret = 0; /* Wait for any underway transactions to complete before stopping. */ gsi_channel_trans_quiesce(channel); - ret = stop ? gsi_channel_stop_retry(channel) : 0; + if (stop) { + struct gsi *gsi = channel->gsi; + + mutex_lock(&gsi->mutex); + + ret = gsi_channel_stop_retry(channel); + + mutex_unlock(&gsi->mutex); + } + /* Finally, ensure NAPI polling has finished. */ if (!ret) napi_synchronize(&channel->napi); @@ -948,15 +952,14 @@ 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; + if (ret) { + /* Disable the completion interrupt and NAPI if successful */ + gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); + napi_disable(&channel->napi); + } - gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); - napi_disable(&channel->napi); - - return 0; + return ret; } /* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */ From patchwork Wed Feb 3 15:28:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 375430 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp440078jah; Wed, 3 Feb 2021 07:31:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyozij10xg1WJ9wDS4GBoDq+Mf8+3EQjSMR8UuFTgxwFdENgayquuR/5H730Mra7UdAXq6G X-Received: by 2002:adf:dd10:: with SMTP id a16mr4164789wrm.207.1612366297487; Wed, 03 Feb 2021 07:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366297; cv=none; d=google.com; s=arc-20160816; b=LG6DjgLZAknB3Pxph0tBk9frylVYqAzZJntWCdDJXKL/6r92UCWIyEqAQKVV65Ie8f IOIpvwJYNkxp24ez9Dqh55D5uuy6uhildly4dKP5dsp0rhmTrZrnchMP0HN+hKYHgM/o YLobA1zh6xLC/Dw8bAmAZ11ETbhEWviT7a+kVB0UZjM08i9Jnz9EChyPUisGfKHTl4KF /Ayv54Di3mBBmVYOG/Yg3Zks1OSr/9Pw3vvnLT8cOxADORIsCk8K7tVgrpYB5S9iqePQ jhF56g0lL9XuLoyDQbGwAjES6lu4I7lX5I/LzA70rFHNjHy6AqeIxv+eoSYC1r15jKYC Cq+w== 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=ctT+U1JJRhDXj7a+ZLi4WV5LisqIA2NCLe0Qt/Ic+HU=; b=YNYI0fKlK3qmYZ+LdOF0h7s9WUE2LcUEpDrnj6fdCXCsMNRFQq3MPXdn9cKXLdRZoN O9qwM8q7mJQuekAeJx7gCV/+6Rz3v3JHLz0qPqpN5dbi/6swOnikF8euVzxH2t5M5Yno LF8Se7w3CyNgksehbuX6iG9g27bREE/GGsrppS2EbcMd3g0oEmh0Mkciv1knLXLjBKVD Q6JdgyJykma0/Nz2fV2ITDPQJ965NE2PP6kbaqBRk0tbnGj6IFBIhIsm5jak6I8uOQaQ hbnFEN1WGXFCk0ApPXi75Ea6PHkL4R7uaeZ++LzpGPQ+6ALqTnXEHBDrvWsidZPf1+GL KyoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w4NU4U+T; 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 d11si1560837eje.586.2021.02.03.07.31.37; Wed, 03 Feb 2021 07:31:37 -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=w4NU4U+T; 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 S234288AbhBCPaO (ORCPT + 7 others); Wed, 3 Feb 2021 10:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233759AbhBCP3n (ORCPT ); Wed, 3 Feb 2021 10:29:43 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C374FC06178C for ; Wed, 3 Feb 2021 07:29:02 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id e7so22709907ile.7 for ; Wed, 03 Feb 2021 07:29:02 -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=ctT+U1JJRhDXj7a+ZLi4WV5LisqIA2NCLe0Qt/Ic+HU=; b=w4NU4U+T6kwNtRNLwO2PhEjVIJpUWoCZdrNhJkXG6jTKXAZA2QT0nwZxAk/1+31fWS NzOl4SYTARW47iFwlmdHWZ2e+Q4ffQjjoqcgGPTQuT3L/TrcdnpNX1RrNZ3dPrfi1lmw E+OpX2/5sR3oLCMVGWxshmrZGyQ81XzfbWdiTjey1HlJVGkP5eWGGBB9bGxmMtd0ti+Z w1GPtnPhrye+PAjKQwZdiUx3+XIZLwVqBsTaE4nosvkrycVdWgpq+VcDaAlFU44jC/uS ezxsxgmJ0MXd+GWkNCppGwInHOxhePem8JifJPKdijnu+A5DggAwuivh8OxMqBKw1GjN HNcw== 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=ctT+U1JJRhDXj7a+ZLi4WV5LisqIA2NCLe0Qt/Ic+HU=; b=BKrajuHEyVS/9kuQptxX0rjf8xPe2ds4D6uAz5/Iss8MzAA8LqCk0W0O4Zyxm73HAd Ci659PsokSHCMOj+zR6NYm8Ih5z7ESSEjMMd9Gg7P5wVNKMFvIce8k7fmfhIPCShf3Cd bkhJbmsNhX4Y9VkokFYGS5dZN5SF6OHxD3cBY19SwMPpfFGX4vGR+Alx+p94AL2s5TTE rRy3w/HDUIEi3mzGXQfvDDXAFVoDQzy8nHnlZv/a6OgCNBEjwT1fCdWgafz4CxZ7RWvb jPDnadvcbQGCgwhIc+HNG6pfA3Dgtm3VCDro4aKz3oGSX0/WgCfHOLSA2/CsY4SVRY65 d+Tw== X-Gm-Message-State: AOAM5331JEmAZk91HNt0FruecNdiVq33bT0rAy1o0AbNGFzssY+G+1aP TLiP+nRsbgcX+vfJFUqDoudcOw== X-Received: by 2002:a05:6e02:1407:: with SMTP id n7mr3030056ilo.242.1612366142266; Wed, 03 Feb 2021 07:29:02 -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 a15sm1119774ilb.11.2021.02.03.07.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:01 -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 2/7] net: ipa: synchronize NAPI only for suspend Date: Wed, 3 Feb 2021 09:28:50 -0600 Message-Id: <20210203152855.11866-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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 --- drivers/net/ipa/gsi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 2671b76ebcfe3..420d0f3bfae9a 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -939,10 +939,6 @@ static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) mutex_unlock(&gsi->mutex); } - /* Finally, ensure NAPI polling has finished. */ - if (!ret) - napi_synchronize(&channel->napi); - return ret; } @@ -984,8 +980,14 @@ 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); + /* Synchronize NAPI if successful, to ensure polling has finished. */ + ret = __gsi_channel_stop(channel, stop); + if (!ret) + napi_synchronize(&channel->napi); + + return ret; } /* Resume a suspended channel (starting will be requested if STOPPED) */ From patchwork Wed Feb 3 15:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 375429 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp440068jah; Wed, 3 Feb 2021 07:31:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ1xsHxaRPZj72JPssPGBis266iNjLZCKDpP0AyDvzgT45tArTXN3tHla0Tyxtq+WFh4mP X-Received: by 2002:a5d:6351:: with SMTP id b17mr4163359wrw.410.1612366297006; Wed, 03 Feb 2021 07:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366296; cv=none; d=google.com; s=arc-20160816; b=aZN/PdCsNtgOifoQkRlTEFOBbH0igauL4lzwUNna6p0MXvjW/nhBuZ6d21nTRVSh1o 8XecUup99KMOQZ8l2X4tZ53ufbbrhEMZFeMEoU363BV8IbgX/OmJ2GLSiuTYmd5MjFGp /V3rsoFMpwNH7+jIbjhx+b5qLd7Aw3Pkx7bh/xhLRF4A2AsVKrPwbyZKYQpuBz/gxHAP vjCLuI0H1E2XZ0g+q771uzmaAfEshsyS8srrVcUNHt28+PR+8RrFA+JJwbxRuwlMmzka 69+TifFbEKlCnyqc7IX3qKgKXKreHL0D0hVV0AN9C8MoVgtIY/70iJ/5bssE7s6ACcVj NaHA== 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=CDjXjfXQF95s6RsUrh4TUR9OI+8JXa+z9p3uoFQLMv0=; b=g6uAvAzveohIo2Yptz/BrpQdvktUEgiZApsWleGAgDiz0VVDDCPZEl8FNBfZe7LnNN AmPAnkWeU15f/6ijLT8c0g8o9tdtWfiKpoZUTM+X1yKHqf8giiWrXlCAvNRa5vdq0Dwk r8B/GqDaqNS3lPgKkGYxrgWJkYWsdy5o3ow9KGkPqBcuDTQqW2dW36OyWaNtD7sh/DIY gsnX3PkQOmFMzsqSXPEu3xlko5Oix0VmWsUCD2XDVlDt5DwWD5UVtvcIBPNO2/89AXeU a0qJD0LRAWvguBL7xKqslg9WTaXu4fxPNnMqMtSdjnmUuBZqWfpfV+xpMI0+9qIPuyjG pHlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qzNGvd2H; 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 d11si1560837eje.586.2021.02.03.07.31.36; Wed, 03 Feb 2021 07:31:36 -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=qzNGvd2H; 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 S234255AbhBCPaH (ORCPT + 7 others); Wed, 3 Feb 2021 10:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbhBCP3o (ORCPT ); Wed, 3 Feb 2021 10:29:44 -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 F2C1FC061793 for ; Wed, 3 Feb 2021 07:29:03 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id f6so5467245ioz.5 for ; Wed, 03 Feb 2021 07:29:03 -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=CDjXjfXQF95s6RsUrh4TUR9OI+8JXa+z9p3uoFQLMv0=; b=qzNGvd2HmSEdDOGUyQIb9sVwJzsL6ntkp8azJ+8XbITQISkCCFacv1Y4YaAloIxOh0 j5SGNy1FnNdE9qFNVmi9MNvSDMYUB46I72pUtmvaYcbDf2BonYv1OsYxkZW21jc54oCT JunszIMHQ5Yg+FVQBLAhgodEJT0Ik3UXneDEtRreG5FMPCyzEAyn6TELgsK5OF/3AdU9 eTI6w/oVZ3EIqvOsgsmH6cBH6LV7EwtAodLcquo8RzMExCkhUzgawDAa+SKgjXrGwmQB Pw22oJXYf/pH19TnZJrk6uxhNH86VN742h28xSbWhdHmLYwHDTHYA3Y+prwzw4Ohqz+h Yu6g== 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=CDjXjfXQF95s6RsUrh4TUR9OI+8JXa+z9p3uoFQLMv0=; b=GO0Lm6y/DPapBRFqW1pnlpy71rRLFKCUP5j5f8aFwWoju+RUJ6H5zCeIChBGoq4h46 F7p+h6e1vYlJGArasj6Ryb4i6JqpndqThjZfthD/AiMBActUJBi/FiUDZfqoaSNX16IB 0XXYNuibUurw0SefujvUSsEFdhUd9z69TqwLD8PDXBg2Q0NuqWyKwQvpA1o1J88b1Lov tz/RSCc1KWgOsDGjcYrBLcaG4ydB/6C1dpJ/gvnfGKAscBhNTCdNz5K27ChQZ+51lNZ+ eeeOvKAittLrAcx2w+69aXkpRKm/GLBvrZU4E0zbk2UjuWJWdSF+smRduPBu8Xmp7Abm Cgkw== X-Gm-Message-State: AOAM533C8hfIe6Q17s0gTJQe6UWJCY7ysPfhf7IC2np37GD92Yjo00/i VJMc4DKxDbecF5KI8yWHRIaupw== X-Received: by 2002:a02:b703:: with SMTP id g3mr3456175jam.15.1612366143286; Wed, 03 Feb 2021 07:29:03 -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 a15sm1119774ilb.11.2021.02.03.07.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:02 -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 3/7] net: ipa: do not cache event ring state Date: Wed, 3 Feb 2021 09:28:51 -0600 Message-Id: <20210203152855.11866-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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 420d0f3bfae9a..0f44e374c0a7e 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 */ @@ -1104,7 +1108,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 Wed Feb 3 15:28:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 375433 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp441552jah; Wed, 3 Feb 2021 07:33:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjZImz6NoLcUyYz3Z3N0abrqccfyx4GMV+m2G/rHOgHIzpX+/6w3zLw3KXpk2SGgSxQc12 X-Received: by 2002:a05:6402:c92:: with SMTP id cm18mr3619217edb.367.1612366387432; Wed, 03 Feb 2021 07:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366387; cv=none; d=google.com; s=arc-20160816; b=vv7rOCl5+hM48Vjws+/CKIijk5RyWZaEah78WGm+RxcsAJ14ILXfDyL8gCXxQ2BNds gPaOYjXmbhtHKXkUyNrc63jXaOGokYB1P3rN5YNzrxOwiujSXh5UuGFjRl0A9SO1/iPW SFAA2lLKotPQvnZbrOjGB18js9FVxBn565TlqIjLl2kUN5kaCNfFb8RJhGmLschoFBk2 40Vc6oUMh9yMyix5Xfh1EMsXctgq049CNt02VxYXaYbTvq5r3nvOIAC47VbyjXn8MMcr 1kHQ2RdG22JpICMTxRYsivbycotgTtDLxkYMuDcXxlbwctaTfR1aRrBL4WmKqVbbC/Qt qkXA== 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=zoJ5y5eTcucpoNMLZYUi2nrvnkJBkeBfKXvX/T3dU5lf71rbKvsE73KJi9CMr5XoDI fCnizlUED26wa/33EBYhq0/soNpunhtlt1MOFvmHPgp/RuxA+emCkbhyD35I97JI6JRX 9BM0p59E0mNb5bW7paj2rBCqp1wKUTcCthTvXyVCQAPGkduT7E4uAD0CSqSzPKr0bZoH BKiHnaBCoIVUhaalIMceLOzLKH6Sl5LoLK+rylv16RnfJ4bGWUKlJ4aD3jQYocT63qDf pG0ohLCBex+T2CG0j7rvoE4rtz27eReaPVVBbUkR7KtEsjb/yYTp4K3Ioa48DKL88hSf r7Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jMZs86uV; 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 d17si1594123edv.89.2021.02.03.07.33.06; Wed, 03 Feb 2021 07:33:07 -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=jMZs86uV; 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 S233520AbhBCPcl (ORCPT + 7 others); Wed, 3 Feb 2021 10:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233865AbhBCP3r (ORCPT ); Wed, 3 Feb 2021 10:29:47 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09ECEC0617A7 for ; Wed, 3 Feb 2021 07:29:05 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id n201so1305359iod.12 for ; Wed, 03 Feb 2021 07:29:05 -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=jMZs86uVyvZ/BUdRF50YnogWNWfr84cD8rDT5RKFqR/Z1eu/C7fSq1YMvVGkWgplOd wAcghBWHu84bvcOXKk+/sZmV0ItuVTH/bRH+UV+koNY4C2ksxWpTJFugcfmLnZlU6rr5 qgMbhF0495K9ItQEE3vGMDGHhEt7aGaEvt0hw6JCSrGGWD98b7MIRgI0qYsJavti2nat PRIk3SHfbMV89F6W9cwLbD2eYBhQ4c7hf04gWfxJRzUTGIhqBdZ2BF2U2q8K6zCZUJPo fq6qG1AiNXZ+tsYfuujwfk41jIcCrDt6XATZl9Y2l9U6wqSOjjIzghe47X53YwKh8olh 3xsQ== 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=OQJdnSYAY0CLiVVft/rLF1p9zj9GWw95ttdZBRixubzLb8RIj6nnoA/cgE49jZYsYV IepO9vM1zSQ3GvOnP4PCiW3lK5jJwGI8OAlLcuPIAEvkTtHRWRonLixYyScVsfWkrAhS +inqcrlMRRfOBUhtwXN+j4EoDhaSFcvPTKO5ckH6oE/lvHa3YHaVoYx6WXDvQ/ObfnXd QyWSXhZBORaxKTXH92lor9nPTTat+RE0O2XbcWaqjAi05Ff4P1AQb+FXahaoJvMqUAKk hA2fSjZzL5+wofV9fsqwD2gkmX8+CEEzLtxga8XcQZIr8C/7PyVJEYaq1/gdGOwV5MZu i8Og== X-Gm-Message-State: AOAM531jPCOV4yxxlHZrZsnBhNSbFpHEJx5v4b+yq9hMREkfNWvXFVDs vH7EWcD44ilx532JhNwG5byCtRxde9meSg== X-Received: by 2002:a02:c909:: with SMTP id t9mr3431290jao.125.1612366144556; Wed, 03 Feb 2021 07:29:04 -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 a15sm1119774ilb.11.2021.02.03.07.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:03 -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 4/7] net: ipa: remove two unused register definitions Date: Wed, 3 Feb 2021 09:28:52 -0600 Message-Id: <20210203152855.11866-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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 Wed Feb 3 15:28:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 375434 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp441591jah; Wed, 3 Feb 2021 07:33:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwD5rhczXw0ggm+Ca2wlfgl2mGR6liqJa8tICKbK7voVpAC3I7pygQJv32GOYTZ+ppESH++ X-Received: by 2002:a50:fe86:: with SMTP id d6mr3576934edt.80.1612366391694; Wed, 03 Feb 2021 07:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366391; cv=none; d=google.com; s=arc-20160816; b=J05m3nQdt9fN265BmHMtWqWZCBKbqtXKghHN49UfJMqIPTjWYCHQbiDl+QBr7LUOC1 jqj3JSYrhEvR6Ig7+LM4U6MxVfSXGuW21oaWh10TqaXZOIrG1UuOrrdMJApvYrEAjLg8 p5eEIIFb3pOM2O5Q1l58nRIYqBGwEyMZ1GI+xAYU5cY0aOWMHH/+tkSr5AvlsIxTwAqz /MzVCku4my7n3PsppLrf92sFnJqAyyA4agv4a3/T4NDDcEqPuY4bUfBWPBK7+zZceFvi EBGMsvJGRI+C9JO4QNpOD5f9xn9AyW7zMJh2t+ESY8XmS31jZRm5mpWXD5qApffx5upI mmEQ== 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=kx0qu0uz/7EySjT2JTJO1BxKPkwJuUu6UpV+dw7rfiw509j5P0IKf5rXUPKWjpwzf/ Z9w9GKfqlZha1wQzZ9OZaGH+4PdGMNMV3jNhQhYE+GzZuzDkYBKUeBbi165VTL2v5qKT rdalyZ2+Nmb52wJ9z0Luc7vAUguTGBxvl8iNLmdp6h36uEZ4KVGypOWMjhCTudedmhEU rHzVh8IWopiP76YMkEoBaEbGrjB2YYjZihJCJ5OuMdHPUyme9wK42telTbEVoeD+4l8S a9eF1vDd3wuUxEgpEOF7c6X3rS98GoBacHucJ5A5EY2VrzHav/UEk+K3AalEPeC2d7eR TnAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YovxfAMa; 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 d17si1594123edv.89.2021.02.03.07.33.09; Wed, 03 Feb 2021 07:33:11 -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=YovxfAMa; 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 S234467AbhBCPcz (ORCPT + 7 others); Wed, 3 Feb 2021 10:32:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbhBCP3r (ORCPT ); Wed, 3 Feb 2021 10:29:47 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28BBEC061573 for ; Wed, 3 Feb 2021 07:29:06 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id f6so5467380ioz.5 for ; Wed, 03 Feb 2021 07:29:06 -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=YovxfAMaF76XT4oZiDC/n4BsB6CfbxFMoq6w3nj3sc9K8BkiMOWb8UgvpQVmeZkvwA P+5FkylqmSrH8aOKZA/3AX4qI0KYjJ8AtL/KeaimrjMEdNNfSBJFsLwLgO2BfIfRWtV3 Q502dUpZyZejYHakd9ulrcP2aVwOTmH2NysY1/rgUI9N1fGIZpxOr7X8hQLmxJY7T7lR x6vovDwjdeTIdQgBJieQYcNUK2zzySJ3c83oEjkBqekehRwN3skmj/leMsHg/uMf8WT5 7WZcIZj8F5Zdvn0tS3ATXZxxin6G6OVwlkXJW/eXCc3l2w9kAQKZwVixb0p9TSn5igLq 3+jw== 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=UigmsQPTgj5giqKEGDm9AvYvHLCclEg1cnUwbbBEh8DrEPmVWxQ7OzbBQ3wxB8zMWJ 8mz9ppeKqr9k6AtyUqU+d5WRfQbkDEWFYGgLsE3GCt8m6v4Na9XKK1MIFfZ1/+bT+yoE zPPUGTqSCR3xy70E81C4PP0vRnfQt+wBBei1+BPag9sfdyrMyt7HsF0zZuHOOWbe1/s6 Yzku777cnSqlYKn9z1pPDM6v3/7s+8n7wLMBNTU0EydGfpAotdNFbfDgBZ9mTbP2ZF7d mHuP+ktl0/N6DbZEtHU9Dk/sM8Dg6d4N+W2HOr/B69liaFFLML7twxchpVQS9aU9BQds 9nng== X-Gm-Message-State: AOAM530f9oQ1TMP+7+qzNFHu5BPBMG2AyHToEcFbD64o5rsQeyHYdo0X h9t43uhTcT8eSwhDMtFaKch8pg== X-Received: by 2002:a05:6638:378c:: with SMTP id w12mr3458310jal.107.1612366145643; Wed, 03 Feb 2021 07:29:05 -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 a15sm1119774ilb.11.2021.02.03.07.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:05 -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 5/7] net: ipa: use a Boolean rather than count when replenishing Date: Wed, 3 Feb 2021 09:28:53 -0600 Message-Id: <20210203152855.11866-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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 Wed Feb 3 15:28: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: 375431 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp440112jah; Wed, 3 Feb 2021 07:31:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyq4gc8PjdWN+lUPrd3jNuqpms7RXBe7anNCMrK4aXZkMu7EiRSRh2piZKNxo557jKkYvoq X-Received: by 2002:a17:906:d18e:: with SMTP id c14mr3218338ejz.302.1612366299791; Wed, 03 Feb 2021 07:31:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366299; cv=none; d=google.com; s=arc-20160816; b=BF77SEhOIEwupvnJQnEDGrBG4GorJYKdu+MsfZ7fDKR1rUywor7bEbKM7om3voPeI5 kKZdd4SGL41641rH9ohGknS90ZcbJVwobMAUYeqIa8SFSL3klzMU3bQ3Tw5ZR7hXWp3d STnWp72GRygWCCvx8JDLWj3GQIlqWHQO6jL7cibkuMl+LsSPTMw3wyOl629gax84MCpy tky0peVlugjyh9JQEgiNfu3tJSpkAlokwIYpt0T9n383gvyo4VEVSSgtOqg6Vg7q3wxr eMBZAD11O91mgnJ3LQIQOMLweGL0W/geqOLua89NXvA231nSjIX3srSP+cRgG18wUiKW hHBA== 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=d1GG5xtqmthkmTugUP/7OjwEgLFEwksvtvu3fYj5whqfIZUdtFF1OhcNUme510zohq VZh6lWuyqq8wO3TcLzAUyVHTcjzA5kq1cq0cl3zAiJNj8Q3o5H1Yme4SukXfOv0x5319 M+sUcAmFCv1uJkeDcr27lxhtuJX5LKCvEyW+9u8N3GRWFSg/sVDjLkraISk7EyzpcWXm GZTapAb8Cz/2B9bsan8x/XPJhsYTWiQYAjsTFnp9jnV7wHp9oeGuNofes9MVCLjfY59h nKQeQqr//r1IAqJU/S9a9G0Y6nNh9yrWzigSxAeCpwQH9am29s0unqnbrz0PMDrEeSdZ A1mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ihyMBeZH; 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 d11si1560837eje.586.2021.02.03.07.31.39; Wed, 03 Feb 2021 07:31:39 -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=ihyMBeZH; 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 S233759AbhBCPa4 (ORCPT + 7 others); Wed, 3 Feb 2021 10:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234296AbhBCPa0 (ORCPT ); Wed, 3 Feb 2021 10:30:26 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B0DFC0617AA for ; Wed, 3 Feb 2021 07:29:07 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id e133so14797191iof.8 for ; Wed, 03 Feb 2021 07:29:07 -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=ihyMBeZHOYDRwhA97Y0VNZOgqPLUdd6gsZglBawAKVdApJXPCH/lhyadqr+oE127v9 K6/FiukWucBm8B9tC7LnshCTCphoaFBvC24l8GRkKXlMotsytnouOt+GqsxIY4L29Abl WAKPZhfTJvWI2RHAHxT9jUtDvX3Dkf7n2JfYWiDy/e5dFRzH1vHhct/AShg24zZoC+iW 8RxwxsWLIhjRqmmZGZLNq/dVGjA+A9YvrVNKEJ1gI2jDXBTTbMYfZ6b0paX1ru5OF0dD E7MQothzZl8yGZV+2Y4zOUjRg1csaOFrBx2urW4VyoaSpl5QqM36ZeKIaTk3FLdlY3uv /4UA== 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=FT2lOcbZMZzLq+TkCtIGCbAK6caJ2K4mqB1gvoVsSistpxctt3i056k5orhmzld/2U 7BJbQgyDYhY0iegHvubrM0Ky5Sd6LRqa7WhG8idWl9mlVNd3hkNxvyZsCGKXwQLXcA7J 1KgEwuWKhJK9TdXJ+DTaS6wJnrSrhpMcV41nQ0D+EpTYRVBE/KqUqV8aJGMRDM2iKEEv 9smxukUxK8V3mNWzYHHHPFMTfCTBNZFK8QTV2mwXBnFXqjlgGUQ7bUp0vie721NS9F2g cxyi19Kn/ate/ooAvLDSZXzQ4hUmgybF1Iuk+OqK0KwkzcWWE0TI7xSo0DMyy4CkhHLR GUyg== X-Gm-Message-State: AOAM531c1nz48nW2jpR8v+bziuHOSD/PwoG50X4wjqr0UgT0bpwzVxrL y9nYs0gv5YzCU9bD07nfTjRLgQ== X-Received: by 2002:a05:6638:271f:: with SMTP id m31mr3456968jav.23.1612366146675; Wed, 03 Feb 2021 07:29:06 -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 a15sm1119774ilb.11.2021.02.03.07.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29:06 -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 6/7] net: ipa: get rid of status size constraint Date: Wed, 3 Feb 2021 09:28:54 -0600 Message-Id: <20210203152855.11866-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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 Wed Feb 3 15:28: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: 375432 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp441462jah; Wed, 3 Feb 2021 07:33:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV9XqpBD9oSKcHP63WSC8r8T64awJybPdjvmwwAGhmI2ffuI+GneiMDYE10kpx6ewS5NNw X-Received: by 2002:aa7:db4e:: with SMTP id n14mr3496778edt.101.1612366383123; Wed, 03 Feb 2021 07:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612366383; cv=none; d=google.com; s=arc-20160816; b=Ca2TylPApXsMSBjtCPg6NxlKc6iCYYwoqrrHEaOlCngioDH4uZvrPIm+ohGuRSppZQ bF8HSG2rJBcn7ofC2+VTbr5Vi4Gz1/zdvG9yZ3cXy0yOzbNlQBqwzAVWqXS0DaumHi95 6W1Aqj0GbxLeRjLqDT04APqR6EjYxgO6wBhPJ1xXaar+xI6Noa3FCPJA+w5jIPpolqt0 7i18Dzi3DnybdZZknOMNKT+mHmgHvQMilGIPlPXmWRuq0fgoGC4v3HGgIQiPDx4A6Wfx pbWJvQ1l4Xm3Xl61IjF7qneNVIAq9dSwijFhROt6qEkSeKkdkwJ62LJb2FG5Tu2cG65s WDMg== 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=JAOaamGhlmu9KtZacrf098LM8Hk3FBzjntfWRXU6U1Fy2IRh3gBlYXzDRjq07yeKna w10+olX+5dWVQ3mxY1di0/MbRpv7gpMrP7IaJT7HNCgVv210sFCl2pTIDTHbnLL+Iu1N tuRlflkyDGP1UowP3Q8fFvu3tIfqyGcHWv3arkLsfPidAfXYSRbIgr2TtImGM8VWXlL3 Z9nH2b6gi7Ix610EE3F0YfN7oGCywvOlUTl+sg1LjEWTV2PtoYLJgIk7q6avWWLTAh/m L7gv+oKfXKsM9MyNEU6ENIz5zIbbptjgZl/aZz4mAJWlvFkGZsAY+OcZnt4HY8bF1h8h Vkkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmkF3rst; 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 d17si1594123edv.89.2021.02.03.07.33.02; Wed, 03 Feb 2021 07:33:03 -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=wmkF3rst; 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 S234419AbhBCPba (ORCPT + 7 others); Wed, 3 Feb 2021 10:31:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbhBCPa2 (ORCPT ); Wed, 3 Feb 2021 10:30:28 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D517C061351 for ; Wed, 3 Feb 2021 07:29:08 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id n14so11813752iog.3 for ; Wed, 03 Feb 2021 07:29: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=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=wmkF3rstvKe+WT+YiOwKc4htIr03ntvhnhwiLHIZIojEmxC482Wf2XJ0oNwcMbvK0n T6p4jJIS2hlyhgNbwmgCmsJOqLwMLzFEAdjQ4aXBHizY0k1VBz1hq5Xevkt0jrWiXvmB hoxa7XMa7pEklv7soXXOwTeoW4WJMIA7v8D1plwJAf+0+7Sk3LaYib71DcPs7TvAY7qR 7VEeNo1+mIse9LkAR2cK8FOpiztuXdZ4Th2UYP7rCxMkH+odnobGTE+V7Br/Xuc5r/+O oepy9WQ2US5Ak0gwbiV5SRvw4p+aNrxAMTiM8c060MuS0iNqJYUli/68iwEcfIdt5EfV fMpA== 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=kyTIT7nwejqz5jSn1+AidD1ojppbpj/pcBlSy8E4Vat1ueS1HIAoDwo5sWSqp/6rjL goLw8fweRNYNo9G/Er50EXano2Qakk852C+SAArws22k/3zfp7BqlW6RntvV/oXfiJyf g1tzZM5Xz0m0gv+UpQQqHZTZe+VCEmnfrNwmxTdimjFM9J1wSiDiIbpbwLBQDemurTrp /Rdu+gbAjzNbQG6VzU+8m7Up6N1OnnqC3VO6phAnIYJYf93i5K+9xM40JIOrbz8auU4k c6LxuIaNJLeXbtDW8AJvMm37CXiQEqqS2rTovu/QDcubSZdi8Tq+v6NtVkYT657QaOA8 8Z4Q== X-Gm-Message-State: AOAM532rnwTKLjRFbUc5lS2M2i1j5df2XfyQJrFunBQRTVSH3+Cbuk0Z mtdI5TOiQGCpH615zOzc7vMQxA== X-Received: by 2002:a02:3e96:: with SMTP id s144mr3434727jas.81.1612366147685; Wed, 03 Feb 2021 07:29:07 -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 a15sm1119774ilb.11.2021.02.03.07.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 07:29: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 7/7] net: ipa: avoid field overflow Date: Wed, 3 Feb 2021 09:28:55 -0600 Message-Id: <20210203152855.11866-8-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210203152855.11866-1-elder@linaro.org> References: <20210203152855.11866-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; }