From patchwork Thu Mar 7 09:21:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 13585252 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 864A1C54E49 for ; Thu, 7 Mar 2024 09:22:04 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=XZhPcS225OT5paa2O8dik8n31t44g6BDozHdb+QawMo=; b=sX49rTZ2OQWxqG 18vFKlZYMN0bBSHn4vGzXvbPTaIQ1ZJOCwnwZBNApCgs8OtPKZojJ8tMnkloyX1Gaz2vK7rcnrmv9 CliUWiwrbM63OUT1x9tF8Yd2rJu0s5Icnx4ODUUUglE1TihPI4DZ9nZbhcbZgmEouFxsvSe2AVuqC YGin7BuBvAXHoGkGLAgqk2Xr0jAOc/sxpFSFKe8KGaInAcG/26ACEyBh+u/hlz77S4vfvXQMmLGky 72sIY5Z9Jx/lhM3BRjOH5apu0bV7a7d/7kqY1+2cWxeSO82D4KqS0fahw5Bp6qH6RVCBj/Nxgp9ZX PvBz9CuT8XcYz9ETaPBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri9wj-00000003pY9-0LB4; Thu, 07 Mar 2024 09:21:49 +0000 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri9wg-00000003pX6-0aeX for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 09:21:47 +0000 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-220ef791617so271277fac.1 for ; Thu, 07 Mar 2024 01:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709803304; x=1710408104; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X6jZ+dVs7XI8S4fNRPjyKyWA5AZAbLPF6Th9taWNEc8=; b=WCbi5jVDyDmLKeAqxHAEZc4SiZ+MGgRiyOZU0iXlUJiOUKBYIjZx39nApzoi0AstDj NlurWQDwLJ6D9+Ckng51KnloE/u3yj3OxtuBOttse6BqHIKN/FCLzkRm0Xymwi/FBsyb FkYvgbi8PvL4rbViWDsI7OftdD17poIpclPUbvv0TliBzUSu90PQdp86+mwIBF0gFQnG C3/ltjMZ4BZ5N1c3R4AQnGHDFKFfVHJSjU/5wUSC1OzINtMs4CofFOLrJbMMXGVL/wjV SC3EGgPexDUQzgN0z7HfP5KDR9vf0WYcTJNZuvUUGAwDeR8hvvr0e7+HNF+L5pIDpF87 9O8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709803304; x=1710408104; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X6jZ+dVs7XI8S4fNRPjyKyWA5AZAbLPF6Th9taWNEc8=; b=NpndRulfyYjWtKq5zG38OTXWFd8lAXB5/r0aDFQocYp3BUgWAiSjcVclZ+sCMihYhq aXhHtyZfwy2wHD3/eC2/zIgX6FRdC00y6j1kdv62kG8+crEl24wDBdVCDm6w4/OVCYAb nWewaXIzK7t3wqDEYkQVknYDwoJemN2/JKV65GySH2zBvD7d6mOEEKjHO7RR4B1EdADb xzYYQZtua4PWdMKytE4UjGoNZYw/GjfeG12fn6SQbkxwlOE6WDfaPZIAff0TttwIXICC rTaynUh2F73yjpF2LUk0R4n/6jR+c+CUwhpUABUuYUDC/YtkdOu09b06AWXS821vh+mz 7DPw== X-Forwarded-Encrypted: i=1; AJvYcCUdztf6r/XarZoFeH/mbGKaGnxRkZ0/dNoDN5eubuZiNPDE9cK9PTaBaCZ/euj3Sf7u8hC4xAuedI+61i+41EdU8u24WR+nFInyFZHx4Qug77GgH34= X-Gm-Message-State: AOJu0Yzebbqd/yfFq25s4nt6Y8UU+nJ4CMDh5oM/5vhMKpUk4R54zQ3K rlbd7uhDaWihs2RLB/DSA4nZaLYSkDuYko6l2EUQ1Ts17/y+BZeM9x3hKPPY/98= X-Google-Smtp-Source: AGHT+IHiqrQZgef41/ev0CdPkKkjI/0sBHEh/20WTBrud6oiZM3o2NSI2JXdtVDL2NYyh+uSd5QyHA== X-Received: by 2002:a05:6870:114a:b0:21e:df09:fbb6 with SMTP id 10-20020a056870114a00b0021edf09fbb6mr6182351oag.41.1709803304722; Thu, 07 Mar 2024 01:21:44 -0800 (PST) Received: from localhost.localdomain (h-217-31-164-171.A175.priv.bahnhof.se. [217.31.164.171]) by smtp.gmail.com with ESMTPSA id ei4-20020a056a0080c400b006e57e220ceasm12189872pfb.6.2024.03.07.01.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 01:21:44 -0800 (PST) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Jens Wiklander Subject: [PATCH] firmware: arm_ffa: support running as a guest in a vm Date: Thu, 7 Mar 2024 10:21:32 +0100 Message-Id: <20240307092132.943881-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240307_012146_201389_EBDB2DB1 X-CRM114-Status: GOOD ( 16.60 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for running the driver in a guest to a hypervisor. The main difference is that the notification interrupt is retrieved with FFA_FEAT_NOTIFICATION_PENDING_INT and that FFA_NOTIFICATION_BITMAP_CREATE doesn't need to be called. FFA_FEAT_NOTIFICATION_PENDING_INT gives the interrupt the hypervisor has chosen to notify its guest of pending notifications. Signed-off-by: Jens Wiklander --- drivers/firmware/arm_ffa/driver.c | 45 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index f2556a8e9401..c183c7d39c0f 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1306,17 +1306,28 @@ static void ffa_sched_recv_irq_work_fn(struct work_struct *work) ffa_notification_info_get(); } +static int ffa_get_notif_intid(int *intid) +{ + int ret; + + ret = ffa_features(FFA_FEAT_SCHEDULE_RECEIVER_INT, 0, intid, NULL); + if (!ret) + return 0; + ret = ffa_features(FFA_FEAT_NOTIFICATION_PENDING_INT, 0, intid, NULL); + if (!ret) + return 0; + + pr_err("Failed to retrieve one of scheduler Rx or notif pending interrupts\n"); + return ret; +} + static int ffa_sched_recv_irq_map(void) { - int ret, irq, sr_intid; + int ret, irq, intid; - /* The returned sr_intid is assumed to be SGI donated to NS world */ - ret = ffa_features(FFA_FEAT_SCHEDULE_RECEIVER_INT, 0, &sr_intid, NULL); - if (ret < 0) { - if (ret != -EOPNOTSUPP) - pr_err("Failed to retrieve scheduler Rx interrupt\n"); + ret = ffa_get_notif_intid(&intid); + if (ret) return ret; - } if (acpi_disabled) { struct of_phandle_args oirq = {}; @@ -1329,12 +1340,12 @@ static int ffa_sched_recv_irq_map(void) oirq.np = gic; oirq.args_count = 1; - oirq.args[0] = sr_intid; + oirq.args[0] = intid; irq = irq_create_of_mapping(&oirq); of_node_put(gic); #ifdef CONFIG_ACPI } else { - irq = acpi_register_gsi(NULL, sr_intid, ACPI_EDGE_SENSITIVE, + irq = acpi_register_gsi(NULL, intid, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH); #endif } @@ -1442,17 +1453,15 @@ static void ffa_notifications_setup(void) int ret, irq; ret = ffa_features(FFA_NOTIFICATION_BITMAP_CREATE, 0, NULL, NULL); - if (ret) { - pr_info("Notifications not supported, continuing with it ..\n"); - return; - } + if (!ret) { - ret = ffa_notification_bitmap_create(); - if (ret) { - pr_info("Notification bitmap create error %d\n", ret); - return; + ret = ffa_notification_bitmap_create(); + if (ret) { + pr_err("notification_bitmap_create error %d\n", ret); + return; + } + drv_info->bitmap_created = true; } - drv_info->bitmap_created = true; irq = ffa_sched_recv_irq_map(); if (irq <= 0) {