Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp47459ima; Thu, 25 Oct 2018 15:12:21 -0700 (PDT) X-Google-Smtp-Source: AJdET5fdmK/0vKnmaErV7DmaZ1WDTkLR7QZYtV8wmVpUbSubnk+N7cCo65pRTx3YEwCqZRHnp7Gg X-Received: by 2002:a63:c341:: with SMTP id e1-v6mr894907pgd.452.1540505541783; Thu, 25 Oct 2018 15:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540505541; cv=none; d=google.com; s=arc-20160816; b=hA7zgJdKiELnHDG3rdIftz5mxCSBPYINeo2JoUQwOar5VRoy0hkojYA5gro03fdOyd EImKi3kHnNS9PSDPLJwD0B3Ig7Wq/8oj20znzY9gITT2TKG8lTy2lXCzR/B6PsW8csPq ctmAK3Q2/avjKU1/OaoO3ScvFnlfMddNrshJ+U3Ds+o+Xz6REy4vF0fRrkUO3EX6hxLw yNv6WjdDtPH0jP9xHsnK5aWT9N7VkedaOztUFjGx0BL7uu6qNk0GAanr+Tto2kfQa1xf zvN3UJxKsfB7rbViNkUKvPnai9Bh5VI4Saj6T5ioFlXIl65nshReaAiZoK5CfnvzB24z zBwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=GW8SZV4U/33zEYscr4lUF0/+PdPOEE1RSzvBVBekrRY=; b=fSDQ44ja/HUkFIqR7Ex6YBLDWRMbydjaN6emD6iVBombyZd54wqG2UIHzcStBPnAPg tTW7PqWHoXspJxf/yzbltMD0oKEmIgVsWqujik+GokTrpjVZdQGYH2akUrEHJcve2yGF m8uvCD4+Jwh2CsBF332NOiOvLWM/A085fE6vtqJl+u7+zCBuSn+2EoWlhrKUf4mYOeuB yoDk3jqRajhEr0+3UKyyipnQ8Q5VFDgKuQIh8qXse3QFTUTrVG2qKL4DFWSbif/Jp9+/ EsyaY0vqUNrblpJguHTTCsQjWDhCxEK7z42aZmq79EOQfomJrPLfLh4QnRFQnbyxj6kS JY2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aQKF1Epp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23-v6si8972853plz.225.2018.10.25.15.11.51; Thu, 25 Oct 2018 15:12:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aQKF1Epp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbeJZGpx (ORCPT + 99 others); Fri, 26 Oct 2018 02:45:53 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:43428 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbeJZGpx (ORCPT ); Fri, 26 Oct 2018 02:45:53 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w9PMBCTs105874; Thu, 25 Oct 2018 17:11:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1540505472; bh=GW8SZV4U/33zEYscr4lUF0/+PdPOEE1RSzvBVBekrRY=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=aQKF1EppdgTy4JMoazWVJLmtn+tKcfPAOGSiE9dzXfWezfGYWuZ1OcDc0tQuW1wUC lvhZDaCHkr1BN5Td7ubsNCYtVefFPGjJIHDAbjIf/KnwDzxdIcQDaCBHYsDog1OB/2 n4E/QTWKWWObzyOKf+UPkPncW2WXICMc+mdthv2o= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id w9PMBChn008546 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 25 Oct 2018 17:11:12 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 25 Oct 2018 17:11:12 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 25 Oct 2018 17:11:12 -0500 Received: from [128.247.58.153] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9PMBCJP029064; Thu, 25 Oct 2018 17:11:12 -0500 Subject: Re: [PATCH v4 15/17] remoteproc: da8xx: declare reserved memory region for vdev device To: Loic PALLARDY , "bjorn.andersson@linaro.org" , "ohad@wizery.com" CC: "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Arnaud POULIQUEN , "benjamin.gaignard@linaro.org" References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> <1532697292-14272-16-git-send-email-loic.pallardy@st.com> <039aad0dc35d4d919bb10a9e37a860f7@SFHDAG7NODE2.st.com> From: Suman Anna Message-ID: <3da26f61-7d58-11e5-75a3-7d865f9bf21f@ti.com> Date: Thu, 25 Oct 2018 17:11:12 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <039aad0dc35d4d919bb10a9e37a860f7@SFHDAG7NODE2.st.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/24/18 8:19 AM, Loic PALLARDY wrote: > > >> -----Original Message----- >> From: Suman Anna >> Sent: mercredi 24 octobre 2018 04:58 >> To: Loic PALLARDY ; bjorn.andersson@linaro.org; >> ohad@wizery.com >> Cc: linux-remoteproc@vger.kernel.org; linux-kernel@vger.kernel.org; >> Arnaud POULIQUEN ; >> benjamin.gaignard@linaro.org >> Subject: Re: [PATCH v4 15/17] remoteproc: da8xx: declare reserved memory >> region for vdev device >> >> Hi Loic, >> >> On 7/27/18 8:14 AM, Loic Pallardy wrote: >>> This patch introduces da8xx_rproc_parse_fw() to declare a >>> carveout region based on reserved memory for vdev buffer >>> allocation. >>> >>> Signed-off-by: Loic Pallardy >>> --- >>> drivers/remoteproc/da8xx_remoteproc.c | 38 >> +++++++++++++++++++++++++++++++++++ >>> 1 file changed, 38 insertions(+) >>> >>> diff --git a/drivers/remoteproc/da8xx_remoteproc.c >> b/drivers/remoteproc/da8xx_remoteproc.c >>> index b668e32..679a076 100644 >>> --- a/drivers/remoteproc/da8xx_remoteproc.c >>> +++ b/drivers/remoteproc/da8xx_remoteproc.c >>> @@ -16,6 +16,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -179,10 +180,47 @@ static void da8xx_rproc_kick(struct rproc *rproc, >> int vqid) >>> writel(SYSCFG_CHIPSIG2, drproc->chipsig); >>> } >>> >>> +static int da8xx_rproc_parse_fw(struct rproc *rproc, const struct firmware >> *fw) >>> +{ >>> + struct device *dev = rproc->dev.parent; >>> + struct rproc_mem_entry *mem; >>> + struct device_node *node; >>> + struct resource res; >>> + int err; >>> + >>> + node = of_parse_phandle(dev->of_node, "memory-region", 0); >>> + if (!node) { >>> + dev_err(dev, "No memory-region specified\n"); >>> + return -EINVAL; >>> + } >>> + >>> + err = of_address_to_resource(node, 0, &res); >>> + if (err) { >>> + dev_err(dev, "Bad memory-region definition\n"); >>> + return err; >>> + } >>> + >>> + /* Register memory region for vdev buffer allocation */ >>> + mem = rproc_of_resm_mem_entry_init(dev, 0, >> resource_size(&res), >>> + res.start, "vdev0buffer");> + >>> + if (!mem) >>> + return -ENOMEM; >>> + >>> + rproc_add_carveout(rproc, mem); >>> + >>> + return rproc_elf_load_rsc_table(rproc, fw); >>> +} >> >> Thanks for the patch, but this creates a kernel crash for me due to >> overlaps with manually created carveouts. I currently have a single >> memory-region and all allocations come from the same DMA pool, but the >> rproc_of_resm_mem_entry_init() creates an overall mem entry without the >> va being set (no alloc function plumbed in). In general, it is permitted >> to use the same reserved-memory node with multiple devices, so the index >> usage should have allowed it to do DMA allocations with vdev devices, >> but the loading is performed even before the vdev allocations and the >> da_to_va matches the first entry with no va set causing the crash. > > Hummm, I didn't fall in this case, but clearly da_to_va should not crashed. > Not allocated carveout should be bypassed in the loop. Thanks for pointing this. I need to fix it. da_to_va didn't crash, it just returned a bogus va based on base address 0x0 (as you can see below) as it looks through all carveouts, and my loading crashed. This brings us to fact that we now need to distinguish allocated carveouts vs non-allocated carveouts. regards Suman > > The rproc_of_resm_mem_entry_init() is simply registering the reserved memory to be attached to vdev device. > So that normal it won't be allocated by rproc core (there is no alloc/free function specificied in this helper). > > Regards, > Loic >> >> Here's my debugfs output of the carveout_memories for reference, >> >> Carveout memory entry: >> Name: vdev0buffer >> Virtual address: 00000000 >> DMA address: 0x00000000 >> Device address: 0xc3000000 >> Length: 0x1000000 Bytes >> >> Carveout memory entry: >> Name: vdev0vring0 >> Virtual address: c3000000 >> DMA address: 0xc3000000 >> Device address: 0xc3000000 >> Length: 0x3000 Bytes >> >> Carveout memory entry: >> Name: vdev0vring1 >> Virtual address: c3004000 >> DMA address: 0xc3004000 >> Device address: 0xc3004000 >> Length: 0x3000 Bytes >> >> Carveout memory entry: >> Name: DSP_MEM_DATA >> Virtual address: c3100000 >> DMA address: 0xc3100000 >> Device address: 0xc3100000 >> Length: 0xf00000 Bytes >> >> You can drop both this patch and the keystone_remoteproc patch from the >> series. I did not run into any issues there since I did not have any >> RSC_CARVEOUT entries there. Also, see my comments on the next patch >> (the >> changes in ST) in general regarding these API. Looks like this needs >> some more time in ironing out the issues. >> >> regards >> Suman >> >> >> >>> + >>> static const struct rproc_ops da8xx_rproc_ops = { >>> .start = da8xx_rproc_start, >>> .stop = da8xx_rproc_stop, >>> .kick = da8xx_rproc_kick, >>> + .parse_fw = da8xx_rproc_parse_fw, >>> + .load = rproc_elf_load_segments, >>> + .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, >>> + .sanity_check = rproc_elf_sanity_check, >>> + .get_boot_addr = rproc_elf_get_boot_addr, >>> }; >>> >>> static int da8xx_rproc_get_internal_memories(struct platform_device >> *pdev, >>> >