Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2487157pxb; Fri, 8 Oct 2021 08:46:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoHUt3FT4UubR67WGB5HVmnovbk2JSA4lWEcIjZdZr09sz6fPq15cguIDYsKjv02jak7wJ X-Received: by 2002:aa7:cb8a:: with SMTP id r10mr15910651edt.237.1633708011692; Fri, 08 Oct 2021 08:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633708011; cv=none; d=google.com; s=arc-20160816; b=FeEarBSqon8joADyWnTTblFTsXiuODvHUc4JPa02wKhGBZD0DbLYkcM6WfoHo6bhTL txexU433CdxnY/svDAI6+WxC9539d/pcb1MK+L4khVmg+yXqo8WHan1zQWdMKIjDGMol BOtZoOEh63IRHm0D6Xa3JxtKWXizDKYD1KYDawqDpmsw1cVeN+dRfeaxM4tRcprd4Uck 1NfhHUiBihmohKIzAFFvZSxOfChQLGaquAvq887YDFK0xtDoyfixBtAnMzaoQA5dmX6X eAmos0LCOIgahJgsjBn6l7zcpkIinqxup+out3f7BfHnhnFkF3Izm3yqWZZtUwRQiv1E Ro0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=M+x5MOER261MbUl0OssjbNlVFcMcQKLgCQodPM213LU=; b=kxH4kD0pfL1bKB2jSB6zXYltfFLaFYsy0auHZ5FfnQBfDRe3cVcpZyRV7pLe3WgA5v LayotZyM6rPsTxnrq9AQy0fPjqzKLGtGzHIMOyaoGNJzICxHuWrnnbm58U7kBGb2HQHP 0NXrG5Y458ca2YfPWxzwFMWuUb/cEOGJUYVdolGNGq5vvibTl3zd1//RLU2vZwNIQqtf IT8/AOoXg00WtL157KHi5BkRMW+GJpalrv1iQdmb71WMxQLyqCYk8TXE2CnnE6QihSPi uGGSHPJiu1H3hExYHkCbU4GJ1dIl3hhzkIDbtj+gyZTukRZUTM2vnTTE0WofyDp+Rf4A COZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBYvelRo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rl8si3688783ejb.778.2021.10.08.08.46.28; Fri, 08 Oct 2021 08:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBYvelRo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243459AbhJHPpA (ORCPT + 99 others); Fri, 8 Oct 2021 11:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243460AbhJHPot (ORCPT ); Fri, 8 Oct 2021 11:44:49 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BC2C06177D for ; Fri, 8 Oct 2021 08:42:51 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id k23so7927897pji.0 for ; Fri, 08 Oct 2021 08:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=M+x5MOER261MbUl0OssjbNlVFcMcQKLgCQodPM213LU=; b=uBYvelRobKTfrDeV3HYp85ouWk4dpJoJmi8LRMKm+v4WEZNLzrwNNM2uwITNlZqyKx 9nJhun35xgulMrcjVdIEaHTDcA6P22Gece914rSouoUkTYTSEKLL2P+V98A9JV9E962r IsDpEyl+2igx9kfpAhTABuj7LhFNsTGJsrrxJtTVWmVJ2ZevVjhz22U+O64OfD5CfphV c5CX28NOkKW372SSjJxpdxw214uXsaHMC2ihgyIp9YFkw38//zvzZKYVDeDZUqwjgX2F xJ/DX9HGQSNuaCxBEUTter4ka5UkKjCgKjngvw9qIZfk/MtJORNHZksNkarVYzruX5NE ZChg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=M+x5MOER261MbUl0OssjbNlVFcMcQKLgCQodPM213LU=; b=4p1ii2jYNQTbrWlpTkux/83UBA+d/bVs6J+b0+lmbP5hea42u6zPU3f3EuPrW3XT5j /sbPlOgr8dDCfIg+svP+akG8d1lQce2tQ6jN3H00O+Eed7s1SJmM7wAxP2rCs88uwzJ4 G3zIH4LO4TBNB9LzirssrTv3vQfcEeE18EI/QSfu2ZIosC1x5XxDZY+MRQMzxWGKGj2U 3DaLYufWWDNz7f54i3wUZ/XUkE7+DiLp8v/5JpadnD0dmZ+E63jYFfSa+cXJG8uuMwWJ rTAa2470/1X88LJ74RgaIlVv3m3vGVwAbJpl0Odu28QZsuQifGTQHJcKCR/jgJSpWWV7 5MZg== X-Gm-Message-State: AOAM533OXO+Z1ge5Lx9xeH0pRVYPsBr0dl4lGLuCDmhB7OD0uTJud9FM YvDgvYakvPnZ463vB5IKvhHAsg== X-Received: by 2002:a17:90a:c68b:: with SMTP id n11mr13173254pjt.90.1633707770960; Fri, 08 Oct 2021 08:42:50 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 130sm3110371pfy.209.2021.10.08.08.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 08:42:49 -0700 (PDT) Date: Fri, 8 Oct 2021 09:42:47 -0600 From: Mathieu Poirier To: Shengjiu Wang Cc: Shengjiu Wang , Ohad Ben Cohen , Bjorn Andersson , Rob Herring , Shawn Guo , Sascha Hauer , Sascha Hauer , Fabio Estevam , NXP Linux Team , "open list:REMOTE PROCESSOR (REMOTEPROC) SUBSYSTEM" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linux-kernel Subject: Re: [PATCH v5 3/4] remoteproc: imx_dsp_rproc: Add remoteproc driver for DSP on i.MX Message-ID: <20211008154247.GA3614893@p14s> References: <1632625630-784-1-git-send-email-shengjiu.wang@nxp.com> <1632625630-784-4-git-send-email-shengjiu.wang@nxp.com> <20211006162511.GA3370862@p14s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 08, 2021 at 09:53:18AM +0800, Shengjiu Wang wrote: > Hi Mathieu > > On Thu, Oct 7, 2021 at 12:25 AM Mathieu Poirier > wrote: > > > > Hi Shengjiu, > > > > This pachset doesn't apply to rproc-next, which is now located here[1]. The > > change is in linux-next but not in mainline yet. > > > > https://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git/log/?h=rproc-next > > Ok, I will double check it and fix it. > > > > > On Sun, Sep 26, 2021 at 11:07:09AM +0800, Shengjiu Wang wrote: > > > Provide a basic driver to control DSP processor found on NXP i.MX8QM, > > > i.MX8QXP, i.MX8MP and i.MX8ULP. > > > > > > Currently it is able to resolve addresses between DSP and main CPU, > > > start and stop the processor, suspend and resume. > > > > > > The communication between DSP and main CPU is based on mailbox, there > > > are three mailbox channels (tx, rx, rxdb). > > > > > > This driver was tested on NXP i.MX8QM, i.MX8QXP, i.MX8MP and i.MX8ULP. > > > > > > Signed-off-by: Shengjiu Wang > > > --- > > > drivers/remoteproc/Kconfig | 11 + > > > drivers/remoteproc/Makefile | 1 + > > > drivers/remoteproc/imx_dsp_rproc.c | 1206 ++++++++++++++++++++++++++++ > > > 3 files changed, 1218 insertions(+) > > > create mode 100644 drivers/remoteproc/imx_dsp_rproc.c > > > > > > > [...] > > > > > + > > > +/** > > > + * imx_dsp_attach_pm_domains() - attach the power domains > > > + * @priv: private data pointer > > > + * > > > + * On i.MX8QM and i.MX8QXP there is multiple power domains > > > + * required, so need to link them. > > > + */ > > > +static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv) > > > +{ > > > + struct device *dev = priv->rproc->dev.parent; > > > + int ret, i; > > > + > > > + priv->num_domains = of_count_phandle_with_args(dev->of_node, > > > + "power-domains", > > > + "#power-domain-cells"); > > > + > > > + /* If only one domain, then no need to link the device */ > > > + if (priv->num_domains <= 1) > > > + return 0; > > > + > > > + priv->pd_dev = devm_kmalloc_array(dev, priv->num_domains, > > > + sizeof(*priv->pd_dev), > > > + GFP_KERNEL); > > > + if (!priv->pd_dev) > > > + return -ENOMEM; > > > + > > > + priv->pd_dev_link = devm_kmalloc_array(dev, priv->num_domains, > > > + sizeof(*priv->pd_dev_link), > > > + GFP_KERNEL); > > > + if (!priv->pd_dev_link) > > > + return -ENOMEM; > > > + > > > + for (i = 0; i < priv->num_domains; i++) { > > > + priv->pd_dev[i] = dev_pm_domain_attach_by_id(dev, i); > > > + if (IS_ERR(priv->pd_dev[i])) { > > > + ret = PTR_ERR(priv->pd_dev[i]); > > > + goto detach_pm; > > > + } > > > > I have pointed a problem with the error handling in the above during the > > previous review and it was not addressed. > > I have considered your comments. Actually when > dev_pm_domain_attach_by_id() return NULL, the device_link_add() > will break, I have added comments below, so above error handling > for dev_pm_domain_attach_by_id() is enough. I would have used IS_ERR_OR_NULL() so that potential code inserted between the two function doesn't automatically assume priv->pd_dev[i] is valid. But what you have here will work. Reviewed-by: Mathieu Poirier > Best regards > Wang Shengjiu > > > > > + > > > + /* > > > + * device_link_add will check priv->pd_dev[i], if it is > > > + * NULL, then will break. > > > + */ > > > + priv->pd_dev_link[i] = device_link_add(dev, > > > + priv->pd_dev[i], > > > + DL_FLAG_STATELESS | > > > + DL_FLAG_PM_RUNTIME); > > > + if (!priv->pd_dev_link[i]) { > > > + dev_pm_domain_detach(priv->pd_dev[i], false); > > > + ret = -EINVAL; > > > + goto detach_pm; > > > + } > > > + } > > > + > > > + return 0; > > > + > > > +detach_pm: > > > + while (--i >= 0) { > > > + device_link_del(priv->pd_dev_link[i]); > > > + dev_pm_domain_detach(priv->pd_dev[i], false); > > > + } > > > + > > > + return ret; > > > +} > > > +