Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1211588lqd; Thu, 25 Apr 2024 08:51:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3GBfT+NVPmkC7FdnwmCD9CJDvvHxUS1xC86sbFdQCMvpKJ/EnU2pKas1Fj04cNPyo3NPfIX6PktDRY+O93ynmqYQA6Wd8bO34YJ1eOw== X-Google-Smtp-Source: AGHT+IHSfD0J+sun2oxSKiY2zsQxJ6rvVp/AmaQ87h9IaidA9bQqRb60jS90dGrs43HCQvh1uQzW X-Received: by 2002:a17:90a:4748:b0:2a5:ffb1:debd with SMTP id y8-20020a17090a474800b002a5ffb1debdmr5887438pjg.33.1714060319573; Thu, 25 Apr 2024 08:51:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714060319; cv=pass; d=google.com; s=arc-20160816; b=XhUmW8Ed4vZgqymw9fmOZql7Ooa3aB9QN4DRpDRxwyQ+eA6LIyZDzX4UlZMqj8Qcdt ekBM7yqUKlwDS72BO3866f6JCD7lknJfPlX5TWG6QtJGaUNJx+4Z8sOar9e0f2J4dskR cv7MGhu7edNYv+xUJPn/MduQnArsoPzJ0biEFGi42pRU6w9o2S+UpsOnOepFu4UW6hxu TD3bWcTQ3PxvVV4+x02uBnlPFnUvtt073SVne9hhiydOuZqYfUHtr9YlH8aCgwTJRClW 6D6C69DFIb3dhSnu/t2gXqmP7K7qNQnjpklx+U7FkKU+2xasbZurELj94Oxi2aB0rhZg e1OQ== ARC-Message-Signature: i=2; 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:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=kVfecRLul1bWESph5bgI+QIEjsAZi68hrnU3YEYNhsU=; fh=+zm082K58NqpOJ49zWjGfiUHYNcKVPOWeqvPHkaAW3c=; b=fL8hrOP2H9cYchM2VV76WlU6IAzpd7pB45CaeOe5javI+vcIi5T11xLMIdRUtRXrSC ur6f2QwNgj5hYzprC8hVTLLh1KAzzeVh2WL0UgWGoGHCTCrgs0VLfCOcKjN1QyyjFPpy JDAKJYaUY9ZgecsI2L3G92E9HjiTet5pXH0uHHFl0iA4qlNtCmE/c0dRqNkcBxYKTWEU jDa3aUnL5hOAJkCch7Q5vYZsc+cf7IHaR2o9BcQ37xgyH/x3nbXDzJbrFCJqt0Ps2aFf GzKcHqMgAnBt684er6xk3TXRLOzyABGrWh/Uko718+yen5lPqKg/8//O9mE/bs07FaCS 4XmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=Mzei7UZm; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-158845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g7-20020a17090a300700b002a4c761ac8fsi14871827pjb.156.2024.04.25.08.51.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 08:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=Mzei7UZm; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-158845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me 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 34D3A283C7B for ; Thu, 25 Apr 2024 15:51:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22A3914D282; Thu, 25 Apr 2024 15:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="Mzei7UZm" Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 881B212B156; Thu, 25 Apr 2024 15:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714060302; cv=none; b=i7BcfNXO5DdZPZ4QGTtyvHrrBiZwbydFlHvZBr+Zcb1ovNWBB43mnbNfFhvpwjsNDoh+XSayEvt7ibMdDl0gWa/rsN5lo1U30NjAe32ZR2Xftag1NwyajrSyrtUbwcBkml447tQ8JODz4gluk5DZ3rkh6VZzskQtEmV016xFI9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714060302; c=relaxed/simple; bh=JnNuiwEjp88T0SxNSyjjxPwL8xwkm7/welwhj9Mm3fU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ju87+G1RaxgroRRaTjWTQj3Gm+Du0kK6HvQQEAwS6adZaax7+E9bAkmm2jfqtIGmtXytisg4n2ojWg2ZNiUNTHcB2Rlou+HbK39fMgoKk6ctXkXHjBc8olMQ72gx4qSwPESrdClP65A6qEmgkV3ohPde8PgGex6UeQUcuYq7tcw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=Mzei7UZm; arc=none smtp.client-ip=185.70.40.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1714060292; x=1714319492; bh=kVfecRLul1bWESph5bgI+QIEjsAZi68hrnU3YEYNhsU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Mzei7UZmRTxq/ydowLnAD+P4ThggwXzpEPGgfRubUFcYtbOKJnxjGIMfuem/SQvIM +yHk5RLEQPGxp+XREUAiXeGMGWjrGprT0VJ1jj3MH2/b55hvKujgkxco0T7WQlpbLl yPxwxkPq84udniaYcvemwXAOle5lSAnfzBosSNAQMUWpgB6Oo1uOvo+sd1txeZ8Lo0 qlw+gEwwul2Yo1FzC1OSiwBt1AO7mDOp2atcdcPijyM+M4Cc/lpspQTR5Z11ul9dZS I4JOWa/3ugKXcZuGKnhA+0u1LyjFwzPZr0Zwj4vKDZ4TvjMVk6Odt2wCipuVBPI8PT GgiMeTOM3/kZw== Date: Thu, 25 Apr 2024 15:51:29 +0000 To: Viresh Kumar From: Benno Lossin Cc: "Rafael J. Wysocki" , Miguel Ojeda , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rust-for-linux@vger.kernel.org, Manos Pitsidianakis , Erik Schilling , =?utf-8?Q?Alex_Benn=C3=A9e?= , Joakim Bech , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 1/3] rust: Add bindings for OPP framework Message-ID: <5a6542d6-4644-4083-99e4-73de7038fe92@proton.me> In-Reply-To: <20240422102415.xvmuja6bdfxgl4pv@vireshk-i7> References: <06bb914eae00671a69b393bf86bb01ddec86c16f.1712314032.git.viresh.kumar@linaro.org> <20240422102415.xvmuja6bdfxgl4pv@vireshk-i7> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 50e695419f6a03950bbc639587da801f21c5bfea Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 22.04.24 12:24, Viresh Kumar wrote: > Thanks for the review Benno. I was waiting for more review comments to > come in and hence didn't reply earlier with an update. >=20 > On 07-04-24, 09:54, Benno Lossin wrote: >> On 05.04.24 13:09, Viresh Kumar wrote: >>> + clk_names: Option>>, >> >> Why are you using `Pin>`? The vector may reallocate the backing >> storage at any point in time. >=20 >>> + /// Sets the configuration with the OPP core. >>> + pub fn set(&mut self, dev: &Device) -> Result<()> { >>> + // Already configured. >>> + if self.token.is_some() { >> >> Why does the config hold onto this token? Would it make sense to consume >> the config and return a `Handle` or `Token` abstraction? Then you don't >> need to check if the config has been "used" before. >=20 >>> +#[repr(transparent)] >>> +pub struct OPP(*mut bindings::dev_pm_opp); >> >> I think you should use the `ARef` pattern instead: >> >> #[repr(transparent)] >> pub struct OPP(Opaque); >> >> unsafe impl AlwaysRefCounted for OPP { >> // ... >> } >> >> Then you can use `ARef` everywhere you use `OPP` currently. >=20 > All these comments look good to me. Updated the code with them (not > reposting them for now) I currently do not have a lot of time, so I will re-review it when you post a new version. > -------------------------8<------------------------- >=20 > rust/bindings/bindings_helper.h | 1 + > rust/kernel/lib.rs | 2 + > rust/kernel/opp.rs | 888 ++++++++++++++++++++++++++++++++ One other nice thing that you could do would be to split this patch into multiple smaller ones. That makes understanding the pieces a lot easier. --=20 Cheers, Benno