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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 51909C6FA83 for ; Fri, 2 Sep 2022 20:00:31 +0000 (UTC) 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=18mCPvKipl1NgsnJnyycfuogcIpUQBplwiDYfEnQWYQ=; b=n32XPZJq7ul/Lx KEbC0fFTceQI9611kQvjevTHw0xQ14p8KXoKZrG5a+CbjNKQLMwhpNlVKZpXI5mJe5fkmYTBr270l wNLkGO67c1a9sxgjRwbSzmQliPJAweG6Yke80m9mX1mMOxvBUVPOi3b/x6sLJUNxFfHqhhE1xyu/f 2CEJlKY4HxAKD1kWmuOrMrL7pwbvXyFw/AU9rlb+sSXNfgsBg2irtBs/64ydetrhD7ti/c0I3/uVy u/CpmW62jqUT/BSG8qUTtdZLgC1a7ZUI6v6ppdHSCkULB/RivU+mHc4waiBFMXrTcHvtHF7XLNIM8 zgSKFzb2szsPPv8Tty1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCor-00AWG4-KG; Fri, 02 Sep 2022 19:59:13 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCon-00AW8d-NM for linux-arm-kernel@lists.infradead.org; Fri, 02 Sep 2022 19:59:12 +0000 Received: by mail-pl1-x62b.google.com with SMTP id f12so2817161plb.11 for ; Fri, 02 Sep 2022 12:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=dGK7WWAPGizMxBGKUMh+FvHewx1Mr93Lo4bVqiaiirA=; b=VFFkGttZfBJiRrzaJZvMz2ztkWWT/BcUmpVRh4lxAdICIbqR/sC2O9Ewh/fi75InDP 3wDxXOIot7i6yfnwQigC10UVDVnS+1bnSj6zBCrBAYA1ygE49BZWzimXy/oJrdcTejZj gytUmRcC7YLlBzIYACz6HDr7NR6+sMmePbAu62fJptKZ7VaWMnZ6up7xyqpki3x3FZRF ZXKvciv/en8/oWL5XWRramH+IYv/xhJZoCclaPvoYRfwJMzcKrrU8UOZ2noNuocf4s7y pD8j8/VkaeFgN2ua0OpKbMhNWDA3RvF41d1bysBcpnQqYOZn7eupoPGeitWjKXpIVgSh ivPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=dGK7WWAPGizMxBGKUMh+FvHewx1Mr93Lo4bVqiaiirA=; b=X2N1/SkX3dehEtlItxjcZ/SJm67rjflXjXDW5x4rrZqw5DjvIsVyhuSRVQ70DcvlxI LvbeaT3GdKJn3vc0Zmafw5J1C1zfIu18UGHsUSQaacBPPKvCbyKX+Fb014bxNfqKGBY9 SVV38ASRbIsmxxkWjDPhjiq80kNA6VZ+6ObGrOHYPiQfnP48zenms/6o7VBPgtZ6yIef HwrvllzS7ed9VdN2V38mVv+65m88u0dpBBKz6jRrZruMpkDi2ooi+a6+Sl1yuiULZjxQ S+0+vHTmRhBGfVU3cY5YJ0Id9VvOgGjM0thcdeCGfH+otiOWiqUgOqB0prJz2f95ScEd OcMg== X-Gm-Message-State: ACgBeo32WOlbFEaEw4rRKdc1VUfWbWyReKDZlnJPad0Y6QbCk3uDe0SO tYzb2JTEOyGC2SmrFUZL8Idgtg== X-Google-Smtp-Source: AA6agR7CZQpU238NDro/ZPLlEbYC08h0PdgJfvn8EJ//LePSPJFMGFvuNGAhREt18+wROZ36j+immA== X-Received: by 2002:a17:902:e80e:b0:174:b2e1:8b5c with SMTP id u14-20020a170902e80e00b00174b2e18b5cmr25200428plg.20.1662148746714; Fri, 02 Sep 2022 12:59:06 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id s64-20020a17090a69c600b001fdc88d206fsm1870426pjj.9.2022.09.02.12.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 12:59:05 -0700 (PDT) Date: Fri, 2 Sep 2022 13:59:03 -0600 From: Mathieu Poirier To: Tanmay Shah Cc: Tanmay Shah , bjorn.andersson@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, michal.simek@xilinx.com, ben.levinsky@xilinx.com, tanmay.shah@xilinx.com, michal.simek@amd.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v9 6/6] drivers: remoteproc: Add Xilinx r5 remoteproc driver Message-ID: <20220902195903.GB1787913@p14s> References: <20220708013955.2340449-1-tanmay.shah@amd.com> <20220708013955.2340449-7-tanmay.shah@amd.com> <20220901202517.GB626605@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-20220902_125909_840062_CD660ADB X-CRM114-Status: GOOD ( 52.02 ) 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [...] > > > + > > > +static const struct rproc_ops zynqmp_r5_rproc_ops =3D { > > > + .prepare =3D zynqmp_r5_rproc_prepare, > > > + .unprepare =3D zynqmp_r5_rproc_unprepare, > > > + .start =3D zynqmp_r5_rproc_start, > > > + .stop =3D zynqmp_r5_rproc_stop, > > > + .load =3D rproc_elf_load_segments, > > > + .parse_fw =3D zynqmp_r5_parse_fw, > > > + .find_loaded_rsc_table =3D rproc_elf_find_loaded_rsc_table, > > > + .sanity_check =3D rproc_elf_sanity_check, > > > + .get_boot_addr =3D rproc_elf_get_boot_addr, > > > +}; > > > + > > > +/** > > > + * zynqmp_r5_add_rproc_core() > > > + * Probes ZynqMP R5 processor device node > > > + * this is called for each individual R5 core > > > + * > > > + * @cdev: Device node of each r5 core > > > + * > > > + * Return: zynqmp_r5_core object for success, error pointer in case = of error. > > > + */ > > > +static struct zynqmp_r5_core *zynqmp_r5_add_rproc_core(struct device= *cdev) > > > +{ > > > + struct zynqmp_r5_core *r5_core; > > > + struct rproc *r5_rproc; > > > + int ret; > > > + > > > + /* Set up DMA mask */ > > > + ret =3D dma_set_coherent_mask(cdev, DMA_BIT_MASK(32)); > > > + if (ret) > > > + return ERR_PTR(ret); > > > + > > > + /* Allocate remoteproc instance */ > > > + r5_rproc =3D rproc_alloc(cdev, dev_name(cdev), > > > + &zynqmp_r5_rproc_ops, > > > + NULL, sizeof(struct zynqmp_r5_core)); > > > + if (!r5_rproc) { > > > + dev_err(cdev, "failed to allocate memory for rproc instance\n"); > > > + return ERR_PTR(-ENOMEM); > > > + } > > > + > > > + r5_rproc->auto_boot =3D false; > > > + r5_core =3D (struct zynqmp_r5_core *)r5_rproc->priv; > > > + r5_core->dev =3D cdev; > > > + r5_core->np =3D dev_of_node(cdev); > > > + if (!r5_core->np) { > > > + dev_err(cdev, "can't get device node for r5 core\n"); > > > + return ERR_PTR(-EINVAL); > > Here @r5_rproc is leaked and r5_rproc->rproc never free'ed. > = > This function is only used in cluster_init. > = > r5_rproc->rproc is free'ed in release_r5_core label in > zynqmp_r5_cluster_init function if this function fails. It would be the case if @r5_core was returned, but it is not. A such @r5_core[i] zynqmp_r5_cluster_init() is still null and the memory leaked. > = > This avoids multiple free of same resource. > = > > = > > > + } > > > + > > > + /* Add R5 remoteproc core */ > > > + ret =3D rproc_add(r5_rproc); > > > + if (ret) { > > > + dev_err(cdev, "failed to add r5 remoteproc\n"); > > > + return ERR_PTR(ret); > > Same. > Same as above. > > = > > > + } > > > + > > > + r5_core->rproc =3D r5_rproc; > > > + return r5_core; > > > +} > > > + > > > +/** > > > + * zynqmp_r5_get_tcm_node() > > > + * Ideally this function should parse tcm node and store information > > > + * in r5_core instance. We will use hardcoded TCM information from > > > + * driver for now in this function. > > > + * > > It would be a good idea to explain _why_ hardcoded values are used. > It is explained in function, but will add in description too. > > = > > = > > > + * @cluster: pointer to zynqmp_r5_cluster type object > > > + * > > > + * Return: 0 for success and error code for failure. > > > + */ > > > +static int zynqmp_r5_get_tcm_node(struct zynqmp_r5_cluster *cluster) > > > +{ > > > + struct device *dev =3D cluster->dev; > > > + struct zynqmp_r5_core *r5_core; > > > + int tcm_bank_count, tcm_node; > > > + int i, j; > > > + > > > + /* > > > + * ToDo: Use predefined TCM address space values from driver while > > I'm not sure why there is a "ToDo" here since this is exactly what you = are > > doing. > Ack. ToDo needs to go. > > > + * system-dt spec is not final for TCM > > > + */ > > > + tcm_bank_count =3D ARRAY_SIZE(zynqmp_tcm_banks); > > > + > > > + /* count per core tcm banks */ > > > + tcm_bank_count =3D tcm_bank_count / cluster->core_count; > > > + > > > + if (tcm_bank_count <=3D 0) > > > + return -EINVAL; > > As far as I can tell this can't happen and as such should be removed. > = > I kept this check for future, when we add TCM dt nodes. I will remove it. > = > > = > > > + > > > + /* > > > + * r5 core 0 will use all of TCM banks in lockstep mode. > > > + * In split mode, r5 core0 will use 128k and r5 core1 will use anot= her > > > + * 128k. Assign TCM banks to each core accordingly > > > + */ > > > + tcm_node =3D 0; > > > + for (i =3D 0; i < cluster->core_count; i++) { > > > + r5_core =3D cluster->r5_cores[i]; > > > + r5_core->tcm_banks =3D devm_kcalloc(dev, tcm_bank_count, > > > + sizeof(struct mem_bank_data *), > > > + GFP_KERNEL); > > > + if (!r5_core->tcm_banks) > > > + return -ENOMEM; > > > + > > > + for (j =3D 0; j < tcm_bank_count; j++) { > > > + /* > > > + * Use pre-defined TCM reg values. > > > + * Eventually this should be replaced by values > > > + * parsed from dts. > > > + */ > > > + r5_core->tcm_banks[j] =3D > > > + (struct mem_bank_data *)&zynqmp_tcm_banks[tcm_node]; > > > + tcm_node++; > > > + } > > > + > > > + r5_core->tcm_bank_count =3D tcm_bank_count; > > > + } > > > + > > > + return 0; > > > +} > > > + > > > +/** > > > + * zynqmp_r5_get_mem_region_node() > > > + * parse memory-region property from dt node and add > > > + * memory region carveouts > > > + * > > > + * @r5_core: pointer to zynqmp_r5_core type object > > > + * > > > + * Return: 0 for success and error code for failure. > > > + */ > > > +static int zynqmp_r5_get_mem_region_node(struct zynqmp_r5_core *r5_c= ore) > > > +{ > > > + struct device_node *np, *rmem_np; > > > + struct reserved_mem **rmem; > > > + int res_mem_count, i; > > > + struct device *dev; > > > + > > > + dev =3D r5_core->dev; > > > + np =3D r5_core->np; > > > + > > > + res_mem_count =3D of_property_count_elems_of_size(np, "memory-regio= n", > > > + sizeof(phandle)); > > > + if (res_mem_count <=3D 0) { > > > + dev_warn(dev, "failed to get memory-region property %d\n", > > > + res_mem_count); > > > + r5_core->rmem_count =3D 0; > > > + return 0; > > > + } > > > + > > > + rmem =3D devm_kcalloc(dev, res_mem_count, > > > + sizeof(struct reserved_mem *), GFP_KERNEL); > > > + if (!rmem) > > > + return -ENOMEM; > > > + > > > + for (i =3D 0; i < res_mem_count; i++) { > > > + rmem_np =3D of_parse_phandle(np, "memory-region", i); > > > + if (!rmem_np) > > > + goto release_rmem; > > > + > > > + rmem[i] =3D of_reserved_mem_lookup(rmem_np); > > > + if (!rmem[i]) { > > > + of_node_put(rmem_np); > > > + goto release_rmem; > > > + } > > > + > > > + of_node_put(rmem_np); > > > + } > > > + > > > + r5_core->rmem_count =3D res_mem_count; > > > + r5_core->rmem =3D rmem; > > > + return 0; > > > + > > > +release_rmem: > > > + for (i--; i >=3D 0; i--) > > > + kfree(rmem[i]); > > Function of_reserved_mem_lookup() doesn't allocate a new reserved_mem s= tructure, > > you get a reference to an existing one. As such there is no need to ex= plicitly > > free individual elements of the rmem array. > Ack. > > = > > > + devm_kfree(dev, rmem); > > > + return -ENOMEM; > > > +} > > > + > > > +/* > > > + * zynqmp_r5_core_init() > > > + * Create and initialize zynqmp_r5_core type object > > > + * > > > + * @cluster: pointer to zynqmp_r5_cluster type object > > > + * > > > + * Return: 0 for success and error code for failure. > > > + */ > > > +static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster, > > > + enum rpu_oper_mode fw_reg_val, > > > + enum rpu_tcm_comb tcm_mode) > > > +{ > > > + struct device *dev =3D cluster->dev; > > > + struct zynqmp_r5_core *r5_core; > > > + int ret, i; > > > + > > > + ret =3D zynqmp_r5_get_tcm_node(cluster); > > > + if (ret < 0) { > > > + dev_err(dev, "can't get tcm node, err %d\n", ret); > > > + return ret; > > > + } > > > + > > > + for (i =3D 0; i < cluster->core_count; i++) { > > > + r5_core =3D cluster->r5_cores[i]; > > > + > > > + ret =3D zynqmp_r5_get_mem_region_node(r5_core); > > > + if (ret) > > > + dev_warn(dev, "memory-region prop failed %d\n", ret); > > > + > > > + /* Initialize r5 cores with power-domains parsed from dts */ > > > + ret =3D of_property_read_u32_index(r5_core->np, "power-domains", > > > + 1, &r5_core->pm_domain_id); > > > + if (ret) { > > > + dev_err(dev, "failed to get power-domains property\n"); > > > + return ret; > > > + } > > > + > > > + ret =3D zynqmp_r5_set_mode(r5_core, fw_reg_val, tcm_mode); > > > + if (ret) { > > > + dev_err(dev, "failed to set r5 cluster mode %d, err %d\n", > > > + cluster->mode, ret); > > > + return ret; > > > + } > > > + } > > > + > > > + return 0; > > > +} > > > + > > > +/* > > > + * zynqmp_r5_cluster_init() > > > + * Create and initialize zynqmp_r5_cluster type object > > > + * > > > + * @cluster: pointer to zynqmp_r5_cluster type object > > > + * > > > + * Return: 0 for success and error code for failure. > > > + */ > > > +static int zynqmp_r5_cluster_init(struct zynqmp_r5_cluster *cluster) > > > +{ > > > + enum zynqmp_r5_cluster_mode cluster_mode =3D LOCKSTEP_MODE; > > > + struct device *dev =3D cluster->dev; > > > + struct device_node *dev_node =3D dev_of_node(dev); > > > + struct platform_device *child_pdev; > > > + struct zynqmp_r5_core **r5_cores; > > > + enum rpu_oper_mode fw_reg_val; > > > + struct device **child_devs; > > > + struct device_node *child; > > > + enum rpu_tcm_comb tcm_mode; > > > + int core_count, ret, i; > > > + > > > + ret =3D of_property_read_u32(dev_node, "xlnx,cluster-mode", &cluste= r_mode); > > > + > > > + /* > > > + * on success returns 0, if not defined then returns -EINVAL, > > > + * In that case, default is LOCKSTEP mode > > > + */ > > > + if (ret !=3D -EINVAL && ret !=3D 0) { > > > + dev_err(dev, "Invalid xlnx,cluster-mode property\n"); > > > + return -EINVAL; > > > + } > > > + > > > + /* > > > + * For now driver only supports split mode and lockstep mode. > > > + * fail driver probe if either of that is not set in dts. > > > + */ > > > + if (cluster_mode =3D=3D LOCKSTEP_MODE) { > > Why is are LOCKSTEP_MODE and LOCKSTEP_MODE defined when the same values= were > > already added in xlnx-zynqmp.h in patch 3/6? > = > Actually LOCKSTEP_MODE defined in this driver is taken from dt-bindings of > this driver. However, PM_RPU_MODE_LOCKSTEP defined in firmware represents > value expected by firmware. They are not the same defines. LOCKSTEP_MODE = =3D 1 > which is defined as per xlnx,cluster-mode bindings and similar to ti > cluster-mode bindings. PM_RPU_MODE_LOCKSTEP =3D 0 which is expected from > firmware. Ah yes, you are correct. > = > = > > And why not add SINGLE_CPU_MODE > > there as well instead of duplicating things in enum zynqmp_r5_cluster_m= ode? > = > = > SINGLE_CPU_MODE just represents xlnx,cluster-mode value from dt-bindings.= It > is not supported in firmware. > = > There are multiple ways to configure r5 cluster in single-cpu mode. > = > 1) Add new EEMI call which asks firmware to configure cluster in single-c= pu > mode. > = > or 2) use existing EEMI calls and configure cores from driver. As > single-cpu-mode is not supported yet, I am not sure, how it will > = > be implemented or what its design will look like. So, I haven't modified > anything in firmware driver related to single-cpu mode. > = > That is fine. > > > + tcm_mode =3D PM_RPU_TCM_COMB; > > > + fw_reg_val =3D PM_RPU_MODE_LOCKSTEP; > > > + } else if (cluster_mode =3D=3D SPLIT_MODE) { > > > + tcm_mode =3D PM_RPU_TCM_SPLIT; > > > + fw_reg_val =3D PM_RPU_MODE_SPLIT; > > > + } else { > > > + dev_err(dev, "driver does not support cluster mode %d\n", cluster_= mode); > > > + return -EINVAL; > > > + } > > > + > > > + /* > > > + * Number of cores is decided by number of child nodes of > > > + * r5f subsystem node in dts. If Split mode is used in dts > > > + * 2 child nodes are expected. > > > + * In lockstep mode if two child nodes are available, > > > + * only use first child node and consider it as core0 > > > + * and ignore core1 dt node. > > > + */ > > > + core_count =3D of_get_available_child_count(dev_node); > > > + if (core_count <=3D 0) { > > > + dev_err(dev, "Invalid number of r5 cores %d", core_count); > > > + return -EINVAL; > > > + } else if (cluster_mode =3D=3D SPLIT_MODE && core_count !=3D 2) { > > > + dev_err(dev, "Invalid number of r5 cores for split mode\n"); > > > + return -EINVAL; > > > + } else if (cluster_mode =3D=3D LOCKSTEP_MODE && core_count =3D=3D 2= ) { > > > + dev_warn(dev, "Only r5 core0 will be used\n"); > > > + core_count =3D 1; > > > + } > > > + > > > + child_devs =3D kcalloc(core_count, sizeof(struct device *), GFP_KER= NEL); > > > + if (!child_devs) > > > + return -ENOMEM; > > > + > > > + r5_cores =3D kcalloc(core_count, > > > + sizeof(struct zynqmp_r5_core *), GFP_KERNEL); > > > + if (!r5_cores) { > > > + kfree(child_devs); > > > + return -ENOMEM; > > > + } > > > + > > > + i =3D 0; > > > + for_each_available_child_of_node(dev_node, child) { > > > + child_pdev =3D of_find_device_by_node(child); > > > + if (!child_pdev) { > > > + of_node_put(child); > > > + ret =3D -ENODEV; > > > + goto release_r5_cores; > > > + } > > > + > > > + child_devs[i] =3D &child_pdev->dev; > > > + > > > + /* create and add remoteproc instance of type struct rproc */ > > > + r5_cores[i] =3D zynqmp_r5_add_rproc_core(&child_pdev->dev); > > > + if (IS_ERR(r5_cores[i])) { > > > + of_node_put(child); > > > + ret =3D PTR_ERR(r5_cores[i]); > > > + goto release_r5_cores; > > If we are here and i =3D=3D 0, we are leaking a reference to child_pdev= since the > > loop in release_r5_cores won't execute. > Ack. I will check if i =3D=3D 0 and put_device() before jumping to > release_r5_cores. > > = > > > + } > > > + > > > + i++; > > > + > > > + /* > > > + * If two child nodes are available in dts in lockstep mode, > > > + * then ignore second child node. > > > + */ > > > + if (i =3D=3D core_count) { > > > + of_node_put(child); > > > + break; > > > + } > > Instead of using the i to check the cores, simply break if cluster_mode= =3D=3D > > LOCKSTEP_MODE. That will avoid the fragile dance around the manipulati= on of > > variable i and simplify the release of resources in release_r5_cores. > > = > Actually variable name "i" needs to be changed. I need that variable to > track how many cores=A0 are added successfully. > = > So, if first core is added and second core fails, then I can release > resources allocated for first core successfully. > = > So, instead of "i" I can use meaningful variable name like "cores_added" = or > "cores_allocated". You can still use variable @i, just don't use it to break out of the loop. = As I pointed out, it would be much easier to simply do that if in lockstep mode. > = > > > + } > > > + > > > + cluster->mode =3D cluster_mode; > > > + cluster->core_count =3D core_count; > > > + cluster->r5_cores =3D r5_cores; > > > + > > > + ret =3D zynqmp_r5_core_init(cluster, fw_reg_val, tcm_mode); > > > + if (ret < 0) { > > > + dev_err(dev, "failed to init r5 core err %d\n", ret); > > > + cluster->core_count =3D 0; > > > + cluster->r5_cores =3D NULL; > > > + goto release_r5_cores; > > > + } > > > + > > > + kfree(child_devs); > > > + return 0; > > > + > > > +release_r5_cores: > > > + for (i--; i >=3D 0; i--) { > > > + put_device(child_devs[i]); > > > + rproc_del(r5_cores[i]->rproc); > > > + rproc_free(r5_cores[i]->rproc); > > > + } > > > + kfree(r5_cores); > > > + kfree(child_devs); > > > + return ret; > > > +} > > > + > > > +static void zynqmp_r5_cluster_exit(void *data) > > > +{ > > > + struct platform_device *pdev =3D (struct platform_device *)data; > > > + struct zynqmp_r5_cluster *cluster; > > > + struct zynqmp_r5_core *r5_core; > > > + int i; > > > + > > > + cluster =3D (struct zynqmp_r5_cluster *)platform_get_drvdata(pdev); > > > + if (!cluster) > > > + return; > > > + > > > + for (i =3D 0; i < cluster->core_count; i++) { > > > + r5_core =3D cluster->r5_cores[i]; > > > + put_device(r5_core->dev); > > > + rproc_del(r5_core->rproc); > > > + rproc_free(r5_core->rproc); > > > + } > > > + > > > + kfree(cluster->r5_cores); > > > + kfree(cluster); > > > + platform_set_drvdata(pdev, NULL); > > > +} > > > + > > > +/* > > > + * 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) > > > +{ > > > + struct zynqmp_r5_cluster *cluster; > > > + struct device *dev =3D &pdev->dev; > > > + int ret; > > > + > > > + cluster =3D kzalloc(sizeof(*cluster), GFP_KERNEL); > > > + if (!cluster) > > > + return -ENOMEM; > > > + > > > + cluster->dev =3D dev; > > > + > > > + ret =3D devm_of_platform_populate(dev); > > > + if (ret) { > > > + dev_err_probe(dev, ret, "failed to populate platform dev\n"); > > > + kfree(cluster); > > > + return ret; > > > + } > > > + > > > + /* wire in so each core can be cleaned up at driver remove */ > > > + platform_set_drvdata(pdev, cluster); > > > + > > > + ret =3D zynqmp_r5_cluster_init(cluster); > > > + if (ret) { > > > + zynqmp_r5_cluster_exit(pdev); > > > + dev_err_probe(dev, ret, "Invalid r5f subsystem device tree\n"); > > > + return ret; > > > + } > > > + > > > + ret =3D devm_add_action_or_reset(dev, zynqmp_r5_cluster_exit, pdev); > > > + if (ret) > > > + return ret; > > > + > > > + return 0; > > > +} > > > + > > > +/* Match table for OF platform binding */ > > > +static const struct of_device_id zynqmp_r5_remoteproc_match[] =3D { > > > + { .compatible =3D "xlnx,zynqmp-r5fss", }, > > > + { /* end of list */ }, > > > +}; > > > +MODULE_DEVICE_TABLE(of, zynqmp_r5_remoteproc_match); > > > + > > > +static struct platform_driver zynqmp_r5_remoteproc_driver =3D { > > > + .probe =3D zynqmp_r5_remoteproc_probe, > > > + .driver =3D { > > > + .name =3D "zynqmp_r5_remoteproc", > > > + .of_match_table =3D zynqmp_r5_remoteproc_match, > > > + }, > > > +}; > > > +module_platform_driver(zynqmp_r5_remoteproc_driver); > > > + > > > +MODULE_DESCRIPTION("Xilinx R5F remote processor driver"); > > > +MODULE_AUTHOR("Xilinx Inc."); > > > +MODULE_LICENSE("GPL"); > > There is a discrepency between the GPL-2.0 in the SPDS identifier and t= he above. > > = > > More comments tomorrow or Tuesday. > > = > > Thanks, > > Mathieu > > = > > > -- = > > > 2.25.1 > > > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel