From patchwork Tue Dec 22 18:00:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 346645 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5544367jai; Tue, 22 Dec 2020 10:02:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwp3B9bgJNAo4MEUjk5pEdZlUacgSdot7uOtrGOdmDUIUZsixzAe6KfIYqEOjAyrMUAarBa X-Received: by 2002:a17:907:1010:: with SMTP id ox16mr21030127ejb.439.1608660143849; Tue, 22 Dec 2020 10:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608660143; cv=none; d=google.com; s=arc-20160816; b=08JFGBX0EEc2rAt1hf2tmwAJGOJ/XV+khTtH93qdAmQKoFDMLkEpzXj4m4/HSeboKu qr0c7fEJzMRTU1DPc0KTVMleaC2GUIArd8slwaZK2seLicMVnTgQ/n0gFeiO69ucE3cO pwup6wjhyDcrXRcHWiZ45hAQjxFOGBIYXn7uvxs12mjkDnxT2T10ahTb0oTqFZplbwcp syFBY1UV0bP+a5OCnd6r4BO9KjW2NLvtLQiHqzWUj8BFfCwDwSPcjzIc8LpKARI4HWT3 P9lv8USoOONLax26E6ikg4RSvRuNi+hDwEdoArNCq9XUO6JR5319SgqSuX0MEVbHVeTs thhw== 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=X9vpT9HP+T68ID/sfzmEYx652yUR/SG2I6ViTerD2lk=; b=ISln2yPLL+pljlXfmkyj98it1RdOkkgpVKrFoQ6jbnnBAiXZwjlG8wFVj3w4+XZ3ej 58DYKv9VwuN1YHJHXVIJW3ZxWISZ+AGPyjf/J7O5w7DF1Mo1PGL0UsIcrILAbSGWs+gw nkHj5aP8E0ccA7uv3HSGylLoTfAgzDQew3syydPCFw9SeJik79FPv40NH0GVEDRtzIdA q8TBr9VxPsN7JsUThDPFM7sLm7+HlAk1LV+PPrcCmFTRwvhotLIKO1W8XY6nEGVhdBxm Ylnhw6iGNRRs3p2hPFVDLg4nmtzKc0ZgBZ7QILcB4e8NdiMHI+gyfsZ6QPmQCJ4hUOIg xFiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ChyVeNDi; 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 r24si12290848edq.449.2020.12.22.10.02.23; Tue, 22 Dec 2020 10:02:23 -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=ChyVeNDi; 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 S1728156AbgLVSA7 (ORCPT + 8 others); Tue, 22 Dec 2020 13:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728134AbgLVSA6 (ORCPT ); Tue, 22 Dec 2020 13:00:58 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E9EC061793 for ; Tue, 22 Dec 2020 10:00:18 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id 2so12739490ilg.9 for ; Tue, 22 Dec 2020 10:00:18 -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=X9vpT9HP+T68ID/sfzmEYx652yUR/SG2I6ViTerD2lk=; b=ChyVeNDiVBOQvYIrrBXZaHw5Cuajv/Io2nJlEgzp43ppcE0lvyMBltZdDWZrDHcuXt eWhveSXSTjOjso+jCpS58vuiJuzcMVXoiiQpfbV3dBIc42iXX9AabXkVO/5LRas6DX4h XkLhA5VhEFkglsiURfapN2VnlXD4lpO+IogNWutN4ryCT6tRa0KrlrEMelqXFE6H6NK8 vWkVUaG3FDIjY4EhPN1cyd7yqzJ+1BLW+Swzkr8lYnMriKKVv3ASTvqre9+D164xwpof MkO9FUlGg3yxXCNFnhqLvcfkSwgvG0RJfmqp5F+51W2x0NBJHMG8EDu0Z5ke0tkoQEgr 05Ow== 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=X9vpT9HP+T68ID/sfzmEYx652yUR/SG2I6ViTerD2lk=; b=HLR9HLhDHECoXpjPBtwOnxTB9iVgs5VFCR9Am3IH9Q6LDjTqevmtLUIEI9fw1s2wja 0MnmZLkvS4NeJsb3f6Jd8x+nNeu8Z06RkdNXweUDbFc/6f8LP80ys7Yhq4/9pTxFuofU I90ZM6LST9PwpVTc3nKhBgy7VxrJa+lgHO+XcIQL2maGcNapDi2sbVfJ/Ckc6W8BAhZF Wit+N2nndxpAPjjZvVA23WB6Gd/puUNonhvNgak8Hbw+vjCEla2rJfaW37X6goykY9Bt vSxSY4efygcGB2Q47EYUQmaGJzgnFmZ5dMHRkqAFS+8+FD6p9LdjiN6CT4HX1Nsb2mC1 9/ag== X-Gm-Message-State: AOAM533mIvibUmT2ASz8DAyDCjSvwEswCBqDpwyDQ0aH4R5xnjvtI3iB japjcRJS1iAd7DguiBLdaq4NYQ== X-Received: by 2002:a05:6e02:1a6b:: with SMTP id w11mr22572947ilv.112.1608660017131; Tue, 22 Dec 2020 10:00:17 -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 f29sm16328385ilg.3.2020.12.22.10.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 10:00:16 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/3] net: ipa: clear pending interrupts before enabling Date: Tue, 22 Dec 2020 12:00:10 -0600 Message-Id: <20201222180012.22489-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201222180012.22489-1-elder@linaro.org> References: <20201222180012.22489-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We enable the completion interrupt for channel or event ring commands only when we issue them. The interrupt is disabled after the interrupt has fired, or after we have timed out waiting for it. If we time out, the command could complete after the interrupt has been disabled, causing a state change in the channel or event ring. The interrupt associated with that state change would be delivered the next time the completion interrupt is enabled. To avoid previous command completions interfering with new commands, clear all pending completion interrupts before re-enabling them for a new command. Fixes: b4175f8731f78 ("net: ipa: only enable GSI event control IRQs when needed") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index c4795249719d4..4aee60d62ab09 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -340,7 +340,13 @@ static int evt_ring_command(struct gsi *gsi, u32 evt_ring_id, * is issued here. Only permit *this* event ring to trigger * an interrupt, and only enable the event control IRQ type * when we expect it to occur. + * + * There's a small chance that a previous command completed + * after the interrupt was disabled, so make sure we have no + * pending interrupts before we enable them. */ + iowrite32(~0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET); + val = BIT(evt_ring_id); iowrite32(val, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); gsi_irq_type_enable(gsi, GSI_EV_CTRL); @@ -453,7 +459,13 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) * issued here. So we only permit *this* channel to trigger * an interrupt and only enable the channel control IRQ type * when we expect it to occur. + * + * There's a small chance that a previous command completed + * after the interrupt was disabled, so make sure we have no + * pending interrupts before we enable them. */ + iowrite32(~0, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_CLR_OFFSET); + val = BIT(channel_id); iowrite32(val, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET); gsi_irq_type_enable(gsi, GSI_CH_CTRL); From patchwork Tue Dec 22 18:00:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 346646 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5544378jai; Tue, 22 Dec 2020 10:02:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwz4IFhPyTsG/+/LvPpZ4xR41QR0d0dJvgfeLYxXj3RxkrSSmJfuMbRm/SdD7pkzG4V0mGC X-Received: by 2002:a17:906:e94c:: with SMTP id jw12mr21401133ejb.56.1608660144566; Tue, 22 Dec 2020 10:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608660144; cv=none; d=google.com; s=arc-20160816; b=DUOYWRFo1dqGBmEs5LoXcS4cTMg36qed52CpjCvvHkcTUxzZiJ2zA6kWPP522ciJtP rSw/7H+SX/Oq75qk6zP3ZGMklRvE1v5sXG1yplu02A2DVtqnmEjfDSWksQmuotAeepcK Ci7RrJoA+5baSPCVIfOYzs8+//6fHTkV3/SIyvZmWipS08sgd/39sWJyZRPfIHnz6N6n RO/2Fjdv/yZXbGdTBO+3kA1qgLK2RKU30yWQIClFe25UMnej8OXydDitrR264M4WVRJP WQIonBVHKZtrARxpixw3/eopWEZtonAK2SiCo22QWsqVcDdQoZuKKT6o1Zh+we5UdJqP ytqw== 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=G2kmR2+L0O4KXPUATZH9veHazZttzCa4gZrsM0KnvR4=; b=aeYNxjhaTDpFzoNupyBHNVMm5kboUeW+jzgGbCdmnLbqNxhlDN61xvSyFrkIGKCUTg UPPJZLjBUOs72ZJA+tpbtsJzkS5yeg/iHXvTz/xGReLqvb3OhkqLGwh1H/i5B3NR51+Z grqndFAc0bNXtuVQdREVe5vv0HYFRgZF5b05Evkt7GfIviHtw7Q0J7ook50gqp0yGsn0 Y8Lbtq9QCPNTXNSDRMJfgqHai+SgmrSQPuyeJXbA5/QwCuBOOrjMAc2B8r3r6mU9l4kL AJKeTTnTQF2XukIwWdlHu2R/PjgC/2ygT88cz9pdZRhMf1T0SPIvSMmvJ5YHw3E0xo/d jv6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wxBOAFSN; 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 r24si12290848edq.449.2020.12.22.10.02.24; Tue, 22 Dec 2020 10:02: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=wxBOAFSN; 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 S1728200AbgLVSBi (ORCPT + 8 others); Tue, 22 Dec 2020 13:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728186AbgLVSBh (ORCPT ); Tue, 22 Dec 2020 13:01:37 -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 F20CAC061282 for ; Tue, 22 Dec 2020 10:00:18 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id z136so12766267iof.3 for ; Tue, 22 Dec 2020 10:00:18 -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=G2kmR2+L0O4KXPUATZH9veHazZttzCa4gZrsM0KnvR4=; b=wxBOAFSN0JQMJ2SzeI7Lx6EQE5eKxCxga6x3DlLraAiT3QY9i1/d2+s7bZIF2ruJbp 3TIaqA2jxrv06wKqQsWxhVI9ipuzFHtpQa9dd5E0KUUTlfgrtJhZit/KbRU6y+aM5YOh V0z0dzIOfz0zWhCn0HvTFxB7o8OAfoYa8tn8AZ+GYHPMQ/91E4uRplklZXM3jgh6yfSN gJjwLjro47H9I+KOZv9T48UEQT7iuO7sbGga3mia7SN4/Bbinr/O46i4rQS8hlfhKh7j ROIfaC9vf/y7miszMhbQoY7NSx9AjKUT5ov1Xb669q/CDZvWzI197cY1dLWa8pO3ZBab WDlg== 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=G2kmR2+L0O4KXPUATZH9veHazZttzCa4gZrsM0KnvR4=; b=M2dS6l6QRU2OXRgc1vRawmWS6kFHE5mMVrO+d3XrzI/ujTGnZ3VoV5gV4K2TruJV4B F715DPxlq7TJ/gv/yM9rckcSCfQqzbE/5FmsEcEcch52a5es9IccurTPInYvC8ewhgQ3 asYrABOBFVrDcaRnio8u8feW6vBYTpqcpix33NYvXD2jX/9fDIRN1LIFDBFri7gVzdEF AypkfTFOE5glA1Tu8gEybWb2TPUuiCtl6zwJEMexiAVJK7q1mtD7WL8xawpRyWsKfE/4 3k7po6Wmp8UbEijibhEommlafkSw2mmPzVfTiPsoISJp+a7+YpHqO3tDJhGY3R4xD/7n rdKA== X-Gm-Message-State: AOAM530o4HASlozD9dxqP+2ltRrrYBktxULyhRm/kvNOMjurLqQgKqAA PrfHq0NZ7nryyCfm1MwEnKWeEeOXXXEGpA== X-Received: by 2002:a5e:9512:: with SMTP id r18mr18884304ioj.86.1608660018249; Tue, 22 Dec 2020 10:00:18 -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 f29sm16328385ilg.3.2020.12.22.10.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 10:00:17 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 2/3] net: ipa: use state to determine channel command success Date: Tue, 22 Dec 2020 12:00:11 -0600 Message-Id: <20201222180012.22489-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201222180012.22489-1-elder@linaro.org> References: <20201222180012.22489-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The result of issuing a channel control command should be that the channel changes state. If enabled, a completion interrupt signals that the channel state has changed. This interrupt is enabled by gsi_channel_command() and disabled again after the command has completed (or we time out). There is a window of time--after the completion interrupt is disabled but before the channel state is read--during which the command could complete successfully without interrupting. This would cause the channel to transition to the desired new state. So whether a channel command ends via completion interrupt or timeout, we can consider the command successful if the channel has entered the desired state (and a failure if it has not, regardless of the cause). Fixes: d6c9e3f506ae8 ("net: ipa: only enable generic command completion IRQ when needed"); Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) -- 2.20.1 Reported-by: kernel test robot diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 4aee60d62ab09..4f0e791764237 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -505,15 +505,15 @@ static int gsi_channel_alloc_command(struct gsi *gsi, u32 channel_id) ret = gsi_channel_command(channel, GSI_CH_ALLOCATE); - /* Channel state will normally have been updated */ + /* If successful the channel state will have changed */ state = gsi_channel_state(channel); - if (!ret && state != GSI_CHANNEL_STATE_ALLOCATED) { - dev_err(dev, "channel %u bad state %u after alloc\n", - channel_id, state); - ret = -EIO; - } + if (state == GSI_CHANNEL_STATE_ALLOCATED) + return 0; - return ret; + dev_err(dev, "channel %u bad state %u after alloc\n", + channel_id, state); + + return -EIO; } /* Start an ALLOCATED channel */ @@ -533,15 +533,15 @@ static int gsi_channel_start_command(struct gsi_channel *channel) ret = gsi_channel_command(channel, GSI_CH_START); - /* Channel state will normally have been updated */ + /* If successful the channel state will have changed */ state = gsi_channel_state(channel); - if (!ret && state != GSI_CHANNEL_STATE_STARTED) { - dev_err(dev, "channel %u bad state %u after start\n", - gsi_channel_id(channel), state); - ret = -EIO; - } + if (state == GSI_CHANNEL_STATE_STARTED) + return 0; - return ret; + dev_err(dev, "channel %u bad state %u after start\n", + gsi_channel_id(channel), state); + + return -EIO; } /* Stop a GSI channel in STARTED state */ @@ -568,10 +568,10 @@ static int gsi_channel_stop_command(struct gsi_channel *channel) ret = gsi_channel_command(channel, GSI_CH_STOP); - /* Channel state will normally have been updated */ + /* If successful the channel state will have changed */ state = gsi_channel_state(channel); - if (ret || state == GSI_CHANNEL_STATE_STOPPED) - return ret; + if (state == GSI_CHANNEL_STATE_STOPPED) + return 0; /* We may have to try again if stop is in progress */ if (state == GSI_CHANNEL_STATE_STOP_IN_PROC) @@ -604,9 +604,9 @@ static void gsi_channel_reset_command(struct gsi_channel *channel) ret = gsi_channel_command(channel, GSI_CH_RESET); - /* Channel state will normally have been updated */ + /* If successful the channel state will have changed */ state = gsi_channel_state(channel); - if (!ret && state != GSI_CHANNEL_STATE_ALLOCATED) + if (state != GSI_CHANNEL_STATE_ALLOCATED) dev_err(dev, "channel %u bad state %u after reset\n", gsi_channel_id(channel), state); } @@ -628,9 +628,10 @@ static void gsi_channel_de_alloc_command(struct gsi *gsi, u32 channel_id) ret = gsi_channel_command(channel, GSI_CH_DE_ALLOC); - /* Channel state will normally have been updated */ + /* If successful the channel state will have changed */ state = gsi_channel_state(channel); - if (!ret && state != GSI_CHANNEL_STATE_NOT_ALLOCATED) + + if (state != GSI_CHANNEL_STATE_NOT_ALLOCATED) dev_err(dev, "channel %u bad state %u after dealloc\n", channel_id, state); } From patchwork Tue Dec 22 18:00:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 346647 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5544389jai; Tue, 22 Dec 2020 10:02:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyukpL8da38zsAeFBfwSE3Z/R09A0XujGkmH6xD5lqvppCArjhPT7pXnBgEYt9Yu3KyaisN X-Received: by 2002:aa7:d9c1:: with SMTP id v1mr21586575eds.115.1608660144919; Tue, 22 Dec 2020 10:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608660144; cv=none; d=google.com; s=arc-20160816; b=BnHnvqXbajbALq/zpD7KkyhuNaJGNiwzjBOMno/nfC9LFRAEX3FZytTTTrJtJdUFgL 2MMVaO75niKjKjBPE95EYL7/Stu445GSGffX3yiRINJvjrRktnH9QA5jWevDkle0whDO DnBu41JXwqsBU+M3hlpqJgpMgAEdWeC21Rp+Xb5og0sL8G6AWE16rFlv2IMTLjRHCcUQ nPy2q7ZqPjaZQ33v5iXk8+U+svTBZOS+jG4FrOCrCZHx2hn/76kVexxstRkjS3OQEmtd X5iInlN3J4AEg3yi4HUSEdCdbEPeJAw99Z+9+1vHAl+neCPIIwyPF5uOE25VjeT5gs+N FOiw== 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=KARs1QZcnC/nptat3ZvE0oGL0cJbgcKd2gJzkqzYJPg=; b=o6YoFPNTcnl7WA5sFh82NYKM8qj/1B5tftmBckZxNjx/hwVDm/kbMweNzc8GPtKhIW tRc4mdsh9j5n5J8SWzo8ELgpOn/174JKNhgOngt4231RAFGAcI+Id3TPkOdAT2iXUAjh CoAd1pcfHgmbFjwNhd42RBG/+b/2/IBuHZP3cyv1TyJCklAGrHbBvPZ0c41il83blL65 kf7kjUW9ZIqhsVsEyx7lKrDMoHTE/3dWYv5kTRyXLQQvAdai68lxR9Bhpx76PsvN3F1u H8GfYSfMsyhVyoJrl/+j6lptwRUaDkh/GBHjQfXIZtb40UFoxCnr+q7j60b9NQvp9RzQ yamw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HryWO/h3"; 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 r24si12290848edq.449.2020.12.22.10.02.24; Tue, 22 Dec 2020 10:02: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="HryWO/h3"; 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 S1727936AbgLVSBi (ORCPT + 8 others); Tue, 22 Dec 2020 13:01:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbgLVSBh (ORCPT ); Tue, 22 Dec 2020 13:01:37 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F4D4C061248 for ; Tue, 22 Dec 2020 10:00:20 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id w18so12786408iot.0 for ; Tue, 22 Dec 2020 10:00:20 -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=KARs1QZcnC/nptat3ZvE0oGL0cJbgcKd2gJzkqzYJPg=; b=HryWO/h3lBSjvEGFPksqzPRaaiEVaNcnYrATbUSIHTPogwutQWP4VKY18XesCk+0aW JrFVSOsUX3YSp++IP7Be7aQgvRj5sIc5jDmZnP6PZGWmoIbfO/UDHMYOpxcD9VYq5cyb AQmY7i88slMOfdypv9sy/8g691sRe5lfWUhJS95jrqOD+ix/Kk5slwQPZuidHUu73lyb AODGnQN2YDlozbr6lZz98ZNnHECY9ySysKSVtUfJuqrQNqKVwgbZWPY3boEDL3vgoz/h uzumNfy3VcLZ3A42qdlvbh9PorIs3tiUKAmyV0IYHmMtH99ah/7gWKxJeKgGHQ/JAg2z I7Ig== 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=KARs1QZcnC/nptat3ZvE0oGL0cJbgcKd2gJzkqzYJPg=; b=jkscj3ENPNsKzg1rp0S2miLnh6bvSPfrklYEGnHJYg85wQXGDk5wc93GlFMr+DZaey Ga+G8ie09i5aME1x8TBjIxOfBJBdqOt5TgRYy66Kr83yPLmKdZM27sbHaEFxGcP35c07 E0IJ6tpkT7OYapEZ05n4K6411GOi45a3Zacm67vKkIYW7krUijc7tuWuBbCjAPHn+0j+ iRVDr5PwVTK/bXijfa2GFRUQ5RV9ayEG81wgLwDbx90reybAtutcft56YL7RDgycv8Sj aJWNvv1bjOEHzkGzB8/dM/wMH0PRkxzNqvMdS69WxLXcz8r7DvccZEhd0F/pJ7kiFspW BgaA== X-Gm-Message-State: AOAM531WXg3hJWOfHIsn1q6cpukwngfhHlsE4xAAG4JtF5Aa2s2BnHuX CXtGZcqR1CjZS0HtJmelIpwqNg== X-Received: by 2002:a6b:8e92:: with SMTP id q140mr18931070iod.182.1608660019481; Tue, 22 Dec 2020 10:00:19 -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 f29sm16328385ilg.3.2020.12.22.10.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 10:00:18 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 3/3] net: ipa: use state to determine event ring command success Date: Tue, 22 Dec 2020 12:00:12 -0600 Message-Id: <20201222180012.22489-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201222180012.22489-1-elder@linaro.org> References: <20201222180012.22489-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch implements the same basic fix for event rings as the previous one does for channels. The result of issuing an event ring control command should be that the event ring changes state. If enabled, a completion interrupt signals that the event ring state has changed. This interrupt is enabled by gsi_evt_ring_command() and disabled again after the command has completed (or we time out). There is a window of time during which the command could complete successfully without interrupting. This would cause the event ring to transition to the desired new state. So whether a event ring command ends via completion interrupt or timeout, we can consider the command successful if the event ring has entered the desired state (and a failure if it has not, regardless of the cause). Fixes: b4175f8731f78 ("net: ipa: only enable GSI event control IRQs when needed") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 4f0e791764237..579cc3e516775 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -384,13 +384,15 @@ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) } ret = evt_ring_command(gsi, evt_ring_id, GSI_EVT_ALLOCATE); - if (!ret && evt_ring->state != GSI_EVT_RING_STATE_ALLOCATED) { - dev_err(gsi->dev, "event ring %u bad state %u after alloc\n", - evt_ring_id, evt_ring->state); - ret = -EIO; - } - return ret; + /* If successful the event ring state will have changed */ + if (evt_ring->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); + + return -EIO; } /* Reset a GSI event ring in ALLOCATED or ERROR state. */ @@ -408,9 +410,13 @@ static void gsi_evt_ring_reset_command(struct gsi *gsi, u32 evt_ring_id) } ret = evt_ring_command(gsi, evt_ring_id, GSI_EVT_RESET); - if (!ret && evt_ring->state != GSI_EVT_RING_STATE_ALLOCATED) - dev_err(gsi->dev, "event ring %u bad state %u after reset\n", - evt_ring_id, evt_ring->state); + + /* If successful the event ring state will have changed */ + if (evt_ring->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); } /* Issue a hardware de-allocation request for an allocated event ring */ @@ -426,9 +432,13 @@ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id) } ret = evt_ring_command(gsi, evt_ring_id, GSI_EVT_DE_ALLOC); - if (!ret && evt_ring->state != GSI_EVT_RING_STATE_NOT_ALLOCATED) - dev_err(gsi->dev, "event ring %u bad state %u after dealloc\n", - evt_ring_id, evt_ring->state); + + /* If successful the event ring state will have changed */ + if (evt_ring->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); } /* Fetch the current state of a channel from hardware */