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 6B5A0C27C40 for ; Wed, 22 Nov 2023 20:27:42 +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=NFAB0AvJale5mjdTyKCUe4kIWN0e6nsDpNZBcQkVM10=; b=2Z1oTIcyBxuOwt 04/pLAc7ebIc201Jfvgz+dtyAUfKsq14boykg/uP0Ccu8sT+MQdwG9tQszL3JE54gQh0KR18q+bNG g4sedPbbz8O75z7Qk4bfnkC3hRVEUTRR+Tj5/a+YccPP90ZCmmJZT4Uz9ZTnNW2Ao07wBhKJBQmZ4 UdMDrlQVgKgcV1lJxVE3VggFedp424Y5YKZXptQAPDyiLoHjAzoXkpNpse9y22BonP3fLDVLSSYwt 37GuoKZwpiQPFoQUvxmXy3sJNtoZwv+3GnMe0mNelyOfzTJ7cfY8dY63KMQQROdDNbgW3xIkPLEL6 6Hv3x+SWS8HnbiAqlZLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5toY-0031L0-1y; Wed, 22 Nov 2023 20:27:14 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5toV-0031Jb-1k for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 20:27:13 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5c229dabbb6so130416a12.0 for ; Wed, 22 Nov 2023 12:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700684825; x=1701289625; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TBy3xGKxlkC1z2sWBe+pNLmOxRoFG7lvqR5IZu6tCeQ=; b=vr9O2rJqktBPVahLsSaQSd6pmSHB5PinndjXp4gbpshh8klDOmWyPX/yro8Z5VlJT9 Na1bAxxl4k1TNpb1u2phd3rvbZgieGgCXNSzgnM2OjPVKmxTrHEpdqPwA+TXqUrak8uF 9MJ/LA8Ut393NSnsFxoE/T6kKN0wc924P14TSqjtMtReFOBWkpvlBA03ECCeeL+WITof j//qyT3SCZuzex/Drkz0Reisb7uaDGV1B4BgSwOrp0fGndz95vtpxxjtfE7y0ORK138+ mHHVOSpUV6vk4LZqYegMzoORvn4sG+GHr0XKP3kjnrWDUCLaGPnJsYdvYRZtaSVc/VwF 21VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700684825; x=1701289625; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TBy3xGKxlkC1z2sWBe+pNLmOxRoFG7lvqR5IZu6tCeQ=; b=JPyjSTXQ7eo1XQnbMdDP7ObGLhiRotrAtkNdNOFZRxYGS/o/wNPHrcpcLJ3flUcwOX bxoUdaw4PbeYhVfJA+UCdSg6vE2r9liGYbnOV1hUwJSIAoRpugJMXev31Kbm/l0MGF1y WpQ1DlcxKRyvK29GoHAjE23X0h7Pbu0iVQyUZZFtuZOLxOd9QnKe4vZ5J0xhEtLAHwQG YG24RzQSi4byoa6K5areAeze1r9drYAI3EwRyrxOGECQgYsgSF5TovE7ZG0ZhWMKlRiN Y3BOzWUrP1vYiED0Go8myQ0fjaYhWtUEhewGYS01ZFF35EW+DclmG+CTnMV6QBw6L1f7 IkFw== X-Gm-Message-State: AOJu0YwUBKNDEFb09XvxfQ8rZQbYXgJfk4LcbIR6EQWsSh1otzuQNEuR 8MqQM5Z2+JjePlk+RgL3rfb7aw== X-Google-Smtp-Source: AGHT+IE/kV6pzLlXs5i/gyxu13nVhalvqP73+0HqOoD4OksdoIF+3RWtoPt/dD3tWbTtELULOVkfZw== X-Received: by 2002:a17:90b:180f:b0:280:8356:10b2 with SMTP id lw15-20020a17090b180f00b00280835610b2mr3785292pjb.5.1700684825056; Wed, 22 Nov 2023 12:27:05 -0800 (PST) Received: from p14s ([2604:3d09:148c:c800:178e:e668:ba84:1eed]) by smtp.gmail.com with ESMTPSA id gj14-20020a17090b108e00b00267b38f5e13sm164998pjb.2.2023.11.22.12.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 12:27:04 -0800 (PST) Date: Wed, 22 Nov 2023 13:27:01 -0700 From: Mathieu Poirier To: Tanmay Shah Cc: andersson@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, michal.simek@amd.com, ben.levinsky@amd.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 4/4] remoteproc: zynqmp: parse TCM from device tree Message-ID: References: <20231117174238.1876655-1-tanmay.shah@amd.com> <20231117174238.1876655-5-tanmay.shah@amd.com> 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-20231122_122711_602659_C138ADD3 X-CRM114-Status: GOOD ( 38.47 ) 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 Wed, Nov 22, 2023 at 10:51:08AM -0700, Mathieu Poirier wrote: > On Fri, Nov 17, 2023 at 09:42:38AM -0800, Tanmay Shah wrote: > > ZynqMP TCM information is fixed in driver. Now ZynqMP TCM information > > is available in device-tree. Parse TCM information in driver > > as per new bindings. > > > > Signed-off-by: Tanmay Shah > > --- > > > > Changes in v7: > > - move checking of pm_domain_id from previous patch > > - fix mem_bank_data memory allocation > > > > drivers/remoteproc/xlnx_r5_remoteproc.c | 152 ++++++++++++++++++++---- > > 1 file changed, 128 insertions(+), 24 deletions(-) > > > > diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c > > index 22bccc5075a0..270af73344ef 100644 > > --- a/drivers/remoteproc/xlnx_r5_remoteproc.c > > +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c > > @@ -75,8 +75,8 @@ struct mbox_info { > > }; > > > > /* > > - * Hardcoded TCM bank values. This will be removed once TCM bindings are > > - * accepted for system-dt specifications and upstreamed in linux kernel > > + * Hardcoded TCM bank values. This will stay in driver to maintain backward > > + * compatibility with device-tree that does not have TCM information. > > */ > > static const struct mem_bank_data zynqmp_tcm_banks_split[] = { > > {0xffe00000UL, 0x0, 0x10000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 64KB each */ > > @@ -587,12 +587,21 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > > bank_size = r5_core->tcm_banks[i]->size; > > pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id; > > > > - ret = zynqmp_pm_request_node(pm_domain_id, > > - ZYNQMP_PM_CAPABILITY_ACCESS, 0, > > - ZYNQMP_PM_REQUEST_ACK_BLOCKING); > > - if (ret < 0) { > > - dev_err(dev, "failed to turn on TCM 0x%x", pm_domain_id); > > - goto release_tcm_split; > > + /* > > + * If TCM information is available in device-tree then > > + * in that case, pm domain framework will power on/off TCM. > > + * In that case pm_domain_id is set to 0. If hardcode > > + * bindings from driver is used, then only this driver will > > + * use pm_domain_id. > > + */ > > + if (pm_domain_id) { > > + ret = zynqmp_pm_request_node(pm_domain_id, > > + ZYNQMP_PM_CAPABILITY_ACCESS, 0, > > + ZYNQMP_PM_REQUEST_ACK_BLOCKING); > > + if (ret < 0) { > > + dev_err(dev, "failed to turn on TCM 0x%x", pm_domain_id); > > + goto release_tcm_split; > > + } > > } > > > > dev_dbg(dev, "TCM carveout split mode %s addr=%llx, da=0x%x, size=0x%lx", > > @@ -604,7 +613,8 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > > bank_name); > > if (!rproc_mem) { > > ret = -ENOMEM; > > - zynqmp_pm_release_node(pm_domain_id); > > + if (pm_domain_id) > > + zynqmp_pm_release_node(pm_domain_id); > > goto release_tcm_split; > > } > > > > @@ -617,7 +627,8 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > > /* If failed, Turn off all TCM banks turned on before */ > > for (i--; i >= 0; i--) { > > pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id; > > - zynqmp_pm_release_node(pm_domain_id); > > + if (pm_domain_id) > > + zynqmp_pm_release_node(pm_domain_id); > > } > > return ret; > > } > > @@ -659,13 +670,16 @@ static int add_tcm_carveout_lockstep_mode(struct rproc *rproc) > > pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id; > > > > /* Turn on each TCM bank individually */ > > - ret = zynqmp_pm_request_node(pm_domain_id, > > - ZYNQMP_PM_CAPABILITY_ACCESS, 0, > > - ZYNQMP_PM_REQUEST_ACK_BLOCKING); > > - if (ret < 0) { > > - dev_err(dev, "failed to turn on TCM 0x%x", > > - pm_domain_id); > > - goto release_tcm_lockstep; > > + > > + if (pm_domain_id) { > > + ret = zynqmp_pm_request_node(pm_domain_id, > > + ZYNQMP_PM_CAPABILITY_ACCESS, 0, > > + ZYNQMP_PM_REQUEST_ACK_BLOCKING); > > + if (ret < 0) { > > + dev_err(dev, "failed to turn on TCM 0x%x", > > + pm_domain_id); > > + goto release_tcm_lockstep; > > + } > > } > > > > bank_size = r5_core->tcm_banks[i]->size; > > @@ -683,7 +697,8 @@ static int add_tcm_carveout_lockstep_mode(struct rproc *rproc) > > bank_name); > > if (!rproc_mem) { > > ret = -ENOMEM; > > - zynqmp_pm_release_node(pm_domain_id); > > + if (pm_domain_id) > > + zynqmp_pm_release_node(pm_domain_id); > > goto release_tcm_lockstep; > > } > > > > @@ -700,7 +715,8 @@ static int add_tcm_carveout_lockstep_mode(struct rproc *rproc) > > /* If failed, Turn off all TCM banks turned on before */ > > for (i--; i >= 0; i--) { > > pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id; > > - zynqmp_pm_release_node(pm_domain_id); > > + if (pm_domain_id) > > + zynqmp_pm_release_node(pm_domain_id); > > } > > return ret; > > } > > @@ -931,6 +947,8 @@ static int zynqmp_r5_add_pm_domains(struct rproc *rproc) > > } > > } > > > > + return 0; > > + > > fail_add_pm_domains_lockstep: > > while (--j >= 0) { > > device_link_del(r5_core->pm_dev_core1_link[j]); > > @@ -1012,7 +1030,7 @@ static int zynqmp_r5_rproc_unprepare(struct rproc *rproc) > > > > for (i = 0; i < r5_core->tcm_bank_count; i++) { > > pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id; > > - if (zynqmp_pm_release_node(pm_domain_id)) > > + if (pm_domain_id && zynqmp_pm_release_node(pm_domain_id)) > > dev_warn(r5_core->dev, > > "can't turn off TCM bank 0x%x", pm_domain_id); > > } > > @@ -1087,6 +1105,83 @@ static struct zynqmp_r5_core *zynqmp_r5_add_rproc_core(struct device *cdev) > > return ERR_PTR(ret); > > } > > > > +static int zynqmp_r5_get_tcm_node_from_dt(struct zynqmp_r5_cluster *cluster) > > +{ > > + struct zynqmp_r5_core *r5_core; > > + int i, j, tcm_bank_count, ret; > > + struct platform_device *cpdev; > > + struct mem_bank_data *tcm; > > + struct device_node *np; > > + struct resource *res; > > + u64 abs_addr, size; > > + struct device *dev; > > + > > + for (i = 0; i < cluster->core_count; i++) { > > + r5_core = cluster->r5_cores[i]; > > + dev = r5_core->dev; > > + np = dev_of_node(dev); > > + > > + /* we have address cell 2 and size cell as 2 */ > > + ret = of_property_count_elems_of_size(np, "reg", > > + if (ret <= 0) { > > + dev_err(dev, "can't get reg property err %d\n", ret); > > + return -EINVAL; > > + } > > + > > + tcm_bank_count = ret; > > This is useless - please use @tcm_bank_count instead of @ret above. > I am done reviewing this set. Thanks, Mathieu > > + > > + r5_core->tcm_banks = devm_kcalloc(dev, tcm_bank_count, > > + sizeof(struct mem_bank_data *), > > + GFP_KERNEL); > > + if (!r5_core->tcm_banks) > > + ret = -ENOMEM; > > + > > + r5_core->tcm_bank_count = tcm_bank_count; > > + for (j = 0; j < tcm_bank_count; j++) { > > + tcm = devm_kzalloc(dev, sizeof(struct mem_bank_data), > > + GFP_KERNEL); > > + if (!tcm) > > + return -ENOMEM; > > + > > + r5_core->tcm_banks[j] = tcm; > > + > > + /* get tcm address without translation */ > > + ret = of_property_read_reg(np, j, &abs_addr, &size); > > + if (ret) { > > + dev_err(dev, "failed to get reg property\n"); > > + return ret; > > + } > > + > > + /* > > + * remote processor can address only 32 bits > > + * so convert 64-bits into 32-bits. This will discard > > + * any unwanted upper 32-bits. > > + */ > > + tcm->da = (u32)abs_addr; > > + tcm->size = (u32)size; > > + > > + cpdev = to_platform_device(dev); > > + res = platform_get_resource(cpdev, IORESOURCE_MEM, j); > > + if (!res) { > > + dev_err(dev, "failed to get tcm resource\n"); > > + return -EINVAL; > > + } > > + > > + tcm->addr = (u32)res->start; > > + tcm->bank_name = (char *)res->name; > > + res = devm_request_mem_region(dev, tcm->addr, tcm->size, > > + tcm->bank_name); > > + if (!res) { > > + dev_err(dev, "failed to request tcm resource\n"); > > + return -EINVAL; > > + } > > + } > > + } > > + > > + return 0; > > +} > > + > > /** > > * zynqmp_r5_get_tcm_node() > > * Ideally this function should parse tcm node and store information > > @@ -1165,10 +1260,19 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster, > > struct zynqmp_r5_core *r5_core; > > int ret, i; > > > > - ret = zynqmp_r5_get_tcm_node(cluster); > > - if (ret < 0) { > > - dev_err(dev, "can't get tcm node, err %d\n", ret); > > - return ret; > > + r5_core = cluster->r5_cores[0]; > > + if (of_find_property(r5_core->np, "reg", NULL)) { > > + ret = zynqmp_r5_get_tcm_node_from_dt(cluster); > > + if (ret) { > > + dev_err(dev, "can't get tcm node from dt, err %d\n", ret); > > + return ret; > > + } > > + } else { > > + ret = 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 = 0; i < cluster->core_count; i++) { > > -- > > 2.25.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel