[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/8] xen/arm: Add SCMI over SMC calls handling layer


  • To: Julien Grall <julien@xxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrei Cherechesu <andrei.cherechesu@xxxxxxxxxxx>
  • Date: Mon, 9 Dec 2024 19:37:29 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yzxybjhZfS5Xoqr1xkLsFs1MW/KUCSim6B/zXoAdOic=; b=YILJrtxAuFsX0LPo8hPSjCcLm+Q/71JhOCDTshUz5HBcnT0Q5pbaQO2g3Nn2F/TpEI8OY0wrOoAP+fILszKMStdfu7iuE0Xc3jdie80VdvA5oZFBnGSwZ4sgCYm8t5aC7mcVmt/OqcZdg4/m2BXl1QvvffDGx2vPv+kWgr2fuAz5fTmiIZ3slEwoHDda5ZMSd22XgiOPnbjlttq3T+HJytRenNH3eRVBxzB7XbrqIqYVQvL4PV/zvQ1NlzvHpl82qaP2jxUP6Q5XquAekxSigYho9StkS7z41/mnWJh3VOGMwK0NvGrou2dCu3f/Zg9eRT2D9ypAlMcV/SYCUUocuw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RxqmTOPAq+IZYf8Z+NY/K1x3FCwXAZXYS4tyWk6Wh6ruV319fZ+AMVGvKtMUZIz1Tf4W6/6zRSM06NnqjfyLUyNFPEufRtGq3DWUfWcRej16qybFdH59eOnK3CdpirYsbdoz9WkK1xsLCJ/J/YE7CN/f1261ijQa+lGX+OJ2MeTnOyuwtBIQ6rXOxDZlqy8ErDIb5glg4ntGYcxLPX2VMjTHNAMfEfcFMN11HlBDDieI9VolP6++iJo/w9/LeRtduE/ay+mle+0W+Y+QMjy4bCeGgYsTTVsO0bSWmE7g0L243lKk/chTU990nI1ELhnok8VC+67nJ3O9EPiG9NrSWw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com;
  • Cc: S32@xxxxxxx, Andrei Cherechesu <andrei.cherechesu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 09 Dec 2024 17:38:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien, Grygorii,

On 11/11/2024 12:33, Julien Grall wrote:
> Hi,
>
> On 01/11/2024 15:22, Grygorii Strashko wrote:
>> Hi
>>
>> I'd be apprcieated if could consider my comments below.
>>
>> On 30.09.24 14:47, Andrei Cherechesu (OSS) wrote:
>>> From: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
>>>
>>> Introduce the SCMI layer to have some basic degree of awareness
>>> about SMC calls that are based on the ARM System Control and
>>> Management Interface (SCMI) specification (DEN0056E).
>>>
>>> The SCMI specification includes various protocols for managing
>>> system-level resources, such as: clocks, pins, reset, system power,
>>> power domains, performance domains, etc. The clients are named
>>> "SCMI agents" and the server is named "SCMI platform".
>>>
>>> Only support the shared-memory based transport with SMCs as
>>> the doorbell mechanism for notifying the platform. Also, this
>>> implementation only handles the "arm,scmi-smc" compatible,
>>> requiring the following properties:
>>>     - "arm,smc-id" (unique SMC ID)
>>>     - "shmem" (one or more phandles pointing to shmem zones
>>>     for each channel)
>>>
>>> The initialization is done as 'presmp_initcall', since we need
>>> SMCs and PSCI should already probe EL3 FW for supporting SMCCC.
>>> If no "arm,scmi-smc" compatible node is found in Dom0's
>>> DT, the initialization fails silently, as it's not mandatory.
>>> Otherwise, we get the 'arm,smc-id' DT property from the node,
>>> to know the SCMI SMC ID we handle. The 'shmem' memory ranges
>>> are not validated, as the SMC calls are only passed through
>>> to EL3 FW if coming from Dom0 and as if Dom0 would be natively
>>> running.
>>>
>>> Signed-off-by: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
>>> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
>>> ---
>>>   xen/arch/arm/Kconfig                |  10 ++
>>>   xen/arch/arm/Makefile               |   1 +
>>>   xen/arch/arm/include/asm/scmi-smc.h |  52 +++++++++
>>>   xen/arch/arm/scmi-smc.c             | 163 ++++++++++++++++++++++++++++
>>
>> Could it be moved in separate folder - for example "sci" or "firmware"?
>> There are definitely more SCMI specific code will be added in the future
>> as this solution is little bit too simplified.
>>
>>>   4 files changed, 226 insertions(+)
>>>   create mode 100644 xen/arch/arm/include/asm/scmi-smc.h
>>>   create mode 100644 xen/arch/arm/scmi-smc.c
>>>
>>> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
>>> index 323c967361..adf53e2de1 100644
>>> --- a/xen/arch/arm/Kconfig
>>> +++ b/xen/arch/arm/Kconfig
>>> @@ -245,6 +245,16 @@ config PARTIAL_EMULATION
>>>         not been emulated to their complete functionality. Enabling this 
>>> might
>>>         result in unwanted/non-spec compliant behavior.
>>> +config SCMI_SMC
>>
>> Could you please rename it to clearly specify that it is only dom0/hwdom
>> specific? Like SCMI_SMC_DOM0 or SCMI_SMC_HW_DOM.
>
> I expect this series to be just a stop gap until we support SCMI for the VMs. 
> Once this is merge, I don't expect we would want to keep a Kconfig to allow 
> SCMI just for dom0. Therefore, I am not entirely convinced the proposed new 
> name is a good idea.

