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 AA93C2E738F for ; Thu, 16 Jul 2026 08:37: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=1784191061; cv=none; b=RGENuP/BMhpzBYoeXuZ0Czphnyf58bES/Dr2rnWfGSl8nuT7FxLR7IMpA+zEx4ki/V9B+wPso5gIjhp2ZA0ZuPQGXDGRdMTsmJvklDNJnW8DLQqNY8l2hPX5PgfZyR5kuLme8OsLyTiioP8joGUiW1kVMd8ddwqbns1daV/WehM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784191061; c=relaxed/simple; bh=YCH1yylulf8EbgQrB2WZCIRrwVIgjivx9cOy+yUc6pQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SyiRVffpb3Eb+dsZFiuSu7+8VQp+woGOHfV0QCXXMOBbRCKA4j3KOcu06KEqypHge+5wyymDO5vbQ+5Qv3LEncI2p8n8h4OEniANNiH9m62OVNBc0BznVzHcZdBXXrLLGpaKIZ3+5vbcYwGDbN2HWoHTIFhMMnIHwHQTDUM5k9U= 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=mFs3axel; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Kq93ubgo; 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="mFs3axel"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Kq93ubgo" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66G8375u2123300 for ; Thu, 16 Jul 2026 08:37:38 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=mFs3axelzO9r0n365nnN37XvtQq N78hfiyC8tHfroaPs6sX9bJqLCJwPThrLHpLrKBKParEuiaFs/DS22cj9eF+WaQx xWxynwBdAkt5+Dv/Legd2vWpO1EcGYyGbmwIrmAMrAubpGqGvCtFmO1ESzpntW99 BY6sKDiKlVLO6lD7XGZK+0RcAL2mpV+cBecAyLT7zgkt+909Kvk4l7b/bhuipKxF l/TGwlViEEZIbet7MSJr5JA3AfQHAt/fajqFb+dn+gNR/md2nO3gIcyznuhQjllS uldc9/6Yzp/6ZewQmP23MjqcEK3y+QTCzbqULjcRF1tUCnUTRkpR/oiazGA== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4feuex0430-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 16 Jul 2026 08:37:38 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-51c1a9764f0so77414081cf.1 for ; Thu, 16 Jul 2026 01:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784191058; x=1784795858; 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=Kq93ubgoMCh4JurFN0/av80+Dusndxo7C5Tikw5lNDZJcW5QqVVhTc7FKB2Nox4US+ kjTprqlTqlxv+DwV9EwnosLByG7ga8NNK1ukrBmnIhZAvZPMeyaT7HStHEAob+10GIrA Eis5setqx5w0I404ucGPX/xhNA/DMyHJr/FCOq7jxGGfHKCglUsJmJzDW498nBUrsY0C hV6VG3Fe486AWeRwUJdhE01zQMhHOB7DlRdhViwslK3e4Min43qnyeQ9H4mw+qyi2yky f5X0xv7rof+30syhD33SSCgjSVsavOGEgRfdxfiLYt6S3p2tioxNRSHX30mQdRcBY6Fv pi7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784191058; x=1784795858; 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=tXeXlKtEmgyuqEsXPKsSDABk6yhFospZGBbnXw/F/lg1KmdLesTeJAdxzysj9uXM+9 9jhTl2Ta7YJS4kXjpxYnMGw1xSYUjjlMSDtPuQYPV8z7h4B02BTvScRQFyXPe5p55fl8 otYlS6U44uKtQq7JcRC1pWg07gHe1d+p8VlQbkrDS430VzRggx+HnXE02Qpw2Vt3h60Y cBENUuy5dLxVFlayz8F8a36DLTyrAWCd9VruzuRMdh8Luw9nDB6LguDqbfP5UICjZBou C35xYWg0Umm9pWsfayK8kstn61k8SVzTur+4SpTxEeorADAwurkwtNEHfC27kdtCQ+fE kiYw== X-Forwarded-Encrypted: i=1; AHgh+Rpn1MOkNbswPl1i4shUfoIYh9pJllXIaArDB/5PCsFFmgQE1OvVNwezEqlAvkuClHNCXziNeWmbbo247K4=@vger.kernel.org X-Gm-Message-State: AOJu0YxrrPW+5nvnjdw3urglsWXYTX/S9HRY2rE/oyk1RhY8GL3r6ECt nLdL8ebCY0/5TIO7q2md2PgzfOkPCTpxMMDyctHIB7rfyQ1s8DmCCtfvJmrv0US0I6LA8XtU/pM 25TNUeCz/xUz8vL7HgVQPcYz4BVxvdRNxONkgRKYiDgq0/3OW37mATi07zplJwixT4GI= X-Gm-Gg: AfdE7ckSnrNNBMrhBZ7EEfKGsGANEPBIBROzLYVTEHg1YPJNOQ/DSV0i5OryxwNc28q W/3dhvLMNVeX1vn+ONK7p1EAjbccPQT0ViFDbY7crgfd/A34aYMKsk9m52zKUa6HHtYaTxbk0Zv uxeQlSg4ZuZ8RxZOPJBfOdugvYEqU9n+Dce3eIS8pvUJcYTe7Y9m8uVwQn479tFfJFaGd/7zg1n egqyBmxt11nMMZwbxD6BxyMUAtZDrg6qXEwmFdeS/HymbKchPsFfARNyRmETNkVbeVuyuvQK0+x 5CQXZ6Z+GRJFLZM4RrQ4da+AP+pi9IzH/HbQjEOul4g2YBg02OpbYByNsxiVQFh51iWRyjMmb20 diWShY3gr+63JyeDRUiLANZNCvcgsee92JI407LF3epFg38Dbzq4= X-Received: by 2002:a05:622a:994:b0:51a:89db:95a4 with SMTP id d75a77b69052e-51cbf177b90mr203948641cf.6.1784191057908; Thu, 16 Jul 2026 01:37:37 -0700 (PDT) X-Received: by 2002:a05:622a:994:b0:51a:89db:95a4 with SMTP id d75a77b69052e-51cbf177b90mr203948441cf.6.1784191057426; Thu, 16 Jul 2026 01:37:37 -0700 (PDT) Received: from trex (182.red-79-144-196.dynamicip.rima-tde.net. [79.144.196.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49541e94e7asm43614295e9.12.2026.07.16.01.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 01:37:36 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez@oss.qualcomm.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, beanhuo@micron.com, 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 v1 1/2] ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN Date: Thu, 16 Jul 2026 10:37:19 +0200 Message-ID: <20260716083728.2226422-2-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260716083728.2226422-1-jorge.ramirez@oss.qualcomm.com> References: <20260716083728.2226422-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: 8bit X-Authority-Analysis: v=2.4 cv=JeeMa0KV c=1 sm=1 tr=0 ts=6a589852 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=2lELrtOEK2EaG96G7mOeag==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=w0io_FmA1e-6CLxyNa8A:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-ORIG-GUID: 5YkMkMsvvccXyGx5vhzlKSevL8NwJCYW X-Proofpoint-GUID: 5YkMkMsvvccXyGx5vhzlKSevL8NwJCYW X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfXx6fE0cQsKsXi jSXr0L86F8tZMAX+TH6/Hb5O6lAVf6+P1kuTgDn/EkH39y5WgLU9u1MDbjtxYLxoOOY29BYL+6t g8cz2TvwVeoD3Kryf+Z9eBxipHXIx5E= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfX9H+uSX8ey8aM BdSBPY3Vci/heKAXPT+Sj/ecXWLXmSataLXKx5hzXB8gDcKE2pfK9+6d5SradW5O3OuFuBAgXWP heVNOw+ENwkIMndAijCZZxnpt3pCqMFicFF9Rhjx3FpI3dreqeqC8UVGdpbXvYj5YdtR0g5v7HM h80zVxzB//MFdHu7IS7FNetNYAQCKfpbcUx85EClL6R06DKpJMmVEzOnIL3/yK+Wfw41C0IzaFO 66vBegH1jm5Qz9hghjGudDR2tDAuyOol6ys1w0hXIEodPtgcMF1apX96BBOqOZ0gpihqYWOy6EB JRTDaLJ2I+aiYqbLIi+9tUE2PSe43ghkbpNhdG09f18uesPzMYAPqGbyxkHYN3q22lnIh3B0N5K b0Q7jT8rUpnBwXKxBCG+wkaM+N9HpkbdMisjirmNoRcrZaJmhJPOjThJDG8SJC54LDB6f3/W6Mc GVGxjdIs3XQsffZP8yQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-16_03,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607160087 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, size_t len, bool send) { struct scsi_device *sdev = hba->ufs_rpmb_wlun; + /* Retry the power-on UNIT ATTENTION (ASC 0x29); the SCSI core does not. */ + struct scsi_failure failure_defs[] = { + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = 3, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; + struct scsi_failures failures = { + .failure_definitions = failure_defs, + }; + const struct scsi_exec_args exec_args = { + .failures = &failures, + }; u8 cdb[12] = { }; cdb[0] = 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]); return scsi_execute_cmd(sdev, cdb, send ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, - buffer, len, /*timeout=*/30 * HZ, 0, NULL); + buffer, len, /*timeout=*/30 * HZ, /*retries=*/0, + &exec_args); } /* UFS RPMB route frames implementation */ -- 2.54.0