mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Sudeep Holla <sudeep.holla@kernel.org>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, maz@kernel.org,
	will@kernel.org, catalin.marinas@arm.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, steven.price@arm.com,
	aneesh.kumar@kernel.org, oupton@kernel.org, gshan@redhat.com,
	joey.gouly@arm.com, tabba@google.com, yuzenghui@huawei.com,
	linux-coco@lists.linux.dev, gankulkarni@os.amperecomputing.com,
	sdonthineni@nvidia.com, alpergun@google.com,
	fj0570is@fujitsu.com, WeiLin.Chang@arm.com,
	lpieralisi@kernel.org, enju.kohei@fujitsu.com
Subject: Re: [PATCH v18 2/7] firmware: arm_rmm: Check for RMI support at init
Date: Wed, 23 Sep 2026 23:31:57 +0100	[thread overview]
Message-ID: <12024d6c-b8df-434c-8b63-29f5780a13a0@arm.com> (raw)
In-Reply-To: <20260914-nano-narwhal-of-blizzard-dbc6a0@sudeepholla>

Hi Sudeep,

Apologies, this one took longer to address. Thanks for raising this,
response inline.

On 14/09/2026 11:27, Sudeep Holla wrote:
> On Sat, Sep 12, 2026 at 09:36:05AM +0100, Suzuki K Poulose wrote:
>> From: Steven Price <steven.price@arm.com>
>>
>> Query the RMI version number and check if it is a compatible version.
>> The first two feature registers are read and exposed for future code to
>> use.
>>
>> We only support this for Little Endian kernels, the Big Endian kernel
>> support is anyway marked BROKEN and is being removed.
>>
>> Signed-off-by: Steven Price <steven.price@arm.com>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

> [...]
> 
>> diff --git a/include/linux/arm-rmi-cmds.h b/include/linux/arm-rmi-cmds.h
>> new file mode 100644
>> index 0000000000000..9792bf0e00cb9
>> --- /dev/null
>> +++ b/include/linux/arm-rmi-cmds.h
>> @@ -0,0 +1,36 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Copyright (C) 2026 ARM Ltd.
>> + */
>> +
>> +#ifndef __LINUX_ARM_RMI_CMDS_H_
>> +#define __LINUX_ARM_RMI_CMDS_H_
>> +
>> +#include <linux/arm-smccc-rmi.h>
>> +#include <linux/bug.h>
>> +#include <linux/processor.h>
>> +#include <linux/types.h>
>> +
>> +
>> +/*
>> + * rmi_smccc_invoke: Invoke the RMI call and return the results in @regs_out
>> + * @regs_in: Registers with the arguments filled in.
>> + * @regs_out: Ouptput results from the call.
>> + */
>> +static inline void rmi_smccc_invoke(struct arm_smccc_1_2_regs *regs)
>> +{
>> +	struct arm_smccc_1_2_regs args = *regs;
>> +	unsigned long status;
>> +
>> +	while (1) {
>> +		arm_smccc_1_2_invoke(&args, regs);
>> +		status = RMI_RETURN_STATUS(regs->a0);
>> +		if (status != RMI_BUSY && status != RMI_BLOCKED)
>> +			break;
>> +		cpu_relax();
>> +	}
>> +}
> 
> I haven't done a detailed review, this is just a drive through comment.
> The while(1) gained my attention.
> 
> Should RMI_BLOCKED be returned to the caller instead of retried here?

Short answer yes, to be safe.

> 
> RMM spec defines RMI_BLOCKED as persisting until the Host takes action.
> It also says it is returned when another SRO on the same context is
> incomplete. You may be running it on different CPUs and hence different

I agree this is poorly documented and we are working on improving the
documentation on this front.

RMI_BLOCKED is a side effect of an incomplete operation (in other
words long running) that has turned some "resource" into an
intermediate state. e.g.

The following operations could put objects into an intermediate
state until the RMM completes it, to ensure correctness.

  * Unmap a large IPA range triggering SMMU TLB invalidations.
    For KVM, we serialize the unmap S2 with kvm->mmu_lock with
    write lock. So two operations could not race (even a map
    at the same location).

  * Delegate/Undelegate, which again could end up in SMMU GPC
    invalidations.
    The only case where we race and do parallel "delegate" is
    while handling concurrent VCPU faults on two different physical
    CPUs. Even there a failing thread handles this by returning
    to the guest and taking the fault again (if it wasn't
    resolved by the other thread). We could additionally tighten
    this by using write lock for the fault (just like pKVM).

  * Change the tracking region granularity. e.g, convert from FINE
    granulartiy to COARSE or INTERMEDIATE, causing all granules in
    the target region to be locked. This is not something we do
    in Linux. We mandate the firmware maintains FINE granularity,
    at least for now. Even with dynamic tracking, we don't expect
    to fold the tracking granularity for regions with "mixed"
    entries (which would fail anyway due to the mismatch).

  * An object bound SRO handle is active, while another SRO initiating
    operation is issued. This possible with a buggy host.
    e.g., RMI_REALM_ACTIVATE is called while RMI_RTT_INIT_RIPAS is
    in progress. In KVM we serialize this with kvm->arch.config_lock.