AFAIU, Julien, you don't agree with renaming the config, nor with moving the
support to a separate folder since it's something temporary? That's my view
as well.

These changes do not introduce support for a layer of mediators for
interacting with system firmware, but only for one simplified implementation.
So I suppose the patch set that adds that support also creates the folder
(named 'sci' - per Gregorii's proposal - or 'firmware' to align with Linux),
and the required config.

But I'm up for doing whatever you consider more suitable.

>
>
>>
>>> +    bool "Enable forwarding SCMI over SMC calls from Dom0 to EL3 firmware"
>>> +    default y
>>> +    help
>>> +      This option enables basic awareness for SCMI calls using SMC as
>>> +      doorbell mechanism and Shared Memory for transport ("arm,scmi-smc"
>>> +      compatible only). The value of "arm,smc-id" DT property from SCMI
>>> +      firmware node is used to trap and forward corresponding SCMI SMCs
>>> +      to firmware running at EL3, if the call comes from Dom0.
>>> +
>>>   endmenu
>>>   menu "ARM errata workaround via the alternative framework"
>>> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
>>> index 7792bff597..b85ad9c13f 100644
>>> --- a/xen/arch/arm/Makefile
>>> +++ b/xen/arch/arm/Makefile
>>> @@ -45,6 +45,7 @@ obj-y += platform_hypercall.o
>>>   obj-y += physdev.o
>>>   obj-y += processor.o
>>>   obj-y += psci.o
>>> +obj-$(CONFIG_SCMI_SMC) += scmi-smc.o
>>>   obj-y += setup.o
>>>   obj-y += shutdown.o
>>>   obj-y += smp.o
>>> diff --git a/xen/arch/arm/include/asm/scmi-smc.h b/xen/arch/arm/ 
>>> include/asm/scmi-smc.h
>>> new file mode 100644
>>> index 0000000000..c6c0079e86
>>> --- /dev/null
>>> +++ b/xen/arch/arm/include/asm/scmi-smc.h
>>> @@ -0,0 +1,52 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>>> +/*
>>> + * xen/arch/arm/include/asm/scmi-smc.h
>>> + *
>>> + * ARM System Control and Management Interface (SCMI) over SMC
>>> + * Generic handling layer
>>> + *
>>> + * Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
>>> + * Copyright 2024 NXP
>>> + */
>>> +
>>> +#ifndef __ASM_SCMI_SMC_H__
>>> +#define __ASM_SCMI_SMC_H__
>>> +
>>> +#include <xen/types.h>
>>> +#include <asm/regs.h>
>>> +
>>> +#ifdef CONFIG_SCMI_SMC
>>> +
>>> +bool scmi_is_enabled(void);
>>> +bool scmi_is_valid_smc_id(uint32_t fid);
>>> +bool scmi_handle_smc(struct cpu_user_regs *regs);
>>> +
>>> +#else
>>> +
>>> +static inline bool scmi_is_enabled(void)
>>> +{
>>> +    return false;
>>> +}
>>> +
>>> +static inline bool scmi_is_valid_smc_id(uint32_t fid)
>>> +{
>>> +    return false;
>>> +}
>>> +
>>> +static inline bool scmi_handle_smc(struct cpu_user_regs *regs)
>>
>> I propose to add "struct domain *d" as the first parameter to make it
>> more abstract from Xen internals.
>
> I am not sure to understand why we would want the call to be more abstract. 
> This function should *only* act on the vCPU currently loaded. So it makes 
> sense to use "current->domain".

So this should stay the same, right?

@Grygorii,

Regarding `scmi_is_valid_smc_id()`, I will make it private to the
SCMI-SMC driver.

And regarding squashing [v2,4/8] to [v2,3/8], IMO it is clearer
this way: to have the implementation of the driver in a different
commit than the usage/refactorings needed to accomodate it. And
this makes it easier to revert the behaviour too, eventually. But
I don't have a strong preference on this and I'm open to squash
the commits if you believe it is better that way.

>
> Cheers,
>

Regards,
Andrei Cherechesu




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.