From mboxrd@z Thu Jan 1 00:00:00 1970 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 CD512C64E7D 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 9537C22260 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 S1726751AbgKSWto (ORCPT ); Thu, 19 Nov 2020 17:49:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbgKSWtl (ORCPT ); Thu, 19 Nov 2020 17:49:41 -0500 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C37AC0613D4 for ; Thu, 19 Nov 2020 14:49:41 -0800 (PST) Received: by mail-io1-xd42.google.com with SMTP id u21so7910084iol.12 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=eI2YjjUf9ut7w6h1g/9KARGXrxcHoXBlAaCtoZ+9Aq1JYiRbZF5UXuU+214IEGDRaY mwImASzfX7dFcSbHYDC6F/g4qXAf+GttWRGQhYBzzoRRDrgQyx0KyLTptIPhxFTWRiMs O/bynxJwJCwn+wdsX6YXfArdaAAgSAW83B1grsSGUyUDUT0arLM68u/5qT5xs398vC18 wqhZeHHE7AHhMEJ2R6sSL9ilwkB4VL4GbVr7uqndiWrhOeOC+HpIanEPwke6onGgeCCt KEpNRR/lo5bq8g+8RR9BtlqyY6yjN8oTcGTgnmCW5/VDwVHqIJ7n0syOE/dCmK00pNmI dtxQ== X-Gm-Message-State: AOAM531t6qazGNoTISl7EI6vfhYFKaGeNk71KKAa6BJINgTFzdMHopJj CSXDlnGb7IRa6/iYl5XPwwHJwA== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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, -- 2.20.1