Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4011904rdh; Fri, 29 Sep 2023 08:42:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFB+NP7pF2k0SiX62s5s76moUK3Bn1KAdKw6VL5sjQ3pgKB8t7lTBBa/bNlVCocxcytXl5R X-Received: by 2002:a05:6a20:4286:b0:15d:ec88:356e with SMTP id o6-20020a056a20428600b0015dec88356emr5777051pzj.41.1696002119706; Fri, 29 Sep 2023 08:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696002119; cv=none; d=google.com; s=arc-20160816; b=pwSVKnUT5fomQ6wUlAM3BspTJVBAiW8Ht+FP4aQweIJP7Jj5jS7cnSDbISwQWEw0rZ tFaCxsYEIIYie/Nr6lnVcBFz7h1rRKXhPU/yG1Obp478K62xr9fA6zSqO4DCGCv7xYUW ql8+A8tpwWbIEbP5TnDaTZfid3QLJauAkYt7MUtGFkgItTEnP301GcbmsYoDRjBFYlQO TUB/OV9Mty4hrqEorpOyHYrejbmX4cI1W8OY91ng5u4W/Rp1olo3gx2oyKOpjGKUKAoM Zzv615WInQdNicpnzSs8KU+j09HTI8XMga8qlvTkK2qIM0Rm7G9tyT461BxqQunMvG4S x5pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=zZLLptIHy07YsBmb/GEo+E/998gLkUpfNaxLx2IIDN8=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=leqEGRkbESZnbc+umu4ELgp99CkCaDV4M7Kgk4XAInsn2JM3h9JeEewFHCqIxSaEL+ Uzb3hkY/CVUnMn32+red2SL0W+7pLh9LwnnmA1nUPWnHcGTLFvWwYuUhTquDLlpO83XA 7LxAeEoIvJhOkhbAySdsAKMnNft8QI3c9jtfnGnfZj6rZi1XZSwwiK6wlNS6Ed8VI8S1 nLxSa+Hhi65HELJVtQhyRHU2pPD9f+6b+sGL5eL5u9aPUNV7KuZK68b2e2nqcMx73USh LhyEHWiHS2DScVezGB1jym4J/c7aqOhxIewIqYupAXPiltZ6/L+qPqoxydXJlyvR+VFv So4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l190-20020a6388c7000000b00565325c6ca6si21136386pgd.489.2023.09.29.08.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7B9B582A04A9; Fri, 29 Sep 2023 08:04:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233488AbjI2PDc (ORCPT + 99 others); Fri, 29 Sep 2023 11:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbjI2PDZ (ORCPT ); Fri, 29 Sep 2023 11:03:25 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B36C71A7 for ; Fri, 29 Sep 2023 08:03:19 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D3831106F; Fri, 29 Sep 2023 08:03:57 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CBCE3F5A1; Fri, 29 Sep 2023 08:03:18 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:02:53 +0100 Subject: [PATCH v3 04/17] firmware: arm_ffa: Implement the FFA_RUN interface MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230929-ffa_v1-1_notif-v3-4-c8e4f15190c8@arm.com> References: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> In-Reply-To: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Marc Bonnici , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2472; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=3/hdIfSwI04CJ8YoVOAM5D8uyI/IOxahGfihf3h43bU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucuyb+IhwHkIr8NkHq2LIo7vVzNfZRZsmBWR 4z6tmAq9BKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnLgAKCRAAQbq8MX7i mG9sD/908ogrCGeAYlAX2T65/u61ZJ7us0nLl5Uheh/+02XbBaRhe5MTBlWCuxDsgwR+evhSYU3 NwZ+qXzILP+4auBk2iAlAxfSh9tGliHl2UOOCsb8ovJaLgagrw0zXJyYJkwz5OPshhY5EkfMnt3 ffwMTulCVOv6iLyGnghUQsyxGZOff5IMuGouns2vqnmEW4CmLqDkBo1X/vnXefbZlt2Lz9eSAjO RuVdrdEZoB90GM2q/FCns3FFtmg/pb59uh4paZ8+kaoyQ+sB5GoZXg+Q17bbTlar9Ypm9Sp5Rui R8wcjmq7I58eIXNWwCbz6jVY1nw3X46H5JOEPXZElh57O7PajQLrJLV4pQwgXQH6PMaNwmd4d3l iJf+UbzPbDEo7JkBz+43MWhMEXGZwsQDAmOUXF0n/TQUBsqpLHHGZqbr42FJqoXo6qrjXO5fnNV m5rk4WRCOgmCzRZnE1ewRI1Oxdg+3QoUplO43iTFP3tZjUADnTQl8mQ8mpP0byodrXWaRIRSI0A P0Zl2+qvKUG9qZjgnrBGdRVJ7HoFU821Z2ZQ+KqxQNbHF3Xe5Y4yHN9gYn3sNukQx0PWQ8tSQuI BukTyIlcNQBrrUg3Loqo+XFukGt5Nlcco2QOziTsxJfSh8kWllWq4qle1u1bIHS2p6Gxbeg38LN W/D92epURHxVZ2g== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:04:37 -0700 (PDT) FFA_RUN is used by a scheduler to allocate CPU cycles to a target endpoint execution context specified in the target information parameter. If the endpoint execution context is in the waiting/blocked state, it transitions to the running state. Expose the ability to call FFA_RUN in order to give any partition in the system cpu cycles to perform IMPDEF functionality. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 22 ++++++++++++++++++++++ include/linux/arm_ffa.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 26bf9c4e3b5f..b265063e76ea 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -616,6 +616,23 @@ static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, return 0; } +static int ffa_run(struct ffa_device *dev, u16 vcpu) +{ + ffa_value_t ret; + u32 target = dev->vm_id << 16 | vcpu; + + invoke_ffa_fn((ffa_value_t){ .a0 = FFA_RUN, .a1 = target, }, &ret); + + while (ret.a0 == FFA_INTERRUPT) + invoke_ffa_fn((ffa_value_t){ .a0 = FFA_RUN, .a1 = ret.a1, }, + &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + + return 0; +} + static void ffa_set_up_mem_ops_native_flag(void) { if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) || @@ -708,10 +725,15 @@ static const struct ffa_mem_ops ffa_drv_mem_ops = { .memory_lend = ffa_memory_lend, }; +static const struct ffa_cpu_ops ffa_drv_cpu_ops = { + .run = ffa_run, +}; + static const struct ffa_ops ffa_drv_ops = { .info_ops = &ffa_drv_info_ops, .msg_ops = &ffa_drv_msg_ops, .mem_ops = &ffa_drv_mem_ops, + .cpu_ops = &ffa_drv_cpu_ops, }; void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 2ea1717a0825..12fd134bf670 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -387,10 +387,15 @@ struct ffa_mem_ops { int (*memory_lend)(struct ffa_mem_ops_args *args); }; +struct ffa_cpu_ops { + int (*run)(struct ffa_device *dev, u16 vcpu); +}; + struct ffa_ops { const struct ffa_info_ops *info_ops; const struct ffa_msg_ops *msg_ops; const struct ffa_mem_ops *mem_ops; + const struct ffa_cpu_ops *cpu_ops; }; #endif /* _LINUX_ARM_FFA_H */ -- 2.42.0