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 */