From patchwork Fri Jun 16 05:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Wang X-Patchwork-Id: 13282003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DC27EB64D7 for ; Fri, 16 Jun 2023 05:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AmMq6IDi8lNZwPCfR0Q3ehWuc3GZGMngiBsdGM72rEQ=; b=blALX5aO2W4ivH +6DBZ6YXlochCDGJHFw6JNzpxKZKRjhnyWXkBqnfRFidDQHv7ctMRDfBWT3tsmVUPS64NcdcQMan9 4xHBNxCfUclUc0CAtGCB/zUNWqM0pCXtaOJOAizWk3pcQSQpeZG2Z5w7/B5ELxQbVO1LHR6V4+wjQ slP9JneSGHqeuSak8c69CwgFNalT0swgVbfytbvrxABIdf+lM9++wPq58Si/u56fWzkuqo9jQloih n1gwFAc3AZMoAfTofM2guRyU77Isubixu6GYFbd2E3wAOdLvaqJNGUT7D7jABVzOdz/QW5ytSvUHl GrKzg3wGZRb06JcgXToQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qA2F0-00GurT-2I; Fri, 16 Jun 2023 05:43:22 +0000 Received: from inva020.nxp.com ([92.121.34.13]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qA2Eo-00Guly-0R for linux-arm-kernel@lists.infradead.org; Fri, 16 Jun 2023 05:43:12 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 88E131A06B6; Fri, 16 Jun 2023 07:43:04 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 260A41A05B8; Fri, 16 Jun 2023 07:43:04 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 21477181D0C0; Fri, 16 Jun 2023 13:43:03 +0800 (+08) From: Alison Wang To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: leoyang.li@nxp.com, xuelin.shi@nxp.com, xiaofeng.ren@nxp.com, feng.guo@nxp.com, Alison Wang Subject: [PATCH 3/8] ethosu: Add inference type option for model and op Date: Fri, 16 Jun 2023 13:59:08 +0800 Message-Id: <20230616055913.2360-4-alison.wang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230616055913.2360-1-alison.wang@nxp.com> References: <20230616055913.2360-1-alison.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_224310_463065_70B094B2 X-CRM114-Status: GOOD ( 13.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds inference type option for model and op. Signed-off-by: Feng Guo Reviewed-by: Peng Fan --- drivers/firmware/ethosu/ethosu_core_interface.h | 6 +++++- drivers/firmware/ethosu/ethosu_inference.c | 14 +++++++++++++- drivers/firmware/ethosu/ethosu_inference.h | 1 + drivers/firmware/ethosu/ethosu_rpmsg.c | 4 +++- drivers/firmware/ethosu/ethosu_rpmsg.h | 3 ++- drivers/firmware/ethosu/uapi/ethosu.h | 11 ++++++++++- 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/ethosu/ethosu_core_interface.h b/drivers/firmware/ethosu/ethosu_core_interface.h index ef63c3b55352..b60508e4792f 100644 --- a/drivers/firmware/ethosu/ethosu_core_interface.h +++ b/drivers/firmware/ethosu/ethosu_core_interface.h @@ -35,13 +35,16 @@ namespace EthosU { #define ETHOSU_CORE_BUFFER_MAX 16 /** Maximum number of PMU counters to be returned for inference */ -#define ETHOSU_CORE_PMU_MAX 8 +#define ETHOSU_CORE_PMU_MAX 4 #define ETHOSU_CORE_MSG_MAGIC 0x41457631 #define ETHOSU_CORE_MSG_VERSION_MAJOR 0 #define ETHOSU_CORE_MSG_VERSION_MINOR 2 #define ETHOSU_CORE_MSG_VERSION_PATCH 0 +#define ETHOSU_CORE_INFERENCE_MODEL 0 +#define ETHOSU_CORE_INFERENCE_OP 1 + /** * enum ethosu_core_msg_type - Message types * @@ -107,6 +110,7 @@ struct ethosu_core_inference_req { struct ethosu_core_buffer network; uint8_t pmu_event_config[ETHOSU_CORE_PMU_MAX]; uint32_t pmu_cycle_counter_enable; + uint32_t inference_type; }; struct ethosu_core_inference_rsp { diff --git a/drivers/firmware/ethosu/ethosu_inference.c b/drivers/firmware/ethosu/ethosu_inference.c index 853947a2334e..b5e94e19bce0 100644 --- a/drivers/firmware/ethosu/ethosu_inference.c +++ b/drivers/firmware/ethosu/ethosu_inference.c @@ -92,7 +92,8 @@ static int ethosu_inference_send(struct ethosu_inference *inf) inf->net->buf, inf->pmu_event_config, ETHOSU_PMU_EVENT_MAX, - inf->pmu_cycle_counter_enable); + inf->pmu_cycle_counter_enable, + inf->inference_type); if (ret) return ret; @@ -233,6 +234,17 @@ int ethosu_inference_create(struct ethosu_device *edev, inf = devm_kzalloc(edev->dev, sizeof(*inf), GFP_KERNEL); if (!inf) return -ENOMEM; + switch (uapi->inference_type) { + case ETHOSU_UAPI_INFERENCE_MODEL: + inf->inference_type = ETHOSU_CORE_INFERENCE_MODEL; + break; + case ETHOSU_UAPI_INFERENCE_OP: + inf->inference_type = ETHOSU_CORE_INFERENCE_OP; + break; + default: + inf->inference_type = ETHOSU_CORE_INFERENCE_MODEL; + break; + } inf->edev = edev; inf->net = net; diff --git a/drivers/firmware/ethosu/ethosu_inference.h b/drivers/firmware/ethosu/ethosu_inference.h index 07370ca01f22..8414eadbda92 100644 --- a/drivers/firmware/ethosu/ethosu_inference.h +++ b/drivers/firmware/ethosu/ethosu_inference.h @@ -74,6 +74,7 @@ struct ethosu_inference { uint32_t pmu_event_count[ETHOSU_PMU_EVENT_MAX]; uint32_t pmu_cycle_counter_enable; uint64_t pmu_cycle_counter_count; + uint32_t inference_type; struct list_head list; }; diff --git a/drivers/firmware/ethosu/ethosu_rpmsg.c b/drivers/firmware/ethosu/ethosu_rpmsg.c index cb7e4556f635..e4cf398468e4 100644 --- a/drivers/firmware/ethosu/ethosu_rpmsg.c +++ b/drivers/firmware/ethosu/ethosu_rpmsg.c @@ -107,7 +107,8 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp, struct ethosu_buffer *network, uint8_t *pmu_event_config, uint8_t pmu_event_config_count, - uint8_t pmu_cycle_counter_enable) + uint8_t pmu_cycle_counter_enable, + uint32_t inference_type) { struct ethosu_core_msg msg = { .magic = ETHOSU_CORE_MSG_MAGIC, @@ -132,6 +133,7 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp, req.ifm_count = ifm_count; req.ofm_count = ofm_count; req.pmu_cycle_counter_enable = pmu_cycle_counter_enable; + req.inference_type = inference_type; for (i = 0; i < ifm_count; i++) ethosu_core_set_size(ifm[i], &req.ifm[i]); diff --git a/drivers/firmware/ethosu/ethosu_rpmsg.h b/drivers/firmware/ethosu/ethosu_rpmsg.h index dd08e0d7945b..a4a639997a26 100644 --- a/drivers/firmware/ethosu/ethosu_rpmsg.h +++ b/drivers/firmware/ethosu/ethosu_rpmsg.h @@ -63,7 +63,8 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp, struct ethosu_buffer *network, uint8_t *pmu_event_config, uint8_t pmu_event_config_count, - uint8_t pmu_cycle_counter_enable + uint8_t pmu_cycle_counter_enable, + uint32_t inference_type ); int ethosu_rpmsg_init(struct ethosu_rpmsg *erp, diff --git a/drivers/firmware/ethosu/uapi/ethosu.h b/drivers/firmware/ethosu/uapi/ethosu.h index 903316dff7b3..c4a0df67336c 100644 --- a/drivers/firmware/ethosu/uapi/ethosu.h +++ b/drivers/firmware/ethosu/uapi/ethosu.h @@ -62,7 +62,7 @@ namespace EthosU { #define ETHOSU_FD_MAX 16 /* Maximum number of PMUs available */ -#define ETHOSU_PMU_EVENT_MAX 8 +#define ETHOSU_PMU_EVENT_MAX 4 /**************************************************************************** * Types @@ -173,6 +173,14 @@ struct ethosu_uapi_device_capabilities { __u32 driver_major_rev; }; +/** + * enum ethosu_uapi_inference_type - Inference type + */ +enum ethosu_uapi_inference_type { + ETHOSU_UAPI_INFERENCE_MODEL = 0, + ETHOSU_UAPI_INFERENCE_OP +}; + /** * struct ethosu_uapi_inference_create - Create network request * @ifm_count: Number of IFM file descriptors @@ -185,6 +193,7 @@ struct ethosu_uapi_inference_create { __u32 ifm_fd[ETHOSU_FD_MAX]; __u32 ofm_count; __u32 ofm_fd[ETHOSU_FD_MAX]; + enum ethosu_uapi_inference_type inference_type; struct ethosu_uapi_pmu_config pmu_config; };