From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F31BAC433F5 for ; Fri, 8 Oct 2021 15:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9A2F61037 for ; Fri, 8 Oct 2021 15:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243345AbhJHPpA (ORCPT ); Fri, 8 Oct 2021 11:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243306AbhJHPot (ORCPT ); Fri, 8 Oct 2021 11:44:49 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867CDC06177C for ; Fri, 8 Oct 2021 08:42:51 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id cs11-20020a17090af50b00b0019fe3df3dddso7419831pjb.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=S2Mjw6dvg5hraKSExIYNGfcN1snqsAdMYp4Ktauo+Z5SdYJC9x4gFFRNjvZYOiiD8q GRg+74S1JGq31GGNMTblMSWgeQZkMAnv34evBvz+RF7Q4GKIYurH2angLxfIQPMHMGmR fiKrgIgZId9gnLVOEXfntH7Sv9OpxKGta62W5LiOWmRKpEZAqKl/iJUQi4MaELT/eHEk qI8XKXcJPrvGGrLfcMJUFu3qwoTiw903tK8AXqps9UcujUA32838XtvR/4hNMEo5iAwR e8KiYQMouIzyturTh/JdhUGXgZS+mkLQ2hhzfbrsDOdSJJRcDfB/XvPiXDAWHqiHF1vZ 2Teg== X-Gm-Message-State: AOAM530ekQ6gF423NWv0u7BbMywcHTg8Wl2E5AMlCCJgZF/MBF0XOuXW R9MFTecQWAoSchGsJeeadiR0wg== X-Google-Smtp-Source: ABdhPJy6lAXGCc3KLUKlrLv5Ow61pYCX9c+ztKIVvvukaQ2lF377BooN5dvvWlHZzOw9nftYOjNkgw== 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-remoteproc@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; > > > +} > > > + From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A788C433F5 for ; Fri, 8 Oct 2021 15:44:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C41D6101A for ; Fri, 8 Oct 2021 15:44:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C41D6101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wOp2PZf67jD+ZkFS66X16yEPqS3fO9QS0TdxGT850gs=; b=Lmx48zi07k29rJ H9ydoqoJDptSzDKSeVlGjByHPGjAJ0XYpLkudgn3XjMrnMR0d5cF23d4mFtkw8JP0SzL49HZJ8hPK 4hVdX0wy2jAbnSgFPFKkwLCKZVTZ137jRLWfSrJSBB+HkWSJmKIICrXikPQfyabjuuTveMIq8GFJG RQJQ89bZdm8J/JvHDg4xi0IkWKT30HtdcUvfsOEfO5G3P6byome6fi876PdTreh8wWqIX7D6utgdc cc5XziLWRtyNkY6wB3+wyVU8LT6I+rGKv6BueHXU2wf+652gadSzxU2RU7y7E6HEqGyCZamxRT8Vo CXAHkfazS+DNE6534J8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYs1R-003HGj-4q; Fri, 08 Oct 2021 15:42:57 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYs1M-003HFQ-TJ for linux-arm-kernel@lists.infradead.org; Fri, 08 Oct 2021 15:42:54 +0000 Received: by mail-pj1-x102c.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso5648713pjb.1 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=X9axckiNplitmTBAlZwiv2I0jxeq9it69XHMVsZELRFmWrYunoY86pSETzRlHynpUp LeFRlZvZGNl04Wk6KxIMW4iMTwxnlSACIee45DxrgRkYZvl4AVeiJVREGRjtYwLdf046 L3BztW4icmzqpOWW8TlEN7koWxZz/fTPPXG+lk8FQQl9dk+Fhru9sMnLN2KK2m4YXyzU 0WLcpTM3hnPogk9/qQP0uZQqxsrwSFrDq1tYvlFus0DPlXknoR/76V0kcntOxhfw/xsw gQCbMvP/rcKDxprkii/8P1s7xzu758joGm0LX1lfldD/DojrvgS6zcYk1V39P7GbE2qn HQVg== X-Gm-Message-State: AOAM533brU4IqxHdEMNtU4j3YJQvNVRZUrzuo2MA/4nyJ8W3DLFDjprv QKPqk0lwErhcl2rvi/XSdj3QE1KysJBqiQ== X-Google-Smtp-Source: ABdhPJy6lAXGCc3KLUKlrLv5Ow61pYCX9c+ztKIVvvukaQ2lF377BooN5dvvWlHZzOw9nftYOjNkgw== 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211008_084252_990120_C93B724A X-CRM114-Status: GOOD ( 35.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; > > > +} > > > + _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel