Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4017810rdh; Fri, 29 Sep 2023 08:52:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaNWyhGuvn0ZF6/CmXNVvPU9kMl6fuICPBXS+S6u94fhsjGoreH+5GQAAJpChRS+fcViSC X-Received: by 2002:a05:6358:91a1:b0:143:5826:dece with SMTP id j33-20020a05635891a100b001435826decemr6125255rwa.25.1696002730883; Fri, 29 Sep 2023 08:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696002730; cv=none; d=google.com; s=arc-20160816; b=K0paetc3VySmrvez95SEIdQ43fGRYyx5vvOmA30MRFP+tzIw0U5jBP2T/IUgUcpIoC gGfUFaSawrfK27fZx+PFbyBTkMB7ILJpJSeKPi+aESkc4Pd4d0LVVzfqyG1n1hpYFU7Y klXFQxuBW4VNnCHfe5kKEE1YizV0IRGL2hjLq2tkROHjyLwb/cbrFySKFaNZ85Ss8QU5 Uuz2dfzPPmapJTUDTyKypIexs0RX0JYEoXTNB0LrNPWJl5z96zkrc7hzsjjFb+Q4tHUr oz/BEYfKaYCqIJ/WTARGGvSU5dimbebHln7rKM+0Ep8lN7860wQR7+AZkN1OBuVTtvSO VWaw== 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=uR1v/cNMQj9N/l/kFTTmWGHerDcyD8FAsqwwZGMCTeE=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=oKuDtYwt8j9h29UTvPYsaOPTfLjEVm5Yxro3bPF4X81IJmlBcGAmZyCEFjya11yQef NdKDf4F3ZPaF6vI2yFg/qsT+rGEgJ4/G2VA5we40jYSgUZWts9jvBwB1+ZozooJF2LFR H29sLeHbKTlCPE5sy5NeXUTh4bxpY7q/nkDI+O68iD2lRUWGvSuqy6heQ9HnZN84OkkX Sav9/sAo2TckkyG1f5jrv7C9noC8o/oP7AuahoeeNqGOGuDy+CCDRWmo4QiP6LfRcNM0 K2q5H5zbzzE7YnfLJzHyGZ1epETgkGzjyWxnV4DBiWJJ2MzAigTzC2pftfIQv+3uABLl ZZFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id dw6-20020a056a00368600b006907e44c739si21015967pfb.86.2023.09.29.08.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id B60F985632A7; Fri, 29 Sep 2023 08:03:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233518AbjI2PDj (ORCPT + 99 others); Fri, 29 Sep 2023 11:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233442AbjI2PDZ (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 475A41BB for ; Fri, 29 Sep 2023 08:03:22 -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 3996CDA7; Fri, 29 Sep 2023 08:04:00 -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 D75F33F5A1; Fri, 29 Sep 2023 08:03:20 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:02:55 +0100 Subject: [PATCH v3 06/17] firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230929-ffa_v1-1_notif-v3-6-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=2442; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=WcMcF7+EWspNtIEKv7vhK+PdYzYtK3Hl6T1/APp/RSo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucv9DdfP5qDeC0S7ZKdLh/2EacPtt+fAel+o gzGvF/3OYaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnLwAKCRAAQbq8MX7i mGymD/9pOqUOteL/bKSdzoY3NQCakLGj4XiCROjEievu5tUdHy0Zb3ttZk2FNhwO0U4GTs+zN7q JMY1pBn0Whe/TMy9uoR6QMHY6DydUrmxF8i/Xbg7acJwrYzP/EKGbHrD6nHsIzaw0fbVrZTqC5W LrCV8D0042hPxLhPqFuOrSa8Wi2xtDsE9HI0rV41qzg28H6SKgJnGLwavnGvlpsiAb9hjeNrrBC eO2ZS/vJ+VoZ10DcHBJrmOCXPVkzVM1KSd9nkazpTsP4Gg4NxFIQLNiCA24RT29pJm1F6Mz+1cZ qxPRFroeIabsRziknlj+JG2p/ezP4ZysriTfCWnUeZUIQAqxn5d1Xop+gz2dWqS5sg8ZkdHy9wa Waq9Ys3Mn/bEwq+JCFTqrN0bDJsdtsddVA/rahCLcpDrl0WoLDP1zmJlhf0JfD+JVEia/yhQ8Rn 9mWF/AJvGd8/xdy+e/iL76A+H34ZXxNZ5rP2/QmxJC3Ph2encmrjrISyXwXhuAzNwk9084Fa9ES 2rgkFA6HujhRSgn1MhgUDkGDnUJmLF57TS0LBZvuWspwiK7WEqM2G/sl2VN6ihtJIvaKqDfVSf5 dZm5IZsQJyr2LqWGDrPh+MiyyQMfHZ5qsHsD1tF2uccVe9AukepEBy0x29Bi6VSTfwjyt1PkpTd 9T/z+j/ZK2XvPBQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:03:48 -0700 (PDT) The framework provides an interface to the receiver to determine the identity of the notification. A receiver endpoint must use the FFA_NOTIFICATION_GET interface to retrieve its pending notifications and handle them. Add the support for FFA_NOTIFICATION_GET to allow the caller(receiver) to fetch its pending notifications from other partitions in the system. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index b0d1ddfe0230..02eedb7bc171 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -593,6 +593,14 @@ static int ffa_notification_bitmap_destroy(void) ((u32)(FIELD_GET(NOTIFICATION_HIGH_MASK, (x)))) #define NOTIFICATION_BITMAP_LOW(x) \ ((u32)(FIELD_GET(NOTIFICATION_LOW_MASK, (x)))) +#define PACK_NOTIFICATION_BITMAP(low, high) \ + (FIELD_PREP(NOTIFICATION_LOW_MASK, (low)) | \ + FIELD_PREP(NOTIFICATION_HIGH_MASK, (high))) + +#define RECEIVER_VCPU_MASK GENMASK(31, 16) +#define PACK_NOTIFICATION_GET_RECEIVER_INFO(vcpu_r, r) \ + (FIELD_PREP(RECEIVER_VCPU_MASK, (vcpu_r)) | \ + FIELD_PREP(RECEIVER_ID_MASK, (r))) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -636,6 +644,35 @@ int ffa_notification_set(u16 src_id, u16 dst_id, u32 flags, u64 bitmap) return 0; } +struct ffa_notify_bitmaps { + u64 sp_map; + u64 vm_map; + u64 arch_map; +}; + +static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify) +{ + ffa_value_t ret; + u16 src_id = drv_info->vm_id; + u16 cpu_id = smp_processor_id(); + u32 rec_vcpu_ids = PACK_NOTIFICATION_GET_RECEIVER_INFO(cpu_id, src_id); + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_NOTIFICATION_GET, .a1 = rec_vcpu_ids, .a2 = flags, + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + else if (ret.a0 != FFA_SUCCESS) + return -EINVAL; /* Something else went wrong. */ + + notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3); + notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5); + notify->arch_map = PACK_NOTIFICATION_BITMAP(ret.a6, ret.a7); + + return 0; +} + static int ffa_run(struct ffa_device *dev, u16 vcpu) { ffa_value_t ret; -- 2.42.0