From nobody Mon Sep 28 12:33:36 2026 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 832E14D2EE0 for ; Fri, 21 Aug 2026 15:06:26 +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=1787324788; cv=none; b=JBVXQia+ZKLb64jgK/PIQV21+m3jGMeRSveL7d78ZzKQScFPbvElEpaRKwPgsC8O/ua6XE9y2+KNKYTjXB/QPeGA3ej5p85v/nfzZDe2b/pSGxHcHoPItSjFoGcsOSOA+ykj6pNjJRqUmWBB1vgrWvtbw5PvJiJZ1r8vDG4pHdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787324788; c=relaxed/simple; bh=YCH1yylulf8EbgQrB2WZCIRrwVIgjivx9cOy+yUc6pQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oYgesSuXotK4zlkTvNv/yrPUY1thwVWulJS216Umt63k0dd8kMlFL8BnPZNkkw5tSqE2MHAjOf3uC7mXRe77yLjF9mvMfSMlGAxS97kQnexw9++yyYiB7sWhgGGAVXfRUssfNClaanmu+ts5hFNcHdaq6ugM/MbOd/sUIxxE9ZU= 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=Sdybhw0F; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NGZ+2a3U; 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="Sdybhw0F"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NGZ+2a3U" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67LCoaWQ2029284 for ; Fri, 21 Aug 2026 15:06:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=WqcCf+Dhdx6 Y50GJtvfwTO5MqJahdd7ZlfJbqzun1ro=; b=Sdybhw0FTGysGHJgAe0wLK1rFvT ZYEZNi2NjQ838nO5Ijx2og9/KhbkPqMjewzCeNGEekymYJkBgF7b4F9GBVOsG5WH zuX6dD6xAfxgDrknavd7YEDD3ACVzPMVd48uoi1pyLkNO0A0IBpP6ZGjoaffrV3K TxH/qs0TVzq29gbSkhXM3dbGvPlYr+NTaLupFySY8Taj2Fd/bcybRxd10OSkqC2/ GI/MfhzqDU9EVqxoNorp9JJFCAkolia4m9HTWyNCv+bt0RzFKPnwh2qMcxTcQFIb B6yBxN0xzJA2lQvBmZyX90n21jcgqJMX5PhqWB3W8IilwJrALlUboj0s8NA== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g6fue295q-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 21 Aug 2026 15:06:25 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-9368b4c5964so81000585a.1 for ; Fri, 21 Aug 2026 08:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787324784; x=1787929584; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WqcCf+Dhdx6Y50GJtvfwTO5MqJahdd7ZlfJbqzun1ro=; b=NGZ+2a3UTefLT9aSIFBmaqE78vqj7Te8j7sEVasZEIP1m9ZmN5hKPOwbL5VFgnexjX HG7/zJAHWvSSsNlpRrqOgPrhBcT1oThFDghNRKPtsU2Nf0fiqV4rZ78bvpubk5VREiab P4GbE+UxFmJBugxAd+WzbGKNeib5oS1+O4e+j7I0+J4CnFnWdLAFBwUoKA51AxQWHN4t 238rXRFqCD+KrJtSAc1kmngsm0XA1btHvskAucadeW9/ZB1SzVg5mrVcZy8eZxfg4nKf uMPGwomve1lEqZ24VfzHeFiS6W5Dxr6HifFi0skcaSaO5O2A4/lHaTz8hh0y5HwbsHRu TXhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787324784; x=1787929584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WqcCf+Dhdx6Y50GJtvfwTO5MqJahdd7ZlfJbqzun1ro=; b=kYiqYl6NpOQ5eAhjMu7oP3yBmKOfXtm1Ttk7aRUpGybVautS+eP+jBnWKSVt4rSuuZ Y09A9LBpB2qi7Va6SG7fYd2asjf7IwztgMWlpgdjwL/+RSRlx1am4wD7m5lXf5nIyqll 5WVEXWaC1gAanmStPo1ScM4sAfyqKKs0Mg/d0o6xZS8N8y1VpS3QZ32pyhVLp+TaaHwq CxT4ESpE4EoeHRujkgOWCPGclodIWoyGaXxtmsRF+WCmPswXXhj6hCUOSupL3uHzUdb7 tKssg7fvj5e0OIbjOH6QK7cCTtZvZkslhGEVX16mQipf/G4G9IbAMGOhSGEfVBUK62JI /elA== X-Forwarded-Encrypted: i=1; AHgh+RpA08F6uVRt8j5X3aI5lv9G1+N8+FNemKQtsNEIff7uTEhyYL/DTSgvjt5zm8fira1NKAMTuYBIfiV/U3o=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/NmF5/FZciINC4kMaWK3CC5hAz9XIrw4thwHqEQF8BHHpn0eO Z4x661rykin+VmT3Pe43dwEbDkiRloXlyAnGEiVrvNYFNI3oa2Nd4YWp+uneg8OReeJLWhOToZl BjEwb7lYfuosKG4YmOTvDFzaeyP9CS5qNfwvm80DxcFlcoVgE4qOGhQQ22nkKBdpQTo0= X-Gm-Gg: AR+sD11ckJeJ1yyhIqxJ3Jyu8azcOPqmKG9isJOt9XDQe/1eE4rSfIlz3N1HNBtLm9G ews2EyrH31bJaAV7ViEf4lJdsXglWlJMbHkivtC8urQcYQWYNOZGbEQCeGYNqgd3lsWRqBvnS/e r7IsSHYCjDr2n5yW/b6mtMN7/cAHYmj1QcVnx+EHDFXGkAmca7qtfloA5G2BwRQP00GN62pQxMP S31NqXIof0+z+wPVyhJc/Y7lEdhegunjy8TsMFc/ZaH4Ohak+liJqgTZh8AO/DausTUQiTAVPi2 CQcY8IOVSczD2kcZGUhgVeJoj0QMzgABIS/gO96l817b2r7pEjbD5ZdKULTswFtNDSuP+/BcN6Y pfghuqAzRxmaWkQU7sn0icFxWzjJlT56mExJNmonDB59JI90L2zY= X-Received: by 2002:a05:620a:6f02:b0:931:4b6:a9e6 with SMTP id af79cd13be357-937396f3282mr631548185a.47.1787324782869; Fri, 21 Aug 2026 08:06:22 -0700 (PDT) X-Received: by 2002:a05:620a:6f02:b0:931:4b6:a9e6 with SMTP id af79cd13be357-937396f3282mr631521885a.47.1787324781737; Fri, 21 Aug 2026 08:06:21 -0700 (PDT) Received: from trex (137.red-79-144-199.dynamicip.rima-tde.net. [79.144.199.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14b8050sm17960936f8f.19.2026.08.21.08.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 08:06:20 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez@oss.qualcomm.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, beanhuo@micron.com, beanhuo@iokpp.de, can.guo@oss.qualcomm.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, jenswi@kernel.org, sumit.garg@oss.qualcomm.com Subject: [PATCH v3 1/2] ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN Date: Fri, 21 Aug 2026 17:06:07 +0200 Message-ID: <20260821150612.3944782-2-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260821150612.3944782-1-jorge.ramirez@oss.qualcomm.com> References: <20260821150612.3944782-1-jorge.ramirez@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDExNyBTYWx0ZWRfX6rCfQGbTzd8t QCN7Ah/lfEAHCYjdLzlyXcQcHBUQzMlZG+6sBlgw1gV8a5vhmtA2aGIrvqUJOwdynocZDFy1RjD XBY54lNMttMb9g6OpLbexQ6a6E6vqu0= X-Authority-Analysis: v=2.4 cv=U9+iy+ru c=1 sm=1 tr=0 ts=6a886971 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=qBhfTSQT0jQfJ5OHMlDVQg==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=w0io_FmA1e-6CLxyNa8A:9 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-GUID: PehfG3FvobBbX_Y89TA0lOF70xPHSxUs X-Proofpoint-ORIG-GUID: PehfG3FvobBbX_Y89TA0lOF70xPHSxUs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDExNyBTYWx0ZWRfXwDfTkjgUCkEd pXylauGxkYftbUnYuVys6i0xxCcw/v/eBqvz03xwJyh6Mc6tmuoPyFEZdWU5U+NPCXY6Vn5AK/T SP2OdrsSzqM1ssp5bKpqsZSDkPFyjvDlaSI8rXJY7MEk0NE1U1dBFG62rU4XySjjwICEUvw+1u4 8i0KmaiE/oXxIGjzEdS19GZme7JKa7PBy+jaExnw9/1XlR5k4nI39IRwd5GnkdaZnSGJVgkt1X0 y0OT+qv8+b+SsWv53wr4x0AKvxrDLI9rXjUVvXA1EhP8qCPbf7cTgHimZnwQxilAilnApHIvoD4 V+DjHP4dOIHN5emo3axJuhBf2uWSwwN20HZmvu/95tvkYvi2L0OYUInQXDvedV9sdRXInOkm2Yd EyA1fZkKcDo8/O126Ke26hc4BwQ5HrO49gApFqDIKU9WHoZjXgU/dJkCAkVYUlH+Og5HJFybLLC fjWyXvmNw2oiXeLTw4w== 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-08-21_04,2026-08-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210117 Content-Type: text/plain; charset="utf-8" After a power cycle, the first command sent to a UFS logical unit completes with CHECK CONDITION and a power-on UNIT ATTENTION (ASC 0x29). The SCSI core reports this to the caller instead of retrying it. For the RPMB well-known LU, that first command is the first RPMB frame sent after boot, so the frame fails. RPMB has no earlier, guaranteed access that could clear the condition beforehand, so this breaks RPMB on every cold boot. Ask the SCSI core to retry the power-on UNIT ATTENTION on the RPMB WLUN so that RPMB works from the very first access after a power cycle. Signed-off-by: Jorge Ramirez-Ortiz --- drivers/ufs/core/ufs-rpmb.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufs-rpmb.c b/drivers/ufs/core/ufs-rpmb.c index ffad049872b9..d0c7ea7a36f4 100644 --- a/drivers/ufs/core/ufs-rpmb.c +++ b/drivers/ufs/core/ufs-rpmb.c @@ -40,6 +40,23 @@ struct ufs_rpmb_dev { static int ufs_sec_submit(struct ufs_hba *hba, u16 spsp, void *buffer, siz= e_t len, bool send) { struct scsi_device *sdev =3D hba->ufs_rpmb_wlun; + /* Retry the power-on UNIT ATTENTION (ASC 0x29); the SCSI core does not. = */ + struct scsi_failure failure_defs[] =3D { + { + .sense =3D UNIT_ATTENTION, + .asc =3D 0x29, + .ascq =3D SCMD_FAILURE_ASCQ_ANY, + .allowed =3D 3, + .result =3D SAM_STAT_CHECK_CONDITION, + }, + {} + }; + struct scsi_failures failures =3D { + .failure_definitions =3D failure_defs, + }; + const struct scsi_exec_args exec_args =3D { + .failures =3D &failures, + }; u8 cdb[12] =3D { }; =20 cdb[0] =3D send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN; @@ -48,7 +65,8 @@ static int ufs_sec_submit(struct ufs_hba *hba, u16 spsp, = void *buffer, size_t le put_unaligned_be32(len, &cdb[6]); =20 return scsi_execute_cmd(sdev, cdb, send ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, - buffer, len, /*timeout=3D*/30 * HZ, 0, NULL); + buffer, len, /*timeout=3D*/30 * HZ, /*retries=3D*/0, + &exec_args); } =20 /* UFS RPMB route frames implementation */ --=20 2.54.0 From nobody Mon Sep 28 12:33:36 2026 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 8A0544CA282 for ; Fri, 21 Aug 2026 15:06:27 +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=1787324789; cv=none; b=g0LBpBGThvAgOXDxH8xv+mUURQVJspP/O0M/QtRYFBsqhQ3D+SwFK8JEYlucG26Kd6hxWRyWgfyx7dJxHk184ycI02B27twgwS220Aq+4i+KFpM0NDDok8H+S9OnJmndqAZlB8z+ZHXPG/x5V8jh4IG9D/JXpb+8GGmtCffK7/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787324789; c=relaxed/simple; bh=sD00N96MX+cXHCKZfKm2MT7C5Z/K0H47C57CyGtLjlw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+/zF9KamWQLq+5trgFoSQ4bczONnn+6O6AE31B+zncAZDqniXG8Sy0BYAmAfKeW/tU077jQNcRrCEE/0TSJr1gMCwYtVVLQUES17yFCD5e61PX8YLsOQGXQxZ1EYFHRKUsXCkZkRzvhl7ANVBFowIWyXZxhHTlpQ2y10CIIwSU= 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=CIrC1CMc; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=e6WdVkU/; 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="CIrC1CMc"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="e6WdVkU/" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67LCoXpX2466879 for ; Fri, 21 Aug 2026 15:06:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=qlvi7ccrXBz fPu4z9BFos2jADP8tokNi9C60HKQzio4=; b=CIrC1CMc3jeaHUd9t/G3DfGylmr tahsY9iebdfKUBsDE+3VJy+xcZUg1MCnh6mLgWyI/JW0YuYTFvDVEveIRpzvzvjF 2UxDoTCVF7iUOGmBC1QioqeJXe7C1/M1tZP7Tplknq0WvgPfmRRGIicIr/4XzEG7 wDDDr7cs0Ux8SxbmTeKbOeZjRfX3I0Rj6AO/KmHq0giic0JK+HWm+QxM6D6eZWCt gPG2z3UcwA7iBxzHjPKqyx6NdSxLEwdW0iPksC36svZkWqdqlZQ0c9waZRfslHOM B/eyjssyTgE38GTRzfpm6/PQI3756alBquWGjV+RyoVNX6cKT+sOkFx794Q== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g6gddj6gs-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 21 Aug 2026 15:06:26 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-51c1d137a68so20970511cf.3 for ; Fri, 21 Aug 2026 08:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787324786; x=1787929586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qlvi7ccrXBzfPu4z9BFos2jADP8tokNi9C60HKQzio4=; b=e6WdVkU/vwxKc2ySQHfMihFkZFpTZCwpR13tGw/GlKNIH/elXQBemNvbO+BjwM0Ped Nqx+ov4/WlL5zCm2QK+F9PXofW6d11wFOMIsUmD1uV6hqdEqTgwW77vrrvffOX3HMCwM fDKrtS4asXMFkZLw7zW7pwyOqEyqWsb10IpXNsumSPEVXbYIlWYr4Aklr96+EKQudKVZ LMpOE7K3IuQegsWfsG2pkgDuWO896TjFqcXq8m2ePXVueRMsNQK3zGSRzICkMoIVpMdB q3sQdOF4gU+V+4qsvZ8lPVXl1ynD5+ig1qWN2MZ3z1MXrKuodn5CuipCXaLzS3vJe3F9 8PbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787324786; x=1787929586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qlvi7ccrXBzfPu4z9BFos2jADP8tokNi9C60HKQzio4=; b=SUQ5kRWdvv/SQVT6a01Y9Icl+rnJe3aNuZJxPCkaEaTHaL3hdll+s40qfw2KOg+F2i VlHmRxTzZgRtiDGgB0g8uTRcD8NCho0HoncCSKYQ7NW1F7d3ZUwq1m7UtmcJ3qfynZAw z10A45YB9m678bmYpbmMg8+gfeaZYEqfXdtKm3vEGFeVb6mJgXBE1mUiZ8XpQM+gwXI8 1S4qYHdt7B3hyQwBASA4W9Wk+FPvCQBw68tq0kvQUk1aJ/ZE8d7Tlggb1cNCaAG+a32l 65tiACXAJLv5YKmLhWojGFDh9r5DJVz2JEAC73Onf9Id0aRdmQ8Rf65hwfz7PCrACbEe XR8Q== X-Forwarded-Encrypted: i=1; AHgh+Rr2fgDc/8L7cPm2bCd4MvYcpTmdTpofxd/G1+U8HRpgQiaXQq/AaKaSlWpClrCujMVt1zTYgLt3vO5cSaM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4Jku2yifFgTz7Oj4PsvGT1tZMSkodrqq3malfCvOBHWhnO+bh hgk/7A2MxqOOthMgcRpMtQZs+TxUZ/kIA5onDvUqSIVG8zbgW1PthQkOVq2y/ZGREsO/mjuiuxT 4tyoev+3CLcpNQ5diWTbSVS0oQmEAN4VFNhLMY1rJ2K9YudJb2D2iZ0ZLMrf2aN4JJgM= X-Gm-Gg: AR+sD11+S6Z1VgRpJgsoRN9he5ri5s7vtIkXoYnr++K8EN9tjlplSQxOFI6+I7r9VS0 uw2MdpwxGsRWbclamBWh8dVfwFylwQaHWOu+Or1x/0Mq0EbYJo+tUgss2rObP9GcyrG7X558pns TQ60KLrbG9V0wu0u7IixfUwwz8Hk+xYvFKrFtP3nJgSZendBAS6pRGX3rNNiJNQWRzxUZZOcXdC 8MPuWFKJU4F5tMTge+X+mqO2s2FHqUfTIgb4+TINuydeUyE5cbLR2F964V8KdHjJpeyP5bnYNu9 Em8mQy4xijfHJ18XGNhZnh33sGB21KlZumrzaQT/cDmzelycfegSZ7Rli2ARJqObgzQdPJ5BIF2 lUhkcKhM639Faet3uBbpCnugiyU+QZ84cOMBCmN9BqrluiaY0epQ= X-Received: by 2002:ac8:5a0a:0:b0:52d:8679:ba91 with SMTP id d75a77b69052e-52df5665d69mr63016011cf.8.1787324785604; Fri, 21 Aug 2026 08:06:25 -0700 (PDT) X-Received: by 2002:ac8:5a0a:0:b0:52d:8679:ba91 with SMTP id d75a77b69052e-52df5665d69mr63015081cf.8.1787324785078; Fri, 21 Aug 2026 08:06:25 -0700 (PDT) Received: from trex (137.red-79-144-199.dynamicip.rima-tde.net. [79.144.199.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482b14b8050sm17960936f8f.19.2026.08.21.08.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 08:06:22 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez@oss.qualcomm.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, beanhuo@micron.com, beanhuo@iokpp.de, can.guo@oss.qualcomm.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, jenswi@kernel.org, sumit.garg@oss.qualcomm.com Subject: [PATCH v3 2/2] ufs: rpmb: use a fixed-length RPMB dev_id Date: Fri, 21 Aug 2026 17:06:08 +0200 Message-ID: <20260821150612.3944782-3-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260821150612.3944782-1-jorge.ramirez@oss.qualcomm.com> References: <20260821150612.3944782-1-jorge.ramirez@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDExNyBTYWx0ZWRfX5jbh0R1swR7z iZKaidRb+Y4dv3nVa6tZ2Bx6TiUcTSGFNKKpgrsUXDA8XlCa4+hQxW3LF9GJj4eFb+S//9/Ijgr Ky4vT0l0A/cvgeRbdORbW2c5gHCWrd0= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDExNyBTYWx0ZWRfX/yyZYhgYS6Pd 4tNPj4OtIsFfZzzW5wcdfanXaprBVQjRKkppi+UMUSs6753BaznMIeYbcPo9GvUbsTOKRShzA6o 6Z8/e/7mubB6UaOTjswJDUGcISqjo/v6l9gnTSS1AQDoFKClLWvWd0A+7m24BfaDDmLBJNO+KRj 1sulXMQW6zBa+vN2A2IQbAs75EnV0km9xhQTQ//nI3hel/YzAE0pAIYO5a3fZcGrMOgnLsIU3ao ak1PSyLpo5uanVi0F3OzYynwSiIaltKVzmLDoPOR22W9B5k4CwfdXSCh1cuomFAwmr//CR+Bn7I 1R8DYGWRcHYlY7XJfZ376KJ+K0DLrT2d+koVfXik/6Henx2b08C9W87egZDk4X+FfXNIV/BD7M8 AJzk4+7/tfqQD3UhUe4cUS0dfSy8Hp1wyDu+6ZPRiBklAgzg6y0GahAzvfMaTyYyqlijGhHUqNl ixGWQZ1NENZG7jwFeqw== X-Authority-Analysis: v=2.4 cv=ApHeGu9P c=1 sm=1 tr=0 ts=6a886972 cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=qBhfTSQT0jQfJ5OHMlDVQg==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=OSdCpuDsIsRB4DqEP3sA:9 a=a_PwQJl-kcHnX1M80qC6:22 X-Proofpoint-GUID: t14brWVYtb3AzQX-QYr3DVGlyBSk8dtf X-Proofpoint-ORIG-GUID: t14brWVYtb3AzQX-QYr3DVGlyBSk8dtf 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-08-21_04,2026-08-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210117 Content-Type: text/plain; charset="utf-8" The RPMB authentication key is derived from the dev_id handed to the RPMB subsystem. OP-TEE implements the eMMC RPMB flow, where the dev_id is the eMMC CID, a fixed 16-byte value, and it derives the key on that assumption. The UFS RPMB id built here is "-R", which is variable length and longer than 16 bytes. Passing it verbatim would tie the derived key to a length OP-TEE does not expect and diverge from the fixed-CID eMMC ABI, requiring OP-TEE to be taught about variable-length UFS ids. Hash the UFS id into a fixed 16-byte dev_id with blake2b instead. This keeps the derived key stable and unique per region while matching the eMMC CID layout OP-TEE relies on, so the key-derivation ABI stays identical and no OP-TEE change is needed. blake2b is used because it is already available in bootloaders such as U-Boot that must derive the same dev_id, avoiding the need to add a blake2s implementation there. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Bean Huo --- drivers/ufs/Kconfig | 1 + drivers/ufs/core/ufs-rpmb.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig index f662e7ce71f1..b62c00e7ff06 100644 --- a/drivers/ufs/Kconfig +++ b/drivers/ufs/Kconfig @@ -7,6 +7,7 @@ menuconfig SCSI_UFSHCD tristate "Universal Flash Storage Controller" depends on SCSI && SCSI_DMA depends on RPMB || !RPMB + select CRYPTO_LIB_BLAKE2B if RPMB select PM_DEVFREQ select DEVFREQ_GOV_SIMPLE_ONDEMAND select NLS diff --git a/drivers/ufs/core/ufs-rpmb.c b/drivers/ufs/core/ufs-rpmb.c index d0c7ea7a36f4..a1e169ad3096 100644 --- a/drivers/ufs/core/ufs-rpmb.c +++ b/drivers/ufs/core/ufs-rpmb.c @@ -10,6 +10,7 @@ * Can Guo */ =20 +#include #include #include #include @@ -21,6 +22,7 @@ #include #include "ufshcd-priv.h" =20 +#define UFS_RPMB_ID_LEN 16 /* Match eMMC CID Length */ #define UFS_RPMB_SEC_PROTOCOL 0xEC /* JEDEC UFS application */ #define UFS_RPMB_SEC_PROTOCOL_ID 0x01 /* JEDEC UFS RPMB protocol ID, CDB b= yte3 */ =20 @@ -153,6 +155,7 @@ static void ufs_rpmb_device_release(struct device *dev) int ufs_rpmb_probe(struct ufs_hba *hba) { struct ufs_rpmb_dev *ufs_rpmb, *it, *tmp; + u8 dev_id[UFS_RPMB_ID_LEN]; struct rpmb_dev *rdev; char *cid =3D NULL; int region; @@ -213,8 +216,10 @@ int ufs_rpmb_probe(struct ufs_hba *hba) goto err_out; } =20 - descr.dev_id =3D cid; - descr.dev_id_len =3D strlen(cid); + blake2b(NULL, 0, cid, strlen(cid), dev_id, UFS_RPMB_ID_LEN); + + descr.dev_id =3D dev_id; + descr.dev_id_len =3D UFS_RPMB_ID_LEN; descr.capacity =3D cap; =20 /* Register RPMB device */ --=20 2.54.0