From patchwork Tue Aug 20 10:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13769843 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 19EA118E036 for ; Tue, 20 Aug 2024 10:19:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724149178; cv=none; b=HfVrnv+9sbfr8sWd0m6ijVqlRfcckYEp6xWZVWQ+oefOcmSs1w/CD1oqtAy/UFZ5oDOMPo8nR8Lv1DXCqa6B7PhLeAiRsyHyDPBlkI+rTOgobEbEXugFZ0y8+GVC00Gbl3zJoFWCe21MCjGwV9w0DoJD15Mby0HwUyn6f+qlTds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724149178; c=relaxed/simple; bh=vem8p96L0oMWQEyldLlJtpVhQ994QqnmR0ohREVf2Pc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HMsTubwNGvA8u7+lvkMBGpl5vlGPba/RRzCv54pebl1UB8d1e1mrNZia3RZnOHubBPZ6RBSEBZewv5nWceEylPFr81pzly/xJkL9FF+JQrFqBCQlR/lARQY8bSR/aNrZKYTx6dF5eyVH6U2ZbovIa5VTIwf7a85z+t2SF1z78BQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=VMS5VtPj; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="VMS5VtPj" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f3f163e379so4280331fa.3 for ; Tue, 20 Aug 2024 03:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1724149175; x=1724753975; 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=Ks+2YRAyKgKRE43sjfM9QF4KPwZ0caq5YtrlIAthty4=; b=VMS5VtPjE70UurK+Dk/MxfZbykcsfzo5d+1YEodewel6ocBpfJa3ZqDJyNObe/v6hC r23YYCCNJXkBOTibds8f3Wab+0WaiGLEZtfzmoJvSv95JuB/H981G7YGH0wknim8xzje hO/0V5oG5OcKUlBfovnEeb2KJ6/i8LoSlMNTKNVm3ptj+F/NJ14w4cEAKtVsEsnr5xRM dhkOhj9nOpCsuGc8GxvFDJSbGSKJCk9ldyW5MRs3oSE6McF7X5BLKpBD3VW9mT1kZfqF ELlalWaFL/kySMQPGx9HFi0ZaF6NOttMxhEfKhLyYbr+CPC7tUeBuExGWu7nq2vNpj3a xsbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724149175; x=1724753975; 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=Ks+2YRAyKgKRE43sjfM9QF4KPwZ0caq5YtrlIAthty4=; b=PzbeMUFubr2T4fs5fkDTerqNxcTwJM5ZfQvtt2lICbE54CEtqZNeE23AseDZ3OYUQM rhZCBOsnz9WD58O/pvfQQlkC7P7YhmFN0J+NkfSlQk9lRLP7dZ5l7mqK+2/uNTiJZNKB 7fjtNOKFUQtvKTXIV/8Ho/MCE6eZWEE3eetTmOwWm+tW1btGwwgALHCbv375csa3wCy6 ETMYE7qAM1KErWT50PeUoBN+EFiMU+6PDgRqUqN17P8/4gAHOzY0sfDjYRZcRh3WNOf6 DJiwTizmQvAP2yVshzqGN3AsJhzRt9rBLTcy3FYA0xYZ+gxR8R6RfuyeWVniHzke7IRF mt0g== X-Gm-Message-State: AOJu0YwO4wD5lD+LhCWgzKJFhY6+4ulcE4d0jai3Z2WztrNSN6H4PmOL D+n6MY3i0s1X7rgdqNRlaU3tz7ch2tt6pFXhOqzfLzDPiPUid48VqeejbzsQC4g= X-Google-Smtp-Source: AGHT+IFlb9J3A3Mxm0nx13hYdwklVJKspWeIpZSmdrnA+oVIdgB3VI1lpHABkqDCTT2rIQJsnXm5jw== X-Received: by 2002:a05:651c:54f:b0:2f3:f256:aeec with SMTP id 38308e7fff4ca-2f3f2573d65mr4517381fa.19.1724149175056; Tue, 20 Aug 2024 03:19:35 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a83839464ebsm734550066b.155.2024.08.20.03.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 03:19:34 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: chris.brandt@renesas.com, andi.shyti@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, p.zabel@pengutronix.de, wsa+renesas@sang-engineering.com Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 04/11] i2c: riic: Enable runtime PM autosuspend support Date: Tue, 20 Aug 2024 13:19:11 +0300 Message-Id: <20240820101918.2384635-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240820101918.2384635-1-claudiu.beznea.uj@bp.renesas.com> References: <20240820101918.2384635-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Enable runtime PM autosuspend support for the RIIC driver. With this, in case there are consecutive xfer requests the device wouldn't be runtime enabled/disabled after each consecutive xfer but after the the delay configured by user. With this, we can avoid touching hardware registers involved in runtime PM suspend/resume saving in this way some cycles. The default chosen autosuspend delay is zero to keep the previous driver behavior. Reviewed-by: Wolfram Sang Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - collected tags - added a comment on top of pm_runtime_set_autosuspend_delay() Changes in v3: - none Changes in v2: - none drivers/i2c/busses/i2c-riic.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 6fc41bde2ec2..ec854a525a0b 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -171,7 +171,8 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) } out: - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return riic->err ?: num; } @@ -399,7 +400,8 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t) riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return 0; } @@ -479,6 +481,9 @@ static int riic_i2c_probe(struct platform_device *pdev) i2c_parse_fw_timings(dev, &i2c_t, true); + /* Default 0 to save power. Can be overridden via sysfs for lower latency. */ + pm_runtime_set_autosuspend_delay(dev, 0); + pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); ret = riic_init_hw(riic, &i2c_t); @@ -496,6 +501,7 @@ static int riic_i2c_probe(struct platform_device *pdev) out: pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); return ret; } @@ -512,6 +518,7 @@ static void riic_i2c_remove(struct platform_device *pdev) } i2c_del_adapter(&riic->adapter); pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); } static const struct riic_of_data riic_rz_a_info = {