Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp129467lqr; Wed, 5 Jun 2024 00:43:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUogeIKbsC5/K5SjhCTlnAm+p2NHaQcvzaQhIYmzBxDpj1pItSLAqNPnhhSLqrcwnPcfziVz0/Fb8/JtU/o858iNfPKFLAE85SApsP80Q== X-Google-Smtp-Source: AGHT+IFFQV+RYq9/qIdQMOloOasPZXewvn4cDzcoqB7rsrQXre868FBq3vMAtU40IlX1LyhBfkJC X-Received: by 2002:a05:622a:553:b0:43d:f527:a755 with SMTP id d75a77b69052e-44029e70bf6mr32590251cf.13.1717573415510; Wed, 05 Jun 2024 00:43:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717573415; cv=pass; d=google.com; s=arc-20160816; b=cMKQaaHr2t5tDe9eTnhozBWE2WSFWgbsT/RPpgcxIJa1T5xmjvTahnVRMasqJ6HbYH rjh3Nt0D+aDQ0BCDuJoHT8zTa/Pvr1ajIXbBT8r+Kte0Q2inmVvX+sl6su4Npa8xgOnI jbjdYOGk3i94SimMNCC8uTXA7Zl8oqBjFwB9dwCDTJVbtk/LCxfcOjMmCFZsnhH18xNe NlsvxQRBhIEI+4HAHrJciG2mcSCAQSBS49M+/MZd6ajWTvc6GRjxN6+dmECgJHH29lpC DvL3XjKzlIbw43tDNT4aszWOZSPPXb7F63dbCoHSAFsnntORNsnApOgzVKBJbbbloy+r 3JBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iyjciw8omyqWPArx3sDq7VVjOnmIsURoasHM7cx8Qy0=; fh=wi61KU7G3S9h8ifdAHGGhzImhen5gjeP0QRl9fNmF0U=; b=p9cugZ9SZMTHDoFuzeYekntfAhsRaeduQiFVU+IG2L+eZha3fIkUGuxNYmvUUi65g3 KbfRU9/nX4TBLuoEVhRycJCxasnCepsvJu7RASFzydVaYyoQo+DItWwBiZKHKPz1GipC mO9meYgm9NFEbq+i8JhDUC2BmgD/sJFyNU9HSkea6YgLgaOwiaAcNLALzv2EJHhw2geO rEOgPuQwXVOP8/mKxMEKQE1rs85M6bNmDvd6k3A1yJ7SVLAvCn/xnJAh4UFOcbsWX6lb RpxtwXC7lMh6KZVTNLippe7INvGaygGIR2fyaQkb/ZggEdW+wDvEyKbpdWJJLo3Am7/T ITPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=HTV5YG13; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-wireless+bounces-8521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8521-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-4402829262asi23853111cf.229.2024.06.05.00.43.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 00:43:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=HTV5YG13; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-wireless+bounces-8521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8521-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 40F2B1C225A4 for ; Wed, 5 Jun 2024 07:43:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 303B418C358; Wed, 5 Jun 2024 07:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="HTV5YG13" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 6111C18C33B for ; Wed, 5 Jun 2024 07:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717573397; cv=none; b=QkwjlSKN46SVsqeNYME6dZH3LwT8MuZsv7Y3tuNGp7jjobwN+ZtgHzp1siK2EqbyqV1rHETKWeFPVGue9iB9mYSI4udBkZbhdUjMar/o4PObimgmQ+nAUexFWVFkBxD1Z5mxniModWlXj6RYewf32fJfnoWi/+/Y0grH9bKt3t0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717573397; c=relaxed/simple; bh=l9sh3+D2x2FynAmR7WZMbPzPELRCyU/6nGYVYGh1LAE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ie/ftK/pOtZAJ19BhmQ20PvKrRb5ri09phPgsbLwCiUNtNVWIehjLGEtosG5TUSAnSVp7DwWA22BJedtCWrJJRGnrAjGHtLFPqkvBouk3LnAo3tTAlwdb8rbFKTlyHAWM0VaY07MJeQo9N74godMFK2Qafn8q14XFejxph/UIvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=HTV5YG13; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2e72b8931caso70823061fa.0 for ; Wed, 05 Jun 2024 00:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1717573393; x=1718178193; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iyjciw8omyqWPArx3sDq7VVjOnmIsURoasHM7cx8Qy0=; b=HTV5YG13McBHbauqZYCInJNrmgXetedB/PCKdKjY1kwXtdxdhowEOQgO0OOL9hlmjr 4+pGWrjna1UZBZNtSeq7WeEXK7B7yTitBmw6kECgsoTbz+cQQW6ZCBYF68d1qLG6CZZs jO75kBaem+6XdTzgXNDI1X6BXzrELrACMU9qrgvheHimU2tTxX8sT90uoRoXxlteL+4i n8hcmdH7ucs8Ynob6uMB3S+C4fxMie6q4C6OUDUfUM/tlaMd+JzSVJw4tg3NYmK+Lea8 +/UqJAX/37Gf9VTavnoRp+j3OI2b8/zQ0h7IGLmR11cHRskxd6FyuJOjRxabrsKL74eq 3daQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717573393; x=1718178193; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iyjciw8omyqWPArx3sDq7VVjOnmIsURoasHM7cx8Qy0=; b=FEcsBJxCkIN0m0pJyxru4v6a5ld7ADsmr0+vXIpNRZV+fhAyoTO3N+wqzllWPdeMDK v9SOBKB1Ko+HVZK4JzpSOe3FNa7mSNlwI7sTOgletQoPvgKmwTIbXfzz9Lnx65UZiOe2 wge61GiH2QOIWcvzV6BhpHIgQej0cvBBJaNQzrfjnPbyiuSV/OXa01/Zy5Ur/wI2EJG+ pYYfFQn2nOC0yioWeSrBpgQHVhlMOt9B1QFNQYpNaBavpsN7nJlgJ6eUQrFU6p0filgV Dsrqw29CqdXFEZdLh4c/G3RJqTL2PuO7aMN0EukLzZRY/mrhXiEFaDcL8T22If9qj0n+ 3gGw== X-Forwarded-Encrypted: i=1; AJvYcCUdRvcuVeZkrzUSmG7Tsb5lsIR0jflnIFpblH0P41vvGFdOMqcWF1sJkwSsOKuLbkj0KYFStDSRY/GjYqFqnrNMw03nr2st+oaolrmnBRI= X-Gm-Message-State: AOJu0Yxi/ky9pgTBStdqQd5o3lJAtpdpdXAqcZxf/CjgGRM3Bz5EceZf NkocVeWodGaXJ9CcW94CKaiM2+F5zMo/f7jr6TKIV0R1eehVLhlINzrIBUcjpE6/DuojJ6hRV7F bQFk+BXLdsT4WCZCaxQot1CKlgO6KiJsTePfnHw== X-Received: by 2002:a2e:2416:0:b0:2e2:72a7:843c with SMTP id 38308e7fff4ca-2eac7a54169mr9164901fa.36.1717573393470; Wed, 05 Jun 2024 00:43:13 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240528-pwrseq-v8-0-d354d52b763c@linaro.org> <20240528-pwrseq-v8-10-d354d52b763c@linaro.org> <20240605065245.GB3452034@maili.marvell.com> In-Reply-To: <20240605065245.GB3452034@maili.marvell.com> From: Bartosz Golaszewski Date: Wed, 5 Jun 2024 09:43:02 +0200 Message-ID: Subject: Re: [PATCH v8 10/17] power: sequencing: implement the pwrseq core To: Ratheesh Kannoth Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Balakrishna Godavarthi , Rocky Liao , Kalle Valo , Jeff Johnson , Bjorn Andersson , Konrad Dybcio , Bjorn Helgaas , Srini Kandagatla , Elliot Berman , Caleb Connolly , Neil Armstrong , Dmitry Baryshkov , Alex Elder , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, Jeff Johnson , ath12k@lists.infradead.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, Bartosz Golaszewski , kernel@quicinc.com, Amit Pundir Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 5, 2024 at 8:52=E2=80=AFAM Ratheesh Kannoth wrote: > > On 2024-05-29 at 00:33:18, Bartosz Golaszewski (brgl@bgdev.pl) wrote: > > From: Bartosz Golaszewski > > > > Implement the power sequencing subsystem allowing devices to share > > complex powering-up and down procedures. It's split into the consumer > > and provider parts but does not implement any new DT bindings so that > > the actual power sequencing is never revealed in the DT representation. > > > > Tested-by: Amit Pundir > > Signed-off-by: Bartosz Golaszewski > > --- > > + > > +static struct pwrseq_unit_dep *pwrseq_unit_dep_new(struct pwrseq_unit = *unit) > nit. pwrseq_unit_dep_alloc/create rhymes well with pwrseq_unit_dep_free()= , So what? > > +static void pwrseq_unit_free_deps(struct list_head *list) > > +{ > > + struct pwrseq_unit_dep *dep, *next; > > + > > + list_for_each_entry_safe(dep, next, list, list) { > no need of 'locks' to protect against simutaneous 'add' ? No, this only happens once during release. > > + > > +static int pwrseq_unit_setup_deps(const struct pwrseq_unit_data **data= , > > + struct list_head *dep_list, > > + struct list_head *unit_list, > > + struct radix_tree_root *processed_units= ) > > +{ > > + const struct pwrseq_unit_data *pos; > > + struct pwrseq_unit_dep *dep; > > + struct pwrseq_unit *unit; > > + int i; > > + > > + for (i =3D 0; data[i]; i++) { > Can we add range for i ? just depending on data[i] to be zero looks to be= risky. > Why? It's perfectly normal to expect users to end the array with a NULL pointer. The docs say these arrays must be NULL-terminated. > > + pos =3D data[i]; > > + > > + unit =3D pwrseq_unit_setup(pos, unit_list, processed_unit= s); > > + if (IS_ERR(unit)) > > + return PTR_ERR(unit); > > + > > + dep =3D pwrseq_unit_dep_new(unit); > > + if (!dep) { > > + pwrseq_unit_decref(unit); > This frees only one 'unit'. is there any chance for multiple 'unit', then= better clean > up here ? The references to those will be dropped in pwrseq_release(). > > + > > + /* > > + * From this point onwards the device's release() callback is > > + * responsible for freeing resources. > > + */ > > + device_initialize(&pwrseq->dev); > > + > > + ret =3D dev_set_name(&pwrseq->dev, "pwrseq.%d", pwrseq->id); > > + if (ret) > > + goto err_put_pwrseq; > > + > > + pwrseq->owner =3D config->owner ?: THIS_MODULE; > > + pwrseq->match =3D config->match; > > + > > + init_rwsem(&pwrseq->rw_lock); > > + mutex_init(&pwrseq->state_lock); > > + INIT_LIST_HEAD(&pwrseq->targets); > > + INIT_LIST_HEAD(&pwrseq->units); > > + > > + ret =3D pwrseq_setup_targets(config->targets, pwrseq); > > + if (ret) > > + goto err_put_pwrseq; > > + > > + scoped_guard(rwsem_write, &pwrseq_sem) { > > + ret =3D device_add(&pwrseq->dev); > > + if (ret) > > + goto err_put_pwrseq; > > + } > > + > > + return pwrseq; > > + > > +err_put_pwrseq: > no need to kfree(pwrseq) ? It's literally put on the next line? Bart