Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp505949pxf; Wed, 17 Mar 2021 09:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkF6bYRVFgUWhzRX6+Th+bEHyNyeox1i3WCbmoFshCTwxnocpA3YVyJwb6nAt6VNoa7bOX X-Received: by 2002:a17:906:1706:: with SMTP id c6mr15197013eje.223.1615998305713; Wed, 17 Mar 2021 09:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615998305; cv=none; d=google.com; s=arc-20160816; b=lrBzgn6R6vcm1u0yuD/oSUUJ7GMnHIrg888BMJh+TRbXNb8nyLGLNKyOkVTl2dVChc 7jhY/k1F19Fj3QgN+JhHPbRJ4YbeXaQrH+clLf01DRgO79N89gRAqWvqU6dunUlmTV94 yER7ViC2JJVBql11CwHkOX5Wsk9+Nf3aWYsAaTnoL/3fXXnBQAPPXCwbimuHI+FXR8jj z2X6r8KC7ly0WqfR7Aqj8zDdARc0jB81UWWv1+notPBbYsvFsWylzEZuDewrr5kgWS52 +UjjUdA+JVspTmTk719iM6D5DQsTH92VhsqINPFxowY8cZ8fPC53xXxAvXjYnuxpgG0u zv/w== 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=F/NINQB6sPLYh+yrEh/k+DH7DYJo1ZCA8NxADWNTIuc=; b=AJqAM0zVntbZro2ToDYFnMNH8h5ywvqztnt+y8VisV1eLgtlM/F2e7rwuF78D44BzH Uq/UbN1y2hSnkbvQ32Uh/eYeX+2zlbqcABa4utMsY9kKQWkSaT7ilhhXuy+U/PbTctAc hL5I5DBSOO6zlJQPFChHLwglJI9T4SM9S8yk7QR8iROPgZtROYZtyJ91+wr6P7wBAIG0 g1vnd2l6ktYRD/cyVsqs3EHkqAwTNsxrwJllDDWNTXgTKdkXcBPEn+3qsQhwfDpGTLBq xtX+CneOcvHe3R5d9QNANHlyHNwHODPSDnmo5PVQqxVZS1zeyolE8Umds7AgRoTlS8PK 6TVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lwy1ZiWI; 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 g19si14606855eds.96.2021.03.17.09.24.42; Wed, 17 Mar 2021 09:25:05 -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=lwy1ZiWI; 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 S232360AbhCQQXO (ORCPT + 99 others); Wed, 17 Mar 2021 12:23:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232367AbhCQQW4 (ORCPT ); Wed, 17 Mar 2021 12:22:56 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43E5EC061760 for ; Wed, 17 Mar 2021 09:22:56 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id n10so25074588pgl.10 for ; Wed, 17 Mar 2021 09:22:56 -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=F/NINQB6sPLYh+yrEh/k+DH7DYJo1ZCA8NxADWNTIuc=; b=lwy1ZiWIAtcKPMq2R26yQtWGUBjV2/aZx0LQ5/d5QuNihi8Wtz5itX/qLsFLULsdJm 7h05IW0RREuLx9FjL+YHBC95rXkwbpjzIhuHNIZtFaMA7EuOA+eScoYXw2MGSaFRKVAX 2P/x3fmsNZ2EPyAEGghzUlj4dmRdMu9OYP8eVLPXGM5xFJ4l161c5YBcpnYSb0si1ad/ zTwmcmY/rSF9fYLI30rNoc1hu5Dqyjrq1344Tyw4f181YmPSmMJt17lKgUziZxarFICt d1uhVm1jNw51JcIejSnN+UQERVi46InH2Km0pKVXytIkQcMw3l9goxuyK196nkww2Hyj G+Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=F/NINQB6sPLYh+yrEh/k+DH7DYJo1ZCA8NxADWNTIuc=; b=UkRrorNO+wcBFTVfiQwICEKErEFIq3Mb0/lv1szGw+k1aEW2EAIa904h9yuv4gDODf Oc0qSTFPca1MQYpJXAvwccX0931zQgPrx0thHeFySdqcv3RceimZZ8XgNtYJa9Yt33jm cg2ahNwAbw6DnvCGrEjEL47Mc8+gjpJZTJa3LgDjASpUg4lCaFc6vGX2HqfmDR8Yy7pK qHGxA6CWMzlJz2wJeoi4WVPAosOsLtWZZFLhJRrbrKpsnE0eMF6Nmn0K223E11CE+Itl RwTJM1JRLUJ/1Y+Dfxj+P6Byy6E01zei9HdC7LBsqo+P3C8KJON849PM31aFG4J5B5BC bU+g== X-Gm-Message-State: AOAM532+YGv9Dy9wnDCTDEXbsbrJ9lua2nMatEM2qJ6i+f7MNkVjCX54 NG82hxmvEms552HTKaFDkM7aBA== X-Received: by 2002:aa7:9910:0:b029:1f1:b41b:f95c with SMTP id z16-20020aa799100000b02901f1b41bf95cmr4989428pff.5.1615998175710; Wed, 17 Mar 2021 09:22:55 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 14sm20277815pfo.141.2021.03.17.09.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 09:22:51 -0700 (PDT) Date: Wed, 17 Mar 2021 10:22:49 -0600 From: Mathieu Poirier To: Ben Levinsky Cc: "devicetree@vger.kernel.org" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Michal Simek , "Ed T. Mooring" Subject: Re: [PATCH v26 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver Message-ID: <20210317162249.GA1494354@xps15> References: <20210223154447.13247-1-ben.levinsky@xilinx.com> <20210223154447.13247-6-ben.levinsky@xilinx.com> <20210308190046.GA3983426@xps15> <20210315172558.GA1342614@xps15> <1AD6632B-A69E-406B-A644-440B9C8B929F@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1AD6632B-A69E-406B-A644-440B9C8B929F@xilinx.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > > > +/* > > > + * zynqmp_r5_remoteproc_probe > > > + * > > > + * @pdev: domain platform device for R5 cluster > > > + * > > > + * called when driver is probed, for each R5 core specified in DT, > > > + * setup as needed to do remoteproc-related operations > > > + * > > > + * Return: 0 for success, negative value for failure. > > > + */ > > > +static int zynqmp_r5_remoteproc_probe(struct platform_device *pdev) > > > +{ > > > + int ret, core_count; > > > + struct device *dev = &pdev->dev; > > > + struct device_node *nc; > > > + enum rpu_oper_mode rpu_mode = PM_RPU_MODE_LOCKSTEP; > > > + struct list_head *cluster; /* list to track each core's rproc */ > > > + struct zynqmp_r5_rproc *z_rproc; > > > + struct platform_device *child_pdev; > > > + struct list_head *pos; > > > + > > > + ret = of_property_read_u32(dev->of_node, "xlnx,cluster-mode", &rpu_mode); > > > + if (ret < 0 || (rpu_mode != PM_RPU_MODE_LOCKSTEP && > > > + rpu_mode != PM_RPU_MODE_SPLIT)) { > > > + dev_err(dev, "invalid cluster mode: ret %d mode %x\n", > > > + ret, rpu_mode); > > > + return ret; > > > + } > > > + > > > + dev_dbg(dev, "RPU configuration: %s\n", > > > + rpu_mode == PM_RPU_MODE_LOCKSTEP ? "lockstep" : "split"); > > > + > > > + /* > > > + * if 2 RPUs provided but one is lockstep, then we have an > > > + * invalid configuration. > > > + */ > > > + > > > + core_count = of_get_available_child_count(dev->of_node); > > > + if ((rpu_mode == PM_RPU_MODE_LOCKSTEP && core_count != 1) || > > > + core_count > MAX_RPROCS) > > > + return -EINVAL; > > > + > > > + cluster = devm_kzalloc(dev, sizeof(*cluster), GFP_KERNEL); > > > + if (!cluster) > > > + return -ENOMEM; > > > + INIT_LIST_HEAD(cluster); > > > + > > > + ret = devm_of_platform_populate(dev); > > > + if (ret) { > > > + dev_err(dev, "devm_of_platform_populate failed, ret = %d\n", ret); > > > + return ret; > > > + } > > > + > > > + /* probe each individual r5 core's remoteproc-related info */ > > > + for_each_available_child_of_node(dev->of_node, nc) { > > > + child_pdev = of_find_device_by_node(nc); > > > > The device reference needs to be dropped after use, as described in the function > > documentation. > > > > I'm out of time - I will continue tomorrow. > > > > Mathieu > > > > > > [Ben] By this do you mean that for each platform_device should have a call like > > platform_set_drvdata(child_pdev, NULL); if it fails? or something else? > > Have another read at the documentation and look at how other people have used > it. You may already be aware but Bootlin's kernel cross-reference tool is > really good for that. > > https://elixir.bootlin.com/linux/v5.12-rc3/source > > If I understand what you are saying I will add calls for put_device(child_pdev) in error handling and at end of the loop. That's one part of it. But what will happen if there is no errors to deal with? Where will the reference to child_pdev->dev be dropped? > >