From patchwork Mon Nov 9 10:57:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 321090 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=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 E76C5C56201 for ; Mon, 9 Nov 2020 10:57:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D2A420678 for ; Mon, 9 Nov 2020 10:57:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BHg3RVsP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727774AbgKIK5h (ORCPT ); Mon, 9 Nov 2020 05:57:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52661 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbgKIK5g (ORCPT ); Mon, 9 Nov 2020 05:57:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604919455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VPG94ysVOebXbhN6vHzcu17giV7+YhMXljfh3FMPh2U=; b=BHg3RVsP6jNDo7ed+2KWn+28K3s7Lxdk03bKW7xSJLLv00pVUUWEb9+msk848qFNVaHpZx +vMg2RA2AlE958ctkEeLrtRFbYiiIvE7gH6QutaKfzE+J4xJQohKChcejKvNZwPeXp2gSF +uGQlmtwfngvnGxJgVgKhydi+xDlY0Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-BOFS-y12NjKwHJNILYEKgw-1; Mon, 09 Nov 2020 05:57:33 -0500 X-MC-Unique: BOFS-y12NjKwHJNILYEKgw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C7B61005504; Mon, 9 Nov 2020 10:57:32 +0000 (UTC) Received: from x1.localdomain (ovpn-114-3.ams2.redhat.com [10.36.114.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EC606EF4B; Mon, 9 Nov 2020 10:57:31 +0000 (UTC) From: Hans de Goede To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: Hans de Goede , Andy Shevchenko , linux-pwm@vger.kernel.org, linux-acpi@vger.kernel.org, Andy Shevchenko Subject: [PATCH v2 1/3] pwm: lpss: Log error from pwm_lpss_is_updating() if the update bit is still set Date: Mon, 9 Nov 2020 11:57:24 +0100 Message-Id: <20201109105726.121512-2-hdegoede@redhat.com> In-Reply-To: <20201109105726.121512-1-hdegoede@redhat.com> References: <20201109105726.121512-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org pwm_lpss_is_updating() does a sanity check which should never fail. If the check does actually fail that is worth logging an error, especially since this means that we will skip making the requested changes to the PWM settings. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/pwm/pwm-lpss.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index 3444c56b4bed..939de93c157b 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c @@ -76,7 +76,12 @@ static int pwm_lpss_wait_for_update(struct pwm_device *pwm) static inline int pwm_lpss_is_updating(struct pwm_device *pwm) { - return (pwm_lpss_read(pwm) & PWM_SW_UPDATE) ? -EBUSY : 0; + if (pwm_lpss_read(pwm) & PWM_SW_UPDATE) { + dev_err(pwm->chip->dev, "PWM_SW_UPDATE is still set, skipping update\n"); + return -EBUSY; + } + + return 0; } static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm, From patchwork Mon Nov 9 10:57:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 321089 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=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 2305AC56201 for ; Mon, 9 Nov 2020 10:57:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF3D2206E3 for ; Mon, 9 Nov 2020 10:57:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gptLYbK+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729195AbgKIK5l (ORCPT ); Mon, 9 Nov 2020 05:57:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50869 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbgKIK5k (ORCPT ); Mon, 9 Nov 2020 05:57:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604919459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFQ3NXM+Ll2VDtzUJoZCbgvc0RCST66Ng0luYaRPOdM=; b=gptLYbK+G0C4UhviJndoOgg4p3nbxPGU+zc7PxKaqgyF2pH40OtcxwP6xlpbg5ZLPyvZjd LSyu9QmUdvsP5hztnLXsCoLAnWi9sM0pkptOS+huAY4qwvnYSDKJwLglLdy27vhyLf+ik6 U7lh4mfJMyr+THaqBnNBbgld4U/Lv8U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350--V8jmxqEMeSDz1gB4i3GwQ-1; Mon, 09 Nov 2020 05:57:37 -0500 X-MC-Unique: -V8jmxqEMeSDz1gB4i3GwQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43FE357201; Mon, 9 Nov 2020 10:57:36 +0000 (UTC) Received: from x1.localdomain (ovpn-114-3.ams2.redhat.com [10.36.114.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6A546EF45; Mon, 9 Nov 2020 10:57:34 +0000 (UTC) From: Hans de Goede To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= Cc: Hans de Goede , Andy Shevchenko , linux-pwm@vger.kernel.org, linux-acpi@vger.kernel.org, Andy Shevchenko Subject: [PATCH v2 3/3] pwm: lpss: Set DPM_FLAG_SMART_SUSPEND on Cherry Trail devices Date: Mon, 9 Nov 2020 11:57:26 +0100 Message-Id: <20201109105726.121512-4-hdegoede@redhat.com> In-Reply-To: <20201109105726.121512-1-hdegoede@redhat.com> References: <20201109105726.121512-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org As the comment above the code setting the DPM_FLAG_NO_DIRECT_COMPLETE flag explains: /* * On Cherry Trail devices the GFX0._PS0 AML checks if the controller * is on and if it is not on it turns it on and restores what it * believes is the correct state to the PWM controller. * Because of this we must disallow direct-complete, which keeps the * controller (runtime)suspended, on resume to avoid 2 issues: * 1. The controller getting turned on without the linux-pm code * knowing about this. On devices where the controller is unused * this causes it to stay on during the next suspend causing high * battery drain (because S0i3 is not reached) * 2. The state restoring code unexpectedly messing with the controller */ The pm-core must not skip resume to avoid the GFX0._PS0 AML code messing with the PWM controller behind our back. But leaving the controller runtime-suspended (skipping runtime-resume + normal-suspend) during suspend is fine. Set the DPM_FLAG_SMART_SUSPEND flag to allow this. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v2: - Extend comment to explain why the DPM_FLAG_SMART_SUSPEND is set --- drivers/pwm/pwm-lpss-platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c index ac33861edb48..986786be1e49 100644 --- a/drivers/pwm/pwm-lpss-platform.c +++ b/drivers/pwm/pwm-lpss-platform.c @@ -69,9 +69,13 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev) * this causes it to stay on during the next suspend causing high * battery drain (because S0i3 is not reached) * 2. The state restoring code unexpectedly messing with the controller + * + * Leaving the controller runtime-suspended (skipping runtime-resume + + * normal-suspend) during suspend is fine. */ if (info->other_devices_aml_touches_pwm_regs) - dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE); + dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE| + DPM_FLAG_SMART_SUSPEND); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev);