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: 11919121 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCAB3C64E90 for ; Thu, 19 Nov 2020 22:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EC5C22261 for ; Thu, 19 Nov 2020 22:49:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="m1/Irs8w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgKSWtg (ORCPT ); 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-Google-Smtp-Source: ABdhPJw+NA+fe+LOwp76vay8WAHjL0XbI+J1OEiV1iotcljozXMWLBDqKrXxzx5FfjtnG+Qdc9QQdA== 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 X-Patchwork-Delegate: kuba@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(-) 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: 11919111 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5529AC63777 for ; Thu, 19 Nov 2020 22:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBE5C22259 for ; Thu, 19 Nov 2020 22:49:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uOyYzUjr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbgKSWth (ORCPT ); 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-Google-Smtp-Source: ABdhPJxqMRKJE7HEJ5Va7ap17EWSY6IFGKdgetxCqI+JYMxPNcmOhtGB0p2M213fTuYBR1cBrUst1w== 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 X-Patchwork-Delegate: kuba@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(-) 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: 11919119 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D5E5C64E8A for ; Thu, 19 Nov 2020 22:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C86E22260 for ; Thu, 19 Nov 2020 22:49:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NQbMDdel" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbgKSWti (ORCPT ); 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-Google-Smtp-Source: ABdhPJyqAGnNIngptG2cXBNFx3CSA4orgUA+1eJKEDHqTVLGzO9ufqatp0m0RX5nsZe6h8MJko5sQQ== 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 X-Patchwork-Delegate: kuba@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(-) 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: 11919115 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B609C64E7C for ; Thu, 19 Nov 2020 22:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CECF422464 for ; Thu, 19 Nov 2020 22:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uBhMmRmo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726630AbgKSWtl (ORCPT ); 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-Google-Smtp-Source: ABdhPJyjZlp/Tfg3ZMP9wUIXXk9YhGoOQ/YvJgOKgf3JwNJxWwrBU44DBwf/3gQoMy3LHB3R6dlc7Q== 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 X-Patchwork-Delegate: kuba@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(-) 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: 11919117 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8094BC64E7A for ; Thu, 19 Nov 2020 22:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B71222259 for ; Thu, 19 Nov 2020 22:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CZHDJnV8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgKSWto (ORCPT ); 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-Google-Smtp-Source: ABdhPJyFUZ5g1QunsNuhtnyHZ00MCE4682v8aWwXfV5R5KdG6QhtnDGoVwVlYosEGl1C4k6sXFE39A== 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 X-Patchwork-Delegate: kuba@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(+) 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: 11919113 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B41A9C64E7B for ; Thu, 19 Nov 2020 22:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 572732245D for ; Thu, 19 Nov 2020 22:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LW7B1p54" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgKSWto (ORCPT ); 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-Google-Smtp-Source: ABdhPJxt159FsjtZ0a9d3LRsiofXJXMu2XDRNt69oViEkRJfTZtIJ9N8Ueh8Z81ixfHlKIVgX51+iw== 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 X-Patchwork-Delegate: kuba@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(-) 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,