Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3459704pxp; Tue, 8 Mar 2022 15:03:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZc8wNSJTSj5Z4p2Una1ccqo25KDbTERBMBZWaW8j+lxjz1PWDSOHVw97UaWB+HnmGR65v X-Received: by 2002:a17:90a:4f0b:b0:1be:e31f:bd38 with SMTP id p11-20020a17090a4f0b00b001bee31fbd38mr7320891pjh.76.1646780613621; Tue, 08 Mar 2022 15:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646780613; cv=none; d=google.com; s=arc-20160816; b=KZO5TqLorNFsAGT0iNWXl2n3dHjMMAVlRGjWMn7FFMLiASzGPykDBC2+Lbs/J+G0Op ud8pSlj/zMBbDJMxCeGzIaYv6OegUylGDzSYsnApT9jubgLp4NmpF311tIU+UNhrzcax 60VvATARxlyX+VLSxduP9z1WMqzCHJsGr1THg4CrYtdLhdBIHReri+wm2VUW6yYOhgxS k5A5P0armVz2VsQPTCqE60fpoyUjKz6ZPhNouyc2mN4fWmx5kb9Ip83IioqylYQk61g/ AriQBmVa1KFQGwwk/eS4X9UJ3lRhv+/DWATH7hjJPLN/RFDVwuRDg6GscH2rF+af7cOp +BSQ== 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=43YkTg2tSTH8TFGxr2d6rutnnfdvhDE8rCQmejpk+HA=; b=UzE9+KhpZMsN+caO/UBY/hZVzE3S8S/R6EavP5ygifYtV4W2UNPo3juik2tlj77T7n 0ucyCHXdWdvvlVPN0QZ1kCqAsYA9sgz6a6pPSonA9Dl79UTrm/lTAKOfnftkaGR9cdu6 1TyUXiUfkRD3SUnhjeHSKrGzZE1ktZ+nSA8H9j629nkV0Qwle1DnrsMHlcRnRYJr+SDt EDrI1Pr1izFG6zbZLs66milC0QVD+TXj7L2hGhjYF+bbp/JRwZI3YqVbHVdQLs3L1y0X Nn5T7mak3C/gRcMVmITM9pighw6sOJgUiB39Bg2tSMBJIDp6dMejTQNVPFSp4O32yL0I L5JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ab6VTw3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c28-20020a634e1c000000b00374d6b4991dsi145880pgb.480.2022.03.08.15.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ab6VTw3S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA980BF6E; Tue, 8 Mar 2022 15:02:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348418AbiCHQjb (ORCPT + 99 others); Tue, 8 Mar 2022 11:39:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348400AbiCHQj2 (ORCPT ); Tue, 8 Mar 2022 11:39:28 -0500 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97E494F45C for ; Tue, 8 Mar 2022 08:38:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646757511; x=1678293511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jFUH4GegF6d5+JeCR9dkmblPZiL+BW4LtcHSJPjMPDI=; b=ab6VTw3S2MkuI4uSFKScfVkLBMhRbgv5EzwZp02SGghQ1SCnWQimoHYh XzwYCG5dRFuF2Z/TOFoSytR1F0W58dJob4rBpf5C5eqDvRJx9sh7LvlQc csYut/w1fbNHEUfUTq/wmKhoOMNWFgvPzaksFj6eWizn6UsDP34gozcpq 2CZDrHJiwTr9Ugnh1optWne5UBTS22aU9vmXPrH7xRUCBREsyO4Z0aj4Y ykmGX2MZJAWPkrJ/mkbXUfb1i2IupsmmA5vDHQlAtVldBPZRw0ekPMMEZ l7PZ9EIoUBAjXwhTOJH/7v/Ih5ChcNYuaeiyrrlOEehPQLVe9+GXRVJ6O A==; X-IronPort-AV: E=McAfee;i="6200,9189,10280"; a="315450345" X-IronPort-AV: E=Sophos;i="5.90,165,1643702400"; d="scan'208";a="315450345" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2022 08:38:31 -0800 X-IronPort-AV: E=Sophos;i="5.90,165,1643702400"; d="scan'208";a="537630941" Received: from sannilnx.jer.intel.com ([10.12.231.73]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2022 08:38:20 -0800 From: Alexander Usyskin To: Greg Kroah-Hartman , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Tvrtko Ursulin Cc: Tomas Winkler , Alexander Usyskin , Vitaly Lubart , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 4/5] mei: gsc: add runtime pm handlers Date: Tue, 8 Mar 2022 18:36:53 +0200 Message-Id: <20220308163654.942820-5-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220308163654.942820-1-alexander.usyskin@intel.com> References: <20220308163654.942820-1-alexander.usyskin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomas Winkler Implement runtime handlers for mei-gsc, to track idle state of the device properly. CC: Rodrigo Vivi Signed-off-by: Tomas Winkler Signed-off-by: Alexander Usyskin --- drivers/misc/mei/gsc-me.c | 67 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/misc/mei/gsc-me.c b/drivers/misc/mei/gsc-me.c index cf427f6fdec9..dac482ddab51 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -152,7 +152,72 @@ static int __maybe_unused mei_gsc_pm_resume(struct device *device) return 0; } -static SIMPLE_DEV_PM_OPS(mei_gsc_pm_ops, mei_gsc_pm_suspend, mei_gsc_pm_resume); +static int __maybe_unused mei_gsc_pm_runtime_idle(struct device *device) +{ + struct mei_device *dev = dev_get_drvdata(device); + + if (!dev) + return -ENODEV; + if (mei_write_is_idle(dev)) + pm_runtime_autosuspend(device); + + return -EBUSY; +} + +static int __maybe_unused mei_gsc_pm_runtime_suspend(struct device *device) +{ + struct mei_device *dev = dev_get_drvdata(device); + struct mei_me_hw *hw; + int ret; + + if (!dev) + return -ENODEV; + + mutex_lock(&dev->device_lock); + + if (mei_write_is_idle(dev)) { + hw = to_me_hw(dev); + hw->pg_state = MEI_PG_ON; + ret = 0; + } else { + ret = -EAGAIN; + } + + mutex_unlock(&dev->device_lock); + + return ret; +} + +static int __maybe_unused mei_gsc_pm_runtime_resume(struct device *device) +{ + struct mei_device *dev = dev_get_drvdata(device); + struct mei_me_hw *hw; + irqreturn_t irq_ret; + + if (!dev) + return -ENODEV; + + mutex_lock(&dev->device_lock); + + hw = to_me_hw(dev); + hw->pg_state = MEI_PG_OFF; + + mutex_unlock(&dev->device_lock); + + irq_ret = mei_me_irq_thread_handler(1, dev); + if (irq_ret != IRQ_HANDLED) + dev_err(dev->dev, "thread handler fail %d\n", irq_ret); + + return 0; +} + +static const struct dev_pm_ops mei_gsc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mei_gsc_pm_suspend, + mei_gsc_pm_resume) + SET_RUNTIME_PM_OPS(mei_gsc_pm_runtime_suspend, + mei_gsc_pm_runtime_resume, + mei_gsc_pm_runtime_idle) +}; static const struct auxiliary_device_id mei_gsc_id_table[] = { { -- 2.32.0