From patchwork Wed Jan 13 17:15:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362178 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720637jap; Wed, 13 Jan 2021 09:17:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu1g0NKsBoG22VVwV1FmmqI4bINKKVO0jFSiV0jzzsPb9FT5qTUeKaJqAS6VVTwh6+Z3dX X-Received: by 2002:a17:906:eb12:: with SMTP id mb18mr1938617ejb.257.1610558255128; Wed, 13 Jan 2021 09:17:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558255; cv=none; d=google.com; s=arc-20160816; b=ZFatJ3mIRSG8TdlD5W2w9E2EJm6BlQ9E/sYO+zAWPVEHBCUiLcVol5MYbQd0NsBICh lbI1/ttf8aWBz3m5pq7VmUdWVDpZ6tcqh9Ao2R0iOmIxbFv6K6nJAMzfjFze3YfHuBBT rm2MOz+e8FNqqyS36cXvVJV4Pt7zvYQAXwCWDa/CxhP8vAR7OGMNEIScVz4NpkU1Bd8X KZCMuTSFDlKRpFNvv+aDuS8zyd16rW7EiSKNzpeQGGlUOwIpRJZLgNKmxfiRaDzQKYkz T2CpIVj/vART54kHG/3PrbIZgKhttH/I+CipJCNEtB6NWQbUbf5c2Jnjz0ieaQwYcgMl G8cQ== 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=aRwGdFI2JNmHcGPkamTAcTzIYOj5ZfZH0cIxNdbAZHY=; b=t44dvbu4Zxbt67KVRUQ2Uqrg5JUUOvLZ9lGLmBZL1Z4JVPHjXGRoxZrZtAKdDuDyBR ibZkE75rtyHvdfmIYxhNGzzR+pXELP5SL0YPwIJpqExWre5XTgKH1TJANh0uU4KlYPNT VEMh9ejfxsBFotmraf8B3IQOvR3LbUXoD/2A+ervCdh2H6e1t+FTkaQ8kSjiy1mJwgRS UVLo6ScNMsWa1QkFkCv3+7d6RM92AAUI4Ii5QB+waOgjTbq4xYkHtcYmfhtZHTUh6z4T J8u5E1G6ZPC+uksZ3x9MmXRMr3HFCHEmmh8YyXu/Hgozqo6RxKXXliB0bXcbejpoCGiN +Zpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uXJNMHGX; 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 c1si1354723edk.605.2021.01.13.09.17.34; Wed, 13 Jan 2021 09:17:35 -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=uXJNMHGX; 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 S1728098AbhAMRQx (ORCPT + 7 others); Wed, 13 Jan 2021 12:16:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbhAMRQx (ORCPT ); Wed, 13 Jan 2021 12:16:53 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E00FC0617A2 for ; Wed, 13 Jan 2021 09:15:38 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id d9so5627071iob.6 for ; Wed, 13 Jan 2021 09:15:38 -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=aRwGdFI2JNmHcGPkamTAcTzIYOj5ZfZH0cIxNdbAZHY=; b=uXJNMHGXscrnSoI79efLaUuFvE7/ABS22pvoY3+9K/k0B68J1lt39suBR/zXUoR2Fc FEgfrqHtIJQFokAqr+GmaXSU/AJ+ZEnexW94vAyF4AsofEZDQp0R0EHH6hqVIfRWnvfg 2ddrJa+jaOM9QHG0KrRKM6E8E3GZGlqCCAAgqi8cBNsgHDWyfdBJzNM3svvQ57Gb5dB9 xa1peFwhj3myH7zMiNAgEOi8lwaWvMmfD/7HFD2USuoA794qXM/FTavf/Fe3+7oNKXvj qYAuZT1yfRkCPR1/7y4/fgkP2BFOO2880XJgeja3bp2DuTppNOILc7w4BnCUMNwfzl4o P1Rw== 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=aRwGdFI2JNmHcGPkamTAcTzIYOj5ZfZH0cIxNdbAZHY=; b=aZeHL0B9F62s3K5YrkFqFhuLlT3tOEErBEhoYDulHRBgMEbwPrNsS1HFTgrbett+aF A2+oa93HpNItVcnGJYPpVlxya6xqJrAvxBihwwCw3facizgLEgNX24Aej5a8WZlo8dTq Qab8WekwHyhtuK9svomXRlfKWNMQ0HlCxLoOZqAOBRMcSI13yeAJRvof47Rz8MvVsx6j 91Q+qxfdXW+kDGqcswdZn6V3clNLRvkgveG/7OtyG0FP5U5BdJYyQD5pk3rY1mpm2kte UMsgc+SW0KRGkbQypMOv2fxhcKqO8llUQPembRhh0Soef9GuG/u8SDD9IbxBlkTNs8GN XGxw== X-Gm-Message-State: AOAM531y588r15rLgMPECqBslHnS5Hbzsjuvxwpt+395oUXrOdhpZaN/ ffXJOzJBhUE/q48ttRjdeEzLYA== X-Received: by 2002:a92:9ada:: with SMTP id c87mr3336323ill.5.1610558137845; Wed, 13 Jan 2021 09:15:37 -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 h9sm1120579ili.43.2021.01.13.09.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:37 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: a few simple renames Date: Wed, 13 Jan 2021 11:15:27 -0600 Message-Id: <20210113171532.19248-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The return value of gsi_command() is true if successful or false if we time out waiting for a completion interrupt. Rename the variables in the three callers of gsi_command() to be "timeout", to make it more obvious that's the only reason for failure. In addition, add a "gsi_" prefix to evt_ring_command() so its name is consistent with the convention used for GSI channel and generic commands. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 14d9a791924bf..b5913ce0bc943 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -326,13 +326,13 @@ gsi_evt_ring_state(struct gsi *gsi, u32 evt_ring_id) } /* Issue an event ring command and wait for it to complete */ -static void evt_ring_command(struct gsi *gsi, u32 evt_ring_id, - enum gsi_evt_cmd_opcode opcode) +static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, + enum gsi_evt_cmd_opcode opcode) { struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; struct completion *completion = &evt_ring->completion; struct device *dev = gsi->dev; - bool success; + bool timeout; u32 val; /* We only perform one event ring command at a time, and event @@ -354,13 +354,13 @@ static void evt_ring_command(struct gsi *gsi, u32 evt_ring_id, val = u32_encode_bits(evt_ring_id, EV_CHID_FMASK); val |= u32_encode_bits(opcode, EV_OPCODE_FMASK); - success = gsi_command(gsi, GSI_EV_CH_CMD_OFFSET, val, completion); + timeout = !gsi_command(gsi, GSI_EV_CH_CMD_OFFSET, val, completion); /* Disable the interrupt again */ gsi_irq_type_disable(gsi, GSI_EV_CTRL); iowrite32(0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); - if (success) + if (!timeout) return; dev_err(dev, "GSI command %u for event ring %u timed out, state %u\n", @@ -380,7 +380,7 @@ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) return -EINVAL; } - evt_ring_command(gsi, evt_ring_id, GSI_EVT_ALLOCATE); + 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) @@ -405,7 +405,7 @@ static void gsi_evt_ring_reset_command(struct gsi *gsi, u32 evt_ring_id) return; } - evt_ring_command(gsi, evt_ring_id, GSI_EVT_RESET); + 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) @@ -426,7 +426,7 @@ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id) return; } - evt_ring_command(gsi, evt_ring_id, GSI_EVT_DE_ALLOC); + 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) @@ -456,7 +456,7 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) u32 channel_id = gsi_channel_id(channel); struct gsi *gsi = channel->gsi; struct device *dev = gsi->dev; - bool success; + bool timeout; u32 val; /* We only perform one channel command at a time, and channel @@ -477,13 +477,13 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) val = u32_encode_bits(channel_id, CH_CHID_FMASK); val |= u32_encode_bits(opcode, CH_OPCODE_FMASK); - success = gsi_command(gsi, GSI_CH_CMD_OFFSET, val, completion); + timeout = !gsi_command(gsi, GSI_CH_CMD_OFFSET, val, completion); /* Disable the interrupt again */ gsi_irq_type_disable(gsi, GSI_CH_CTRL); iowrite32(0, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET); - if (success) + if (!timeout) return; dev_err(dev, "GSI command %u for channel %u timed out, state %u\n", @@ -1627,7 +1627,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, enum gsi_generic_cmd_opcode opcode) { struct completion *completion = &gsi->completion; - bool success; + bool timeout; u32 val; /* The error global interrupt type is always enabled (until we @@ -1650,12 +1650,12 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, val |= u32_encode_bits(channel_id, GENERIC_CHID_FMASK); val |= u32_encode_bits(GSI_EE_MODEM, GENERIC_EE_FMASK); - success = gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val, completion); + timeout = !gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val, completion); /* Disable the GP_INT1 IRQ type again */ iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); - if (success) + if (!timeout) return gsi->result; dev_err(gsi->dev, "GSI generic command %u to channel %u timed out\n", From patchwork Wed Jan 13 17:15:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362173 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720539jap; Wed, 13 Jan 2021 09:17:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWae+UDXAHk8x+i/srRYVbqBnroNlwnBLFSztdy/KmaU+MbLW53Tuv7OJuM4Bi4Ik5b48u X-Received: by 2002:aa7:cd44:: with SMTP id v4mr2637749edw.156.1610558248056; Wed, 13 Jan 2021 09:17:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558248; cv=none; d=google.com; s=arc-20160816; b=DwzcO4ULyirPNMby1llDsfmT5nIRS8zmzACfrpS0dQFAxEvqgniYySGUo0eay+XRhq RptVdwbfG3FDrHHcKD0E3W2GcQvRcPmOpVsWRnziulKZlNkPVYSg3r28r5x7/9ZccOey O5BeDLtIddZ6JhcBaM3VkWBOWkm1qpUh65PgMsrHw4PKGcSrAZtm34KuysHeTJekgVSF KqGeVlQdMMufOd4o0u/XgTTq58miqsMjS0TrqzDI0zUkkEG0LrZQmWzca9hOAi6YbIrB ZnIX6+Eb4FESYCLC38U2itSMZFwDGqKBKKYHPkK7bkyUBfnUTW4BZgO7zR1MAU/BK9M4 37/A== 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=GXvZPSGq6x3yeoMxoYd+JlpMOpfBxN00Vmli9SdjOe4=; b=mY10exvsfOjsdDS0lyQEsRQoTnrWgD7pbtuuAHbstl8rMJPrFuQXsiSUE053atOkJ3 6BxJa/zmqdUyPukzn/jJEKUkDKLm30tOexPTxr0N6UBJYDl/5pAqNQzMfiqHZ+FgPk2U KjxTxPANWgrHCurADPqtjIq2qE/HenXVHsJR78F1ZO36nFrvZXRJxxvHxAWoCzSM7oKQ gLMma0PXg29CrDeotZ9FSC3IdlrjYv90prpQKS+A+tGf2ipAH8d7X1zSZsy04uZLgDtA sFc7U6GrWpJeYzq939OJG4Y4wvWFDksUNs5XACgtbCV5LDcnlCgzhkUzc+rbEDw+cX6Z 63zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xXal6/FB"; 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 c1si1354723edk.605.2021.01.13.09.17.27; Wed, 13 Jan 2021 09:17: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="xXal6/FB"; 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 S1728111AbhAMRQy (ORCPT + 7 others); Wed, 13 Jan 2021 12:16:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727988AbhAMRQx (ORCPT ); Wed, 13 Jan 2021 12:16:53 -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 95B0BC0617A3 for ; Wed, 13 Jan 2021 09:15:39 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id z5so5569997iob.11 for ; Wed, 13 Jan 2021 09:15:39 -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=GXvZPSGq6x3yeoMxoYd+JlpMOpfBxN00Vmli9SdjOe4=; b=xXal6/FBYvLJt9S3Aum1Mf3YrBTGnLOJkLzQ1bFhtl6Jgg7XxrBNvHLTkSGE5IcYzT S7EstxEHuf6Tk+5ZD16TsO7bbyBuU7bpzUUUmXsXgq98YFPCEkw9RTCIUP1VNaI4fykw W7/wup2Kk4Ksdtq+Q5E140LGW2bdqsc8CJRJWMUCAWZkTHLXNYjitx+5rIWMzARgJXwV LoIOcquX6A0K+f6uid+H7G1Nn5xpQt+3jXa3JX4taT0eEeZ+PVXp/Dhv0zwkBx71890F MvvaxHoRY1r+tA0nm5B5krkv84Hhr5ErtUvsseHRxKHEfPl2lGQGJ0r/G1lehygSYZnd 2vhA== 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=GXvZPSGq6x3yeoMxoYd+JlpMOpfBxN00Vmli9SdjOe4=; b=XXO/2mGFHfkFr9HCNSG6mrjQ/Lz4D3EbXGiW7v/dMqtkq1P7x57aJfHM+iQnSgybqm 7j3CLKW24K/mk4CUBxwM92q/s8EG+D4WOEzqve0NADzxVwXSBx3rX4iiKpH9ZvHA56h2 n07h5RZyr6kyIxfNSqZORqOSaDhC1R+7EGs3Jhc/emi1805pj3xKHF9VTyebqvDhJta8 IVP+k1x9JY7zGHiHEzlU9qyV4/3AP9lkHVJQgzXpwBz8Yo2nMw+bPYvZaepd7Wxoyqrv FfkZsf2BBNnRgVCRbQjlA4CH5u3LalyAGZL2hBy5z3cAdrTNsYewq3/9QUqzHbZi10ed 4Frw== X-Gm-Message-State: AOAM533RFSY2bP9Gfk753cHjL24XNk9J2XJG8SWeHzuHBE1DJyC6r0HV C11oiL9XKyCVJvylXKFx8mJbIQ== X-Received: by 2002:a92:db52:: with SMTP id w18mr2517597ilq.56.1610558138911; Wed, 13 Jan 2021 09:15:38 -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 h9sm1120579ili.43.2021.01.13.09.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:38 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: introduce some interrupt helpers Date: Wed, 13 Jan 2021 11:15:28 -0600 Message-Id: <20210113171532.19248-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Create a new function gsi_irq_ev_ctrl_enable() that encapsulates enabling the event ring control GSI interrupt type, and enables a single event ring to signal that interrupt. When an event ring changes state as a result of an event ring command, it triggers this interrupt. Create an inverse function gsi_irq_ev_ctrl_disable() as well. Because only one event ring at a time is enabled for this interrupt, we can simply disable the interrupt for *all* channels. Create a pair of helpers that serve the same purpose for channel commands. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 94 ++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 36 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index b5913ce0bc943..e5681a39b5fc6 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -220,6 +220,58 @@ static void gsi_irq_teardown(struct gsi *gsi) /* Nothing to do */ } +/* Event ring commands are performed one at a time. Their completion + * is signaled by the event ring control GSI interrupt type, which is + * only enabled when we issue an event ring command. Only the event + * ring being operated on has this interrupt enabled. + */ +static void gsi_irq_ev_ctrl_enable(struct gsi *gsi, u32 evt_ring_id) +{ + u32 val = BIT(evt_ring_id); + + /* 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); + + iowrite32(val, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); + gsi_irq_type_enable(gsi, GSI_EV_CTRL); +} + +/* Disable event ring control interrupts */ +static void gsi_irq_ev_ctrl_disable(struct gsi *gsi) +{ + gsi_irq_type_disable(gsi, GSI_EV_CTRL); + iowrite32(0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); +} + +/* Channel commands are performed one at a time. Their completion is + * signaled by the channel control GSI interrupt type, which is only + * enabled when we issue a channel command. Only the channel being + * operated on has this interrupt enabled. + */ +static void gsi_irq_ch_ctrl_enable(struct gsi *gsi, u32 channel_id) +{ + u32 val = BIT(channel_id); + + /* 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); + + iowrite32(val, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET); + gsi_irq_type_enable(gsi, GSI_CH_CTRL); +} + +/* Disable channel control interrupts */ +static void gsi_irq_ch_ctrl_disable(struct gsi *gsi) +{ + gsi_irq_type_disable(gsi, GSI_CH_CTRL); + iowrite32(0, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET); +} + static void gsi_irq_ieob_enable(struct gsi *gsi, u32 evt_ring_id) { bool enable_ieob = !gsi->ieob_enabled_bitmap; @@ -335,30 +387,15 @@ static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, bool timeout; u32 val; - /* We only perform one event ring command at a time, and event - * control interrupts should only occur when such a command - * 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); + /* Enable the completion interrupt for the command */ + gsi_irq_ev_ctrl_enable(gsi, evt_ring_id); val = u32_encode_bits(evt_ring_id, EV_CHID_FMASK); val |= u32_encode_bits(opcode, EV_OPCODE_FMASK); timeout = !gsi_command(gsi, GSI_EV_CH_CMD_OFFSET, val, completion); - /* Disable the interrupt again */ - gsi_irq_type_disable(gsi, GSI_EV_CTRL); - iowrite32(0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET); + gsi_irq_ev_ctrl_disable(gsi); if (!timeout) return; @@ -459,29 +496,14 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) bool timeout; u32 val; - /* We only perform one channel command at a time, and channel - * control interrupts should only occur when such a command is - * 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); + /* Enable the completion interrupt for the command */ + gsi_irq_ch_ctrl_enable(gsi, channel_id); val = u32_encode_bits(channel_id, CH_CHID_FMASK); val |= u32_encode_bits(opcode, CH_OPCODE_FMASK); timeout = !gsi_command(gsi, GSI_CH_CMD_OFFSET, val, completion); - /* Disable the interrupt again */ - gsi_irq_type_disable(gsi, GSI_CH_CTRL); - iowrite32(0, gsi->virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET); + gsi_irq_ch_ctrl_disable(gsi); if (!timeout) return; From patchwork Wed Jan 13 17:15:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362174 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720544jap; Wed, 13 Jan 2021 09:17:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4QipOi9l/4z+7sSeoSqhWTLv4lDGXbnBmDYF6bcF5W7qeVMYffV9LbmxWXTbhDncZCb/h X-Received: by 2002:aa7:d5d2:: with SMTP id d18mr2718516eds.126.1610558248438; Wed, 13 Jan 2021 09:17:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558248; cv=none; d=google.com; s=arc-20160816; b=qQNY2uHXTriEEYgp+eCXM4I+jquYuRy/dAqQ4ZA9y0b/GXWmjEn63Q401oyBklKBDX a87UOKNrjYluwcmD9X8w1ocOeLD2GETngj3oyddTQNcHdiFYlGj9RXOn/SOY2LBSQzI1 zCdtpNTU34ZtCkUdP3Bfo4yDkSsqGPt7FH1hVGf2zsyoAY7vaCz53TP9SeerCVAX/5Dl 7UNywSH03WAUZ1cmXS2b9V8zlsZUVJeQC5/EqcXpaydkhpSp2F4AwCvMKbE/J/YFCn+q hT5KBMX0DhDz2RrVuQVYbRPslNVSEFexDUd39kct1n62n1iJYfLd2g9KhWzvY83Z1wyb qnlQ== 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=l1IOSEu+vyCQsNm2sF39ZzPXY+5QREQKKoylCV6H1Jg=; b=O85t84JDnh4+pcOvjSRfXkTiDkTVtqWkjUCbvYTAXX2OqsCiruexdvv2hYq7Z4zeoj kxRitiXkbadGFqKOEyyl/p0oviLJ8T8jaGYbr79QzDl/MiUZDlFu3Zx4ZyCz7SijMMPI d/AZYzzmXpm6EVLfKLdKEzwzCfr8Tkl+P5Z/NmEM2YZp9AGfPGKoYx8Uohnid9RcnNkk LR6xas5/L/jsQlpOROui8aL1eDjBGJoBjBGFvHTj5gIuKeb6tghkNn2LQm4pP5tPOgfd 6GqqeW2W8GPsp/2lIzVdRRVCLVc35nrHbMnf17561uX3SkkoypAOH2053qhUvhhsmT+v Kz9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r1J29VmG; 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 c1si1354723edk.605.2021.01.13.09.17.28; Wed, 13 Jan 2021 09:17: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=r1J29VmG; 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 S1728124AbhAMRQy (ORCPT + 7 others); Wed, 13 Jan 2021 12:16:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728082AbhAMRQx (ORCPT ); Wed, 13 Jan 2021 12:16:53 -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 A8316C0617A5 for ; Wed, 13 Jan 2021 09:15:40 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id u17so5692481iow.1 for ; Wed, 13 Jan 2021 09:15:40 -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=l1IOSEu+vyCQsNm2sF39ZzPXY+5QREQKKoylCV6H1Jg=; b=r1J29VmGqzEuZBHBu8w8M6gaA/yEBauw84YklgDIGC8Me5dWwVlqJEmQ9g6mUeH0f7 neiyLIkHJ+WYeG54zWirQgT48uRaz2Nk0O4otQnLjCUVFMl+XqOzCM0f5rMemd/LDAvB 1aa0v+tDSVv/WAbxNf/JumsXXXmcf0uEzBvbQ5gVxK3A+nkdu0gV7DgjfvH6QhLoxY3X kvjf4geDG88wbhVr4Opf/6pCQWkjrsukt9Fk+RFNdycpjk9u7mr1WshMH5L8nBUAO1Fy 7K/GUWOUKAnuhN/l8GkVXYPdjQ63V8f3Ge23VRzJJa1n43a+ehLUZy8uc8yn4+VA3boT 3mgA== 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=l1IOSEu+vyCQsNm2sF39ZzPXY+5QREQKKoylCV6H1Jg=; b=eeQcHrhH469n/LRBp5Jc+aocTz23AETg3kJVDgs1DzSdH4bQJaIpdG0WE56uy7Bo+4 gBYxRI5wkvPjMw59j99XlOrvVTd2IYdoMks8JPBC40ePfNm+KakqxxBNMZ5+CtyZBb2p viLlM20PIquFRQ3x9aqSRQDfn1scAFCSXMeI3Q8y0aaCEnPtKb3V/30r+Dpv0xy9LeFA WjHSk+EXItMtMofqqQZugKud9iLGwMgRl0c+lu9a++nKDVF1hGnRjy8Wssf/cXyY1K4B c9GkfnUzfiMBVok5IffBdDtX8Dx7zwwpMs9hvt/7IeEUmpHO89I9IjBjtUPddVe/LZ7I gpGg== X-Gm-Message-State: AOAM530Z3Vw7NVzNxLr8zJHCkKGBmlehpbJmqVj86SYkLcM6OEDI9YRn VSbOzs/1I1WbMLg42F4Rzcyu4Q== X-Received: by 2002:a92:4906:: with SMTP id w6mr3225429ila.234.1610558140086; Wed, 13 Jan 2021 09:15:40 -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 h9sm1120579ili.43.2021.01.13.09.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:39 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: use usleep_range() Date: Wed, 13 Jan 2021 11:15:29 -0600 Message-Id: <20210113171532.19248-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The use of msleep() for small periods (less than 20 milliseconds) is not recommended because the actual delay can be much different than expected. We use msleep(1) in several places in the IPA driver to insert short delays. Replace them with usleep_range calls, which should reliably delay a period in the range requested. Fixes: 650d1603825d8 ("soc: qcom: ipa: the generic software interface") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 5 +++-- drivers/net/ipa/ipa_endpoint.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index e5681a39b5fc6..93b143ba92be5 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -611,7 +611,8 @@ static void gsi_channel_reset_command(struct gsi_channel *channel) struct device *dev = channel->gsi->dev; enum gsi_channel_state state; - msleep(1); /* A short delay is required before a RESET command */ + /* A short delay is required before a RESET command */ + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_STOPPED && @@ -900,7 +901,7 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) ret = gsi_channel_stop_command(channel); if (ret != -EAGAIN) break; - msleep(1); + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); } while (retries--); mutex_unlock(&gsi->mutex); diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 9f4be9812a1f3..688a3dd40510a 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1378,7 +1378,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) do { if (!ipa_endpoint_aggr_active(endpoint)) break; - msleep(1); + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); } while (retries--); /* Check one last time */ @@ -1399,7 +1399,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) */ gsi_channel_reset(gsi, endpoint->channel_id, true); - msleep(1); + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); goto out_suspend_again; From patchwork Wed Jan 13 17:15:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362177 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720631jap; Wed, 13 Jan 2021 09:17:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF1FduAEL2xL4RJfl1AUr/WE4Q08y2FZGJvnIRtsGIVXlv7a8s5onrjWAKLsjIZlIcexDB X-Received: by 2002:a50:ed04:: with SMTP id j4mr2701587eds.84.1610558254760; Wed, 13 Jan 2021 09:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558254; cv=none; d=google.com; s=arc-20160816; b=08OaCSayzIzdC0Oypo4clI5srpH6Nz/lD5RJPaEdvUUuA8zNNhqAgoAd5GPH7H0udj TlBBMJkvfPjZ3VmKUVCxg9/QopAl9ZjH83+KVM8oRpIfBIgRVGHWDM1U40NlZUZAyipB VKFJo4opyfQXIhYhlNmW9p5Ga0CFn+kh4AtCTe3T2A4MH2buqPhUlwWF2jMIbjBSYHW4 1zbCSdKDf20Y0XhKlYoixOlP7B+Oc2eAbu0OORoGak+WRsmOjOCKLF7Yzvxx8e+ATb8d HtHvcXUgTY/ZTaui/nDsau1FMCtbTeh2S3Mdels7YJg5htIVsZwsO4uHRj6boQ9CG9Pq w6aw== 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=9HP5QJchHpYyjOaAf3lP3KAwAYZ3mwgofh4y4UljDvM=; b=CW7Pq0jznsZhY3PZWtqUK8DkL7l9cABJf2V3x9yIdd0FiARcStOcme/7mQ7ZiRdhpj LAjLc//jx96MswRN1iRQ+Ooc3Bsh0gaXIkFUTLYlQYfQqQQTiti+Okgyo7zL6hSC8RnL 6VsWQAt0gLOAV3njbYbHzx1ZySlIvULpT8KsvaiyEVy79TJRjewbWJwncfKqnbgNdWJJ FQ1ygKIJFNfeJb3Fxu1A42AttUQxTXDgbMVMtHKgyo6j0Omf9RIaiquFRaFGQicc/uwf F12fhG8W2s1JbJsXIZDYe+cu0SUpQ8RzIcvBaJem4WsQWDhuvLlATwXuu9ZMOSAdCTUS MGng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AHdCpwhK; 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 c1si1354723edk.605.2021.01.13.09.17.34; Wed, 13 Jan 2021 09:17:34 -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=AHdCpwhK; 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 S1728213AbhAMRRU (ORCPT + 7 others); Wed, 13 Jan 2021 12:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728126AbhAMRQ6 (ORCPT ); Wed, 13 Jan 2021 12:16:58 -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 D584DC0617A9 for ; Wed, 13 Jan 2021 09:15:41 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id y19so5671323iov.2 for ; Wed, 13 Jan 2021 09:15:41 -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=9HP5QJchHpYyjOaAf3lP3KAwAYZ3mwgofh4y4UljDvM=; b=AHdCpwhK97XEhzE6KaoVys78e8zun3noFVwcwXWVGjOD6NjAnDi1pM1OP7CEQLvKf4 DR670E9/PS3jDvNT5NBz001lF91xZC/U0jI9R2mmddz5rUrA7zhWc5K4awqOqlqAuzGB Att4bp/gXCF6wa9oub1iQPUSi6Hou3FZqfoq0B5Ah5/oXs+3WILsE/jWfxngz1DKDien n54dI6ix40kCPgeNCzOALbwWFzOWy2smb32xUk2cYDrPfOcg3NgUNGPfyYnmKH0XOvG2 KB73bDsM4Hi1zGxPxixGNR+MWMKBoDZ4LWlw8Fy5KgLKpt9SzW60qjD9TY49SvgePE8x ZMwQ== 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=9HP5QJchHpYyjOaAf3lP3KAwAYZ3mwgofh4y4UljDvM=; b=B9Vf4iMnR5pceSzRiXE4GuiahEGnt24dqPodyfNqat9YWgCw2DLeK2ez2p0KC+3/mB YXB3Fr+znd236q2M2jSv7dKzxwtPUibnAhyKH5P4s4Zls5cg8YI/QqsW0o/4nsjfNQh7 EPt48tRRxM6bg6SK/9hAGfFFsFWOXNCVeFcDHsm5INn6uo9bPuSXyzVrJx7ONnBRrrsO HnCd+25no+ECChUwJG7ZY5fNx+KQfiPVz7VyjnBq5cMfU534PIfnV0z9EgcyXyfBySBj CVTo7v9liP2XHyTgejcr8miu3zHWXDwYRNxglUGQ8kmsyHTv6+48PJTS1NKQcYS5onIy k4Ng== X-Gm-Message-State: AOAM5304RF5IVfzyeqPFUdS74BWu49s5HuG9rPWKCCo+csNfcIgktzW4 5ZWAgdtax4SzX9QiSpgLz15LDQ== X-Received: by 2002:a05:6638:2243:: with SMTP id m3mr3267192jas.115.1610558141221; Wed, 13 Jan 2021 09:15:41 -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 h9sm1120579ili.43.2021.01.13.09.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:40 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: change GSI command timeout Date: Wed, 13 Jan 2021 11:15:30 -0600 Message-Id: <20210113171532.19248-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The GSI command timeout is currently 5 seconds, which is much higher than it should be. Express the timeout in milliseconds rather than seconds, and reduce it to 50 milliseconds. Fixes: 650d1603825d8 ("soc: qcom: ipa: the generic software interface") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 93b143ba92be5..4de769166978b 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -89,7 +89,7 @@ /* Delay period for interrupt moderation (in 32KHz IPA internal timer ticks) */ #define GSI_EVT_RING_INT_MODT (32 * 1) /* 1ms under 32KHz clock */ -#define GSI_CMD_TIMEOUT 5 /* seconds */ +#define GSI_CMD_TIMEOUT 50 /* milliseconds */ #define GSI_CHANNEL_STOP_RX_RETRIES 10 #define GSI_CHANNEL_MODEM_HALT_RETRIES 10 @@ -359,11 +359,13 @@ static u32 gsi_ring_index(struct gsi_ring *ring, u32 offset) static bool gsi_command(struct gsi *gsi, u32 reg, u32 val, struct completion *completion) { + unsigned long timeout = msecs_to_jiffies(GSI_CMD_TIMEOUT); + reinit_completion(completion); iowrite32(val, gsi->virt + reg); - return !!wait_for_completion_timeout(completion, GSI_CMD_TIMEOUT * HZ); + return !!wait_for_completion_timeout(completion, timeout); } /* Return the hardware's notion of the current state of an event ring */ From patchwork Wed Jan 13 17:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362175 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720591jap; Wed, 13 Jan 2021 09:17:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9SzZ5qjLTAa6ITHJFTDBTx2pAq/9++PoI5fTsz5ZgitUxfEx1U0PqOoe4w69W9lp4FnHc X-Received: by 2002:a05:6402:1597:: with SMTP id c23mr2684008edv.212.1610558252273; Wed, 13 Jan 2021 09:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558252; cv=none; d=google.com; s=arc-20160816; b=GVFBpH/cZfi1FsWdIg29WKZFNj+hCPX30D+8VC2hwtR+FiVkcifSKQkdEwsWYdUkNe Q6qRCscFlKKihychWsDSXwkDCI/S9fDfcl4kj74ff0UjtPKAbXECBYXERsyNgMVDJ5T6 2EFbTV2jVELslycU6EES/d5zM0Yknawl+NzS/qLzHj5DXdaq8N742h1Ur9Wwb0AIk7pZ R73/MxK8xtjgCSvY+6PJbwNgA+OMh9RxzSCbMyjomaayzl0qZIYprwy96SeWpCTCA6yN ejRXE4DNfSg4icHyvIeoBhV/9QQDr3/uIJY0HgpZqlBjU2uIdt7utVjiGPkD1V01qAnW NuMw== 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=4ne5Zo1fGRu2iVcYjOo63CG/Ih5OIPi4+1L9+3+54RU=; b=C5cgdAd1w1g1rTFKmhsIihCaCG5rd2V3jz99g3X2sOSmVv8Zn7se83BorMVK9HpQ+y tqNAU0WjK76CEsmTTPB/9PKt6sQx/4aWwaTbqNuLdqFDKgh7Z6VqWk1QyvqCQMMOlRFM x2V8X5RnsYmdJz7ABzUbS9lonsv9tunDnsplpG03w69C6Ds69Ni2Xi3DkB/W/NWOajdK DeS1BN3y5/2oxYlpTWnMnFeS4HmFO7CdaE46A2WV85x4lAJXPphafi5lX3SLO34uXZnu EfCi0Bmc8oevvr3cglE4y4bYMXqT+xMD5CJ9wwZU4RhvEOzaaqRRZy/dw0v/Ur5hT+sy FiFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sbTiZViy; 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 c1si1354723edk.605.2021.01.13.09.17.32; Wed, 13 Jan 2021 09:17:32 -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=sbTiZViy; 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 S1728152AbhAMRQ7 (ORCPT + 7 others); Wed, 13 Jan 2021 12:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbhAMRQ6 (ORCPT ); Wed, 13 Jan 2021 12:16:58 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB72FC0617AA for ; Wed, 13 Jan 2021 09:15:42 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id u26so5667790iof.3 for ; Wed, 13 Jan 2021 09:15:42 -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=4ne5Zo1fGRu2iVcYjOo63CG/Ih5OIPi4+1L9+3+54RU=; b=sbTiZViyBdcIcY4TVKLFp8dMDvOB4aVI4mbfI/SnTr0qjNrxX70pM1g+vz1sNk3GQG 5ua75OuvAWyvNffK2SnKjyBQXPEGehG9YcSDUTb25W9uXNlJeR9g0K+1w/Mw2hoB0ul9 qK88hj4K0F35DtHh+Jpkuo9fZmHGbiFCH1amd5EuGFa6HY1PuQi0fVy9m6vVOjpFLn+6 gw4JytVhDzdpgtnmLZzm0ujlTRNebECGbuGasjItPUm3gR0Mwxd4iGAzNTUT5FlIUOfB 304dS++1ksF9IFYEXKGfWJ23OtEArnIjaE+4WrwsHPQEHbpqKEBMIF1D0ut470lXDoj+ JCLA== 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=4ne5Zo1fGRu2iVcYjOo63CG/Ih5OIPi4+1L9+3+54RU=; b=bn4oSlSBeleyjj1fs3k8FVA3QXSEo8pnjQCzL42Yn2EmIx76nj9Ii8FzsIqriNh7j/ fHVPz7qkqYFpykIBewLGGNWXmq7uIpil7o2rwnh9MffRbNLi+1D04Q6Dz3s1qry0fVUK 4fYTBGzLC96pR1jUjoCh93NjXxFX2R89fr7SH225pyIacLEqbONhAonGlpVBlbempops +xG9UeRsNbXEQtppnSQxe2Nz3z3jSaqRwPfcU5ab3l729ELp1qFVgvtMgkhIuLoCUGdw VdFtwhCBTpbqBXme6HwQIIQKiXTkeUARlmnHGWIADLA9/PTVtnRK9tq2PEVFT/U9ffC8 GIAg== X-Gm-Message-State: AOAM531+UQvpSS7XrBQgT3wDmJN6n3fFt6VD+FnrLV+ZDEDt5yPsfNpC YoITx4J3uPBTUUSaruACQFa7Lg== X-Received: by 2002:a5e:dc0d:: with SMTP id b13mr2581885iok.31.1610558142318; Wed, 13 Jan 2021 09:15:42 -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 h9sm1120579ili.43.2021.01.13.09.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:41 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: change stop channel retry delay Date: Wed, 13 Jan 2021 11:15:31 -0600 Message-Id: <20210113171532.19248-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If a GSI stop channel command leaves the channel in STOP_IN_PROC state, we retry the stop command after a 1-2 millisecond delay. I have been told that a 3-5 millisecond delay is a better choice. Fixes: 650d1603825d8 ("soc: qcom: ipa: the generic software interface") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 4de769166978b..5c163f9c0ea7b 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -903,7 +903,7 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) ret = gsi_channel_stop_command(channel); if (ret != -EAGAIN) break; - usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); + usleep_range(3 * USEC_PER_MSEC, 5 * USEC_PER_MSEC); } while (retries--); mutex_unlock(&gsi->mutex); From patchwork Wed Jan 13 17:15:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 362176 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp720597jap; Wed, 13 Jan 2021 09:17:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlxWDIVkYfRvoswmXwLhd65zlv/vQURmkuApWju80gO6E2HUwVp8Fi2PLBCuCRxRmNfh9v X-Received: by 2002:a17:906:3ac8:: with SMTP id z8mr2286744ejd.273.1610558252648; Wed, 13 Jan 2021 09:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558252; cv=none; d=google.com; s=arc-20160816; b=MExkNnuny4rfU2f9YjVmaVo2/WgmUgRZwf8GMcrBw1PEmjgA06Oa7/mEL/EmSP7wUx gXNrxEgXx4ZzhN+3skjWx85hMIAkb4ofuxenmzWaK8AxmrK52OMaHtldX4z4v+Wbe6D0 25OORC1n4n9Nnxh16E10T1QLfnw42yTiF5ROtHVaz7LXG0+g3K0AIp3pncnyVphhqZx1 ehLj74jnS3BrCU8K/UOlWrGN4f01JSAlnUw1gH73ln0S5ce+ucVAtcd3GbvBdja7NyBv SSSbEVTOQs8GAp7IJ4U5Vtd8KoaGO4eO6MXT1uge6gN84MAQBzwmSZWJOOipsTbzNFFR xoKA== 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=cya1YllzUew1Cz7aOjwGwTo+phSDuV7y8gvGZ//U/9Q=; b=tck4po6LVf8oSH4KMcMxUlgKX9NB1oM3uV8EvW1u4H+Q328pky2c1FUdVmFKwUTTFI dktYe/W0sta0lGSkalGhSBwopIoDgOdhQmGPG+pTS+hjf+MarJO9PaWxsA5N1IU2wKO7 4ClFD+vbkQ8yBGxCYQu90DfcnOHAtUObabrPr1JRT/XdkUPf3h8hEu1A61CmnMU9U+vI XqdToWpFffc8B4RH3uTetBC9j4DQFTTyw07rEooWWwur1GXN1xRPlTfMui/UIQF9Wpsa 75l7C6KNVx1x53FZ9TFU4s6k9pha4vpDCEl1dTMh5JkwV9HVotGoaCaNiEKGdk/MYgH4 E6Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mU/mNVI1"; 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 c1si1354723edk.605.2021.01.13.09.17.32; Wed, 13 Jan 2021 09:17:32 -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="mU/mNVI1"; 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 S1728178AbhAMRRI (ORCPT + 7 others); Wed, 13 Jan 2021 12:17:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728143AbhAMRQ7 (ORCPT ); Wed, 13 Jan 2021 12:16:59 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32376C0617B0 for ; Wed, 13 Jan 2021 09:15:44 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id u26so5667939iof.3 for ; Wed, 13 Jan 2021 09:15:44 -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=cya1YllzUew1Cz7aOjwGwTo+phSDuV7y8gvGZ//U/9Q=; b=mU/mNVI1DbIGzLDbFVMDvJokTzluyxYOZ835J5gSBXl9SNgJli/wh4cNdHzIkBHYdH b3dr+Gphw383vAAc1jzu4Ry+RMtAVkVT96qLS9S9dJ9sDXyCQIRf9w4lh4QHDBNaWHSr fcy1W8pHyz+lOKDFGkUma55jl5L9zqZVgHcK1plyCaOhBxUbqRlvGx0Cl0mA6llTaHLI ZNFS6agCjJpko710CEz1QhKyonVyzVprbrcxDwicKFQ+UktUiiRNW1DvpOE3MoaNIYeD qlp9v7mDHhdjEvbUmoiYh37CDW0s7hBG3tK5Ja1f4b3fe7LKBigxGSt7L2XGMnJKZsWC fgag== 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=cya1YllzUew1Cz7aOjwGwTo+phSDuV7y8gvGZ//U/9Q=; b=Mcsvwm+90caFRP5rYFSunks/QhrrxyaHkrTJZAL7nq9CpBW03NsgkPj2GeH0NxrwC8 ZvI8zYKAoRKfPy6Zwqn+638WEOsHNvtKg9TgL9C5amS4ezwRpuWMMb/vGj/KwTe3Mpki DhdUQmR1CMBhzXunYCbOKEyEf4khyM9L997puap29PggWLUggt0d+CzzBU/gwHlr99QF z3LVJrayusfmr/ys6cllWiWLxyPtST+HisEv4HvZATKw7XsZYONCnWnmZ+ucjGaNFPDw C5yVtO2axrl4dykF3uWYHE/8s1cNjCLEek29Vnp6vq0E9iYlx/axV6ByX1QLv9kg9QRQ zhYA== X-Gm-Message-State: AOAM533sVnD8s0HApX0XwQq44OsOv6S3uGKN1q1K3pM98TD9dGzO9Gl3 aIJjfwfA5UhqwcLijWJNSlsMTQ== X-Received: by 2002:a02:cf9a:: with SMTP id w26mr3268797jar.25.1610558143520; Wed, 13 Jan 2021 09:15:43 -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 h9sm1120579ili.43.2021.01.13.09.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 09:15:42 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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/6] net: ipa: retry TX channel stop commands Date: Wed, 13 Jan 2021 11:15:32 -0600 Message-Id: <20210113171532.19248-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210113171532.19248-1-elder@linaro.org> References: <20210113171532.19248-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For RX channels we issue a stop command more than once if necessary to allow it to stop. It turns out that TX channels could also require retries. Retry channel stop commands if necessary regardless of the channel direction. Rename the symbol defining the retry count so it's not RX-specific. Fixes: 650d1603825d8 ("soc: qcom: ipa: the generic software interface") Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 5c163f9c0ea7b..5b29f7d9d6ac1 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -91,7 +91,7 @@ #define GSI_CMD_TIMEOUT 50 /* milliseconds */ -#define GSI_CHANNEL_STOP_RX_RETRIES 10 +#define GSI_CHANNEL_STOP_RETRIES 10 #define GSI_CHANNEL_MODEM_HALT_RETRIES 10 #define GSI_MHI_EVENT_ID_START 10 /* 1st reserved event id */ @@ -889,14 +889,11 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id) int gsi_channel_stop(struct gsi *gsi, u32 channel_id) { struct gsi_channel *channel = &gsi->channel[channel_id]; - u32 retries; + u32 retries = GSI_CHANNEL_STOP_RETRIES; int ret; gsi_channel_freeze(channel); - /* RX channels might require a little time to enter STOPPED state */ - retries = channel->toward_ipa ? 0 : GSI_CHANNEL_STOP_RX_RETRIES; - mutex_lock(&gsi->mutex); do {