From patchwork Wed Sep 9 00:21:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1360247 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=a1TuTK4M; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BmN4d0qpHz9sTp for ; Wed, 9 Sep 2020 10:22:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729622AbgIIAVy (ORCPT ); Tue, 8 Sep 2020 20:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbgIIAVe (ORCPT ); Tue, 8 Sep 2020 20:21:34 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4391C061756 for ; Tue, 8 Sep 2020 17:21:33 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id y2so673403ilp.7 for ; Tue, 08 Sep 2020 17:21:33 -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=4AO2162Bte/ulZ9CvnofKmBqr4RKglDOxVaujf63iCE=; b=a1TuTK4MtJFjMI99KomH5XteYCTQYRkUTzIPMFhkGS3RBppusrMHJ1452iq2Akobdl mOT92hlud7Ezx19XbZ+Q+T9GD2D2QAwRSz5xDLCmueKASaMZy7Fb3pua5Yny9LJpyjay qt6AwEKqxOBcn/baHxGgfksCzuBagajdJD1ykKc5VUALsLpxNjjBwTKC0CHdWkdMD2qx nx20wh0CxVzBoW0f1K06wYNTOXdnEuNVA37OuJfS/CoWDbhAuF5OxGSlSQkGrrrpFy9O K4pJ6ejXwWaKa6UJegzqfqzGQDyIBFMGd9oYYDfdw1U7fttRIVZLGTzWtP1kF68lcN/j ukIQ== 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=4AO2162Bte/ulZ9CvnofKmBqr4RKglDOxVaujf63iCE=; b=t/EkyhclHaMKaR+vM0UiEbMq6kpIaf3Q3yhZfmxlSlP15FzcNvRp5EdVgE88zn/Rdh feG7XIFBAuvCZS2lkn50BhlCcXb1CqVmWRFBq8xy9NAn5BiYiABF7mHgQj1elESkTOb/ 4zos+LzNZEUVHkJ8stOjPXZ3eMqv14pEjC09IkSUlNnyMBSuXT9m3FEMQustvJiUsPnw 2PkKdif36Sk/Acq+fO9uVNYTxR+7mN4wRl6kffnlBEmKwpI84JwJiz3lOUs1WBROIdKV eSGjnWk4uho0d4ipjcro3JLgiW91WMFAOHSvyNiffE/L+hyuRo1F96JzUnIx/RCy/19Z rNNA== X-Gm-Message-State: AOAM532zXMIVjasdVhDyDMOE+wouMVS5araEMPQ+4MVH6xDBF6BEPCX6 QQVMGuMgJORYcQ0HduDd936RSQ== X-Google-Smtp-Source: ABdhPJxJHNJvd6vjUWApZQY6Iihzu397LyiVMDZUtmGPGDmu/Zlt6omKQG/F4Y+EvlSaPNiE71np+A== X-Received: by 2002:a92:9604:: with SMTP id g4mr1495062ilh.6.1599610893171; Tue, 08 Sep 2020 17:21:33 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id f21sm457739ioh.1.2020.09.08.17.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:21:32 -0700 (PDT) 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/5] net: ipa: use atomic exchange for suspend reference Date: Tue, 8 Sep 2020 19:21:23 -0500 Message-Id: <20200909002127.21089-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200909002127.21089-1-elder@linaro.org> References: <20200909002127.21089-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We take a single IPA clock reference to keep the clock running until we get a system suspend operation. When a system suspend request arrives, we drop that reference, and if that's the last reference (likely) we'll proceed with suspending endpoints and disabling the IPA core clock and interconnects. In most places we simply set the reference count to 0 or 1 atomically. Instead--primarily to catch coding errors--use an atomic exchange to update the reference count value, and report an error in the event the previous value was unexpected. In a few cases it's not hard to see that the error message should never be reported. Report them anyway, but add some excitement to the message by ending it with an exclamation point. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 1fdfec41e4421..6b843fc989122 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -83,6 +83,7 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) /* Take a a single clock reference to prevent suspend. All * endpoints will be resumed as a result. This reference will * be dropped when we get a power management suspend request. + * The first call activates the clock; ignore any others. */ if (!atomic_xchg(&ipa->suspend_ref, 1)) ipa_clock_get(ipa); @@ -502,13 +503,15 @@ static void ipa_resource_deconfig(struct ipa *ipa) */ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) { + struct device *dev = &ipa->pdev->dev; int ret; /* Get a clock reference to allow initialization. This reference * is held after initialization completes, and won't get dropped * unless/until a system suspend request arrives. */ - atomic_set(&ipa->suspend_ref, 1); + if (atomic_xchg(&ipa->suspend_ref, 1)) + dev_err(dev, "suspend clock reference already taken!\n"); ipa_clock_get(ipa); ipa_hardware_config(ipa); @@ -544,7 +547,8 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data) err_hardware_deconfig: ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + if (!atomic_xchg(&ipa->suspend_ref, 0)) + dev_err(dev, "suspend clock reference already dropped!\n"); return ret; } @@ -562,7 +566,8 @@ static void ipa_deconfig(struct ipa *ipa) ipa_endpoint_deconfig(ipa); ipa_hardware_deconfig(ipa); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + if (!atomic_xchg(&ipa->suspend_ref, 0)) + dev_err(&ipa->pdev->dev, "no suspend clock reference\n"); } static int ipa_firmware_load(struct device *dev) @@ -913,7 +918,8 @@ static int ipa_suspend(struct device *dev) struct ipa *ipa = dev_get_drvdata(dev); ipa_clock_put(ipa); - atomic_set(&ipa->suspend_ref, 0); + if (!atomic_xchg(&ipa->suspend_ref, 0)) + dev_err(dev, "suspend: missing suspend clock reference\n"); return 0; } @@ -933,7 +939,8 @@ static int ipa_resume(struct device *dev) /* This clock reference will keep the IPA out of suspend * until we get a power management suspend request. */ - atomic_set(&ipa->suspend_ref, 1); + if (atomic_xchg(&ipa->suspend_ref, 1)) + dev_err(dev, "resume: duplicate suspend clock reference\n"); ipa_clock_get(ipa); return 0; From patchwork Wed Sep 9 00:21: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: 1360254 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hq5DELpR; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BmN5D2fylz9sTS for ; Wed, 9 Sep 2020 10:22:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729993AbgIIAWh (ORCPT ); Tue, 8 Sep 2020 20:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728633AbgIIAVl (ORCPT ); Tue, 8 Sep 2020 20:21:41 -0400 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 DF63EC061786 for ; Tue, 8 Sep 2020 17:21:34 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id u126so1286015iod.12 for ; Tue, 08 Sep 2020 17:21:34 -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=CLkAtO8yV6hC5XQeCIKds/Y/O7Y4arloVOta9bNoDaY=; b=hq5DELpR+vU0Y9o5e2HUj0mATndL/qH/lvWoOo5vpdPAnLmfDyqNVW2XmT94onsQsr qsowN6z3HwhMa7tuAn8DwOQrm6Va35JvqXV2sda28FRc5mgRitvOeT2mN3Ane0hyyDbU WYrH9+XjpJoYQz6usO7IoYk33gAKTd8gGyjs5nC9rd7DQk67XFE+YfhvlwrOzJJaf83w jqsDM1wexcB9D9Pc1af4smM3lwmMrlpX00yLkLx5ky2Q7GJRcpEDoZJ7+Ax5AZrPGVJZ hlgEBHyUZMu0dGFEZ5sa2cJ+/fb8ifo+9EtvXPcHkwQ4eFTqslM3Yt3+exuWte+6VHRt QulQ== 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=CLkAtO8yV6hC5XQeCIKds/Y/O7Y4arloVOta9bNoDaY=; b=i4Bq7UBZGxKE4I545VCsmBaPcQMVk53pSYANLzRwKg6n7zXxgKReoxFF84SJcXm+KL xyez4AiXMmvomEfv/2kEFZQq7U5XNId1jNleDNKXTXJ1BnuNKlFOH9Gn8IqsXVjyMkXM sXrunUYuUepW7EUkc6Mnd6afK6CV3sjkgbtub7pSZrfyENLHvU75ezoQW3a30Veov9w2 TWcGG/BxX3+9Y80/6RUpw8tTfYfl42FpnvY55eIM+HUAIIjh05PJp6pWd328Kh4/bPyq hyix3E7O7tKEw4sXzx4fPZrjBshNbpfa9kRnac4Ey7xMiKRHbRprkzn0MbMVKdebktFz EjEQ== X-Gm-Message-State: AOAM530Wgcce380c5vAD+ZsnV/XYn14jF8fFJ7klBCR12N5r40pfcnT+ 8jRpHW+PKi27/0EtcYtM/yYQSg== X-Google-Smtp-Source: ABdhPJyzaytMOdMELvsLiAoxAUyb2niwFIKcmbNaUbQfBW1zi44brpxBXl/X/F5gRw/0l7C1M2zV+Q== X-Received: by 2002:a02:ac5:: with SMTP id 188mr1673917jaw.79.1599610894247; Tue, 08 Sep 2020 17:21:34 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id f21sm457739ioh.1.2020.09.08.17.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:21:33 -0700 (PDT) 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/5] net: ipa: manage endpoints separate from clock Date: Tue, 8 Sep 2020 19:21:24 -0500 Message-Id: <20200909002127.21089-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200909002127.21089-1-elder@linaro.org> References: <20200909002127.21089-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, when (before) the last IPA clock reference is dropped, all endpoints are suspended. And whenever the first IPA clock reference is taken, all endpoints are resumed (or started). In most cases there's no need to start endpoints when the clock starts. So move the calls to ipa_endpoint_suspend() and ipa_endpoint_resume() out of ipa_clock_put() and ipa_clock_get(), respectiely. Instead, only suspend endpoints when handling a system suspend, and only resume endpoints when handling a system resume. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_clock.c | 4 ---- drivers/net/ipa/ipa_main.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_clock.c b/drivers/net/ipa/ipa_clock.c index 398f2e47043d8..f2d61c35ef941 100644 --- a/drivers/net/ipa/ipa_clock.c +++ b/drivers/net/ipa/ipa_clock.c @@ -229,8 +229,6 @@ void ipa_clock_get(struct ipa *ipa) goto out_mutex_unlock; } - ipa_endpoint_resume(ipa); - atomic_inc(&clock->count); out_mutex_unlock: @@ -249,8 +247,6 @@ void ipa_clock_put(struct ipa *ipa) if (!atomic_dec_and_mutex_lock(&clock->count, &clock->mutex)) return; - ipa_endpoint_suspend(ipa); - ipa_clock_disable(ipa); mutex_unlock(&clock->mutex); diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 6b843fc989122..b8e4a2532fc1a 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -917,6 +917,8 @@ static int ipa_suspend(struct device *dev) { struct ipa *ipa = dev_get_drvdata(dev); + ipa_endpoint_suspend(ipa); + ipa_clock_put(ipa); if (!atomic_xchg(&ipa->suspend_ref, 0)) dev_err(dev, "suspend: missing suspend clock reference\n"); @@ -943,6 +945,8 @@ static int ipa_resume(struct device *dev) dev_err(dev, "resume: duplicate suspend clock reference\n"); ipa_clock_get(ipa); + ipa_endpoint_resume(ipa); + return 0; } From patchwork Wed Sep 9 00:21: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: 1360251 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=D+4idf1N; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BmN4z1nTVz9sTH for ; Wed, 9 Sep 2020 10:22:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729941AbgIIAWY (ORCPT ); Tue, 8 Sep 2020 20:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729005AbgIIAVl (ORCPT ); Tue, 8 Sep 2020 20:21:41 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C88AC061796 for ; Tue, 8 Sep 2020 17:21:36 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id a8so706686ilk.1 for ; Tue, 08 Sep 2020 17:21:36 -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=OPjPRK2p71t9ZdCjb3Zea5jYz+oh8o7PLedtAuj54eo=; b=D+4idf1NZ8wKX+Bvh68xw2GihYbk8Qrdt50Io/Apvp1qPCja9YQMLuhYNc1SwEtQ0d pRabs+i056pIR1SzF5zNKXdS3jwfmE9D6vm4W1INKUsfuK35MyUKZPi6G2YmNDGwlObH bG2vUjwff2txxqMpwnlVvP1SYKohPJ7+t24tNF1/CGd1Z2Jg9QPtapDL8bVHcjds3Az2 HaqCT8rGI1rT2StYCoV7MMMPDY2bV3wO8VMldMU3PJJO/olsqMmePxogbIsKIgZFFS6t jT9m7keaOEDXMcmXW8O9C7ARqeTcsj1mfIe9QAdMmfZKGqmgMdE8sTCiEiLPYaeNSgJN SOcA== 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=OPjPRK2p71t9ZdCjb3Zea5jYz+oh8o7PLedtAuj54eo=; b=i7etoOtCZ6pbcLvpkrBHyxKhFOiSabMcYZOx8z6ODm3jSpopXYgLlEzqdxugHOcThI ItTwXe5K5IHdMAFZe/7hMzdiIYAEzDlL7cKSC0YIellrL4r6wEYmKPBYz8L8/MaXOI+6 kuvXY2v1vtCJ+ktUfAuUIbfJPRh/9qJGx5OrtRf2AFQLch7LjuzutVnsBbs8MB+gDSCa Mt0BgDzrnTBjIiW7uSuIlEBh4zBcN9Npmk7/1At+o1gbVaW5b2zqpQhNCyZcJQcQvF41 FZ2UZW8CeuKmEVBf8VnAei9JIjE43DngUEsu0GcLfThL3O+MC6XRyjttv61r4yry0PaR ZR5w== X-Gm-Message-State: AOAM532ik+qfXc/JwU0o/Wn2Qw01Q8rwqSDHcT3L8SL7etG4Ei9jt0WF QSsFq8oiZyXHak7xrx5fcvT88A== X-Google-Smtp-Source: ABdhPJz61ej4TTXIIjTL9Va5qRhEZ65lluaOfX0jgyU8NxspTHrOeg3vsdHmC01QYwnbGUqOhraHNA== X-Received: by 2002:a05:6e02:1023:: with SMTP id o3mr1396823ilj.141.1599610895311; Tue, 08 Sep 2020 17:21:35 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id f21sm457739ioh.1.2020.09.08.17.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:21:34 -0700 (PDT) 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/5] net: ipa: use device_init_wakeup() Date: Tue, 8 Sep 2020 19:21:25 -0500 Message-Id: <20200909002127.21089-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200909002127.21089-1-elder@linaro.org> References: <20200909002127.21089-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The call to wakeup_source_register() in ipa_probe() does not do what it was intended to do. Call device_init_wakeup() in ipa_setup() instead, to set the IPA device as wakeup-capable and to initially enable wakeup capability. When we receive a SUSPEND interrupt, call pm_wakeup_dev_event() with a zero processing time, to simply call for a resume without any other processing. The ipa_resume() call will take care of waking things up again, and will handle receiving the packet. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa.h | 2 -- drivers/net/ipa/ipa_main.c | 43 ++++++++++++++++---------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/net/ipa/ipa.h b/drivers/net/ipa/ipa.h index 407fee841a9a8..a1adc308e030f 100644 --- a/drivers/net/ipa/ipa.h +++ b/drivers/net/ipa/ipa.h @@ -104,8 +104,6 @@ struct ipa { void *zero_virt; size_t zero_size; - struct wakeup_source *wakeup_source; - /* Bit masks indicating endpoint state */ u32 available; /* supported by hardware */ u32 filter_map; diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index b8e4a2532fc1a..92ea6a811ae31 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -75,18 +75,19 @@ * @ipa: IPA pointer * @irq_id: IPA interrupt type (unused) * - * When in suspended state, the IPA can trigger a resume by sending a SUSPEND - * IPA interrupt. + * If an RX endpoint is in suspend state, and the IPA has a packet + * destined for that endpoint, the IPA generates a SUSPEND interrupt + * to inform the AP that it should resume the endpoint. If we get + * one of these interrupts we just resume everything. */ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { - /* Take a a single clock reference to prevent suspend. All - * endpoints will be resumed as a result. This reference will - * be dropped when we get a power management suspend request. - * The first call activates the clock; ignore any others. + /* Just report the event, and let system resume handle the rest. + * More than one endpoint could signal this; if so, ignore + * all but the first. */ if (!atomic_xchg(&ipa->suspend_ref, 1)) - ipa_clock_get(ipa); + pm_wakeup_dev_event(&ipa->pdev->dev, 0, true); /* Acknowledge/clear the suspend interrupt on all endpoints */ ipa_interrupt_suspend_clear_all(ipa->interrupt); @@ -107,6 +108,7 @@ int ipa_setup(struct ipa *ipa) { struct ipa_endpoint *exception_endpoint; struct ipa_endpoint *command_endpoint; + struct device *dev = &ipa->pdev->dev; int ret; /* Setup for IPA v3.5.1 has some slight differences */ @@ -124,6 +126,10 @@ int ipa_setup(struct ipa *ipa) ipa_uc_setup(ipa); + ret = device_init_wakeup(dev, true); + if (ret) + goto err_uc_teardown; + ipa_endpoint_setup(ipa); /* We need to use the AP command TX endpoint to perform other @@ -159,7 +165,7 @@ int ipa_setup(struct ipa *ipa) ipa->setup_complete = true; - dev_info(&ipa->pdev->dev, "IPA driver setup completed successfully\n"); + dev_info(dev, "IPA driver setup completed successfully\n"); return 0; @@ -174,6 +180,8 @@ int ipa_setup(struct ipa *ipa) ipa_endpoint_disable_one(command_endpoint); err_endpoint_teardown: ipa_endpoint_teardown(ipa); + (void)device_init_wakeup(dev, false); +err_uc_teardown: ipa_uc_teardown(ipa); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); ipa_interrupt_teardown(ipa->interrupt); @@ -201,6 +209,7 @@ static void ipa_teardown(struct ipa *ipa) command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; ipa_endpoint_disable_one(command_endpoint); ipa_endpoint_teardown(ipa); + (void)device_init_wakeup(&ipa->pdev->dev, false); ipa_uc_teardown(ipa); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); ipa_interrupt_teardown(ipa->interrupt); @@ -714,7 +723,6 @@ static void ipa_validate_build(void) */ static int ipa_probe(struct platform_device *pdev) { - struct wakeup_source *wakeup_source; struct device *dev = &pdev->dev; const struct ipa_data *data; struct ipa_clock *clock; @@ -763,19 +771,11 @@ static int ipa_probe(struct platform_device *pdev) goto err_clock_exit; } - /* Create a wakeup source. */ - wakeup_source = wakeup_source_register(dev, "ipa"); - if (!wakeup_source) { - /* The most likely reason for failure is memory exhaustion */ - ret = -ENOMEM; - goto err_clock_exit; - } - /* Allocate and initialize the IPA structure */ ipa = kzalloc(sizeof(*ipa), GFP_KERNEL); if (!ipa) { ret = -ENOMEM; - goto err_wakeup_source_unregister; + goto err_clock_exit; } ipa->pdev = pdev; @@ -783,7 +783,6 @@ static int ipa_probe(struct platform_device *pdev) ipa->modem_rproc = rproc; ipa->clock = clock; atomic_set(&ipa->suspend_ref, 0); - ipa->wakeup_source = wakeup_source; ipa->version = data->version; ret = ipa_reg_init(ipa); @@ -862,8 +861,6 @@ static int ipa_probe(struct platform_device *pdev) ipa_reg_exit(ipa); err_kfree_ipa: kfree(ipa); -err_wakeup_source_unregister: - wakeup_source_unregister(wakeup_source); err_clock_exit: ipa_clock_exit(clock); err_rproc_put: @@ -877,11 +874,8 @@ static int ipa_remove(struct platform_device *pdev) struct ipa *ipa = dev_get_drvdata(&pdev->dev); struct rproc *rproc = ipa->modem_rproc; struct ipa_clock *clock = ipa->clock; - struct wakeup_source *wakeup_source; int ret; - wakeup_source = ipa->wakeup_source; - if (ipa->setup_complete) { ret = ipa_modem_stop(ipa); if (ret) @@ -898,7 +892,6 @@ static int ipa_remove(struct platform_device *pdev) ipa_mem_exit(ipa); ipa_reg_exit(ipa); kfree(ipa); - wakeup_source_unregister(wakeup_source); ipa_clock_exit(clock); rproc_put(rproc); From patchwork Wed Sep 9 00:21: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: 1360246 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=GtxiWvZy; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BmN4X0rbwz9sTN for ; Wed, 9 Sep 2020 10:22:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729779AbgIIAVz (ORCPT ); Tue, 8 Sep 2020 20:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728971AbgIIAVl (ORCPT ); Tue, 8 Sep 2020 20:21:41 -0400 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 C1947C061798 for ; Tue, 8 Sep 2020 17:21:37 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id q6so641666ild.12 for ; Tue, 08 Sep 2020 17:21:37 -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=C+4RJZne7XWnSNpMScCQkiPgvon7cqSHe4LlitFTkv0=; b=GtxiWvZyyPJXhAnEqPmFRyB1Iwm/yOJg+CcAcbtkzQyjJlbWzaEyhnOQjzqBwXKo3D 9JQyr17zUT2RnvfiYlhhg3oFOt7Ogs/pthIq4Jxc0vPVcajwml3Ip/jlx14KcCPydm4O JYB143HO5vjRwfNMfCVFSpFU7oJmHFoVbV/b2CaOVhksmyiM/8WYLTfiQuq45Nl30hRr l7PdGLTfb8XG17Fo1zl2RODD1wxEPrqzK8Pf/Oq7xbUWViY87GPdn2Wl72j02Te8ayT4 R06fi0wDnpGU879RpFlzPmpmyDbjXusF9id9XZHmuRMO4Gf8WbAUpRENTeOMxVVFDmDT EjaA== 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=C+4RJZne7XWnSNpMScCQkiPgvon7cqSHe4LlitFTkv0=; b=jZJNB6CVUE7jRWH52hJlsBfjD7wb3NQchOiKhae5QhhALbT0MCVG/nrVh68cTeQ6zf hUZhQlrU3/YQ+vrzK2rKErcwUg2HBOo72YmDucMd0p571f5TwPkwa0K3e9ik3r5eqMlX N38CfRDyNuE4oBHVS0uHHFsqqO77ZEUEp1RKwrSVCg2ZNvpahFjvmXsOvyn+q0QWE556 4+DwbIBItsy46eGuRIa4zhfZibiwFiO2qm0xjtxLSOq4H3I0/2MOXtXb7bmhpJSUnHt+ W6wyvfgueDV6WeU2hcW+VEI77iEyVeMHeTK7QE5rp9uBHadVhQZo3D9LR15mYDuYMuBT S6mQ== X-Gm-Message-State: AOAM533Gkm3T9vLiUWOMZ9+CK3smIw+qmAoGOgOC5SH0nyvQ8dAZBZYn str4nCRgUkg6qySgjOS/oSLhJA== X-Google-Smtp-Source: ABdhPJyQs0NlFJVVQcPt1Fprj0cFZca4Dlw3CpJSD9OOToUdZ7XtGb4Nz9Twt8m78EsKb3vgQWKKkg== X-Received: by 2002:a05:6e02:1205:: with SMTP id a5mr1440543ilq.167.1599610896416; Tue, 08 Sep 2020 17:21:36 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id f21sm457739ioh.1.2020.09.08.17.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:21:35 -0700 (PDT) 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/5] net: ipa: enable wakeup on IPA interrupt Date: Tue, 8 Sep 2020 19:21:26 -0500 Message-Id: <20200909002127.21089-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200909002127.21089-1-elder@linaro.org> References: <20200909002127.21089-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that we handle wakeup interrupts properly, arrange for the IPA interrupt to be treated as a wakeup interrupt. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 90353987c45fc..cc1ea28f7bc2e 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -237,8 +237,16 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa) goto err_kfree; } + ret = enable_irq_wake(irq); + if (ret) { + dev_err(dev, "error %d enabling wakeup for \"ipa\" IRQ\n", ret); + goto err_free_irq; + } + return interrupt; +err_free_irq: + free_irq(interrupt->irq, interrupt); err_kfree: kfree(interrupt); @@ -248,6 +256,12 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa) /* Tear down the IPA interrupt framework */ void ipa_interrupt_teardown(struct ipa_interrupt *interrupt) { + struct device *dev = &interrupt->ipa->pdev->dev; + int ret; + + ret = disable_irq_wake(interrupt->irq); + if (ret) + dev_err(dev, "error %d disabling \"ipa\" IRQ wakeup\n", ret); free_irq(interrupt->irq, interrupt); kfree(interrupt); } From patchwork Wed Sep 9 00:21: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: 1360252 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=K1ikBxwO; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BmN551bQPz9sTN for ; Wed, 9 Sep 2020 10:22:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729876AbgIIAWW (ORCPT ); Tue, 8 Sep 2020 20:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbgIIAVl (ORCPT ); Tue, 8 Sep 2020 20:21:41 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE443C061799 for ; Tue, 8 Sep 2020 17:21:38 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id t18so67620ilp.5 for ; Tue, 08 Sep 2020 17:21:38 -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=GXt6HV+Ir2mOjyqv+jsDtLLXzMvpXAXcGItzvsZha8c=; b=K1ikBxwOY2ZfMmKbyNAEfa+2REjTqMN5eToafYQxqDBbSkbgmYHhxvACi/tyeBGRuU YYlVJsbOjE1qn4oxIJMnuCo2jsxS080MXAa4SsC+XWNS257yjSYa3VBOFh47Cox/ZfKA MrFt1VB9WWLDTG8FYVgjeOtWDiwnXS0PIG403ri43pQKqqpnf1/DDayLHncvpXuT+fR/ YUJhPqJvB0IoSw9DiUJ/G7uR2HGzAAahhgrEz+ao7bb67jFJjrpDVYqYvwiv0KRyE6gI TjVyR6PeWVZsQm0KVeM7LKeAydLYQLR7tHOlSKvxMdeQB0R9wxuhC//7VP5+5i/wBBKp U/Fg== 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=GXt6HV+Ir2mOjyqv+jsDtLLXzMvpXAXcGItzvsZha8c=; b=W2PtnmjrLc18y9ezjlNZZSQYeK9udHtNUHLJ4AhoP3+o5H++F9tOuXw8Hwhds9JrZ/ to2fWhm4ZJoP1pC2CEfUmBmbkrDbwvB9WGtzcz1retCxRjJsZkWDwuSa4sNwSXgLxRTN Ay3FUXbqCImkIsO+c4gVSZQi5uhRSd0M0aMUsrSloWKGoiazvqJe4dXoViuUov3T5ICx J+dDf6xEtYdTLOvxCBN/gUnjOtSjXcGa7hadVff5rmyz2L0ccm2qedUV7BvXL6blatfm VCyM8rawaK5hnnMU3rLS9OeO4htEdUwum8ABvXYEnJnqt1YclBFBvWyo2JtXT/Mjwk9Y +G8w== X-Gm-Message-State: AOAM531Yb5gjsoTG/iOwJMTbe7aYEBdPY5oo4EDWUhCcIZ9dmUeF1MQy Abz+wBLvPvV4GAQvfmi2bgZFeQ== X-Google-Smtp-Source: ABdhPJz8Y/hkeZJj/oWXAMsOPa7lCT6ojQegClkfzBAlqYnHR0bugPQcNg9H8Kq5XTc8HyJcAi3YAg== X-Received: by 2002:a92:9145:: with SMTP id t66mr1300389ild.305.1599610897475; Tue, 08 Sep 2020 17:21:37 -0700 (PDT) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id f21sm457739ioh.1.2020.09.08.17.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:21:37 -0700 (PDT) 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/5] net: ipa: do not enable GSI interrupt for wakeup Date: Tue, 8 Sep 2020 19:21:27 -0500 Message-Id: <20200909002127.21089-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200909002127.21089-1-elder@linaro.org> References: <20200909002127.21089-1-elder@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We now trigger a system resume when we receive an IPA SUSPEND interrupt. We should *not* wake up on GSI interrupts. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 17 ++++------------- drivers/net/ipa/gsi.h | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 0e63d35320aaf..cb75f7d540571 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1987,31 +1987,26 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch, } gsi->irq = irq; - ret = enable_irq_wake(gsi->irq); - if (ret) - dev_warn(dev, "error %d enabling gsi wake irq\n", ret); - gsi->irq_wake_enabled = !ret; - /* Get GSI memory range and map it */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi"); if (!res) { dev_err(dev, "DT error getting \"gsi\" memory property\n"); ret = -ENODEV; - goto err_disable_irq_wake; + goto err_free_irq; } size = resource_size(res); if (res->start > U32_MAX || size > U32_MAX - res->start) { dev_err(dev, "DT memory resource \"gsi\" out of range\n"); ret = -EINVAL; - goto err_disable_irq_wake; + goto err_free_irq; } gsi->virt = ioremap(res->start, size); if (!gsi->virt) { dev_err(dev, "unable to remap \"gsi\" memory\n"); ret = -ENOMEM; - goto err_disable_irq_wake; + goto err_free_irq; } ret = gsi_channel_init(gsi, prefetch, count, data, modem_alloc); @@ -2025,9 +2020,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch, err_iounmap: iounmap(gsi->virt); -err_disable_irq_wake: - if (gsi->irq_wake_enabled) - (void)disable_irq_wake(gsi->irq); +err_free_irq: free_irq(gsi->irq, gsi); return ret; @@ -2038,8 +2031,6 @@ void gsi_exit(struct gsi *gsi) { mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); - if (gsi->irq_wake_enabled) - (void)disable_irq_wake(gsi->irq); free_irq(gsi->irq, gsi); iounmap(gsi->virt); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 061312773df09..3f9f29d531c43 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -150,7 +150,6 @@ struct gsi { struct net_device dummy_dev; /* needed for NAPI */ void __iomem *virt; u32 irq; - bool irq_wake_enabled; u32 channel_count; u32 evt_ring_count; struct gsi_channel channel[GSI_CHANNEL_COUNT_MAX];