From mboxrd@z Thu Jan 1 00:00:00 1970 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 8F459C7EE2E for ; Mon, 5 Jun 2023 19:49:13 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject:From: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z4znj3dLb8V0OQiGGDeflbLN3SoAwddFUiCMEY/hVps=; b=uCnyQ/b3Lpbvqb JKOHj6pWkM2HeTD5cnPJqZg8FYj9yj57iwiWav9kKg0ZnHSw2ivOO2yGsNHY7RD4pjg1gD5gQ1/9U +t9fQ1WVPGpDpJzhbgRqkSqNjc2wiP0w9oYgsnyOeGhM/M4S4myLb5jmf8YiX6oGX0uc+0QDbMkmC zbC/z+so01m5UQZExDtx7ZQ98skhdWoSgAeSJXxRtxwuWrnQAI2SZtyif6kIVqyIU0z9PzuqwPhv9 26JaeF9IwcvUsaiiKvQq8Ftz2T8r3yJ7s1sRouO6TTvloqPTJCJXkMwGs4G/MkqkPmdGdsAivVx9u masH028QCjs43Ru/JkBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6GC4-00GbQH-2D; Mon, 05 Jun 2023 19:48:44 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6GC1-00GbMo-1B for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2023 19:48:42 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-33bbc91dcb7so26797585ab.3 for ; Mon, 05 Jun 2023 12:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685994518; x=1688586518; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=pqz7dKlCFpKHeC1hM9llutxXnmBYOpbsNK/LcnDGjLA=; b=iE7rEZ/5jJEFJkOeyJTDZWDelOFZAqkJA9+l/dzLOqBEhImk+CwYgekGbj4JKgZAEf EayXIDaR5bzrYTKmPrOhq+1fiU/YjtKvOdIHu1q+LIHUE2mtQuEZe0UvNkz/aiHlpUTb GPOr60SnttLPNeVMJJBy2Npq+ZBa5+2875Rau4jT7N65k2mA/fOAYOTCAs7Pgjchfx1r dTnjllpX11zMgBNJDxKBYu9oDfEn9hQQHJNoUogQz4YvL8UbDMghwQcBs5TRp76SKWj+ H8Yzfd1E3kzSadZ6tCdKWMj/M5+P1F4FppCV0c5rmkSH+ZauzvZ89vrS49RCXf+cF/ZB XXAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685994518; x=1688586518; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pqz7dKlCFpKHeC1hM9llutxXnmBYOpbsNK/LcnDGjLA=; b=ZUXCRXb9m0lIGldtrq+RSc2ljhhpTsB2GfbDGSmHw4K8brk80CxF+UKDXsGHEUG/cl 97NuvfenmD7z21057D9G4na1CjvRqqwkmdayMFiTCM8rEmf3ZRq300AjPasxOxTEZeK2 jPyf6KsvNbhcVgPSws0VU+Jiv866uyqR3RTvaMtbaHqyED/OOux8NEbW2p2edyORPr01 MaDZDtVk3aJj69goncaPVwVpuYW+XV5+WQfsgZcyLJGODufFfwhX/mu6pET3fJQdJVGF +4rhDJBm0LQu34tAIThgkg53/B8W6j6SvZE3TQLCoXb7FYTSFTerRFCOzpPfWikHRfFU YZcw== X-Gm-Message-State: AC+VfDxQ2skngDscFk9vaTUtCCQFGO3ccnU37UxsZEVr7MGNudilYk6y +CtP5aByKlROaKxv9Ir+EmQMnA== X-Google-Smtp-Source: ACHHUZ6TdCehFloH2eMhgF6TB0a01z4a2fQfHv42ISig5LnVp7kPTKBiIS5RncSPu9gGyCXCtH3qyA== X-Received: by 2002:a5e:8b47:0:b0:777:b7a0:75d7 with SMTP id z7-20020a5e8b47000000b00777b7a075d7mr203183iom.13.1685994518678; Mon, 05 Jun 2023 12:48:38 -0700 (PDT) Received: from [172.22.22.28] ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id y28-20020a02ce9c000000b0041684163ee1sm710229jaq.146.2023.06.05.12.48.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 12:48:38 -0700 (PDT) Message-ID: Date: Mon, 5 Jun 2023 14:48:37 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Alex Elder Subject: Re: [PATCH v13 13/24] gunyah: rsc_mgr: Add platform ops on mem_lend/mem_reclaim To: Elliot Berman , Srinivas Kandagatla , Prakruthi Deepak Heragu Cc: Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Will Deacon , Andy Gross , Catalin Marinas , Jassi Brar , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230509204801.2824351-1-quic_eberman@quicinc.com> <20230509204801.2824351-14-quic_eberman@quicinc.com> Content-Language: en-US In-Reply-To: <20230509204801.2824351-14-quic_eberman@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_124841_405543_6C7103BD X-CRM114-Status: GOOD ( 28.32 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/9/23 3:47 PM, Elliot Berman wrote: > On Qualcomm platforms, there is a firmware entity which controls access > to physical pages. In order to share memory with another VM, this entity > needs to be informed that the guest VM should have access to the memory. You might be able to avoid the lock by using rcu_assign_pointer() and rcu_dereference(), but I'm not recommending it (because I'm not sure). I have one more suggestion below. Reviewed-by: Alex Elder > Co-developed-by: Prakruthi Deepak Heragu > Signed-off-by: Prakruthi Deepak Heragu > Signed-off-by: Elliot Berman > --- > drivers/virt/gunyah/Kconfig | 4 ++ > drivers/virt/gunyah/Makefile | 2 + > drivers/virt/gunyah/gunyah_platform_hooks.c | 80 +++++++++++++++++++++ > drivers/virt/gunyah/rsc_mgr.h | 3 + > drivers/virt/gunyah/rsc_mgr_rpc.c | 18 ++++- > include/linux/gunyah_rsc_mgr.h | 17 +++++ > 6 files changed, 122 insertions(+), 2 deletions(-) > create mode 100644 drivers/virt/gunyah/gunyah_platform_hooks.c > > diff --git a/drivers/virt/gunyah/Kconfig b/drivers/virt/gunyah/Kconfig > index 1a737694c333..de815189dab6 100644 > --- a/drivers/virt/gunyah/Kconfig > +++ b/drivers/virt/gunyah/Kconfig > @@ -4,6 +4,7 @@ config GUNYAH > tristate "Gunyah Virtualization drivers" > depends on ARM64 > depends on MAILBOX > + select GUNYAH_PLATFORM_HOOKS > help > The Gunyah drivers are the helper interfaces that run in a guest VM > such as basic inter-VM IPC and signaling mechanisms, and higher level > @@ -11,3 +12,6 @@ config GUNYAH > > Say Y/M here to enable the drivers needed to interact in a Gunyah > virtual environment. > + > +config GUNYAH_PLATFORM_HOOKS > + tristate > diff --git a/drivers/virt/gunyah/Makefile b/drivers/virt/gunyah/Makefile > index bacf78b8fa33..4fbeee521d60 100644 > --- a/drivers/virt/gunyah/Makefile > +++ b/drivers/virt/gunyah/Makefile > @@ -1,4 +1,6 @@ > # SPDX-License-Identifier: GPL-2.0 > > +obj-$(CONFIG_GUNYAH_PLATFORM_HOOKS) += gunyah_platform_hooks.o > + > gunyah-y += rsc_mgr.o rsc_mgr_rpc.o vm_mgr.o vm_mgr_mm.o > obj-$(CONFIG_GUNYAH) += gunyah.o > diff --git a/drivers/virt/gunyah/gunyah_platform_hooks.c b/drivers/virt/gunyah/gunyah_platform_hooks.c > new file mode 100644 > index 000000000000..60da0e154e98 > --- /dev/null > +++ b/drivers/virt/gunyah/gunyah_platform_hooks.c > @@ -0,0 +1,80 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#include > +#include > +#include > + > +#include "rsc_mgr.h" > + > +static struct gh_rm_platform_ops *rm_platform_ops; > +static DECLARE_RWSEM(rm_platform_ops_lock); > + > +int gh_rm_platform_pre_mem_share(struct gh_rm *rm, struct gh_rm_mem_parcel *mem_parcel) > +{ > + int ret = 0; > + > + down_read(&rm_platform_ops_lock); > + if (rm_platform_ops && rm_platform_ops->pre_mem_share) > + ret = rm_platform_ops->pre_mem_share(rm, mem_parcel); > + up_read(&rm_platform_ops_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(gh_rm_platform_pre_mem_share); > + > +int gh_rm_platform_post_mem_reclaim(struct gh_rm *rm, struct gh_rm_mem_parcel *mem_parcel) > +{ > + int ret = 0; > + > + down_read(&rm_platform_ops_lock); > + if (rm_platform_ops && rm_platform_ops->post_mem_reclaim) > + ret = rm_platform_ops->post_mem_reclaim(rm, mem_parcel); > + up_read(&rm_platform_ops_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(gh_rm_platform_post_mem_reclaim); > + > +int gh_rm_register_platform_ops(struct gh_rm_platform_ops *platform_ops) Can (should) platform_ops be declared as const? (I think it can, that would be better as long as you don't expect operation function pointers to be added after registration.) If you do that, all such arguments will probably need to be updated to pointer-to-const. > +{ > + int ret = 0; > + > + down_write(&rm_platform_ops_lock); > + if (!rm_platform_ops) > + rm_platform_ops = platform_ops; > + else > + ret = -EEXIST; > + up_write(&rm_platform_ops_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(gh_rm_register_platform_ops); . . . _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel