Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6596490ybl; Wed, 15 Jan 2020 07:12:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyImZPORHtR5Al7Q6vkZbwUyeNtrBTmWwVLs2lyJZWDXuF5sag5Jllt4B6p6GdobiGKp4aL X-Received: by 2002:aca:3f54:: with SMTP id m81mr156371oia.73.1579101161018; Wed, 15 Jan 2020 07:12:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579101161; cv=none; d=google.com; s=arc-20160816; b=Ox4znI59LJ5EnrwXCXr2yEoH8Xzsq51Td/RxM/YY2HyM/WMeetXB2cfxCKKCsXfJDZ Ss3sGtdC8ndSXTpaJd+Fp1hSrFSx0Ph1g8CBemDT920u9lLxLBuPIUV5Ve9AsdiiipwQ ZTkatyr8a7uLYDK6PZ+EYi08NezD4guXE1sSA6aTKYxwjH59oz+bdiplTA2NFF3zvr07 TBURai6hy7yuDbKd3m1OCgrzrR5UOA2XwVe/1jNPGUu74VEwv5NnHiT84jEcsX33mlBu C8tKxW/mxWLAd/2Dezb7cWvSaY1HJHFAm/Rio53t/UTnY/Bt6MHALSt6RWehTzIkueLP 67GQ== 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=oY/yYuph59ZqrkV+Eznpr3R9n6eoYf1RmuTALklKNYw=; b=k5DPIUMBlUfinKAWRh0CaDlx7dCBgl0AW9wufkP+CBeez62Mon+cY531e24TOfLCR4 CHKmgEW80V086yABseBSkUngZO95t468zlOsuRUaeds0BWfZ+IFaVRnjAnE+8bwJ9Tc4 WpSpSSVinsK4gqQ3g0qlkmfXFoeeMDP6BKmIXjuljI6zzmJvAkFozDMQDNLL8Jp7AKxk QOMXIiYJ6YNR9lYcyq+1m9YWskp3b/BC4G50+3+W3WIoHi2D7I/pxExiC5TittpdvgQJ oMU5V8sehEx43wBd7u+Iy4p9RS1vrSpNACz5dP5KIdQQjnW3yEI8u3RxP/E5hitU15Tt AOVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=Uw26TWOQ; 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=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si11060248otq.23.2020.01.15.07.12.27; Wed, 15 Jan 2020 07:12:41 -0800 (PST) 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=@st.com header.s=STMicroelectronics header.b=Uw26TWOQ; 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=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729164AbgAOPJj (ORCPT + 99 others); Wed, 15 Jan 2020 10:09:39 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:30782 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726562AbgAOPJi (ORCPT ); Wed, 15 Jan 2020 10:09:38 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00FEw6Cs015516; Wed, 15 Jan 2020 16:09:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=oY/yYuph59ZqrkV+Eznpr3R9n6eoYf1RmuTALklKNYw=; b=Uw26TWOQnY4Wgr1w38wQ//dX+AdZ0SGREbBKLtiOo1UrmQHp8m1cpJvf13KVNDegVbhG oJpMi1I3hK3ZbwRhaRzdAggRYhlDRBZyDyVI2O8VjABKx0vtCmVG3j2X8nzlTW2AxyD/ gKkBStVz15PYnVlMUaC+Cyk7eqoenV7t+nvuhQ8J3fihVYyN6ICL16TJsNiyKaF1RInW JBtVz5LoClXV7D/Ui2RjvoggUaxI3XGVCP59Sm3ROpAOawPq2ca0eLc8cP+nQg3xMK2+ oq5Pl7cjbiI1yUQVVIngyuenAXAWk96hRsp0ODXv4ihsrMhmqkmfsLKaUNzSSMB8u5eA IA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2xf78sc0y4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jan 2020 16:09:34 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7398B10002A; Wed, 15 Jan 2020 16:09:30 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5B51F2BC7D2; Wed, 15 Jan 2020 16:09:30 +0100 (CET) Received: from lmecxl0889.lme.st.com (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 15 Jan 2020 16:09:29 +0100 Subject: Re: [PATCH] remoteproc: Add support for predefined notifyids To: =?UTF-8?Q?Cl=c3=a9ment_Leger?= CC: Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc , linux-kernel References: <20200115102142.11229-1-cleger@kalray.eu> <088ceab9-f135-6e70-dcf6-f75ec46110b1@st.com> <79048597.12371594.1579098506802.JavaMail.zimbra@kalray.eu> From: Arnaud POULIQUEN Message-ID: Date: Wed, 15 Jan 2020 16:09:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <79048597.12371594.1579098506802.JavaMail.zimbra@kalray.eu> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-15_02:2020-01-15,2020-01-15 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/20 3:28 PM, Clément Leger wrote: > Hi Arnaud, > > ----- On 15 Jan, 2020, at 15:06, Arnaud Pouliquen arnaud.pouliquen@st.com wrote: > >> Hi Clément, >> >> On 1/15/20 11:21 AM, Clement Leger wrote: >>> In order to support preallocated notify ids, if their value is >>> equal to FW_RSC_NOTIFY_ID_ANY, then do no allocate a notify id >>> dynamically but try to allocate the requested one. This is useful when >>> using custom ids to bind them to custom vendor resources. For instance, >>> it allow to assign a group of queues to a specific interrupti in order >>> to dispatch notifications. >>> >>> Signed-off-by: Clement Leger >>> --- >>> drivers/remoteproc/remoteproc_core.c | 27 +++++++++++++++++++-------- >>> include/linux/remoteproc.h | 1 + >>> 2 files changed, 20 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/remoteproc/remoteproc_core.c >>> b/drivers/remoteproc/remoteproc_core.c >>> index 307df98347ba..b1485fcd0f11 100644 >>> --- a/drivers/remoteproc/remoteproc_core.c >>> +++ b/drivers/remoteproc/remoteproc_core.c >>> @@ -351,14 +351,27 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) >>> /* >>> * Assign an rproc-wide unique index for this vring >>> * TODO: assign a notifyid for rvdev updates as well >>> - * TODO: support predefined notifyids (via resource table) >>> */ >>> - ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); >>> - if (ret < 0) { >>> - dev_err(dev, "idr_alloc failed: %d\n", ret); >>> - return ret; >>> + if (rsc->vring[i].notifyid == FW_RSC_NOTIFY_ID_ANY) { >>> + ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); >>> + if (ret < 0) { >>> + dev_err(dev, "idr_alloc failed: %d\n", ret); >>> + return ret; >>> + } >>> + notifyid = ret; >>> + >>> + /* Let the rproc know the notifyid of this vring.*/ >>> + rsc->vring[i].notifyid = notifyid; >>> + } else { >>> + /* Reserve requested notify_id */ >>> + notifyid = rsc->vring[i].notifyid; >>> + ret = idr_alloc(&rproc->notifyids, rvring, notifyid, >>> + notifyid + 1, GFP_KERNEL); >>> + if (ret < 0) { >>> + dev_err(dev, "idr_alloc failed: %d\n", ret); >>> + return ret; >>> + } >>> } >>> - notifyid = ret; >>> >>> /* Potentially bump max_notifyid */ >>> if (notifyid > rproc->max_notifyid) >>> @@ -366,8 +379,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) >>> >>> rvring->notifyid = notifyid; >>> >>> - /* Let the rproc know the notifyid of this vring.*/ >>> - rsc->vring[i].notifyid = notifyid; >>> return 0; >>> } >> The rproc_free_vring function resets the notifyid to -1 on free. >> This could generate a side effect if the resource table is not reloaded. > > Oh indeed, I did not thought of that. What would you recommend ? > If using -1 in free vring, notify ids will be reallocated at next > round. Regarding the code i'm not sure that it is useful to reset the notifyID to -1 on free. In current version, on alloc, the notifyID is overwriten without check. And as vdev status is updated, vring struct in resource table should be considered as invalid Except if i missed a usecase/race condition... > > I was also worried that it would break some existing user applications > which uses "0" as a notify id in vring but expect the id to be > allocated dynamically. With my modification, it means it will try to > use "0" as a predefined id, leading to allocation failure. > Yes this could introduce regression for firmware that sets 0 as default value. Probably better to introduce this patch with a new version of the resource table :) Regards Arnaud >> >>> >>> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h >>> index 16ad66683ad0..dcae3394243e 100644 >>> --- a/include/linux/remoteproc.h >>> +++ b/include/linux/remoteproc.h >>> @@ -123,6 +123,7 @@ enum fw_resource_type { >>> }; >>> >>> #define FW_RSC_ADDR_ANY (-1) >>> +#define FW_RSC_NOTIFY_ID_ANY (-1)This define can also be used in >>> rproc_free_vring > > Indeed. > > Thanks for your review. > > Regards, > > Clément > >> >> Regards, >> Arnaud >>> >>> /** >>> * struct fw_rsc_carveout - physically contiguous memory request