Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp77405ima; Thu, 25 Oct 2018 15:50:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5eLsPEGiaipPr9waWqED6et9gS2d9hY1a/kxUPCo/1QWwb/tVzeSwSyLHiFf583XmOnt5UD X-Received: by 2002:a63:5e43:: with SMTP id s64mr1000794pgb.101.1540507851687; Thu, 25 Oct 2018 15:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540507851; cv=none; d=google.com; s=arc-20160816; b=nacuRaQOiWSOWXekQ56qQvKP/HaMJg7tW19goFfaQaVC/Fts9WtGqHFW7yzYPLX957 I9CF5jCxbxaxmKv4pTNvA9kmyIJSxYtucnRXLmOf1wW70Nn613rQ3Ywksy2++pEFoBH4 bBe9s+1mAQZ5gv2Zdysy2P2bHthoFJEl0gmf0xpnFvvimWkWfuXst1qstXYtldoHuU+J Ess9I/EeZ/oWaNFEH6DPBLfr3IWJJYg4X7HnZ4ZQNGSALBwbIcPrTFk0llpPfzP/T6sX x63C9OfvPsr+lWYFE01yqgavdViY0KPvfwgsr5FguQ333aBv3petsrEtyw/ip8gIhJWa 9X3Q== 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=M5RrSis0IJYZXofFfHCRuJXKKOp70bhksYRr4BEZTC4=; b=N5OT/YuLTwTapIVn059NnMrZMNAyIRRTjJNwBWFZyA/aCdlwAGiq5/uYp6BpOi1XQM ttLXoP1PYqZ4U3nzaAe6bJk3pKgb0R+nLjzzslUhyry8n2oiG9Vm5+88S67Recp6CIkZ jfzY35kNcWyb/ioXPXBNrGH3x4/ktPvCeZQI1WcMH9ZOylGpChGWE1p8tJfAo2BXdyrb tBv6l+VeK8TtEDNcKWPDR6wpFh9Hg/PX0Kjbr8ZptK2txE5Uk9UqhmnUntbylKhTmdBu zQ/TIu0GOTnz1/nEg6yk1NUH6RVpT6FbXywK4XIER2h78PsVaUsPQevry1DA85fAOR07 e6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kbf6jSps; 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 bc1-v6si8705465plb.204.2018.10.25.15.50.35; Thu, 25 Oct 2018 15:50:51 -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=kbf6jSps; 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 S1727574AbeJZHYn (ORCPT + 99 others); Fri, 26 Oct 2018 03:24:43 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:49138 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726570AbeJZHYn (ORCPT ); Fri, 26 Oct 2018 03:24:43 -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 w9PMo7Qm115848; Thu, 25 Oct 2018 17:50:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1540507807; bh=M5RrSis0IJYZXofFfHCRuJXKKOp70bhksYRr4BEZTC4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=kbf6jSpsba5WGUjWG7ihJmx136src61qT9g7t0vIv4CBkZeYRZxBMauZ7Aip7V83C tCfHByi5LdY4xv19G9NhLbZ7xbeK1rflEItMIAzPTG4OwQ/FFDjGdZzt2DwkXSEVx/ 5n870mb8T+TAm46D9E3/+t2pGZlr3skP5I4KJPHE= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id w9PMo7Nc051841 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 25 Oct 2018 17:50:07 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE104.ent.ti.com (10.64.6.25) 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:50:07 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE106.ent.ti.com (10.64.6.27) 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:50:07 -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 w9PMo7Zg010934; Thu, 25 Oct 2018 17:50:07 -0500 Subject: Re: [PATCH v4 10/17] remoteproc: add helper function to check carveout device address 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-11-git-send-email-loic.pallardy@st.com> <2844874b-9484-aeee-c614-411d0ff38d12@ti.com> <8b16461d7d99487480253cde5cdcfd2c@SFHDAG7NODE2.st.com> From: Suman Anna Message-ID: <5e86ac7e-e0db-205e-1c60-bc0be9f75859@ti.com> Date: Thu, 25 Oct 2018 17:50:07 -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: <8b16461d7d99487480253cde5cdcfd2c@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 Hi Loic, On 10/24/18 10:24 AM, Loic PALLARDY wrote: > Hi Suman, > >> -----Original Message----- >> From: Suman Anna >> Sent: mercredi 24 octobre 2018 00:14 >> 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 10/17] remoteproc: add helper function to check >> carveout device address >> >> Hi Loic, >> >> On 7/27/18 8:14 AM, Loic Pallardy wrote: >>> This patch introduces a function to verify that a specified carveout >>> is fitting request device address and associated length >>> >>> Signed-off-by: Loic Pallardy >>> --- >>> drivers/remoteproc/remoteproc_core.c | 47 >> ++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 47 insertions(+) >>> >>> diff --git a/drivers/remoteproc/remoteproc_core.c >> b/drivers/remoteproc/remoteproc_core.c >>> index 1e0fe3e..5dd5edf 100644 >>> --- a/drivers/remoteproc/remoteproc_core.c >>> +++ b/drivers/remoteproc/remoteproc_core.c >>> @@ -259,6 +259,53 @@ struct rproc_mem_entry * >>> return mem; >>> } >>> >>> +/** >>> + * rproc_check_carveout_da() - Check specified carveout da configuration >>> + * @rproc: handle of a remote processor >>> + * @mem: pointer on carveout to check >>> + * @da: area device address >>> + * @len: associated area size >>> + * >>> + * This function is a helper function to verify requested device area >> (couple >>> + * da, len) is part of specified carevout. >> >> %s/carevout/carveout/ > OK >> >>> + * >>> + * Return: 0 if carveout matchs request else -ENOMEM >> >> %s/matchs/matches/ > OK >> >>> + */ >>> +int rproc_check_carveout_da(struct rproc *rproc, struct >> rproc_mem_entry *mem, >> >> static int since this seems to be only a local function. > OK >> >>> + u32 da, u32 len) >>> +{ >>> + struct device *dev = &rproc->dev; >>> + int delta = 0; >>> + >>> + /* Check requested resource length */ >>> + if (len > mem->len) { >>> + dev_err(dev, "Registered carveout doesn't fit len >> request\n"); >>> + return -ENOMEM; >> >> ENOMEM not typically used for these kind of errors, you were probably >> inclined to used this since it is dealing with memory. > > -EINVAL will be better >> >>> + } >>> + >> >> Both the below codepaths are exercised only when da is not >> FW_RSC_ADDR_ANY, and you are returning 0 otherwise (which is the case of >> matches as per your description above). Is that what you really want - >> should it be an error > > Yes when da is equal to FW_RSC_ADDR_ANY we should check the length too Can you update the comments in the function description accordingly as well, the current code silently returns 0 if da = FW_RSC_ADDR_ANY. > >> >>> + if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) >> { >>> + /* Update existing carveout da */ >>> + mem->da = da; >> >> Where would you need to update this? > In that case, we have 2 carveouts with the same name. > One has some fixed requests. The other one has none. > The goal here is to align both on the one which has the strongest requirements. > I think length is missing. It almost looks like there is a need for range overlap checks on all the carveouts after all of them are registered, and error out if any overlap irrespective of the name schema. regards Suman > > Regards, > Loic > >> >> regards >> Suman >> >>> + } else if (da != FW_RSC_ADDR_ANY && mem->da != >> FW_RSC_ADDR_ANY) { >>> + delta = da - mem->da; >>> + >>> + /* Check requested resource belongs to registered carveout >> */ >>> + if (delta < 0) { >>> + dev_err(dev, >>> + "Registered carveout doesn't fit da >> request\n"); >>> + return -ENOMEM; >>> + } >>> + >>> + if (delta + len > mem->len) { >>> + dev_err(dev, >>> + "Registered carveout doesn't fit len >> request\n"); >>> + return -ENOMEM; >>> + } >>> + } >>> + >>> + return 0; >> >> >>> +} >>> + >>> int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) >>> { >>> struct rproc *rproc = rvdev->rproc; >>> >