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 X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E953C433DB for ; Wed, 13 Jan 2021 09:45:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DD96233F8 for ; Wed, 13 Jan 2021 09:45:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DD96233F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=guTLvtyyv4Nlm6yDFM8CrBumfweL6YLcWnKQrFGq6zE=; b=EfuA2K8om9v0jaeGViVT/G32T IhArIMRoxSgv79IUlPcpAz1yIuTuXdj5AXHHfQep+8g1vyBitEmWppdd8DXC1TBIe3AAdzIr9i8ST FuzCdNMCMXmIvy4/H4TQXq60UPPCy14F18uYoAD2eKj/2izZYVtywkMivLm2spzH+lXijYR13SI5Y DETYLnNrQuTJlGIJteElDx/DmH9MwGhjYacNEcQiYnTbOdoiB4iyFrwMVJkZvjmkhxO7EKbj8C1+m U7iQzAjo8ejQiutmi1b8CG5X/Ow5/3Rd8t+hbNhppuhQwP4tK9H0O61krQRgwRWM0G0sS/zL8bp/d SaR038U1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzchO-0007tQ-It; Wed, 13 Jan 2021 09:44:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzchJ-0007r6-GF for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 09:44:15 +0000 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 A20D41063; Wed, 13 Jan 2021 01:44:11 -0800 (PST) Received: from bogus (unknown [10.57.35.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 59F233F66E; Wed, 13 Jan 2021 01:44:10 -0800 (PST) Date: Wed, 13 Jan 2021 09:44:08 +0000 From: Sudeep Holla To: Jens Wiklander Subject: Re: [PATCH v3 6/7] firmware: arm_ffa: Setup in-kernel users of FFA partitions Message-ID: <20210113094408.pjkno4nalk5zizxa@bogus> References: <20201204121137.2966778-1-sudeep.holla@arm.com> <20201204121137.2966778-7-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210113_044413_804058_5C925178 X-CRM114-Status: GOOD ( 25.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trilok Soni , Devicetree List , David Hartley , Andrew Walbran , Achin Gupta , arve@android.com, Arunachalam Ganapathy , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Dec 11, 2020 at 11:59:40AM +0100, Jens Wiklander wrote: > One more comment below. > > On Fri, Dec 11, 2020 at 11:45 AM Jens Wiklander > wrote: > > > > Hi Sudeep, > > > > Some more comments below. > > > > On Fri, Dec 4, 2020 at 1:11 PM Sudeep Holla wrote: > > > > > > Parse the FFA nodes from the device-tree and register all the partitions > > > whose services will be used in the kernel. > > > > > > In order to also enable in-kernel users of FFA interface, let us add > > > simple set of operations for such devices. > > > > > > The in-kernel users are registered without the character device interface. > > > > > > Signed-off-by: Sudeep Holla > > > --- > > > drivers/firmware/arm_ffa/common.h | 2 + > > > drivers/firmware/arm_ffa/driver.c | 186 ++++++++++++++++++++++++++++++ > > > include/linux/arm_ffa.h | 36 +++++- > > > 3 files changed, 223 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/firmware/arm_ffa/common.h b/drivers/firmware/arm_ffa/common.h > > > index d019348bf67d..eb1371c2b2b8 100644 > > > --- a/drivers/firmware/arm_ffa/common.h > > > +++ b/drivers/firmware/arm_ffa/common.h > > > @@ -6,6 +6,7 @@ > > > #ifndef _FFA_COMMON_H > > > #define _FFA_COMMON_H > > > > > > +#include > > > #include > > > #include > > > > > > @@ -17,6 +18,7 @@ typedef ffa_res_t > > > > > > int __init arm_ffa_bus_init(void); > > > void __exit arm_ffa_bus_exit(void); > > > +bool ffa_device_is_valid(struct ffa_device *ffa_dev); > > > > > > #ifdef CONFIG_ARM_FFA_SMCCC > > > int __init ffa_transport_init(ffa_fn **invoke_ffa_fn); > > > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c > > > index 257b331d781c..3e4ba841dbf8 100644 > > > --- a/drivers/firmware/arm_ffa/driver.c > > > +++ b/drivers/firmware/arm_ffa/driver.c > > > @@ -24,9 +24,13 @@ > > > > > > #include > > > #include > > > +#include > > > #include > > > +#include > > > #include > > > +#include > > > #include > > > +#include > > > > > > #include "common.h" > > > > > > @@ -179,6 +183,20 @@ static int ffa_version_check(u32 *version) > > > return 0; > > > } > > > > > > +static int ffa_rx_release(void) > > > +{ > > > + ffa_res_t ret; > > > + > > > + ret = invoke_ffa_fn(FFA_RX_RELEASE, 0, 0, 0, 0, 0, 0, 0); > > > + > > > + if (ret.a0 == FFA_ERROR) > > > + return ffa_to_linux_errno((int)ret.a2); > > > + > > > + /* check for ret.a0 == FFA_RX_RELEASE ? */ > > > + > > > + return 0; > > > +} > > > + > > > static int ffa_rxtx_map(phys_addr_t tx_buf, phys_addr_t rx_buf, u32 pg_cnt) > > > { > > > ffa_res_t ret; > > > @@ -203,6 +221,50 @@ static int ffa_rxtx_unmap(u16 vm_id) > > > return 0; > > > } > > > > > > +static int __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, > > > + struct ffa_partition_info **buffer) > > > +{ > > > + int count; > > > + ffa_res_t partition_info; > > > + > > > + mutex_lock(&drv_info->rx_lock); > > > + partition_info = invoke_ffa_fn(FFA_PARTITION_INFO_GET, uuid0, uuid1, > > > + uuid2, uuid3, 0, 0, 0); > > > + > > > + if (partition_info.a0 == FFA_ERROR) > > > + return ffa_to_linux_errno((int)partition_info.a2); > > > + > > > + count = partition_info.a2; > > > + > > > + if (buffer) > > > + memcpy(*buffer, drv_info->rx_buffer, sizeof(*buffer) * count); > > > + > > > + ffa_rx_release(); > > > + > > > + mutex_unlock(&drv_info->rx_lock); > > > + > > > + return count; > > > +} > > > + > > > +static int ffa_partition_probe(const char *uuid_str, > > > + struct ffa_partition_info *buffer) > > > +{ > > > + int count; > > > + uuid_t uuid; > > > + u32 uuid0_4[4] = { 0 }; > > > + > > > + if (uuid_parse(uuid_str, &uuid)) { > > > + pr_err("invalid uuid (%s)\n", uuid_str); > > > + return -ENODEV; > > > + } > > > + > > > + export_uuid((u8 *)uuid0_4, &uuid); > > > + count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], uuid0_4[2], > > > + uuid0_4[3], &buffer); > Wrong byte order? > According to section 5.3 of the SMCCC, UUIDs are returned as a single > 128-bit value using the SMC32 calling convention. This value is mapped > to argument registers x0-x3 on AArch64 (resp. r0-r3 on AArch32). x0 > for example shall hold bytes 0 to 3, with byte 0 in the low-order > bits. > I need to spend some time to understand the concern here. Initially I agreed with your analysis and then a quick review make be realise it is all OK. I need to check if my understanding is correct again. I thought I will take example and check here itself. UUID: "fd02c9da-306c-48c7-a49c-bbd827ae86ee" UUID[0] UUID[1] UUID[2] UUID[3] (referring uuid0_4 above) dac902fd c7486c30 d8bb9ca4 ee86ae27 It seems correct as per SMCCC convention to me, or am I missing something obvious ? -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel