From patchwork Thu Aug 19 22:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 499779 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp950120jab; Thu, 19 Aug 2021 15:19:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz19FEgIDEOfAa0ZgxdYYo9kqWLFhDM8Rd1YNlJzZ52zTRNpTGK3fdt0hkGdwJ56wuCWgg X-Received: by 2002:a17:906:25db:: with SMTP id n27mr17654330ejb.108.1629411581806; Thu, 19 Aug 2021 15:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629411581; cv=none; d=google.com; s=arc-20160816; b=dc3KinlZ9Ng0GgIT8N7pdTEKZhJYH8qFzGYMDMtmx2qNiBIUjbD175I3mgqWtxRDvA ENSdPi2RUtBdpnJCGi/guWRHAeA2S+0MSxZWjinc1p6pMr+y2OVbfwJ2hOsm4cozZVYr Nit7CZFuOQ5ui4/C7F3Y5FjY0XKXAYPRz0cjwsBYQQ8xZXAyUqVHJFefb5+L0atZ33r+ v7Se575ieqSqQUhgT38AlNgGjQzI2D4shHw8ADgrdqaf61/3EimUxETThGy6BePqxBRD GVNEAL8IClHqFolnLsMw7qdyYbRzbGm3SARpB/GODQnT29XUSB0moq5aQZFdek29k7x6 Q0Ww== 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=RpntrM1ojw2u707sqzIhjLaMl82LdztxT4txCgjSHJ8=; b=BjrjmPwx6UjCXNvb+KEs/2qlsqC0XbzGweS51DuAeuEluRrIPtRyMP490EgPP1NEzq dPO8Hky58NQeFXWieU5iTeb9reT2ttlEVPW4r7MtKtnGrN//WwK8XBLOO/VP7LYprb9F hQRClIu5PWIBhoA+rzAbg1mMFbp1pl340nC8psgZmliyRMIo7mpsC9CowNKmKHbtkn0s WoAHbrfy8p6SHTwSASlcfrnVqK8Msvlqa1gX7pNpIivARd7dNpLZRZ0yTOkqmdNUu55u xWIQ9IO9ziyzaJeokImRKkWxRPAAzGZ7f6Z/YYWkKZmWG9HzjRumYiTdt09vezpqgzO2 ReRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vp+d2kr1; 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 l14si4567062eds.2.2021.08.19.15.19.41; Thu, 19 Aug 2021 15:19:41 -0700 (PDT) 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=Vp+d2kr1; 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 S236920AbhHSWUQ (ORCPT + 8 others); Thu, 19 Aug 2021 18:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236765AbhHSWUI (ORCPT ); Thu, 19 Aug 2021 18:20:08 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2570BC061756 for ; Thu, 19 Aug 2021 15:19:32 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id b200so9675899iof.13 for ; Thu, 19 Aug 2021 15:19:32 -0700 (PDT) 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=RpntrM1ojw2u707sqzIhjLaMl82LdztxT4txCgjSHJ8=; b=Vp+d2kr1vHaaDyRPGeK1E7OMCamEZUKB9u0jcPpuxm5zdjLvv/fo5Zfbsvj/6gq62X DpaY7O2p2NRx3MkC+WdgXUnnT5OqCmy/VHZVWCvnCwjsga5IIg3giZukBsX/kh0ySd/Q 6Y4heoDSiClADHXuAxJkp+vnBW4pVFC63VdS5ATO4NthNQ4eHsdMRYF79dN7C1lctE+n P5enikwYkgifcuPU23VogD9nTWb155j6kjbrQiWEZOAYc0dmHWhZbWu4d7oTj7THNn0y fqMr5BIjsHux2Iz0cw4zDGle3rF7V3I383BjDBZw2YCA4nsWlSlCLA/sDKqcCqdNwJoL raEg== 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=RpntrM1ojw2u707sqzIhjLaMl82LdztxT4txCgjSHJ8=; b=q170TtYlgs1GXTuLXy6AdUE9MzpKbUua7npJhC+GQA5ofr8eYp3bAOj7Kwc4zh0J07 8sp3rJokyncxLkOMJYhJBWAsGO8AUav6CCpWrlfBVWbWfCOm/UMjYylt/XfpICAnTi3F pdCKvBO8/dPBkFPX/wnEhbNNweEdZTEkSof7kNu8dg5KG2RRGTdxo4BPBl8xYs4Nh33w pQWA28090w7FAMhliqSoRLHrWcKoXxeBUNVevT3e65Ods4hy+wNTC4zbjID8rIJbFXqV wHE+B3KGAEOyvQa/9H0PtRrf9gpBmlcPTiWASKBMzRAQoRPz3B4FjG4k3DPG2AdHlZen dCWQ== X-Gm-Message-State: AOAM5337lm6r5AfAxnVnqu/KyBL/nFMwMoMIgzb2FCAus7nxf5tYkNoz YQDwQI5/o+q4Wi4vcs7i/QyR4Q== X-Received: by 2002:a5d:85cf:: with SMTP id e15mr13333195ios.208.1629411571614; Thu, 19 Aug 2021 15:19:31 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id o15sm2245188ilo.73.2021.08.19.15.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 15:19:31 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net: ipa: don't use ipa_clock_get() in "ipa_smp2p.c" Date: Thu, 19 Aug 2021 17:19:24 -0500 Message-Id: <20210819221927.3286267-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210819221927.3286267-1-elder@linaro.org> References: <20210819221927.3286267-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the "modem-init" Device Tree property is present for a platform, the modem performs early IPA hardware initialization, and signals this is complete with an "ipa-setup-ready" SMP2P interrupt. This triggers a call to ipa_setup(), which requires the hardware to be powered. Replace the call to ipa_clock_get() in this case with a call to pm_runtime_get_sync(). And replace the corresponding calls to ipa_clock_put() with calls to pm_runtime_put() instead. There is a chance we get an error when taking this power reference. This is an unlikely scenario, where system suspend is initiated just before the modem signals it has finished initializing the IPA hardware. For now we'll just accept that this could occur, and report it if it does. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_smp2p.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c index 04b977cf91593..f6e2061cd391c 100644 --- a/drivers/net/ipa/ipa_smp2p.c +++ b/drivers/net/ipa/ipa_smp2p.c @@ -16,7 +16,6 @@ #include "ipa_smp2p.h" #include "ipa.h" #include "ipa_uc.h" -#include "ipa_clock.h" /** * DOC: IPA SMP2P communication with the modem @@ -153,6 +152,7 @@ static void ipa_smp2p_panic_notifier_unregister(struct ipa_smp2p *smp2p) static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id) { struct ipa_smp2p *smp2p = dev_id; + struct device *dev; int ret; mutex_lock(&smp2p->mutex); @@ -161,17 +161,20 @@ static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id) goto out_mutex_unlock; smp2p->disabled = true; /* If any others arrive, ignore them */ - /* The clock needs to be active for setup */ - ret = ipa_clock_get(smp2p->ipa); - if (WARN_ON(ret < 0)) - goto out_clock_put; + /* Power needs to be active for setup */ + dev = &smp2p->ipa->pdev->dev; + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "error %d getting power for setup\n", ret); + goto out_power_put; + } /* An error here won't cause driver shutdown, so warn if one occurs */ ret = ipa_setup(smp2p->ipa); WARN(ret != 0, "error %d from ipa_setup()\n", ret); -out_clock_put: - (void)ipa_clock_put(smp2p->ipa); +out_power_put: + (void)pm_runtime_put(dev); out_mutex_unlock: mutex_unlock(&smp2p->mutex); @@ -211,7 +214,7 @@ static void ipa_smp2p_clock_release(struct ipa *ipa) if (!ipa->smp2p->clock_on) return; - (void)ipa_clock_put(ipa); + (void)pm_runtime_put(&ipa->pdev->dev); ipa->smp2p->clock_on = false; }