Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1801324rda; Tue, 24 Oct 2023 03:56:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQh2D+Qc2P+C8l98cWwlSf/GBOQenRlbc2e3SGi1Ls0+f/pqXrebuLgflxMO3QQ0cwolw1 X-Received: by 2002:a05:6a00:2286:b0:693:43b5:aaf3 with SMTP id f6-20020a056a00228600b0069343b5aaf3mr16698766pfe.13.1698145013285; Tue, 24 Oct 2023 03:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698145013; cv=none; d=google.com; s=arc-20160816; b=MHtiEq/wRuDO6wdy0Xi+ERgNoQQkeoBwKLBq50n5BLjtpBSia9eS5HtOqiylsChPdC QYsmZI28JMYbHReRP3DPUBP8Dq0e09ocR5OSa/+ed1nFBk9ci6miZ4KF92L6Welp1o6p ECAr2HHqCufq9Kc1jJJg7OtKTLgVt1ZayEF7VXNRj8RpfUA7CrZpwjbqZNPzM2OVWW2J r2EIRXGrWWqtI4SDcBHtmFfNvq5tKQKZMNzLxHIvPaTfz43G5E52SAiJsBvYLbDjfDLS yTJMCbXMJsgIRCyYDaZQw+ACy+Pr1Tl2zCD70TmDM4HvAmpeY6KYyjA8IrClftGnRohS UUQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=+1s5NUXk09OVJQj6pZNDfawsvZk2OrbbPBWDsYTyQTs=; fh=dhwPcdTtT0tgW4dVkTJhiiku0qpZ/EDNwmDp0A4M4v0=; b=e2RQgfFFeNN4wR1IyjI7IZ0f2PQuXuwT2q5VBUGZuAijfdOzJshowIYI9aA/65xPJH GWAWCEbQgsIZmlyROHib6z9WhsAWDGAEdRfT9EkyWYkB5iwObeuChhpHNbzMeQYlhISz fYpw7wWqlQztWG/OIvOJk1iktcSjRX+GGq1i8z9esffBY3qsiAc2Wul/XuowAZMRezZ9 VEsQ1xOGSJoSThkb/Yht142rOswzK/2qiyOgM+pvhdGPx7TxgPI2U9sE8RVdTN6WBir6 oOeZgfS9GrutV/N2b9lE1ktW7bxz5/gHaMLEIkV8/QQBRhOti2m68Vfo+JaDAQZ0Yana lZcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k3-20020aa79d03000000b0068fa57cc15bsi7970820pfp.124.2023.10.24.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 28595807865F; Tue, 24 Oct 2023 03:56:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234464AbjJXK4h (ORCPT + 99 others); Tue, 24 Oct 2023 06:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbjJXK4c (ORCPT ); Tue, 24 Oct 2023 06:56:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 209EC109 for ; Tue, 24 Oct 2023 03:56:30 -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 D4BD715A1; Tue, 24 Oct 2023 03:57:10 -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 1357F3F64C; Tue, 24 Oct 2023 03:56:28 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:19 +0100 Subject: [PATCH 3/4] firmware: arm_ffa: Add checks for the notification enabled state MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231024-ffa-notification-fixes-v1-3-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2821; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=E6NSv6v1x1k9jYmSXi9wqAwct9jHzDEtdSLjqJZKdeA=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZlekawWTp6pU0+zIL+ooCxPn686rd+ILSC Hhq+w8T2puJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mCbFD/9dxq64fStRXBbNV9s6lwBsfxZTteMfOZvLHCLYjvzHUn33Gf2sGL5fml/7Ren7MF8mPvA ZGnOLK9do+ElMIsJ569kWwjpP5edeBS5R+Qs2ckeDQrsMYHEny5Kmn54yEkJLygzho4l8CzdpeA 6jI3WO+oNy8U13h7T3IJfmshizFhogR/+Tcl2OTEKMfVeQJKi4gBmA6BJRYGDHCcB3dTfs4Fkup Dnkuk74tbWojm5lL+l6wcxBIWZwc2R3BfAii9yUC+RSUHl1dNG643KBsKpMAOiHk9Nws1OWZboI u6X7lOacF8sfC0kDOjlpO/MuK57WHfYm7je5/8l0aI1BNQ/gOaN0u834vq3u4t8BzjwUjKzst1u 1KznUD0V96WwUOA1uBn8e669hV+hMLDr2YbmEDxNKC1HfhplKzaG6M7K7RfX7/I5paZU40z7eaf LIoNAejPcbfDGJptk+bt2mf7eLm2n2gcZ/T3nrlCJsfodT9KuiceYAaj99Pd0ta9vIQYxfXsnjc EypyLPkGa7r3Qd3yico3Y5sz6fdKOU8Hze1GYzWWzSJTIvKa81z1kCvD+VDuNBvwRQysRTVGfI0 8UKIHK9s/sASvLpEvKDrGHnCUcf7CyFSaV/aC1aHPdOVwQulkcXCsfciV3WN0KAe9eIVut9fQlh 1p49MAylzEvosjg== 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 03:56:51 -0700 (PDT) We need to check if the FF-A notifications are enabled or not in all the notification operations that are accessible for the FF-A device from the FF-A driver. This helps to avoid making calls to the FF-A firmware even if the notification setup has failed. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 0ab30b571a69..b097452597a2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -99,6 +99,7 @@ struct ffa_drv_info { void *tx_buffer; bool mem_ops_native; bool bitmap_created; + bool notif_enabled; unsigned int sched_recv_irq; unsigned int cpuhp_state; struct ffa_pcpu_irq __percpu *irq_pcpu; @@ -889,6 +890,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) #define FFA_SECURE_PARTITION_ID_FLAG BIT(15) +#define ffa_notifications_disabled() (!drv_info->notif_enabled) + enum notify_type { NON_SECURE_VM, SECURE_PARTITION, @@ -908,6 +911,9 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, struct ffa_dev_part_info *partition; bool cb_valid; + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + partition = xa_load(&drv_info->partition_info, part_id); write_lock(&partition->rw_lock); @@ -1001,6 +1007,9 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) int rc; enum notify_type type = ffa_notify_type_get(dev->vm_id); + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (notify_id >= FFA_MAX_NOTIFICATIONS) return -EINVAL; @@ -1027,6 +1036,9 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, u32 flags = 0; enum notify_type type = ffa_notify_type_get(dev->vm_id); + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (notify_id >= FFA_MAX_NOTIFICATIONS) return -EINVAL; @@ -1057,6 +1069,9 @@ static int ffa_notify_send(struct ffa_device *dev, int notify_id, { u32 flags = 0; + if (ffa_notifications_disabled()) + return -EOPNOTSUPP; + if (is_per_vcpu) flags |= (PER_VCPU_NOTIFICATION_FLAG | vcpu << 16); @@ -1388,6 +1403,7 @@ static void ffa_notifications_cleanup(void) ffa_notification_bitmap_destroy(); drv_info->bitmap_created = false; } + drv_info->notif_enabled = false; } static void ffa_notifications_setup(void) @@ -1422,6 +1438,7 @@ static void ffa_notifications_setup(void) hash_init(drv_info->notifier_hash); mutex_init(&drv_info->notify_lock); + drv_info->notif_enabled = true; return; cleanup: pr_info("Notification setup failed %d, not enabled\n", ret); -- 2.42.0