Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp652079rwb; Fri, 4 Aug 2023 21:00:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKGjqi8MPE8/JdkgL2U7wAyqjNW1cDYuKgHay30giI7HJx6jG4Y1P7m+XesPcg7Tky08+v X-Received: by 2002:a17:902:a40b:b0:1bb:5d9a:9054 with SMTP id p11-20020a170902a40b00b001bb5d9a9054mr3842711plq.12.1691208017674; Fri, 04 Aug 2023 21:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691208017; cv=none; d=google.com; s=arc-20160816; b=MGI1SyVSBWjbAgjek0Uw645jm0RTsLQgXKthm0i9FvLSCE68zAJimeD54crcUpBRcc hhlshI+7RJfKWbS9zDu5GqMRIL+vnnMKk9S/UhnmANue0dq0FSWf6vHo7K9PVIPFnThl XLAk0u6IZfMbIu97Zsiiga9OztlL86wYMtX3OboVVKXtjgV58iOvrtT87iPsbAvCsJBw KDVIsE1rFnQALCmFNWYdS/Va56/UVDkEJJT3Q1DkTYks5yT1gsMdmjKkQou+DfXFtkEc veZjPrFKvRkUttfBbewy+zkraroWDWQmOkMTekKttJ2M7i2GCqvUutWVWlxC3KjJpO3x 1u3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ch6fY2hLh2MwF2POvRVo7UgxBUVKvzcXpv1uMKO5wlk=; fh=oLz4G+KDSb/B/dAZFLz2IZ+6CHUUfg8rTtTN0sZldC0=; b=Z6dKZDjxD+47zx3MFVyJzjy/g7unP9zop3INhx+TI3wAPgKU7iWElmUncP0UeXJmqA VG0GV8fYHIUMhb0jUdpsJH90KrY1+OsYkefbDCIbISZMzYfwxHy/Icku/37tqXeuhYDT Y+Mt92oevzwI4DAzP+I69U6VI5KKIwBxEwQPp0bqdhHFRDY5cvbhsvGo/Q4l9f9/ApiW 5jVIlZH7JZi/VQO7h+wmONpgliRmmf5e4CbayPlguFhtJmglLURZiTT+cUAqyHxPXcZS 88PJiy1n/OiY3CpyQmeIi2QuveQXl5VcAt3W+jqHVg+2dQdpsWlKOk2kIKmdJWgCwTnW Jsxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I0pTknPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170902f14c00b001b876d46162si2601763plb.38.2023.08.04.21.00.02; Fri, 04 Aug 2023 21:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I0pTknPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229575AbjHEDsX (ORCPT + 99 others); Fri, 4 Aug 2023 23:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjHEDsV (ORCPT ); Fri, 4 Aug 2023 23:48:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43FD113E; Fri, 4 Aug 2023 20:48:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CAD3662177; Sat, 5 Aug 2023 03:48:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71E5EC433C7; Sat, 5 Aug 2023 03:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691207299; bh=QU/GmoLUQzSAZRjZezpkLQ4/uCOJLRiuDhLRFYj0Ibo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I0pTknPQGzFlcF5NAMREDDzZnMjikzhGiKA1r7T3iRacWhwiKrqi3PKLKU6l4DTv1 9BFVB/vcGEPVvYAUqUj9Zjie4EZo97sfvH8++fNTSBaztr+giTnDVPxHm50eNtPsjt 3pwAO5IJm8exEd92XAPJqG5IB9nxB/QQn4yqU3GN5jMO84eHBNQdOIS+UQfD+AYqZI U1sr3kBm+BEEaklYbd3RArse+JlyrxT8xAIG0Mewid63g2aOhw2JJvM4J8cebPGcVH dKNBRWaysMbOdu7GO8PPGlTep4phaqvnjM3olEpT6j3UGwFzXkA8buyxWzdx9abZs1 jnq21g7LuZy+w== Date: Fri, 4 Aug 2023 20:51:17 -0700 From: Bjorn Andersson To: Elliot Berman Cc: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Catalin Marinas , Will Deacon , Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Bagas Sanjaya , Andy Gross , 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 Subject: Re: [PATCH v14 05/25] virt: gunyah: msgq: Add hypercalls to send and receive messages Message-ID: <6uyzkx2cvfcz2vrosbj7crrzwo4emi2qitudnmzwh6t7fwqpez@lpg2yqkqgah5> References: <20230613172054.3959700-1-quic_eberman@quicinc.com> <20230613172054.3959700-6-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613172054.3959700-6-quic_eberman@quicinc.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 On Tue, Jun 13, 2023 at 10:20:33AM -0700, Elliot Berman wrote: > Add hypercalls to send and receive messages on a Gunyah message queue. > > Reviewed-by: Alex Elder > Reviewed-by: Srinivas Kandagatla > Signed-off-by: Elliot Berman > --- > arch/arm64/gunyah/gunyah_hypercall.c | 31 ++++++++++++++++++++++++++++ > include/linux/gunyah.h | 6 ++++++ > 2 files changed, 37 insertions(+) > > diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c > index ef48e0b8b5448..c5bf0dd468ec9 100644 > --- a/arch/arm64/gunyah/gunyah_hypercall.c > +++ b/arch/arm64/gunyah/gunyah_hypercall.c > @@ -35,6 +35,8 @@ EXPORT_SYMBOL_GPL(arch_is_gh_guest); > fn) > > #define GH_HYPERCALL_HYP_IDENTIFY GH_HYPERCALL(0x8000) > +#define GH_HYPERCALL_MSGQ_SEND GH_HYPERCALL(0x801B) > +#define GH_HYPERCALL_MSGQ_RECV GH_HYPERCALL(0x801C) > > /** > * gh_hypercall_hyp_identify() - Returns build information and feature flags > @@ -54,5 +56,34 @@ void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identi > } > EXPORT_SYMBOL_GPL(gh_hypercall_hyp_identify); > > +enum gh_error gh_hypercall_msgq_send(u64 capid, size_t size, void *buff, u64 tx_flags, bool *ready) I find the name "ready" unclear, I believe it will be true to indicate that the message queue is not full (i.e. Gunyah is ready to receive another message?) Naming it "full" and reversing the values would make this immediately obvious. > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_hvc(GH_HYPERCALL_MSGQ_SEND, capid, size, (uintptr_t)buff, tx_flags, 0, &res); > + > + if (res.a0 == GH_ERROR_OK) > + *ready = !!res.a1; > + > + return res.a0; > +} > +EXPORT_SYMBOL_GPL(gh_hypercall_msgq_send); > + > +enum gh_error gh_hypercall_msgq_recv(u64 capid, void *buff, size_t size, size_t *recv_size, > + bool *ready) And this "ready" seems to be "more data available". Naming it "empty", and reversing the values, would make this obvious. Perhaps when working with the hypercalls on a regular basis it makes sense to not invert the value space...renaming the two "ready" would be beneficial regardless. > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_hvc(GH_HYPERCALL_MSGQ_RECV, capid, (uintptr_t)buff, size, 0, &res); > + > + if (res.a0 == GH_ERROR_OK) { > + *recv_size = res.a1; > + *ready = !!res.a2; > + } > + > + return res.a0; > +} > +EXPORT_SYMBOL_GPL(gh_hypercall_msgq_recv); > + > MODULE_LICENSE("GPL"); > MODULE_DESCRIPTION("Gunyah Hypervisor Hypercalls"); > diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h > index 6b36cf4787efb..01a6f202d037e 100644 > --- a/include/linux/gunyah.h > +++ b/include/linux/gunyah.h > @@ -111,4 +111,10 @@ static inline u16 gh_api_version(const struct gh_hypercall_hyp_identify_resp *gh > > void gh_hypercall_hyp_identify(struct gh_hypercall_hyp_identify_resp *hyp_identity); > > +#define GH_HYPERCALL_MSGQ_TX_FLAGS_PUSH BIT(0) Unless the flags are growing, passing this as a bool push instead of a flag field seems reasonable. > + > +enum gh_error gh_hypercall_msgq_send(u64 capid, size_t size, void *buff, u64 tx_flags, bool *ready); > +enum gh_error gh_hypercall_msgq_recv(u64 capid, void *buff, size_t size, size_t *recv_size, > + bool *ready); Please wrap things to 80 characters, unless going a little bit over makes things more readable. Regards, Bjorn