Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6305554ybl; Wed, 15 Jan 2020 02:23:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxlUPxX+ER+Y4sz4XOgSIwV48g88OruEcDyjt8570xPXIi3VmgFPyuULYjeG0fuogNP+STZ X-Received: by 2002:a9d:7ccc:: with SMTP id r12mr2326520otn.22.1579083802646; Wed, 15 Jan 2020 02:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579083802; cv=none; d=google.com; s=arc-20160816; b=BSL+1N7HiCOADne4ITV2KtWLSxt0KNhVuviXkPRdFtgZFiltVS2LX0H6ICHR6dUAqG OO5lcgqc46J14opWMVlioS6qYbxO+cD13UxJ55JRH11aRUKnVrx+8k1dCLC/fCClqIvZ 2W6GnEnCpuqLJGLNNBjXnKfva3e8lLdwJPRfLZZSGIrNCPizPSg2rYqJA7ddufEWstCl D2M+Sr+U9Ru9FqtWCZ8XBxFkO5qLY2FzjAt4GpMvZozwONgG54s/46wURFiwwlFhYuXr eszAW3DVDORPZg7jmc2+P/im7tcYOZjHPZ4jjYn7H1ASiecFlpd2V3MFgXcAJREyjlUU GlwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=coWsTXp4V4TYH5Han63gSZrWtYPuRAU9HFOVMXalNEk=; b=o/XRBUzZadvMIO4lidKq0teFfypTF4gr9cL/oCHKE38UuwD+bGQ7RSzWXqq0XX4510 0CDtJjsxf+AaNNk51cD7hvkToKlemTULp/cCVl1Ss3yY90cDNGwkJGDEwPfwAp6CfEZT ZAaO2eyhQKMGCKbvaMSGUJwXp+LpbMnqcjLn+0n/GSrnRehl74vpSHIQENoxmAwK6s7w 0PxNLG/P5DwW3yigGVqO7i/gTe6+eOOyT9TeYz8t9QDUxSdAc9b3Ov0H1HmzfK/nbNXv D2pffPa09Jb29EYYYbi8Jltbr5XR7ZF7MMtnC02E2a0J9lgNyT5wOa1slHv07/6DT3tL vpqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=gQA0Eavk; 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 a205si9312270oii.95.2020.01.15.02.23.11; Wed, 15 Jan 2020 02:23:22 -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=gQA0Eavk; 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 S1729742AbgAOKVz (ORCPT + 99 others); Wed, 15 Jan 2020 05:21:55 -0500 Received: from zimbra2.kalray.eu ([92.103.151.219]:35368 "EHLO zimbra2.kalray.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729631AbgAOKVy (ORCPT ); Wed, 15 Jan 2020 05:21:54 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id DFA6327E0BA4; Wed, 15 Jan 2020 11:21:52 +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 U1wdrKSlpnGz; Wed, 15 Jan 2020 11:21:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 64E4B27E0A5D; Wed, 15 Jan 2020 11:21:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 64E4B27E0A5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1579083712; bh=coWsTXp4V4TYH5Han63gSZrWtYPuRAU9HFOVMXalNEk=; h=From:To:Date:Message-Id; b=gQA0Eavk9MSsZhpSd/SQUtzWw8fM4amN5WILS2w8EaTNEWpZCWdTy7PaH0XKkIbv4 SVeRllH9f89usb2KGupoyLnV9i9GFwb4U69cDu9yOeUKNoHBBdc76lylnZpsW3a7hd 42uz7ytW12dqySjQLrBgJfbTNuQ//V7MSCSLYRrY= 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 lMKAkCjT1Yu6; Wed, 15 Jan 2020 11:21:52 +0100 (CET) Received: from triton.lin.mbt.kalray.eu (unknown [192.168.37.25]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 522C027E031E; Wed, 15 Jan 2020 11:21:52 +0100 (CET) From: Clement Leger To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Clement Leger Subject: [PATCH] remoteproc: Add support for predefined notifyids Date: Wed, 15 Jan 2020 11:21:42 +0100 Message-Id: <20200115102142.11229-1-cleger@kalray.eu> X-Mailer: git-send-email 2.15.0.276.g89ea799 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } 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) /** * struct fw_rsc_carveout - physically contiguous memory request -- 2.15.0.276.g89ea799