Received: by 2002:ac8:6d01:0:b0:423:7e07:f8e4 with SMTP id o1csp6900889qtt; Mon, 18 Dec 2023 09:45:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPgj8EkZ0rbIMfs+zt3q61ijW7lrtGQM6jr7wvZMOQ0sQfITHaplC8HVUUQV2AM2Nwt9+O X-Received: by 2002:a62:e703:0:b0:6d8:bef3:4182 with SMTP id s3-20020a62e703000000b006d8bef34182mr634866pfh.1.1702921527443; Mon, 18 Dec 2023 09:45:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702921527; cv=none; d=google.com; s=arc-20160816; b=CXOzPFXH7BNzG5agLYmiWyuXwPu56hUO4hxEYs4y0Ry3NKyGPLN26u67/7cWItZx2+ 67D88jIqvrN39aEXOjx8KQkjlHac45ioNt6ShXld+WRGWZZHX3WaIBR+jxBgGKKgzLAm qDEK1Gfgw0hlji7X/R4sVZC1TMlCAFDMN+IzF5l46oHvA+fBV9ih3WXcVhRM3gxnfMVw fKGyHGDHYwDv+YgHp+UBb7kU/L0JEwn89y5LRkUL23PWrgt0aEocYduHJ9+7vBv0YGN1 WyIKuDiSvnZ0zjXtR0p62PL3jQfJigXOmUJpE3vQElXIX/lyZN0La9NTuakS77km10Qq ppmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Q+AOlN1QWf7zHgr+1BqJOwJHJOoAiKQ8ZouD3wx/nb4=; fh=Ft8dYvEuFIKwnehVwpL0WG7QMIrRLMi0wgN4ll940k8=; b=or6HpxEfFmJSbPg9v9l4+XgwhQlo8xSHZ9m/0Ud7YtNbmgGuxCoKmFRlJqX/VapRUk 1ZzmHZZNhqpaxU0tvtGpwaj/trjT+7+gv88nKTQPXR9oFEg7aT2M0TIB1HEG2YHhjfjk /dYPjz1kposW8IoHlxfAtpkpFpp6uPDIVJ6oKX+Oe4tl8npTZvWGJFaEomTtj6aIzl3S h5+fytWQDv+t+Mims+J7+BCxT91HS5ItdAicD4tPMvbu2A8MzICuaVDFcQdfE1aULAmf qa1omrNK083RGiyY49vox42Pogr7Y1TJfy6x+krPgKi46Eh+wxkEZz7q38yBei3ZqCYy q7vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hsmO4MPg; spf=pass (google.com: domain of linux-kernel+bounces-4197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y15-20020a62f24f000000b006cd97ba7ccbsi1965790pfl.232.2023.12.18.09.45.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:45:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hsmO4MPg; spf=pass (google.com: domain of linux-kernel+bounces-4197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 308CA28395A for ; Mon, 18 Dec 2023 17:45:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 418DF74E09; Mon, 18 Dec 2023 17:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hsmO4MPg" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F497408A; Mon, 18 Dec 2023 17:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cc4029dc6eso41241111fa.1; Mon, 18 Dec 2023 09:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702921269; x=1703526069; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q+AOlN1QWf7zHgr+1BqJOwJHJOoAiKQ8ZouD3wx/nb4=; b=hsmO4MPgEEvT84rvsWcOuG8HLxtbSnqmbwbKWYoBaFgp9Wgx3EgdAls70FT5zxg54+ v+iNXcIRZtHNYcqtDL75wAu5xpwNm6umzKHFbesJQHVRyNehu2Te+DQOuDBEfMxcTQ2C ojqDmfgaezA0sbuiDy7qa5iRJ0ouW6wMoQUR85srW7F9xOUF1nJQnhlSQ4LQIBwgaUJ3 cwbMTiz1CwREdfCfjfF/7VasvwMb+WedEHkhAK3Dxy8BVEQQBBE8Iq3w1VjyTCQQokL/ bZSAczwKtbkMLMKqNLrYsSWrh7WfwQUxWUtUsvJn7s5+3+AOk5wD0GP7jqIOvgN8cJB7 Ia6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702921269; x=1703526069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q+AOlN1QWf7zHgr+1BqJOwJHJOoAiKQ8ZouD3wx/nb4=; b=i5/vlKX7aJP3PwG4zhEF0fu8LUi62SIkD1P7mE17tJqOrJTU2AULEH0yotYWwBbkIX lSr0VSoPGZBR7rvXC5As9Rgexw5syq8meyJbKOIL0iXALaPL+B89iVXfKx5/VxQmd4+5 98RfjUZthCvhKwtW/fk7+9C6JxLexqsK4xJbVhvIvD9Di7mxwREjX1ocpWThfyhqtLqp RcE1SmAU5FhHAEqNwtEjGHwl2enJV/GZ7TO3UEzWkDPjXC1PHwYOZf97W3iGYK7fchlv JGaHTFkUaec2FX427nJaP5aOsUXSY1jJ8Rc8bAwUQIs5pC4WSt6vzOQ53CK6cF/0oKV0 YlGA== X-Gm-Message-State: AOJu0YzHkB3R7Kzd85CFCm6d2vAS22unW/a5EBo85h1KoKmr8hOv5h3S QS8MHJiuq1wqcgnBk8LptXvE5MQlzXcBGw== X-Received: by 2002:a2e:bc08:0:b0:2cc:41c9:9c71 with SMTP id b8-20020a2ebc08000000b002cc41c99c71mr5214230ljf.25.1702921269208; Mon, 18 Dec 2023 09:41:09 -0800 (PST) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id w22-20020a2e9bd6000000b002cc710614besm455091ljj.0.2023.12.18.09.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:41:08 -0800 (PST) From: Mikhail Rudenko To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , Laurent Pinchart , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab , Mikhail Rudenko Subject: [PATCH v2 09/20] media: i2c: ov4689: Use runtime PM autosuspend Date: Mon, 18 Dec 2023 20:40:30 +0300 Message-ID: <20231218174042.794012-10-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218174042.794012-1-mike.rudenko@gmail.com> References: <20231218174042.794012-1-mike.rudenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use runtime PM autosuspend to avoid powering off the sensor during fast stop-reconfigure-restart cycles. Signed-off-by: Mikhail Rudenko --- drivers/media/i2c/ov4689.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c index 5300e621ff90..64cc6d9e48cc 100644 --- a/drivers/media/i2c/ov4689.c +++ b/drivers/media/i2c/ov4689.c @@ -407,26 +407,27 @@ static int ov4689_s_stream(struct v4l2_subdev *sd, int on) ov4689->cur_mode->num_regs, NULL); if (ret) { - pm_runtime_put(dev); + pm_runtime_put_sync(dev); goto unlock_and_return; } ret = __v4l2_ctrl_handler_setup(&ov4689->ctrl_handler); if (ret) { - pm_runtime_put(dev); + pm_runtime_put_sync(dev); goto unlock_and_return; } ret = cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, OV4689_MODE_STREAMING, NULL); if (ret) { - pm_runtime_put(dev); + pm_runtime_put_sync(dev); goto unlock_and_return; } } else { cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, OV4689_MODE_SW_STANDBY, NULL); - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); } unlock_and_return: @@ -606,7 +607,9 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl) break; } - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return ret; } @@ -877,8 +880,10 @@ static int ov4689_probe(struct i2c_client *client) } pm_runtime_set_active(dev); + pm_runtime_get_noresume(dev); pm_runtime_enable(dev); - pm_runtime_idle(dev); + pm_runtime_set_autosuspend_delay(dev, 1000); + pm_runtime_use_autosuspend(dev); ret = v4l2_async_register_subdev_sensor(sd); if (ret) { @@ -886,11 +891,14 @@ static int ov4689_probe(struct i2c_client *client) goto err_clean_subdev_pm; } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; err_clean_subdev_pm: pm_runtime_disable(dev); - pm_runtime_set_suspended(dev); + pm_runtime_put_noidle(dev); v4l2_subdev_cleanup(sd); err_clean_entity: media_entity_cleanup(&sd->entity); -- 2.43.0