For all practical purposes the above operations should complete in
a single try and another command observing the RMI_BLOCKED should
be able to make progress. That said, for Linux it is better to
return the RMI_BLOCKED back to the caller after an arbitrary
tiny number of times. So I have updated the code to try for
3 times for RMI_BLOCKED and return back to the caller.

We could even drop that and just return back immediately to
the caller. Like I described above, the only case where
we expect to hit the RMI_BLOCKED in Linux is for parallel
faults, which could be handled and/or prevented in Linux.



> context I assume. But this loop takes no such action and hides the status
> from the caller, so a command issued against that context if that can
> happen can spin indefinitely while the operation which would unblock it
> cannot run. Ignore me if it taken care not to happen elsewhere. I am
> just looking at this in isolation.
> 
> Could this retry only RMI_BUSY and propagate RMI_BLOCKED so that the caller
> can arrange for the incomplete operation to make progress if the above
> scenario is possible ?

Ack. I have made the changes in the next version.

Cheers
Suzuki


> 


  reply	other threads:[~2026-09-23 22:32 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12  8:36 [PATCH v18 0/7] firmware: arm_rmm: Add RMM v2.0 base RMI support Suzuki K Poulose
2026-09-12  8:36 ` [PATCH v18 1/7] firmware: arm_rmm: Add SMC definitions for calling the RMM Suzuki K Poulose
2026-09-14  0:28   ` Gavin Shan
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21  9:27     ` Suzuki K Poulose
2026-09-21 10:02       ` Suzuki K Poulose
2026-09-21 21:27         ` Jonathan Cameron
2026-09-23 22:34           ` Suzuki K Poulose
2026-09-21 10:14       ` Suzuki K Poulose
2026-09-21 21:29         ` Jonathan Cameron
2026-09-21 21:33       ` Jonathan Cameron
2026-09-12  8:36 ` [PATCH v18 2/7] firmware: arm_rmm: Check for RMI support at init Suzuki K Poulose
2026-09-14  1:04   ` Gavin Shan
2026-09-14 10:27   ` Sudeep Holla
2026-09-23 22:31     ` Suzuki K Poulose [this message]
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21  9:00     ` Suzuki K Poulose
2026-09-21 21:37       ` Jonathan Cameron
2026-09-12  8:36 ` [PATCH v18 3/7] firmware: arm_rmm: Configure the RMM with the host's page size Suzuki K Poulose
2026-09-14  1:21   ` Gavin Shan
2026-09-14  6:34     ` Suzuki K Poulose
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21  9:31     ` Suzuki K Poulose
2026-09-12  8:36 ` [PATCH v18 4/7] firmware: arm_rmm: Add support for SRO Suzuki K Poulose
2026-09-14  5:04   ` Gavin Shan
2026-09-14  6:22     ` Suzuki K Poulose
2026-09-14  8:19       ` Suzuki K Poulose
2026-09-14  9:59         ` Gavin Shan
2026-09-14  9:50       ` Gavin Shan
2026-09-14 12:50   ` Sudeep Holla
2026-09-14 14:02     ` Suzuki K Poulose
2026-09-14 14:47       ` Suzuki K Poulose
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21 12:42     ` Suzuki K Poulose
2026-09-21 21:46       ` Jonathan Cameron
2026-09-12  8:36 ` [PATCH v18 5/7] firmware: arm_rmm: Activate the RMM Suzuki K Poulose
2026-09-14  5:06   ` Gavin Shan
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21  9:04     ` Suzuki K Poulose
2026-09-12  8:36 ` [PATCH v18 6/7] firmware: arm_rmm: Ensure the RMM has GPT entries for memory Suzuki K Poulose
2026-09-14  5:41   ` Gavin Shan
2026-09-14  8:38     ` Suzuki K Poulose
2026-09-16 18:23   ` Alper Gun
2026-09-21  9:30     ` Suzuki K Poulose
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21  9:32     ` Suzuki K Poulose
2026-09-21 13:38       ` Suzuki K Poulose
2026-09-21 21:58         ` Jonathan Cameron
2026-09-22 22:55           ` Suzuki K Poulose
2026-09-23 16:46             ` Jonathan Cameron
2026-09-12  8:36 ` [PATCH v18 7/7] firmware: arm_rmm: Add wrappers for Realm related RMI commands Suzuki K Poulose
2026-09-14  5:46   ` Gavin Shan
2026-09-15 19:35   ` Alper Gun
2026-09-15 19:55     ` Suzuki K Poulose
2026-09-19  1:27   ` Jonathan Cameron
2026-09-21 21:53 ` [PATCH v18 0/7] firmware: arm_rmm: Add RMM v2.0 base RMI support Jonathan Cameron
2026-09-21 22:38   ` Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12024d6c-b8df-434c-8b63-29f5780a13a0@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=WeiLin.Chang@arm.com \
    --cc=alpergun@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=enju.kohei@fujitsu.com \
    --cc=fj0570is@fujitsu.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=gshan@redhat.com \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sdonthineni@nvidia.com \
    --cc=steven.price@arm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®