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 232B9C5478C for ; Wed, 28 Feb 2024 17:08:56 +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=VhB2ppZoWO67AITzMpz7+5dAk80DGmb4SvxWR/711C8=; b=NPfI33HisH8LF2 Cn/HxgStrhAWH/95n1dJ9B7eaJ8QPmfwsaU1PRGVMw/rWy+UB1cVp8OpnHeCC5bG2n/D1YXVyniWx gFXCXfMg1xnoV4rnXVxqgp7a8S/cPB0wZAzF6Ys7gqiM+R8ZS8gKR20xChQJOP7W+5+dlV/DdGi8p dVlve6sd441ZYI5AEqdizJgS4G2k2fcnrB0xMlMSK+NPUd/lGXK3GoQk4AqmJvbH3zro3Wo1HO7Yo EmR/PTJMTvanSUekGC7aU6iicRRuBiiLTTFXcitduemuQc7BJ9C+2GtHi3KOaunxWP0UJ8L+y1M/o L47ICtauJUl5ueIavKEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfNQE-0000000AEo4-0k9t; Wed, 28 Feb 2024 17:08:46 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfNQC-0000000AEne-0lMn for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 17:08:45 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6e48eef8be5so4125902b3a.1 for ; Wed, 28 Feb 2024 09:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709140123; x=1709744923; 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=vZ7yX46ZRthWSl8mAmdFHCANI4NXz4hftEaGGdUSpkA=; b=JViU4Uo+4pV/bt0O8+GiGuqegsHMeLNo+yFN6VgrfPYGBmHm9YI4+pc3oB5Ye7+qcp uLz2UHrdTZjx3dR59R7tSz0sxbLDwwAkPDm72A4gzOHxj0DurkZdPVJwB5NZxRUYpqDY uXPIwO1Fq8mOQpRH1I8yTHqVsisQs623WUMBCp9Ehcm5d68zz4Blu7mEmAkkXLMJvFQI n6GzHws+yWpoEX00YlySuB8EciJpm8KXD0fVEK6anqIRfCjoTUidnz0UkXYgaQPVVYU9 Lrr2IVOlwH7ibunaeFfS8dGd0mZrwlWZVKSv0GzH48BQ1b+/cUjFuluVy1aFh+BdJrLe apfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709140123; x=1709744923; 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=vZ7yX46ZRthWSl8mAmdFHCANI4NXz4hftEaGGdUSpkA=; b=EAsIBRCGatkZk+bZfavW6P5ThEsnr7IB2gwimdz0UZa/DMk9kwLOKce/X0DhTxHE8I uSSrLMkw67vYXpHssw/RCLx+IS4TxBTTau6ijfgT8NXHku1w8sO8teAGVhThHUUpuf9Y aEc7e+0akzvs+PBkwsPeqhiMt4qW5I9RPQgZP+M0a6eNh6mbMO+RNedw3GnrUS2ZfJAi ncl1KYUr7MytEJU/e0vbIlbQmsOm/JJPQrAnNhWB8e+nl9xD9Kekkvy8YKKTWglEL5mE IvXyV9QBMJyUHj7Swr0x812E0BAZdoclcamnv1oM0kJ5vg5bvCP9PgjVVuepSqYNf5QV jSiA== X-Forwarded-Encrypted: i=1; AJvYcCUB9Em0olPj9EIxCRFBcLLABxu38SX5BS3STGy923BfjfWEgP5XpuJ1qULTvimNARZlpc+zvVetOuyQScQJYs8vka7vRbsbBdB7aJU7NeezgOnzjnw= X-Gm-Message-State: AOJu0YxpjiuUUspHJzTaaOba97HWLB3ypQixSKTgGCI0kXBreg8GBhQM ZfnWOWaFaX+dGLEmUc4a12VcKBGjKU+jdTMJ1RunldeQ/Q9Rb8P3rm1xuYMJdFI= X-Google-Smtp-Source: AGHT+IH+K0cPBkC1fHRGR/g4p5u9bQgkIr3UPw3K8hhP2snwADjcStTQwKq4T9ECeiZWCeuaYPvZQQ== X-Received: by 2002:a05:6a00:80d9:b0:6e5:31f5:94cd with SMTP id ei25-20020a056a0080d900b006e531f594cdmr234150pfb.0.1709140123424; Wed, 28 Feb 2024 09:08:43 -0800 (PST) Received: from p14s ([2604:3d09:148c:c800:96d9:3aed:533c:8c94]) by smtp.gmail.com with ESMTPSA id p54-20020a056a0026f600b006e5360f1cffsm5303122pfw.180.2024.02.28.09.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:08:43 -0800 (PST) Date: Wed, 28 Feb 2024 10:08:40 -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 v11 1/4] remoteproc: zynqmp: fix lockstep mode memory region Message-ID: References: <20240219174437.3722620-1-tanmay.shah@amd.com> <20240219174437.3722620-7-tanmay.shah@amd.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240219174437.3722620-7-tanmay.shah@amd.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_090844_269599_15A4177A X-CRM114-Status: GOOD ( 30.81 ) 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 Mon, Feb 19, 2024 at 09:44:34AM -0800, Tanmay Shah wrote: > In lockstep mode, r5 core0 uses TCM of R5 core1. Following is lockstep > mode memory region as per hardware reference manual. > > | *TCM* | *R5 View* | *Linux view* | > | R5_0 ATCM (128 KB) | 0x0000_0000 | 0xFFE0_0000 | > | R5_0 BTCM (128 KB) | 0x0002_0000 | 0xFFE2_0000 | > > However, driver shouldn't model it as above because R5 core0 TCM and core1 > TCM has different power-domains mapped to it. > Hence, TCM address space in lockstep mode should be modeled as 64KB > regions only where each region has its own power-domain as following: > > | *TCM* | *R5 View* | *Linux view* | > | R5_0 ATCM0 (64 KB) | 0x0000_0000 | 0xFFE0_0000 | > | R5_0 BTCM0 (64 KB) | 0x0002_0000 | 0xFFE2_0000 | > | R5_0 ATCM1 (64 KB) | 0x0001_0000 | 0xFFE1_0000 | > | R5_0 BTCM1 (64 KB) | 0x0003_0000 | 0xFFE3_0000 | > > This makes driver maintanance easy and makes design robust for future > platorms as well. > > Signed-off-by: Tanmay Shah Now that I have a clearer picture of where things are going, I am adding this patch to rproc-next. I'll wait for the DT crew for the rest of this set. Thanks, Mathieu > --- > drivers/remoteproc/xlnx_r5_remoteproc.c | 145 ++---------------------- > 1 file changed, 12 insertions(+), 133 deletions(-) > > diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c > index 4395edea9a64..42b0384d34f2 100644 > --- a/drivers/remoteproc/xlnx_r5_remoteproc.c > +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c > @@ -84,12 +84,12 @@ static const struct mem_bank_data zynqmp_tcm_banks_split[] = { > {0xffeb0000UL, 0x20000, 0x10000UL, PD_R5_1_BTCM, "btcm1"}, > }; > > -/* In lockstep mode cluster combines each 64KB TCM and makes 128KB TCM */ > +/* In lockstep mode cluster uses each 64KB TCM from second core as well */ > static const struct mem_bank_data zynqmp_tcm_banks_lockstep[] = { > - {0xffe00000UL, 0x0, 0x20000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 128KB each */ > - {0xffe20000UL, 0x20000, 0x20000UL, PD_R5_0_BTCM, "btcm0"}, > - {0, 0, 0, PD_R5_1_ATCM, ""}, > - {0, 0, 0, PD_R5_1_BTCM, ""}, > + {0xffe00000UL, 0x0, 0x10000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 64KB each */ > + {0xffe20000UL, 0x20000, 0x10000UL, PD_R5_0_BTCM, "btcm0"}, > + {0xffe10000UL, 0x10000, 0x10000UL, PD_R5_1_ATCM, "atcm1"}, > + {0xffe30000UL, 0x30000, 0x10000UL, PD_R5_1_BTCM, "btcm1"}, > }; > > /** > @@ -540,14 +540,14 @@ static int tcm_mem_map(struct rproc *rproc, > } > > /* > - * add_tcm_carveout_split_mode() > + * add_tcm_banks() > * @rproc: single R5 core's corresponding rproc instance > * > - * allocate and add remoteproc carveout for TCM memory in split mode > + * allocate and add remoteproc carveout for TCM memory > * > * return 0 on success, otherwise non-zero value on failure > */ > -static int add_tcm_carveout_split_mode(struct rproc *rproc) > +static int add_tcm_banks(struct rproc *rproc) > { > struct rproc_mem_entry *rproc_mem; > struct zynqmp_r5_core *r5_core; > @@ -580,10 +580,10 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > 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; > + goto release_tcm; > } > > - dev_dbg(dev, "TCM carveout split mode %s addr=%llx, da=0x%x, size=0x%lx", > + dev_dbg(dev, "TCM carveout %s addr=%llx, da=0x%x, size=0x%lx", > bank_name, bank_addr, da, bank_size); > > rproc_mem = rproc_mem_entry_init(dev, NULL, bank_addr, > @@ -593,7 +593,7 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > if (!rproc_mem) { > ret = -ENOMEM; > zynqmp_pm_release_node(pm_domain_id); > - goto release_tcm_split; > + goto release_tcm; > } > > rproc_add_carveout(rproc, rproc_mem); > @@ -601,7 +601,7 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > > return 0; > > -release_tcm_split: > +release_tcm: > /* 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; > @@ -610,127 +610,6 @@ static int add_tcm_carveout_split_mode(struct rproc *rproc) > return ret; > } > > -/* > - * add_tcm_carveout_lockstep_mode() > - * @rproc: single R5 core's corresponding rproc instance > - * > - * allocate and add remoteproc carveout for TCM memory in lockstep mode > - * > - * return 0 on success, otherwise non-zero value on failure > - */ > -static int add_tcm_carveout_lockstep_mode(struct rproc *rproc) > -{ > - struct rproc_mem_entry *rproc_mem; > - struct zynqmp_r5_core *r5_core; > - int i, num_banks, ret; > - phys_addr_t bank_addr; > - size_t bank_size = 0; > - struct device *dev; > - u32 pm_domain_id; > - char *bank_name; > - u32 da; > - > - r5_core = rproc->priv; > - dev = r5_core->dev; > - > - /* Go through zynqmp banks for r5 node */ > - num_banks = r5_core->tcm_bank_count; > - > - /* > - * In lockstep mode, TCM is contiguous memory block > - * However, each TCM block still needs to be enabled individually. > - * So, Enable each TCM block individually. > - * Although ATCM and BTCM is contiguous memory block, add two separate > - * carveouts for both. > - */ > - for (i = 0; i < num_banks; i++) { > - 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; > - } > - > - bank_size = r5_core->tcm_banks[i]->size; > - if (bank_size == 0) > - continue; > - > - bank_addr = r5_core->tcm_banks[i]->addr; > - da = r5_core->tcm_banks[i]->da; > - bank_name = r5_core->tcm_banks[i]->bank_name; > - > - /* Register TCM address range, TCM map and unmap functions */ > - rproc_mem = rproc_mem_entry_init(dev, NULL, bank_addr, > - bank_size, da, > - tcm_mem_map, tcm_mem_unmap, > - bank_name); > - if (!rproc_mem) { > - ret = -ENOMEM; > - zynqmp_pm_release_node(pm_domain_id); > - goto release_tcm_lockstep; > - } > - > - /* If registration is success, add carveouts */ > - rproc_add_carveout(rproc, rproc_mem); > - > - dev_dbg(dev, "TCM carveout lockstep mode %s addr=0x%llx, da=0x%x, size=0x%lx", > - bank_name, bank_addr, da, bank_size); > - } > - > - return 0; > - > -release_tcm_lockstep: > - /* 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); > - } > - return ret; > -} > - > -/* > - * add_tcm_banks() > - * @rproc: single R5 core's corresponding rproc instance > - * > - * allocate and add remoteproc carveouts for TCM memory based on cluster mode > - * > - * return 0 on success, otherwise non-zero value on failure > - */ > -static int add_tcm_banks(struct rproc *rproc) > -{ > - struct zynqmp_r5_cluster *cluster; > - struct zynqmp_r5_core *r5_core; > - struct device *dev; > - > - r5_core = rproc->priv; > - if (!r5_core) > - return -EINVAL; > - > - dev = r5_core->dev; > - > - cluster = dev_get_drvdata(dev->parent); > - if (!cluster) { > - dev_err(dev->parent, "Invalid driver data\n"); > - return -EINVAL; > - } > - > - /* > - * In lockstep mode TCM banks are one contiguous memory region of 256Kb > - * In split mode, each TCM bank is 64Kb and not contiguous. > - * We add memory carveouts accordingly. > - */ > - if (cluster->mode == SPLIT_MODE) > - return add_tcm_carveout_split_mode(rproc); > - else if (cluster->mode == LOCKSTEP_MODE) > - return add_tcm_carveout_lockstep_mode(rproc); > - > - return -EINVAL; > -} > - > /* > * zynqmp_r5_parse_fw() > * @rproc: single R5 core's corresponding rproc instance > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel