Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6548489ybl; Wed, 15 Jan 2020 06:29:36 -0800 (PST) X-Google-Smtp-Source: APXvYqy4XU5tcAvC2fM27jBYTtt2F1+897xZMtyOB8fPhOyUCNGXKbUeGlcSxw+uQU8ZP+dMn7jM X-Received: by 2002:aca:5fc6:: with SMTP id t189mr6055oib.166.1579098576755; Wed, 15 Jan 2020 06:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579098576; cv=none; d=google.com; s=arc-20160816; b=bFndkHnqS6sCune3yjInzaXtyRKhI0Bx0slds8t+c9DwX/BgMI7CopPn7gJH3dfMcF u7zQeaGz28QbVaM8WOlNSDPOe3YWaJ2m4dFl/VsA/2WpRWUzLy04ARbb6VaRsZOqdg/y /wyp69esCrxFB5HiOL6kk4xv4FHnhgH25IgYHD3sJNzsD82tf40H7UgCwtHYSYwgqS7W bhRsHa8I/BB9YfKb2JWg5hG8fJZt5vE5Jz3lhOexGGl1KtS0zPpNtgfxaoO6RNrxl+o/ /CAU2T4viNGIt4riX6IhEqyyI1nZs9MNtPEv2JvaA6UdMTRwhPjNF3CPEzFxFRQN+3FR XIkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=qIpswqWnsubgtTHTB+MyTQDqzfR9952ta7nxe9fVu3Q=; b=dSQosNohG5amNhHl2vKcbkZWaribOURp/jghgii2Evi2ZzR2N1Zd34GQDnUSWBue+r O9Z3RSeJjUcshIM2KPZIOQHkIcEYS4SgB94vUg+Qn7uHZfW5s0bgnrNeQc0xJUxuXJmi grnxQFlYgW9yIb/SlON9Ei6mbN4qUuFf9ijE2I7JgDma7XEsAyzbyNe5MnKfcHO5nDnv GioryNQvch/NySB8TbH5nyVQbYqoP3uh9RjT9mQHUv9K7hfVleTia94iGdX6/oz5IRlm B5fXGggQnpubMNMQF9UbDM1Y2zCcJ+SWAiWCX3mZ1B8SZFWfZYNiTj4eSVnswwk+yKQv XVBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=RbzHxMYc; 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=QUARANTINE dis=NONE) header.from=kalray.eu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si11108061otj.0.2020.01.15.06.29.24; Wed, 15 Jan 2020 06:29:36 -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=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=RbzHxMYc; 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=QUARANTINE dis=NONE) header.from=kalray.eu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728885AbgAOO2b (ORCPT + 99 others); Wed, 15 Jan 2020 09:28:31 -0500 Received: from zimbra2.kalray.eu ([92.103.151.219]:49296 "EHLO zimbra2.kalray.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbgAOO2b (ORCPT ); Wed, 15 Jan 2020 09:28:31 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 2D56827E02DE; Wed, 15 Jan 2020 15:28:30 +0100 (CET) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id LwG_wuPjVL7U; Wed, 15 Jan 2020 15:28:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 0B21127E1256; Wed, 15 Jan 2020 15:28:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 0B21127E1256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1579098507; bh=qIpswqWnsubgtTHTB+MyTQDqzfR9952ta7nxe9fVu3Q=; h=Date:From:To:Message-ID:MIME-Version; b=RbzHxMYcst2qPU14AlHS0uF2OJj8ryBhvFDhwqU1SftPos7M0+89Uuwx4B+RWdETa ElHTR0stic2r1SqeZ1wp9Fx3PMxKk/89+lYZK3dZ1MpSpuK2ZRj7f4bDsoKy62EX7z 74J4xyL4JY8ZdwpubRMQsKu4rw5n3NMSJgzx9gh8= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r7kxFVGWpQUF; Wed, 15 Jan 2020 15:28:26 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id EA73D27E02DE; Wed, 15 Jan 2020 15:28:26 +0100 (CET) Date: Wed, 15 Jan 2020 15:28:26 +0100 (CET) From: =?utf-8?Q?Cl=C3=A9ment?= Leger To: Arnaud Pouliquen Cc: Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc , linux-kernel Message-ID: <79048597.12371594.1579098506802.JavaMail.zimbra@kalray.eu> In-Reply-To: <088ceab9-f135-6e70-dcf6-f75ec46110b1@st.com> References: <20200115102142.11229-1-cleger@kalray.eu> <088ceab9-f135-6e70-dcf6-f75ec46110b1@st.com> Subject: Re: [PATCH] remoteproc: Add support for predefined notifyids MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.40.202] X-Mailer: Zimbra 8.8.12_GA_3794 (ZimbraWebClient - FF68 (Linux)/8.8.12_GA_3794) Thread-Topic: remoteproc: Add support for predefined notifyids Thread-Index: GrFV/T3a3aqevNM+y1HXDJWFpEoPPQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaud, ----- On 15 Jan, 2020, at 15:06, Arnaud Pouliquen arnaud.pouliquen@st.com w= rote: > Hi Cl=C3=A9ment, >=20 > 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. >>=20 >> Signed-off-by: Clement Leger >> --- >> drivers/remoteproc/remoteproc_core.c | 27 +++++++++++++++++++-------- >> include/linux/remoteproc.h | 1 + >> 2 files changed, 20 insertions(+), 8 deletions(-) >>=20 >> 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, in= t i) >> =09/* >> =09 * Assign an rproc-wide unique index for this vring >> =09 * TODO: assign a notifyid for rvdev updates as well >> -=09 * TODO: support predefined notifyids (via resource table) >> =09 */ >> -=09ret =3D idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); >> -=09if (ret < 0) { >> -=09=09dev_err(dev, "idr_alloc failed: %d\n", ret); >> -=09=09return ret; >> +=09if (rsc->vring[i].notifyid =3D=3D FW_RSC_NOTIFY_ID_ANY) { >> +=09=09ret =3D idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); >> +=09=09if (ret < 0) { >> +=09=09=09dev_err(dev, "idr_alloc failed: %d\n", ret); >> +=09=09=09return ret; >> +=09=09} >> +=09=09notifyid =3D ret; >> + >> +=09=09/* Let the rproc know the notifyid of this vring.*/ >> +=09=09rsc->vring[i].notifyid =3D notifyid; >> +=09} else { >> +=09=09/* Reserve requested notify_id */ >> +=09=09notifyid =3D rsc->vring[i].notifyid; >> +=09=09ret =3D idr_alloc(&rproc->notifyids, rvring, notifyid, >> +=09=09=09=09notifyid + 1, GFP_KERNEL); >> +=09=09if (ret < 0) { >> +=09=09=09dev_err(dev, "idr_alloc failed: %d\n", ret); >> +=09=09=09return ret; >> +=09=09} >> =09} >> -=09notifyid =3D ret; >> =20 >> =09/* Potentially bump max_notifyid */ >> =09if (notifyid > rproc->max_notifyid) >> @@ -366,8 +379,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int = i) >> =20 >> =09rvring->notifyid =3D notifyid; >> =20 >> -=09/* Let the rproc know the notifyid of this vring.*/ >> -=09rsc->vring[i].notifyid =3D notifyid; >> =09return 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. 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=20 use "0" as a predefined id, leading to allocation failure. >=20 >> =20 >> 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 { >> }; >> =20 >> #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=C3=A9ment >=20 > Regards, > Arnaud >> =20 >> /** >> * struct fw_rsc_carveout - physically contiguous memory request