From patchwork Tue Oct 14 07:15:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5078541 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8DBF6C11AC for ; Tue, 14 Oct 2014 07:16:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD4AF20142 for ; Tue, 14 Oct 2014 07:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EBF120148 for ; Tue, 14 Oct 2014 07:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754371AbaJNHQL (ORCPT ); Tue, 14 Oct 2014 03:16:11 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:40570 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754419AbaJNHQF (ORCPT ); Tue, 14 Oct 2014 03:16:05 -0400 Received: by mail-la0-f43.google.com with SMTP id mc6so8037643lab.16 for ; Tue, 14 Oct 2014 00:16:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hcBM+6ASACVvHcNcbLekqFrYDqfCRL21FucX/uNKCEw=; b=Qf0RkP7qR+ds5K1G2nsg+x2+oiPp+JTeMvvhAm1oaCKMxQtxgZTdpf4sYcVe6C/m1Y nxnFbGhVi5vUEr4KgSqEKHM+PgPxiaGwzGjnaAjwnQ8QB/kM+Xdgti+72FR4NqeWnWYp THTNIw1WyCX+GcDwg6Rjf+oXU47ALvtF86hzRMJp7Hva6l1ju1Mo7XqfzAOW/Nzf/ULl bosC8z+i4AUNMjdlTLANtJWjPtv2AEQHyrZR7ISCRI9TX6egPB0Q7jcuuTwsBG++8w/T tSDdASrpmiS5K7FVPboAqKU5FRnkEIdQOZ5/vsoHGQW4Cn85hmxpR30F7Wx28z12O//B kViA== X-Gm-Message-State: ALoCoQnmJOcB1mCgSDQiX1NStPo6yRV18OiSGsRSqYL1/DiP+/wV7CNJz+psaZ8JTUJyt0o9xDO/ X-Received: by 10.112.135.229 with SMTP id pv5mr3416361lbb.52.1413270964173; Tue, 14 Oct 2014 00:16:04 -0700 (PDT) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id a2sm5279497lbs.21.2014.10.14.00.16.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Oct 2014 00:16:03 -0700 (PDT) From: Ulf Hansson To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, Geert Uytterhoeven , Kevin Hilman , Tomasz Figa , Kukjin Kim , Philipp Zabel , Sylwester Nawrocki , "Rafael J. Wysocki" , Pavel Machek , Ulf Hansson Subject: [PATCH 5/7] [media] exynos-gsc: Fixup system PM Date: Tue, 14 Oct 2014 09:15:38 +0200 Message-Id: <1413270940-4378-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413270940-4378-1-git-send-email-ulf.hansson@linaro.org> References: <1413270940-4378-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We had several issues with the system PM support. 1) It were depending on CONFIG_PM_RUNTIME. 2) It unnecessarily tracked the suspend state in a flag. 3) If userspace through sysfs prevents runtime PM operations, could cause the device to stay in low power after a system PM resume, which is not reflected properly. Solve all the above issues by using pm_runtime_force_suspend|resume() as the system PM callbacks. Signed-off-by: Ulf Hansson --- drivers/media/platform/exynos-gsc/gsc-core.c | 41 ++-------------------------- drivers/media/platform/exynos-gsc/gsc-core.h | 3 -- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index 361a807..1b9f3d7 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -1183,46 +1183,9 @@ static int gsc_runtime_suspend(struct device *dev) } #endif -static int gsc_resume(struct device *dev) -{ - struct gsc_dev *gsc = dev_get_drvdata(dev); - unsigned long flags; - - pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state); - - /* Do not resume if the device was idle before system suspend */ - spin_lock_irqsave(&gsc->slock, flags); - if (!test_and_clear_bit(ST_SUSPEND, &gsc->state) || - !gsc_m2m_opened(gsc)) { - spin_unlock_irqrestore(&gsc->slock, flags); - return 0; - } - spin_unlock_irqrestore(&gsc->slock, flags); - - if (!pm_runtime_suspended(dev)) - return gsc_runtime_resume(dev); - - return 0; -} - -static int gsc_suspend(struct device *dev) -{ - struct gsc_dev *gsc = dev_get_drvdata(dev); - - pr_debug("gsc%d: state: 0x%lx", gsc->id, gsc->state); - - if (test_and_set_bit(ST_SUSPEND, &gsc->state)) - return 0; - - if (!pm_runtime_suspended(dev)) - return gsc_runtime_suspend(dev); - - return 0; -} - static const struct dev_pm_ops gsc_pm_ops = { - .suspend = gsc_suspend, - .resume = gsc_resume, + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_PM_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL) }; diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h b/drivers/media/platform/exynos-gsc/gsc-core.h index ef0a656..2dbaa20 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.h +++ b/drivers/media/platform/exynos-gsc/gsc-core.h @@ -48,9 +48,6 @@ #define GSC_CTX_ABORT (1 << 7) enum gsc_dev_flags { - /* for global */ - ST_SUSPEND, - /* for m2m node */ ST_M2M_OPEN, ST_M2M_RUN,