From patchwork Thu Nov 19 22:49:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328472 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817966ils; Thu, 19 Nov 2020 14:51:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFQ/bsgk2ETLd2uVgxiEfekmcjn4kiD50k7cq82nmud3pph3ldmlFf+IB2ZGTEdi8ywY7/ X-Received: by 2002:a50:9fe6:: with SMTP id c93mr32010554edf.30.1605826273337; Thu, 19 Nov 2020 14:51:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826273; cv=none; d=google.com; s=arc-20160816; b=uJxR/S5DKAm9fWCiPg7L5UMPt5PHlYenfmoMC2LE1/+QRxaOQxZo0yR3h4zkqwoDsU UUTTelU6x+G8LQBHVVzldRYV8sBJYpBgj6O6XPgly10nvEhdWs1sNnAU9NQRvOONAkOK LC7OC35AclulAnwuZAz2JuBdJdqiblSVm/2roMsqI++MuY/9EOuFh9THApoogSthPbd7 F53rTVQrunb2JWPhHO5T8xxrg4ekI0IFnxRhInubBfBwgQDUq5UlgdYJ4q/8xm7cdZ0t RD3EJb/XbIM7IRXiBVXSosiRLP2hwQDI3SZK5J3TnWpUyJcSkzK3/VgJdaZc1meMBsrm OhOQ== 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=lFOtB82zYfMy+DN+DQMCF6Al1O4+yIhvAGFtoT3kXTg=; b=QxYfxqur6yPCSr3AoBLGDjCsfgc11U8/SVnsjPHYyeTcLmW228Qj4ftb/sDtnzwsqk hAOfKVnYoK/KHVAvr9T7vsdARWZcrPF2fQqFLj7/Ie3husRcU8o/1eMA/Hj98ic+AtAY o+z1YJIStyufxRYBHobfIzkD0ecMUer6gGBqzIpRkjb3jIDdbhypSiCNW5MbDpSpdDmi e59dJr4kQYSYtjDAEuucwb3pAey+SWsFfDEydBzGaLURXl54y/euOt3GCxZqxv3gBA6Z Yi91F9wGmq3jf2kBOOsIDnbWjcbw0gzlYecepfXGBzlXJwNgNBPeIc+tungC4lb2XAa8 a4Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m1/Irs8w"; 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 hq14si545910ejc.99.2020.11.19.14.51.13; Thu, 19 Nov 2020 14:51:13 -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="m1/Irs8w"; 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 S1726381AbgKSWtg (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgKSWtf (ORCPT ); Thu, 19 Nov 2020 17:49:35 -0500 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF97C0617A7 for ; Thu, 19 Nov 2020 14:49:35 -0800 (PST) Received: by mail-il1-x144.google.com with SMTP id n5so6879779ile.7 for ; Thu, 19 Nov 2020 14:49:35 -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=lFOtB82zYfMy+DN+DQMCF6Al1O4+yIhvAGFtoT3kXTg=; b=m1/Irs8wOJcf29zRtD0c2Rh9tzyrp+HeezwFdRA5/TFNxZzvSy+x7NTQKelgdKBrt5 9QQPBd8y0hbETgzOl/Qj2N89HA8RSSwVYDCCJUZud1QtUW67OOYGjVJgnNtxvIIXR9Hf VgrWv6xxea+ncWgdBWEFJrjEU9pkK73WJmD55vdl1CwIYhttbBPQvQWFLfWUHMm1gcl2 UwsrhWlFtx9vPd/uPxG+9uvTsY42XPgVUhuvHZ102NxpLk1HJOQZR5kUnrGrjYiYP0q2 geru9+5B0HBWRPVEkSK/szDfPVFP+uMrMsuLXWWsirhI9YHmhcyhHVwEtqvtuB48mwDl BbRg== 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=lFOtB82zYfMy+DN+DQMCF6Al1O4+yIhvAGFtoT3kXTg=; b=BYtJZR7FfWmlM2CZjyzzyp2tbUo2r5aVOJNMwvyo+qrg32iKyHU6QJHKW5bBOeoSl3 6XZKOccfKB0tLDU3GU28FcNCwNHMDSlUAuhFQaqaVLmT8Fn9BzYTWJe79Cwkn2R+qPts oQXNWzWf0CYmh5xqFeGfwyEbmdl+3opVBrftZ2ZixAqxK4cx4Fc1g+TE+3niG/R5WBjQ AZqcE82LFz77v6Pd6HvTna1VQ7cw4ypIpDjv8wkdWUNvsf+PYyvt5V9fkOI1J5dLHioz DZnI4NgpHIdCwlM7CYa5iOxTvylCNfpVERmH+2Ybhlgm0RtcVY5+SdjS9e6gaeyG10wq goEQ== X-Gm-Message-State: AOAM533/yyYiHXduY+e7RXZbp+R1FBk7OQL9X3DptsWMBUIvbiPqvuZh Yue1LsxgcfiuviQ/1J3h87Beag== X-Received: by 2002:a05:6e02:1348:: with SMTP id k8mr21483828ilr.154.1605826174684; Thu, 19 Nov 2020 14:49:34 -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 i3sm446532iom.8.2020.11.19.14.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:34 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/6] net: ipa: print channel/event ring number on error Date: Thu, 19 Nov 2020 16:49:24 -0600 Message-Id: <20201119224929.23819-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When a GSI command is used to change the state of a channel or event ring we check the state before and after the command to ensure it is as expected. If not, we print an error message, but it does not include the channel or event ring id, and it easily can. Add the channel or event ring id to these error messages. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 54 +++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 55151960a6985..2bc513c663396 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -365,15 +365,15 @@ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) /* 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) { - dev_err(gsi->dev, "bad event ring state %u before alloc\n", - evt_ring->state); + dev_err(gsi->dev, "event ring %u bad state %u before alloc\n", + evt_ring_id, evt_ring->state); return -EINVAL; } 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, "bad event ring state %u after alloc\n", - evt_ring->state); + dev_err(gsi->dev, "event ring %u bad state %u after alloc\n", + evt_ring_id, evt_ring->state); ret = -EIO; } @@ -389,15 +389,15 @@ static void gsi_evt_ring_reset_command(struct gsi *gsi, u32 evt_ring_id) if (state != GSI_EVT_RING_STATE_ALLOCATED && state != GSI_EVT_RING_STATE_ERROR) { - dev_err(gsi->dev, "bad event ring state %u before reset\n", - evt_ring->state); + dev_err(gsi->dev, "event ring %u bad state %u before reset\n", + evt_ring_id, evt_ring->state); return; } 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, "bad event ring state %u after reset\n", - evt_ring->state); + 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 */ @@ -407,15 +407,15 @@ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id) int ret; if (evt_ring->state != GSI_EVT_RING_STATE_ALLOCATED) { - dev_err(gsi->dev, "bad event ring state %u before dealloc\n", - evt_ring->state); + dev_err(gsi->dev, "event ring %u state %u before dealloc\n", + evt_ring_id, evt_ring->state); return; } 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, "bad event ring state %u after dealloc\n", - evt_ring->state); + 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 */ @@ -479,7 +479,8 @@ static int gsi_channel_alloc_command(struct gsi *gsi, u32 channel_id) /* Get initial channel state */ state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_NOT_ALLOCATED) { - dev_err(dev, "bad channel state %u before alloc\n", state); + dev_err(dev, "channel %u bad state %u before alloc\n", + channel_id, state); return -EINVAL; } @@ -488,7 +489,8 @@ static int gsi_channel_alloc_command(struct gsi *gsi, u32 channel_id) /* Channel state will normally have been updated */ state = gsi_channel_state(channel); if (!ret && state != GSI_CHANNEL_STATE_ALLOCATED) { - dev_err(dev, "bad channel state %u after alloc\n", state); + dev_err(dev, "channel %u bad state %u after alloc\n", + channel_id, state); ret = -EIO; } @@ -505,7 +507,8 @@ static int gsi_channel_start_command(struct gsi_channel *channel) state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_ALLOCATED && state != GSI_CHANNEL_STATE_STOPPED) { - dev_err(dev, "bad channel state %u before start\n", state); + dev_err(dev, "channel %u bad state %u before start\n", + gsi_channel_id(channel), state); return -EINVAL; } @@ -514,7 +517,8 @@ static int gsi_channel_start_command(struct gsi_channel *channel) /* Channel state will normally have been updated */ state = gsi_channel_state(channel); if (!ret && state != GSI_CHANNEL_STATE_STARTED) { - dev_err(dev, "bad channel state %u after start\n", state); + dev_err(dev, "channel %u bad state %u after start\n", + gsi_channel_id(channel), state); ret = -EIO; } @@ -538,7 +542,8 @@ static int gsi_channel_stop_command(struct gsi_channel *channel) if (state != GSI_CHANNEL_STATE_STARTED && state != GSI_CHANNEL_STATE_STOP_IN_PROC) { - dev_err(dev, "bad channel state %u before stop\n", state); + dev_err(dev, "channel %u bad state %u before stop\n", + gsi_channel_id(channel), state); return -EINVAL; } @@ -553,7 +558,8 @@ static int gsi_channel_stop_command(struct gsi_channel *channel) if (state == GSI_CHANNEL_STATE_STOP_IN_PROC) return -EAGAIN; - dev_err(dev, "bad channel state %u after stop\n", state); + dev_err(dev, "channel %u bad state %u after stop\n", + gsi_channel_id(channel), state); return -EIO; } @@ -570,7 +576,8 @@ static void gsi_channel_reset_command(struct gsi_channel *channel) state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_STOPPED && state != GSI_CHANNEL_STATE_ERROR) { - dev_err(dev, "bad channel state %u before reset\n", state); + dev_err(dev, "channel %u bad state %u before reset\n", + gsi_channel_id(channel), state); return; } @@ -579,7 +586,8 @@ static void gsi_channel_reset_command(struct gsi_channel *channel) /* Channel state will normally have been updated */ state = gsi_channel_state(channel); if (!ret && state != GSI_CHANNEL_STATE_ALLOCATED) - dev_err(dev, "bad channel state %u after reset\n", state); + dev_err(dev, "channel %u bad state %u after reset\n", + gsi_channel_id(channel), state); } /* Deallocate an ALLOCATED GSI channel */ @@ -592,7 +600,8 @@ static void gsi_channel_de_alloc_command(struct gsi *gsi, u32 channel_id) state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_ALLOCATED) { - dev_err(dev, "bad channel state %u before dealloc\n", state); + dev_err(dev, "channel %u bad state %u before dealloc\n", + channel_id, state); return; } @@ -601,7 +610,8 @@ static void gsi_channel_de_alloc_command(struct gsi *gsi, u32 channel_id) /* Channel state will normally have been updated */ state = gsi_channel_state(channel); if (!ret && state != GSI_CHANNEL_STATE_NOT_ALLOCATED) - dev_err(dev, "bad channel state %u after dealloc\n", state); + dev_err(dev, "channel %u bad state %u after dealloc\n", + channel_id, state); } /* Ring an event ring doorbell, reporting the last entry processed by the AP. From patchwork Thu Nov 19 22:49:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328467 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817905ils; Thu, 19 Nov 2020 14:51:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJykwpy69irjIN2Zdo+sBDI5FV0fVSwOORFLanZREHKO5D9bF77VywAMrxT4mfvH7dCrlLLu X-Received: by 2002:a17:906:cc84:: with SMTP id oq4mr9791399ejb.513.1605826268510; Thu, 19 Nov 2020 14:51:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826268; cv=none; d=google.com; s=arc-20160816; b=D0aF4Aoba5ImcH4TGWXDIxcf662BbeXNOy5PjGTE0X8hV/LvwtKAR1l4oHGHtT/qnc RBH2yndSvut7BxNwY4LW/C8WrMK8k8NugR5hgyHPc8VXFe6sluJ7zfAZ6ApDK4joyBmT pDOtRZ4RKDdPrz8sCthDPPE9lCpOJoHwXQHSNSvdofG8sTXV8u4b5G9tGpMq754zqTIG mIvYCMs9qhZHEWSToYmE2OCaFRHCAsGIt7zjt0q2V3IODw3dM6WzLJ3VUk6mG+rNYtYD YN1Zh4k0IzGjsX/RVCLBBZuagIPNqF8jFqFN6RN4Qi2PrHvXrNpTzisd1fjFMJsd8wDa EfVA== 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=cgeSJpT+2VpJ8nnnk4D+8w/nk3Hu1aQYbqU02TDgkZI=; b=xdFTSSOssXnD8/lrLTh5GZGYWw8Xk4lZZmkjPA6ZQAgI5Wwa1pbtadJ011SRtlSxuT bE9q2EQjZQqIhvGyIAaXHBQPfm71k9981hUWPOMNsiGp4arHGG4/j2ngYSBXRF6CtU3V FjAXTdFeldyVg4ky2FDiQkitOCNEx2XDHq28siNxEcv81RHcAWNenGfVzPe1pp/GB1vm E+OxKNV/yAu85aSaBk8byflUP0icTNF+hPjbIfm8fjiUDDf9aHaT0hxoFUl1DM+HtIu6 uf8L3FQcGYPeiCZFRH6Ovzi3+zpQCWA5x0Zy2yQXhNu2atwEXSx+Bo/EopF8FDH46sPa m1zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uOyYzUjr; 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 hq14si545910ejc.99.2020.11.19.14.51.08; Thu, 19 Nov 2020 14:51:08 -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=uOyYzUjr; 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 S1726498AbgKSWth (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbgKSWtg (ORCPT ); Thu, 19 Nov 2020 17:49:36 -0500 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817DCC0613D4 for ; Thu, 19 Nov 2020 14:49:36 -0800 (PST) Received: by mail-io1-xd44.google.com with SMTP id d17so7943176ion.4 for ; Thu, 19 Nov 2020 14:49:36 -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=cgeSJpT+2VpJ8nnnk4D+8w/nk3Hu1aQYbqU02TDgkZI=; b=uOyYzUjr1NFc3RYfmSjmJem7iZM/CUh42JLbEsj5dyUVGdbopYnTcZZmMxf9sXYx7K pCy9IiFlVfz9IKcrvVHb+JS0W1XxF5Rn2TukFr9TO2Hn7L5EyHFH47IrgeZ8EaV4ax/r rl+Jg7jF5MkDSOpLgangkdAAfD7+h0oLmKxkVORFY+xVR7mK3/cD4rIvLtyEs1woSXLB Wn3cVYRENaX++GLOT7AgZI01x+BNB9BXJ7sBEVRJt9i3Hf4s5EBIcilUiUBCAXMEOyFV KaPR1x0X7CoLoNSnoiL/WvbGuoQiKQlZfd8XreQKfkptALwuPmVJ7jbQHDpVuoBcM58i +QIg== 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=cgeSJpT+2VpJ8nnnk4D+8w/nk3Hu1aQYbqU02TDgkZI=; b=nWQcvH+J36a+e2A0He2SKeWRgVKJvceh29nRFWxCu3OmtJr72CwOaMDUOdinO2t4Sa rsjCQ5IRjLdG5yI47FBjNHQbVcSk5V8qDz5AZuwRqULcN9WaFo/X+8eD7uh9c6EdvApU cnXC4wsba6CmGqbLfGDQ7fp1ysFAK1n46n2UBeT9xUE77NhkBap2eThECAu6qErtecM7 ksf+Hegh+6aLtfdt+3Kgt+M0SVtWIFIrL9RV36I4DcwctkqwRKmMddh9g2XtdYzHKvIW omNL6guWhi8fqvlmUNK1QVVQZi1xQohpeXH0OErB/5qOw4TqtIMTA2J/nRBdwsRoXieI vcgQ== X-Gm-Message-State: AOAM533mmdsN+c7UJW0fSKQ0EPjxym9sIKchgLOX8xP8tlEoTjC8Awn+ YjsYPm4r9/rDheAGsJF5WQPRmg== X-Received: by 2002:a6b:148e:: with SMTP id 136mr23554982iou.60.1605826175894; Thu, 19 Nov 2020 14:49:35 -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 i3sm446532iom.8.2020.11.19.14.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:35 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/6] net: ipa: don't reset an ALLOCATED channel Date: Thu, 19 Nov 2020 16:49:25 -0600 Message-Id: <20201119224929.23819-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the rmnet_ipa0 network device has not been opened at the time we remove or shut down the IPA driver, its underlying TX and RX GSI channels will not have been started, and they will still be in ALLOCATED state. The RESET command on a channel is meant to return a channel to ALLOCATED state after it's been stopped. But if it was never started, its state will still be ALLOCATED, the RESET command is not required. Quietly skip doing the reset without printing an error message if a channel is already in ALLOCATED state when we request it be reset. 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 2bc513c663396..58bec70db5ab4 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -576,8 +576,10 @@ static void gsi_channel_reset_command(struct gsi_channel *channel) state = gsi_channel_state(channel); if (state != GSI_CHANNEL_STATE_STOPPED && state != GSI_CHANNEL_STATE_ERROR) { - dev_err(dev, "channel %u bad state %u before reset\n", - gsi_channel_id(channel), state); + /* No need to reset a channel already in ALLOCATED state */ + if (state != GSI_CHANNEL_STATE_ALLOCATED) + dev_err(dev, "channel %u bad state %u before reset\n", + gsi_channel_id(channel), state); return; } From patchwork Thu Nov 19 22:49:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328471 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817955ils; Thu, 19 Nov 2020 14:51:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+pAU/7BDdp/s7fDa2Rhl7bKJJ9Pei+s3k63eXMVqjF8JLMSM5gAzjsvX8jJ6+z2L2IbR+ X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr29433315ejg.503.1605826272523; Thu, 19 Nov 2020 14:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826272; cv=none; d=google.com; s=arc-20160816; b=AeOD1pGHjilOKmVDLPKSZTvRvaIrRi/h2FEoYSRUripOe6Mm3UzpqnjvXbKJQdkrta kJ/0sLLuoOhnePvq7/jJHJOsSg2+h/qyZut2f+z4l2WZZjhviBiwFFnwOU67gnKxoTQ2 lZS8RoREmr2b5uE0SiLeGgbSUdS97+shGHNV8ol4P20ZYb7N4ZwZKqNqj96AQNPJtQWK qdQ/Pm2V59RrqFZ2aDru74j+n5AcyVSt24nz0Q4RVx0bIQB14pLhRMnLjzakzOzACAVw mWv7xnMpsAN5iYB/T3eaXteIok5/JiuYpGC0iDpTjVxpw0pvsMad3p21nfBJQvWpT5jX SHsw== 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=UGA7hgxTj0rrDkTjuJWFChVaqNnZoVILxCFPrIN84nI=; b=KbtYClSaNKR8i3hVEw3VWy92wwxxEDJ7YqfqlOq2nD3DEPzTktAXnW1OGpm0iMSHjw lROjn9kKhqVdJXXwuwLF4RVXGahpppEfgv6n/5Q0m4Cbn7yaKwQ03t0PFZ5B01NMqkYR DLtOIMg6AdQrxp8BJqXeVzpHrEc9e3lQt4R1jlxm95fTBpQVv2y8nIUJyhe4Z7ikfdzC zL3a9sJie/0yTrd+RWiH+zsITgwUWRx6WeyC9xZNz7AxFYibshzT7jlBUZnocnrgichA rQXLURVfHk2rK9cIkh0rGCsUTh6SFhTYicTriMhU9O9QHi3m4Pu0rIds2cNkqkhMVDPf HOhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NQbMDdel; 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 hq14si545910ejc.99.2020.11.19.14.51.12; Thu, 19 Nov 2020 14:51:12 -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=NQbMDdel; 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 S1726579AbgKSWti (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgKSWti (ORCPT ); Thu, 19 Nov 2020 17:49:38 -0500 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D585DC0617A7 for ; Thu, 19 Nov 2020 14:49:37 -0800 (PST) Received: by mail-io1-xd41.google.com with SMTP id m13so7910302ioq.9 for ; Thu, 19 Nov 2020 14:49:37 -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=UGA7hgxTj0rrDkTjuJWFChVaqNnZoVILxCFPrIN84nI=; b=NQbMDdelo5Ak8qfJjinOe8675xff8rg5+KFkXVIYJqLnTX9kg0NWl10hz/xqZTVJXA NXNF0RFvkBuFCodcsLLxrSJdFYPbK619yl/hFkfs+WRlN5fb/B7bW89Xr313BLMMYrl0 G++NC8fckKH90eoeMd559KAVjr6KCT+Zu38rE873ge+I4On1PhF236/8x8OOcsBTH2o1 OyXNX9A9I0FRsojg30POMKyImar2XyizOloU/291OQzksz2iFtBKa68PaJgD9xR184cl nJd3MOjB/QQnWWtlcGDrAO7ODX8lXbnBf6i2AcA90UvZIjIuf/sRkeDyCdaysQytDlFv DKiQ== 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=UGA7hgxTj0rrDkTjuJWFChVaqNnZoVILxCFPrIN84nI=; b=OSimIIURQn8dNGJ0QOBi7jGwv+smYX1JTWe2MTgBVspRzzc2uX0f0L8jJQ6LwohOSf c5cw19oj9mG6EIuSjGKZy7COi6JPr2n+ma0YzMHksRdKF3wgYRP64wtt7pnCk9kluOad 20C9rcC58MoT05tvrDOJqbdcd8Ev0j/sc27ftT55HT3uCpSnUrQL3CwKxk6qC1UUz2bS BKUiqZ3maHdU8MPBmews3gvb3TPrzNk4uMeAfFgA1+qml/IR02hk3ZrgyRw9ddK+kj+D 1/ssisYdMU6m4EqQsl7hqRGhWUQw4fqY3I1ghCpBCTTL0pjlSOHL4LR4f+Cg+Y97rKUC WqdQ== X-Gm-Message-State: AOAM532NdacGXD/QQ0PKjDX6zm1aVql+EJYYieKMR0MsUwnic22yvx94 cKSFNnzFkUZECGPLrNVDh5QOmXU4YdgtXg== X-Received: by 2002:a05:6638:124f:: with SMTP id o15mr16247013jas.40.1605826177177; Thu, 19 Nov 2020 14:49: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 i3sm446532iom.8.2020.11.19.14.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:36 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/6] net: ipa: ignore CHANNEL_NOT_RUNNING errors Date: Thu, 19 Nov 2020 16:49:26 -0600 Message-Id: <20201119224929.23819-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org IPA v4.2 has a hardware quirk that requires the AP to allocate GSI channels for the modem to use. It is recommended that these modem channels get stopped (with a HALT generic command) by the AP when its IPA driver gets removed. The AP has no way of knowing the current state of a modem channel. So when the IPA driver issues a HALT command it's possible the channel is not running, and in that case we get an error indication. This error simply means we didn't need to stop the channel, so we can ignore it. This patch adds an explanation for this situation, and arranges for this condition to *not* report an error message. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 58bec70db5ab4..7c2e820625590 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1087,10 +1087,32 @@ static void gsi_isr_gp_int1(struct gsi *gsi) u32 result; u32 val; + /* This interrupt is used to handle completions of the two GENERIC + * GSI commands. We use these to allocate and halt channels on + * the modem's behalf due to a hardware quirk on IPA v4.2. Once + * allocated, the modem "owns" these channels, and as a result we + * have no way of knowing the channel's state at any given time. + * + * It is recommended that we halt the modem channels we allocated + * when shutting down, but it's possible the channel isn't running + * at the time we issue the HALT command. We'll get an error in + * that case, but it's harmless (the channel is already halted). + * + * For this reason, we silently ignore a CHANNEL_NOT_RUNNING error + * if we receive it. + */ val = ioread32(gsi->virt + GSI_CNTXT_SCRATCH_0_OFFSET); result = u32_get_bits(val, GENERIC_EE_RESULT_FMASK); - if (result != GENERIC_EE_SUCCESS) + + switch (result) { + case GENERIC_EE_SUCCESS: + case GENERIC_EE_CHANNEL_NOT_RUNNING: + break; + + default: dev_err(gsi->dev, "global INT1 generic result %u\n", result); + break; + } complete(&gsi->completion); } From patchwork Thu Nov 19 22:49:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328470 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817952ils; Thu, 19 Nov 2020 14:51:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyO2w4gTBAUEk1s6Dj8/Z6O9Pm6nPL79MNHYkNUZLMEotUQypSxMi1k61/X9EgN6UDJY3b X-Received: by 2002:aa7:d4d8:: with SMTP id t24mr8404033edr.159.1605826272160; Thu, 19 Nov 2020 14:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826272; cv=none; d=google.com; s=arc-20160816; b=w/XKsN6QqikREN2Mny+mAxgdUIWViqmL95GfonOD577wUocz6vgGuN7994RcD9FzNV tNBdLfH5ye2hefSZ6/w0dETkPJbu4XLIOCxwFYa04ookp5T8mkRx5ezM7D1RgTxmRiZc pnbOHWzyCUi5vmoSq25/xPwjcYRWSbMXvAFH0sS/62C49cvyDtAXqC3jYUYIWkuBmDNb zcLiP19ZB/3TNoIPYQMnhDkOTtB8Of1GPJlfcIZYzpNDo+tq+dOsSo7MlM6cM2Aq8CXI h1uXQ+bZCYoo93tQQxh3diZiSkg+R1OzuNl2qYuM4KaIT3ReiNkg0JVphHsgLjwSu/xy 42xQ== 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=cKq81cpi43e09d93bbygzldKS5y1EkrmCoJ1FsxEfQo=; b=0LO8951mo4gkZ50tOrdLcOioU5oGr/x/l3funH2x15mS3OgF0YQvYWFsMM4OAx8f23 P6veBUxdSA4IrIZ1gMIMOWrm2/0WKhunzSdtQ/2BhcVrTuxWigp4D14ku6XbylTE0WmA 4MfmufbBkYK3nywFmtX/JKXAvHszVrwoIcyBP7otaO8jEMK4bNirBmWyK37ltcgdRzBG QA0wCOuJmUGNVaDr5ccfPfylSkkORI/TGSzn1+Um6OjWO2ERggn3qqX6k107DHcXDEtu szU48WQUfaX/J/b4g1Y8JzMnbxc2pZPM+nzxCd1WF7acmg2G+O606qObmvYTYhuIN5o3 UpKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBhMmRmo; 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 hq14si545910ejc.99.2020.11.19.14.51.12; Thu, 19 Nov 2020 14:51:12 -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=uBhMmRmo; 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 S1726630AbgKSWtl (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgKSWtk (ORCPT ); Thu, 19 Nov 2020 17:49:40 -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 68AE6C0613D4 for ; Thu, 19 Nov 2020 14:49:39 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id m13so7910360ioq.9 for ; Thu, 19 Nov 2020 14:49: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=cKq81cpi43e09d93bbygzldKS5y1EkrmCoJ1FsxEfQo=; b=uBhMmRmo4RYRxrjlkdy61T7i1J5tzRRK6MtjXiAvpQbZPTTp4HrWS4phIkHV4JFH0k q2/LHKK9icUfZk/DUMC++tQ4RDqnY30drTe/kLF9ncuHeIPar4jGVN0r3j+C6n7lhCz3 nHWip5SAogVuJseM3kp2nEs21VUEdeXp3ETBj9tQQIVddTv/LFb+7qMP0X2kcuP1XGrp ppXovVP9YpfOswvm7AprzMnCX1fL1HDHqcqUqeaQnp0udUEBx0/sujuCb20ur/Kh3HxC 2A1/4QDhqcIpX+vdCIZ4PaTq9xa5wfM++N5ghWIrxlSVGBsK1oJTJg4JS22GmFYXSc0l GnLQ== 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=cKq81cpi43e09d93bbygzldKS5y1EkrmCoJ1FsxEfQo=; b=J7LIWtMrml7wzX1wfQd7Q1bFqGM7IdVOvHqjaFeETHQDriapeAnN44DDQBiEfs3+rE Pu5/DRUnKu+QQkd6mNQ9vMl8By6qe1EY/GDF5FtRmtm8LNHUksgSjZ/VD+cVkfUPamJQ Z/F8o9SVTQXmb8VacAaTC29Y+3G2OLMAzL8NOiQ7ZOAVw1ULrtLBaajPd69V8AInRsWQ LO1Rzpn8X7IAgqLMKcBed30GjY183Ml7Wi6MMT/CB8FJuESrtHV+gHNBRnzZ3FfOqVGM SonaboRXOmv1iozVSxlGWeci53+SASFiR2otrEy5aCvfd67MG+/MvE0ntj/BVv85etkP GHYw== X-Gm-Message-State: AOAM53391SVdYDAsirTRVJyRfC3v/LQiah8MSz/YHqgYaouPm+lzGHHg v+kPEx8oW5wG8jc/y/KA2fXg+zQLjUzp/g== X-Received: by 2002:a05:6638:10ea:: with SMTP id g10mr16945527jae.9.1605826178487; Thu, 19 Nov 2020 14:49: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 i3sm446532iom.8.2020.11.19.14.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:37 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/6] net: ipa: support retries on generic GSI commands Date: Thu, 19 Nov 2020 16:49:27 -0600 Message-Id: <20201119224929.23819-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When stopping an AP RX channel, there can be a transient period while the channel enters STOP_IN_PROC state before reaching the final STOPPED state. In that case we make another attempt to stop the channel. Similarly, when stopping a modem channel (using a GSI generic command issued from the AP), it's possible that multiple attempts will be required before the channel reaches STOPPED state. Add a field to the GSI structure to record an errno representing the result code provided when a generic command completes. If the result learned in gsi_isr_gp_int1() is RETRY, record -EAGAIN in the result code, otherwise record 0 for success, or -EIO for any other result. If we time out nf gsi_generic_command() waiting for the command to complete, return -ETIMEDOUT (as before). Otherwise return the result stashed by gsi_isr_gp_int1(). Add a loop in gsi_modem_channel_halt() to reissue the HALT command if the result code indicates -EAGAIN. Limit this to 10 retries (after the initial attempt). Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 21 +++++++++++++++++++-- drivers/net/ipa/gsi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 7c2e820625590..eb4c5d408a835 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -92,6 +92,7 @@ #define GSI_CMD_TIMEOUT 5 /* seconds */ #define GSI_CHANNEL_STOP_RX_RETRIES 10 +#define GSI_CHANNEL_MODEM_HALT_RETRIES 10 #define GSI_MHI_EVENT_ID_START 10 /* 1st reserved event id */ #define GSI_MHI_EVENT_ID_END 16 /* Last reserved event id */ @@ -1107,10 +1108,16 @@ static void gsi_isr_gp_int1(struct gsi *gsi) switch (result) { case GENERIC_EE_SUCCESS: case GENERIC_EE_CHANNEL_NOT_RUNNING: + gsi->result = 0; + break; + + case GENERIC_EE_RETRY: + gsi->result = -EAGAIN; break; default: dev_err(gsi->dev, "global INT1 generic result %u\n", result); + gsi->result = -EIO; break; } @@ -1624,7 +1631,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); if (success) - return 0; + return gsi->result; dev_err(gsi->dev, "GSI generic command %u to channel %u timed out\n", opcode, channel_id); @@ -1640,7 +1647,17 @@ static int gsi_modem_channel_alloc(struct gsi *gsi, u32 channel_id) static void gsi_modem_channel_halt(struct gsi *gsi, u32 channel_id) { - (void)gsi_generic_command(gsi, channel_id, GSI_GENERIC_HALT_CHANNEL); + u32 retries = GSI_CHANNEL_MODEM_HALT_RETRIES; + int ret; + + do + ret = gsi_generic_command(gsi, channel_id, + GSI_GENERIC_HALT_CHANNEL); + while (ret == -EAGAIN && retries--); + + if (ret) + dev_err(gsi->dev, "error %d halting modem channel %u\n", + ret, channel_id); } /* Setup function for channels */ diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index ecc784e3a8127..96c9aed397aad 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -161,6 +161,7 @@ struct gsi { u32 type_enabled_bitmap; /* GSI IRQ types enabled */ u32 ieob_enabled_bitmap; /* IEOB IRQ enabled (event rings) */ struct completion completion; /* for global EE commands */ + int result; /* Negative errno (generic commands) */ struct mutex mutex; /* protects commands, programming */ }; From patchwork Thu Nov 19 22:49:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328468 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817940ils; Thu, 19 Nov 2020 14:51:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxA2xovpL9s84MM2UiTsE0ySCctCSuUVUw39JmrkHGp78HZMaqViojcZPN41XBB/OWFohDI X-Received: by 2002:aa7:d98b:: with SMTP id u11mr33233590eds.107.1605826270995; Thu, 19 Nov 2020 14:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826270; cv=none; d=google.com; s=arc-20160816; b=nNJs69eMrVQGSVu5iHVDx2MPV6cNX+Evddv5vkPj+7pOCLmS3G6gOXBex299uT5/4M b5Tx2rb6VfCelizSI5RdilEpWRLWQbWBZes+4tKa/ezcvylwF1JzgYgrO0u4ZVcUp2Td 29x1szPBFHQSsw+cMirwcHopdzhW9UyAW976/XMKupZmRo0PToio+iB8e+5mbC7MNTuJ Vz8X/fG1b4d/eGXTOFdUziKJexG2WfqAN/oNe9GUmAdQM1nxSb5QAyPLMDRCQuLxQq54 xMWjTlwTAAeBNbeWOMvUUzPpAYIpBHeD8DyobOHPIyyzTsqigqL9dOos0OYUcbW2XjXs H62w== 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=+Xvc6yFy3B6RA1AySob/CnSMzPD16sI2RoCdvJ3slvY=; b=nyplURBlDawG5td3ob0zStwZA7HjfRBv5L5ontBYP36TUo/hCVkcoP3HQAPnLWS8wU NijZkOaMDvydErJ7CI+hINTCHct0cc3XkU3wYp0/nAOKA3+/4O2Ak7EAE0ErplOKSAWx R927zqUnqzedLxLWjJU1jtO8d+xC0jCJO4BlUuEmjgU7z6ZrpKbxmQ2k3aIesnYT9kra xM4i7K4/a5s8JSsxbNtyra/tWkKLzX7xYNHyf3eIG+tOUvNRRzao3LZXt5bOQL2nO0qG r1g8kqoRT/G/oCQQmHjrGmB8lb8Sp9H5PlmEtVGH9E/Kp+Sj9nd3Pw7e4RCwZcLxwOhz PFTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CZHDJnV8; 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 hq14si545910ejc.99.2020.11.19.14.51.10; Thu, 19 Nov 2020 14:51:10 -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=CZHDJnV8; 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 S1726682AbgKSWto (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbgKSWtl (ORCPT ); Thu, 19 Nov 2020 17:49:41 -0500 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC8BC0617A7 for ; Thu, 19 Nov 2020 14:49:40 -0800 (PST) Received: by mail-il1-x141.google.com with SMTP id n5so6879991ile.7 for ; Thu, 19 Nov 2020 14:49: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=+Xvc6yFy3B6RA1AySob/CnSMzPD16sI2RoCdvJ3slvY=; b=CZHDJnV8efZpm/8lO8PTOPbfKNf1/Rc4jo96XFcyZu+uYmp1lTzFjpdpUGFZ+os8uO DFIIKYOL+Qos0m7imSxRMXr37leU+WFEER2FHEpH9y+sBikbiDF9wSqe/TPPsYEma9L5 8QXp0ZVqKv36WsFUhypN3o7VVhb4uizFC+b3M8ryxV3HJ9EjSZXxlab06RjFIw/Shzsd xCvPmSjaYDAFP54qlDkI8nprljSXC+TyAvAJIVSurxjlzRF9ZBuXLnlJbbcIYVVBW4z6 1yIMBGC11Q6DYBvWOTTkCuFFvPhhXALqHzTbgVjD4QZEYjWcqXd0cRefBlyNfYs2PSSY n0Yw== 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=+Xvc6yFy3B6RA1AySob/CnSMzPD16sI2RoCdvJ3slvY=; b=i82YM016W/WVOpJMzK0SDS92k6NnFAQHzsuHGRWJoooB9gAjT9f6c2Tdd8L3qKh8JB sl7XtxzdGN2BBQ2qoCXsG8GrFeNt92ZmYIojSjG609KKd+vs/RIbNgK6i0srYmWpPBFY GhxvxMgRL/ipsipbHckiwvWxCeMW1UUGujIS9zibZZd7qQki7CNn1ClirB8hAmPtoQ+C ufEheQV7DQc9gHiAQOstObfJ4QPCXZbNYcmPp7y6NYePqV7GHVOMnm4/R5rZZQf7ecuC Y5FTuFF1P8LJ//wxDDYY/Qz3B3DEHore/g2XhiMeWt91SSsNycoQiu16atE+G84HJdXc UF2g== X-Gm-Message-State: AOAM533zhfQKSrf3uxWRWd8lfJ5X2MfUVcMpinOOkKVK3As5Puh5aIW0 Wasmy+MngJtFCBJhn5+Cb/61Jw== X-Received: by 2002:a05:6e02:92f:: with SMTP id o15mr23903000ilt.169.1605826179758; Thu, 19 Nov 2020 14:49:39 -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 i3sm446532iom.8.2020.11.19.14.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:39 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/6] net: ipa: retry modem stop if busy Date: Thu, 19 Nov 2020 16:49:28 -0600 Message-Id: <20201119224929.23819-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IPA driver remove callback, ipa_remove(), calls ipa_modem_stop() if the setup stage of initialization is complete. If a concurrent call to ipa_modem_start() or ipa_modem_stop() has begin but not completed, ipa_modem_stop() can return an error (-EBUSY). The next patch adds a driver shutdown callback, which will simply call ipa_remove(). We really want our shutdown callback to clean things up. So add a single retry to the ipa_modem_stop() call in ipa_remove() after a short (millisecond) delay. This offers no guarantee the shutdown will complete successfully, but we'll at least try a little harder before giving up. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 3fb9c5d90b70e..9f4bd822ac625 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -864,6 +864,11 @@ static int ipa_remove(struct platform_device *pdev) if (ipa->setup_complete) { ret = ipa_modem_stop(ipa); + /* If starting or stopping is in progress, try once more */ + if (ret == -EBUSY) { + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); + ret = ipa_modem_stop(ipa); + } if (ret) return ret; From patchwork Thu Nov 19 22:49:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 328469 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp817942ils; Thu, 19 Nov 2020 14:51:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHw1/OeGWGKAKzpZJDrF26QqKtzvaGo8GeZBulGPWLvJR0atSQxnZ+uc3I8/f1g/qWParZ X-Received: by 2002:aa7:d493:: with SMTP id b19mr31528248edr.279.1605826271372; Thu, 19 Nov 2020 14:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605826271; cv=none; d=google.com; s=arc-20160816; b=Xg+iIBs8he7MqrgOv7dYA4I/A9y5XvAsLHo+OM3X9sDoQGOq451KpeDMAg7wUx6nml gdG8311RZxmUHw/6DNWCZJVgXAU+skBSdgJzKGmkXd05eny7V68d1IKuAVULGTYcsNrr sO93wkEYo+11XfkK57oIZUjXuNitf0WTiSkznm7oWK2DhEZPX95bkEPamsoxm4Eq0Yk2 Rc5/XPguf3DX//0eYVMeRj5/hfzVPWMxjdYd5AAxPqT0l1NXBNcuK2qZ8KynhT9zibZI kaUbWfE8kq90//AYroVprHNSsAOio4ZpxCMDn3m9KXX7qDmatZ8y5s6l2DSyiom0YonU RxrQ== 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=bo4MSwJ0tFuIkBE6whS0DGZ/BGwfpkBFnKgHt6nK9mc=; b=NW80P96nlKTjMiqj3tCEFVrG/qebLUZsw/WEBtlAKz20UVSlZnQpXVlItiphsxuPtA NbU+P8eDjpFUhs0/2049jA9iXkS/KT5/a1qtsx7ujDVZfiSFFc3EU6uAbkoDIuE3lzVi WksEGWqXyi/lklISU1dEkHwqrGGYTVm9iXg/x2HdWVGv905ojEk9tdIJzmvyXtlQzMcG jtkujcLItscnYssA/Lc9voLyZggrakZu/jZ6gkl6XOjqwUD7jvcuAtAiyUiEZSPbF4VH hzEU/MCiiFv8uGiTr2DVVaGhLawPUck1WUFNsfKKTmbGBJ2C2Q1QtxIK9MlFT9F24O8u QAaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LW7B1p54; 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 hq14si545910ejc.99.2020.11.19.14.51.11; Thu, 19 Nov 2020 14:51: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=LW7B1p54; 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 S1726779AbgKSWto (ORCPT + 8 others); Thu, 19 Nov 2020 17:49:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbgKSWtl (ORCPT ); Thu, 19 Nov 2020 17:49:41 -0500 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886E8C0613CF for ; Thu, 19 Nov 2020 14:49:41 -0800 (PST) Received: by mail-io1-xd41.google.com with SMTP id m9so7902614iox.10 for ; Thu, 19 Nov 2020 14:49: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=bo4MSwJ0tFuIkBE6whS0DGZ/BGwfpkBFnKgHt6nK9mc=; b=LW7B1p54sQ0R41QAYybP5dn8QpIlUsIfU+oEIC4hgcjr1EPQzjmgAalqONQ3S+2d6B z0z7uwFyxfpX68Wpbk66MqOiVQeW0MWgrEQ8OzyS2dkdtoMOROZoXS1NooiErSFswwT+ 1BRyCT+ifjMv7YFZZWPSD560NpqsESdwamWdHFxL3/GsmbYAqySkxx6RigEr2hn40Z7d BPQzQvBucOvQyofVIuRLeex0KgW/5bMDtOoVZux/QQJ0FCpnhRKvFqsZ+tLI63juI7uU ZC1k7jX4yeuoBPr1FrJuJ3HOO12JzEeAqJ1EdFCtnXYM+t5F90tTFPuzdXc6PxSItTMn Z/rA== 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=bo4MSwJ0tFuIkBE6whS0DGZ/BGwfpkBFnKgHt6nK9mc=; b=Btd34Qa7LDdjbQzwWOutyZMnbNmEx2CArV9izCvEWCTQ+yRmGpLnI8leowsDpsf+Ps Zf+LlgX+9g4uOLVxM/L7kP9h98m6O+dV1QgG+m9ug+ua+vSDeYXzxfiZgENZ8J4pZwcJ yotiokxEu7pV31QdJ0KhvXCZc0xjWs46yBKM9l9IITStzQejqlBZD0MXkM0h5FXXSqQU 5qXdRYGKr5dfJsjkXC4uA8nwrQP0zn7aFVlCK3m0LbjVyzoa14BMsJ740dXt0aPcinrZ jss89sEhzRlKEpmJjqOQSW8NaQ/dkYLBgyY0SLswSjMCB2w8e2TMPpIkZges5SoqoSLL S1Lg== X-Gm-Message-State: AOAM5307IDjsFVdMWjeFSWYJ4kbjr5qe2jvGnqstYZsK79s/zY7EaUPG tYvPv6DLlDXD+rY8c+Cb/TDvbg== X-Received: by 2002:a5d:8d13:: with SMTP id p19mr8920238ioj.37.1605826180967; Thu, 19 Nov 2020 14:49: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 i3sm446532iom.8.2020.11.19.14.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 14:49:40 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: evgreen@chromium.org, subashab@codeaurora.org, cpratapa@codeaurora.org, bjorn.andersson@linaro.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/6] net: ipa: add driver shutdown callback Date: Thu, 19 Nov 2020 16:49:29 -0600 Message-Id: <20201119224929.23819-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201119224929.23819-1-elder@linaro.org> References: <20201119224929.23819-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A system shutdown can happen at essentially any time, and it's possible that the IPA driver is busy when a shutdown is underway. IPA hardware accesses IMEM and SMEM memory regions using an IOMMU, and at some point during shutdown, needed I/O mappings could become invalid. This could be disastrous for any "in flight" IPA activity. Avoid this by defining a new driver shutdown callback that stops all IPA activity and cleanly shuts down the driver. It merely calls the driver's existing remove callback, reporting the error if it returns one. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 9f4bd822ac625..bbfc071fa2a60 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -889,6 +889,15 @@ static int ipa_remove(struct platform_device *pdev) return 0; } +static void ipa_shutdown(struct platform_device *pdev) +{ + int ret; + + ret = ipa_remove(pdev); + if (ret) + dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret); +} + /** * ipa_suspend() - Power management system suspend callback * @dev: IPA device structure @@ -946,8 +955,9 @@ static const struct dev_pm_ops ipa_pm_ops = { }; static struct platform_driver ipa_driver = { - .probe = ipa_probe, - .remove = ipa_remove, + .probe = ipa_probe, + .remove = ipa_remove, + .shutdown = ipa_shutdown, .driver = { .name = "ipa", .pm = &ipa_pm_ops,