From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27D9B5172C6 for ; Mon, 21 Sep 2026 21:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790027201; cv=none; b=M51yeSile8Nh76fmaln1gXjgAflXYiUDw9xw+H6WsG2XM7R0YVEfmN4ofwDRAKsny+M8Z4aCNXBssz2AGJ7ML3Ya7kNpPJ3rdVbaQJE/8n75MxjKbB0/PB6Bkvui7IEI1cffCmVxb0Y1vzJqIM23tsSgPmg24Um4M1dq0bg+vjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790027201; c=relaxed/simple; bh=QShqD0mzsgr5KsP5VmTpDyoWzdUjfsO4sL+xZPZ8Kno=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fEYiSJL0hIEFKcOuqmtJ4jOr4RwYbayrCOhYL4ugFi3X9SpXK6OeNE+PDY1V+d+H0v4sF6Ib2VFLcgeovPBXwQDNo0P5vycGEAW2sYyUbijDPX9t7YeZhYnmYjma5AynFmmBw4wl6M9T/J/itBV5leG5MCr002iSarMtqL+xvxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=EFoJNMx1; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=P2VQYsZZ; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="EFoJNMx1"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="P2VQYsZZ" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68LKexAk2892059 for ; Mon, 21 Sep 2026 21:46:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ZfOg9XYdQ5/vxidE+9pPRR6RYjJCbLCLOIt2gCT+9Gg=; b=EFoJNMx1X6Pv4FDS tMUSGAa9LvqoGHZBedDqvdBcDA7Cvae9SnITto4f09jRtlbuekCrbMc/2MAKvf6x gy2p3mZ2bhW8HdOSvKsdo/MKLNoMpVqXD90eb3NjmicVlbPWXm3gn48rxPFjxWVd ccE3FYDFyB3GFotA+QlERyQZ16B85/XCfZXm5v3vSsXF7AER0i7zlTvSQHCun1zu nfalxcV7idp0hPZlhBnqfZke+HLmsbX2Sc7DCOy8jejO2OtTqVCkLWdLV1vBiXSp 9DeQc19R9BUJCDEQgouChdIxMP4QiqIcIk83GTs5CpiOtWouC/iXLzm7qBgeMsWJ YRLYVw== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gtysw3get-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 21 Sep 2026 21:46:38 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-39de4e72b33so6332372a91.2 for ; Mon, 21 Sep 2026 14:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790027198; x=1790631998; darn=lists.linux.dev; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=ZfOg9XYdQ5/vxidE+9pPRR6RYjJCbLCLOIt2gCT+9Gg=; b=P2VQYsZZa1ytzTWoBdjszmF1yT5vx9VbfPC0lJpSrVH6I+yrC7V9GIx2Fdy9xUECB3 zp48zlJybqMxzdj92PILEI21k5GJ96QHJqTnIzuH4Isdy+inSI6/1HWaJGJeUi6+ovoH F04YRGGu0Bef2DOWXFpaFsX/ACwsXu404WVElGEwNoEKcUI+5GEkac5tos4s7u8lR8Hk stuut9HM6Slsa1ML+JTWj4gDaSIVS34OXEnFWjxTU58J5A5+WB3PYcZZ0r84p1S71JFN ouUKmKXuePx6TzZWI/pmb6x7qmNfKOEEWQIO9VoOMiyHWJshsc/3k2f6ZFzHXH+Rz9vi W/3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790027198; x=1790631998; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZfOg9XYdQ5/vxidE+9pPRR6RYjJCbLCLOIt2gCT+9Gg=; b=FUcBAsEyrtlJA6BZhrM5v0iGEskG0QiRXxZm0yA7kacvo09E+vPlp/xytAwEF+WILa rD1DqpoT+Jj4itQOm4Uw55bvMj6X/oEnu164B3zDlnQqkQ+VSsZN62zV/7Ei9APvpt9s MzgCkrUi02m92x69yX3CiOJzcBf1iR4cEvePCf031TaL1kDdkJ8i1x34vVkFRpuloVTG 4mMGkyzlpAi0+LpaVKJwojzvhUDedQIA/SPKuOEFnMfGVraubXI/YXQrF5brz+iFCxx+ 2pCfrHMlZ7jRNLzsLcs5vbidwGPcip9j+P9iT1RjY2IDdFHRRWPpb3HmcMd4s1J7Lfol 3wxw== X-Forwarded-Encrypted: i=1; AKwUvBy00bjPZz+oZzruhzIQo7lLABGFu4R69uH8X6bejC8pusjhac+x4L/tnUsyXxGGUcgFaNxJeWignqSa@lists.linux.dev X-Gm-Message-State: AFuF++m/Uo6dvx/48DUCQnDZA4zVFBNPU531AxkwB3irLFNjkfLywsvN Wrksvcm5lsv6YptPJYznQH9NQOn4C6DmGgAJXnCTE8QQMFiDgPo4JkzBRMIOySYrIQ9xcx41tCV i07G/8aP607iJ4eFFhKMCiTJxbG6V4XXqS4OERECboSGcFDOUi9sDCkfGhYbUG6iL X-Gm-Gg: AYBFou0QDvMKKZY9IChIuvegvoIckVx+FPTfJl13HvjIzFjGZhfVLDhE79BgYklaD5+ 34pNRwpK+kx4N3nKMZcIDx8ZboSXagJDEjpkWGYeWyltb35fSNhRXq42iAfAM62wxAH/ycGgHeh evhQJq+ThFmbACy+3xfU2ktRU6P3wr0UdrFwbUfLrV7M3lCNAUvJxfZgR4M6FsX47ACB/RavFsS RAmk9ydeQ53FK1F+ZE0K8u+0Ih/4QWpDtDM04DEM20eW6GRuknbXLAZiFGbZqQIpWJYNFGZMkLs iF79llqnQu/Dwfz3C5fvcp/esdTS+CpeFfMlJo0qxXihNBIvsQ5qEr/o/m5jZOril2zrAzDXUXr bxS7QFHgqwVpKIBwX+Y+pA7g6/g== X-Received: by 2002:a17:90b:2dc3:b0:39e:3ce1:d22f with SMTP id 98e67ed59e1d1-39e54d3674bmr17165995a91.16.1790027197639; Mon, 21 Sep 2026 14:46:37 -0700 (PDT) X-Received: by 2002:a17:90b:2dc3:b0:39e:3ce1:d22f with SMTP id 98e67ed59e1d1-39e54d3674bmr17165954a91.16.1790027197022; Mon, 21 Sep 2026 14:46:37 -0700 (PDT) Received: from localhost ([50.35.44.179]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-144f0c7e0d1sm439586c88.10.2026.09.21.14.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 14:46:35 -0700 (PDT) Date: Mon, 21 Sep 2026 14:46:31 -0700 From: Jonathan Cameron To: Suzuki K Poulose 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 4/7] firmware: arm_rmm: Add support for SRO Message-ID: <20260921144631.00007440@oss.qualcomm.com> In-Reply-To: References: <20260912083611.2513845-1-suzuki.poulose@arm.com> <20260912083611.2513845-5-suzuki.poulose@arm.com> <178978126542.2352296.15676256806777454164.b4-review@b4> Organization: Qualcomm X-Mailer: Claws Mail 4.4.0 (GTK 3.24.51; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIxMDMxOCBTYWx0ZWRfX544sgIVwstU0 BS+//oNZC+kWpY554rptbYecr9wYNu0HCEpuaqWmuOVZEUUFP14TNWHiJHZ/Z0hcQQW2F168GWW HVuU/aoVbqad4LE8iGvZcZUvqTJyMVshL5hjKdqzgbuq0aLN7QI/CA90EvmdX3KVTPogb5Xdl4s 0/8ZI+SL2zKGOQgPEYBxCQlo84WEJavecltgq53beV2TXwd8Vo+oFX6fvgZslG+sSM0EKYQi8Q+ AAaS8y+fN/Kz7LsIn7PjNyYOgRPV+tMV02nwZwx9I8ynUX00n8JdP+Plx8qE0VEoOX5nXX4IDv4 SDumgMWCRPWBH2nM/pn1OmL8fVgDtelc6VmN9V2xe9DARbLeo6j1y/JQCX1F0tB4083qR3IUyzS 90jsWVU7AOT9063YmwFrfarlv0tiyqp8eSjOChudMaqcXpC9ExrixwGvH81gr7zHqHbUSeSdge6 +zfnIsKBR/cuLuiJSEw== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIxMDMxOCBTYWx0ZWRfXz/TKm4+h2bs1 Tps1VdIO6aWguKTt97H9ZXhOmJNMOa7vQGUxwyAhFamjyJubZ6RZGVgmwxq++7vysXUb8nesKbt DS+yGxWJjSt/bwpS5loX0zcumpjCoHE= X-Proofpoint-ORIG-GUID: YoLU1_pyK6zCTqPO5IbNznVhNPi2t3Af X-Proofpoint-GUID: YoLU1_pyK6zCTqPO5IbNznVhNPi2t3Af X-Authority-Analysis: v=2.4 cv=W7etxhWk c=1 sm=1 tr=0 ts=6ab1a5be cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=aNnz9XPx1a4JIXSYt2cE/A==:17 a=kj9zAlcOel0A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=yke8hGA7Qea92797WwgA:9 a=CjuIK1q_8ugA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-21_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609210318 > >> diff --git a/drivers/firmware/arm_rmm/rmi.c b/drivers/firmware/arm_rmm/rmi.c > >> index 5b0e342ce3d5..4f9898ece754 100644 > >> --- a/drivers/firmware/arm_rmm/rmi.c > >> +++ b/drivers/firmware/arm_rmm/rmi.c > >> @@ -15,6 +15,59 @@ > >> #define RMI_FEAT_REG_COUNT 2 > >> static unsigned long rmi_feat_reg_cache[RMI_FEAT_REG_COUNT] __ro_after_init; > > > > Was there a question here you missed ? FWIW: I think inaccurate cropping only! Have been using b4 review tui (which is excellent btw!) Not sure I've gotten the hang of it fully yet. > > I have expanded this to cover all 5 RmiFeatureRegisters exposed by RMM, > and it looks something like this now, with the use of ARRAY_SIZE() to > limit accesses. ... > > >> + > >> + /* Keep just the blocks the RMM didn't use in addr_list */ > >> + for (int i = consumed_blocks; i < count; i++) > >> + sro->addr_list[addr_list_start + i - consumed_blocks] = > >> + sro->addr_list[addr_list_start + i]; > > > > Maybe memmove to make it clear you are shifting a chunk of the array > > down. This might be worth some asci art showing each step in brief. > > Anyhow, something along these lines: > > > > memmove(&sro->addr_list[addr_list_start], > > &sro->addr_list[addr_list_start + consumed_blocks], > > (count - consumed_blocks) * sizeof(*sro->addr_list)); > > > > Obviously doesn't save code, but maybe simpler to understand than > > the loop. > > > > Does the following hunk look better with the comment ? > > /* > * Keep just the blocks the RMM didn't use in addr_list. > * RMM claimed consumed_blocks entries from addr_list_start. > * Move the entries left out at the end i.e. > * [ addr_list_start + consumed_blocks, addr_list_start + found) > * to the rest of the valid entries and adjust the addr_count to > * reflect the available entries. > */ > for (int i = 0, src = addr_list_start + consumed_blocks; > i < found - consumed_blocks; i++) > sro->addr_list[addr_list_start + i] = > sro->addr_list[src + i]; > > sro->addr_count -= consumed_blocks; Good enough. Not sure there is a perfect answer for this one! > > > > >> +} > >> + > >> +static int rmi_sro_reclaim(struct rmi_sro_state *sro, > >> + unsigned long sro_handle, > >> + struct arm_smccc_1_2_regs *out_regs) > >> +{ > >> + unsigned long capacity; > >> + > >> + if (rmi_sro_ensure_capacity(sro, 1)) > >> + rmi_sro_free(sro); > > > > Maybe a comment on why you free the whole lot rather than a smaller > > amount to make some room. > > We don't do partial free of the list today, and having that is > unnecssarily complicating the logic/code. We are going to do a reclaim > anyways. Sure, I could add a comment. Might be useful as a breadcrumb in future but indeed not vital. That was what I was assuming was the case. > > > > > >> + > >> + capacity = RMI_MAX_ADDR_LIST - sro->addr_count; > >> + > >> + rmi_op_mem_reclaim(sro_handle, > >> + virt_to_phys(&sro->addr_list[sro->addr_count]), > >> + capacity, out_regs); > >> + > >> + /* > >> + * RMI_OP_MEM_RECLAIM always return RMI_INCOMPLETE, except when the > >> + * input parameters were invalid. > >> + */ > >> + if (WARN_ON_ONCE(RMI_RETURN_STATUS(out_regs->a0) != RMI_INCOMPLETE)) > >> + return -EINVAL; > >> + if (WARN_ON_ONCE(out_regs->a1 > capacity)) > >> + out_regs->a1 = capacity; > > I guess this should never happen, but bit ugly to fixup the register > > return rather than perhaps using a local variable instead. > > We pass/get the out_regs, so local variable doesn't work, unless > I missed what you were hinting at.. Ahh. Indeed, I wasn't thinking ahead to it being visible after. > > > >> +long rmi_sro_execute(struct arm_smccc_1_2_regs *regs) > >> +{ > >> + bool cancelled = false; > >> + unsigned long sro_handle = regs->a1; > >> + > >> + rmi_smccc_invoke(regs); > >> + > >> + sro_handle = regs->a1; > >> + while (RMI_RETURN_STATUS(regs->a0) == RMI_INCOMPLETE) { > >> + bool can_cancel = RMI_RETURN_CAN_CANCEL(regs->a0) == RMI_OP_CAN_CANCEL; > >> + > >> + switch (RMI_RETURN_MEMREQ(regs->a0)) { > >> + case RMI_OP_MEM_REQ_NONE: > >> + rmi_op_continue(sro_handle, RMI_CONTINUE_KEEP_GOING, > >> + regs); > >> + break; > >> + default: > >> + WARN_ON_ONCE(1); > >> + if (!can_cancel) > >> + return regs->a0; > >> + /* If we have already cancelled, don't retry this */ > > > > Maybe expand that comment a little to say if we can get here under a > > valid sequence and if so are we guaranteed that cancel is complete > > given that is what caller will probably expect if it gets -ECANCELED. > > > > My reading of spec would suggest we can't hit this path for the > > calls that are not memory tranferring. Then again we can't hit the > > first cancel either so all bets are off. So maybe this is the > > bet we can do. Also can_cancel shouldn't be true after > > rmi_op_cancel() as I assume you can't cancel a cancel. > > Ack. This was to handle a buggy RMM (and soothing an LLM bot) Modern job titles: LLM Soother! I aggressively cropped previous email. For avoidance of doubt the rest all looked good to me. > > Thank you for the review. You are welcome. Thanks for pushing this forwards Jonathan > > Cheers > Suzuki > > > > >