Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1014553yba; Thu, 4 Apr 2019 02:27:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqznmv99ClSQDtCEnH7Toih29klooKx3bzf4PrGDWFSmB9LyaP0FhXPFhHAXbGzVboz9F/43 X-Received: by 2002:a17:902:be09:: with SMTP id r9mr5063081pls.215.1554370053277; Thu, 04 Apr 2019 02:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370053; cv=none; d=google.com; s=arc-20160816; b=HryP0/K313IWZIPzidkbA7p9eX6OpPw2tfdscgZvTHbQHYzHpVVXgdEaGNVfMsrgVD 9FILEUqrqwyjGh2xgdSSkxEVzzTmN2QFAc7PLI8qiIqKk4D6sURI3CiYkeVljFbKwoqT Kagr1YgFp9N0KhIPqu5F4lkfAFpT4u6OoJ+6xOIRxyAO8Ybj4W4EBESSyOzNz4WjbfP6 jZUsfmdeSXO1S48LTiQmEC1y38fNWBgtlgcct1HvEHNucox+Q4Ey+Ny4DxsJ5ROhW+i1 N6p2RzhwToIPE0XwqtYg51SHLrRIfEe+PZhxI6kJi6Ugbv2qTF05Ks3tzqtJbHz9VOYK jvng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eBlRme/L6XqZTDhpaHKH1deK4hxDkX/MTzpQPhze8Zw=; b=ip2NN5YRTVbvxkguOhwbFQLoACDos5jiy6myre5k4kD15Z+IdJ01yZ7JlmnH7kab3I 9r9W2Q10usZAM0JGHWw13+5Oe7HIdw3anI1WhV4ra98n1uc/YA3E7eWWUgaBEBMAodox 08F9zcujIbis+OUhYDgEvjhBXpHzC5atBAXw87WaocT5JwjdSGePwgk9RYtC0Yzwy0jk B6UCAMURA4zze5lS6ZolGdX/ZyM0+hHCgyOpi5iNQH/8GOwjRjpM62E0BcfALyZVRxBh zyZLtdeEZDUNhSPh79zfqzmvbQwtXHsMec5YiQdOeYa0U1Dv8yr91FrOwR0uL/s0Yvsm YFhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2o3WDNX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h73si16534822pfj.220.2019.04.04.02.27.18; Thu, 04 Apr 2019 02:27:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2o3WDNX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387498AbfDDJNA (ORCPT + 99 others); Thu, 4 Apr 2019 05:13:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387473AbfDDJM5 (ORCPT ); Thu, 4 Apr 2019 05:12:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 013232147C; Thu, 4 Apr 2019 09:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369176; bh=2GTewGTFxolK0JLmclBkYFNxyhVWbnsycRlIkH3VQaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2o3WDNXkr+k0U24JA0aaGymPcNQRuedFf72E7JUF+PVPOeYZxCx56XIE/VNyWi4/ UxFVi9+t31pmlXUCHMfFT1F/LmPN+Iftt8zITykPMN81IdjoNPIdoHBLCppOt1WI4W mjPNCzQ0iMvK4OgTmI/qUVmM+LnaPACN7tKpihDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenyou Yang , Akinobu Mita , Eugen Hristev , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.0 112/246] media: ov7740: fix runtime pm initialization Date: Thu, 4 Apr 2019 10:46:52 +0200 Message-Id: <20190404084623.072596345@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 12aceee1f412c3ddc7750155fec06c906f14ab51 ] The runtime PM of this device is enabled after v4l2_ctrl_handler_setup(), and this makes this device's runtime PM usage count a negative value. The ov7740_set_ctrl() tries to do something only if the device's runtime PM usage counter is nonzero. ov7740_set_ctrl() { if (!pm_runtime_get_if_in_use(&client->dev)) return 0; ; pm_runtime_put(&client->dev); return ret; } However, the ov7740_set_ctrl() is called by v4l2_ctrl_handler_setup() while the runtime PM of this device is not yet enabled. In this case, the pm_runtime_get_if_in_use() returns -EINVAL (!= 0). Therefore we can't bail out of this function and the usage count is decreased by pm_runtime_put() without increment. This fixes this problem by enabling the runtime PM of this device before v4l2_ctrl_handler_setup() so that the ov7740_set_ctrl() is always called when the runtime PM is enabled. Cc: Wenyou Yang Signed-off-by: Akinobu Mita Tested-by: Eugen Hristev Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov7740.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c index 177688afd9a6..8835b831cdc0 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -1101,6 +1101,9 @@ static int ov7740_probe(struct i2c_client *client, if (ret) return ret; + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + ret = ov7740_detect(ov7740); if (ret) goto error_detect; @@ -1123,8 +1126,6 @@ static int ov7740_probe(struct i2c_client *client, if (ret) goto error_async_register; - pm_runtime_set_active(&client->dev); - pm_runtime_enable(&client->dev); pm_runtime_idle(&client->dev); return 0; @@ -1134,6 +1135,8 @@ error_async_register: error_init_controls: ov7740_free_controls(ov7740); error_detect: + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); ov7740_set_power(ov7740, 0); media_entity_cleanup(&ov7740->subdev.entity); -- 2.19.1