Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1923584pxb; Thu, 7 Oct 2021 18:56:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqQefo2foFuK9WIjkCQkcNdaJW95YbOiPVYdYFB3xZjDTeSX9t05gcJ1rRtjRF4lrB7FjX X-Received: by 2002:a65:6aa3:: with SMTP id x3mr1486578pgu.253.1633658192075; Thu, 07 Oct 2021 18:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633658192; cv=none; d=google.com; s=arc-20160816; b=mAdL66dewz42i6t64w0gSLqg8LmSpOoQ5o5s/6oxGMX0FtrUaBwuq03nGczIFRZX0M 7J7hjuO/WuD4UxDq+QHGUxLev5nkNGeLZvKBhIpEB7Re4hEfylfP1UTU1E6HfQ1ApeSM ocWkXELiA8MM4ecis0ZhBC0kBvs0hbrX10zRCx7JdmolSXIAuQ0HSUKW8i0tyIGq4kuS EGljwj4lX4yGsS7hSXEKT1tdTPN94krjHzKQdGQJnBX0EWbS3Bf6MPUJN26vTxYa2p22 ANLw6jqlE7/icFkLrdT9UNTAIoSY8BYaaXByqwN4FGQoFu9BHdlGBmq1aNYLDyN5kI7h KgdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7todBHdUdrk6e6UQ0gc/p1j76bLvlAp/nPJIsH1ZwrU=; b=NGaoMeU0/KYDnQREx21cjlzMNk5fcjMOx2FGrDNh3ua7Ern+rXAdo4Bit9y6qKch/H ZVSPlGBQ5BjsTETMoheC2d5uBMYwMqq859FDIEpnMRxv+Ok7MOR8DxTU74QTAXY/213l lykFertMQVFZBmNsvH/t29EIIxp7Lo0cJ2uw9D/RJ11SkRmaaMnFukMbYTvkhycMir09 az8nUrs/AVxXcv6PYzJD8LwjWL5mTCSTH/DARtvMUeucPhNf54ciwOSlQ1iBQrmJTVTf OpzGE/bJWpEY+om5gxewrlKfhn1E74r2pHoM/RVdxDJWQFf6jEWgFnL2PVtWe4FPB7U7 rKbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pYnevWap; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w186si38038775pfw.135.2021.10.07.18.56.18; Thu, 07 Oct 2021 18:56:32 -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=@gmail.com header.s=20210112 header.b=pYnevWap; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbhJHBz2 (ORCPT + 99 others); Thu, 7 Oct 2021 21:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhJHBzY (ORCPT ); Thu, 7 Oct 2021 21:55:24 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31121C061570; Thu, 7 Oct 2021 18:53:30 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id p4so8031652qki.3; Thu, 07 Oct 2021 18:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7todBHdUdrk6e6UQ0gc/p1j76bLvlAp/nPJIsH1ZwrU=; b=pYnevWap+Nr7RyAO44CZlMPTpYR5EQmDloM6Oxm/wRKX1hYpweH+gBE4gQcMVfrbmQ K1/A21aj+3oJSnOuO3k3MkrlFKZCgHjIkn0ZrCBlXaOtt7r4L56575GtYEA4jqvBxsee m5cKizWctwS9lPtGra1C1CxemYkXhJEYYf2Xg/eBr7i3lTzJoslhdC2SnSyVuQdle0sC IxecV14wttzHpdidvAmBJpAerxuInifYORccHbTQvGsbmuPnig+TiPLMbE58/MIzWDUa gYC4M0+JxpYZPyjaqCmlvPZE11tt7CpFhgtIk9xPtPiYoiYwg/I2xEd8PUC8OemV1V8/ DdAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7todBHdUdrk6e6UQ0gc/p1j76bLvlAp/nPJIsH1ZwrU=; b=Q9EmrozJgTR7T18o7QCPT0Acu4GHkfqQEzJ192Hv0w4ipz5mHO2lg6kvDgR+hEsv8P FQwvB1dnnHiffaFtA7JG39JIxjDrlaxy/kYi5V+wIK9jtY/8x0iY25YKW0nPZj+n3HVa qgCBxAvYrMJNQE9rJTq88O2AcL8UtdCiMRK0anYP3v8r6hC8MDRhCfgrDuxVucKYDfUq fFiHh3+k0bdwDmdGdioe+OS0UeWxZhnitKofdcYIVg3CBah+SewDVz/FDVmMU6zPIP29 YCx5QXJgNri3zDdTDwB/liUk7HEXJaTKlirE+TD5IN282PzBAgLeN6E174hOMIyb19xT qYoA== X-Gm-Message-State: AOAM530q7Eo8W5AvrjbMTUESMBfOPpLqBOfExRmWEu5SnhcIud7e7JYq O+viPNvsLOlPga6VInSlcferu87fYc3AINPRaYg= X-Received: by 2002:a37:8ce:: with SMTP id 197mr663603qki.492.1633658009360; Thu, 07 Oct 2021 18:53:29 -0700 (PDT) MIME-Version: 1.0 References: <1632625630-784-1-git-send-email-shengjiu.wang@nxp.com> <1632625630-784-4-git-send-email-shengjiu.wang@nxp.com> <20211006162511.GA3370862@p14s> In-Reply-To: <20211006162511.GA3370862@p14s> From: Shengjiu Wang Date: Fri, 8 Oct 2021 09:53:18 +0800 Message-ID: Subject: Re: [PATCH v5 3/4] remoteproc: imx_dsp_rproc: Add remoteproc driver for DSP on i.MX To: Mathieu Poirier 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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; > > +} > > +