From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from speedy.danman.eu (speedy.danman.eu [46.227.180.235]) (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 C78351E4B3 for ; Thu, 23 May 2024 12:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.227.180.235 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467871; cv=none; b=b4VRCrBfbQw6WrumO/IE4OubRloOZ55gEJoB45+6KlK7CCevX9cH8cDUl9BkSobD/OKU/vcOVSUKykkVARjitp0wsK0ZPZ7xSZ5l4mwUerGcVpifFR6m1xOUUIyXXlcKqsVQMIDkckAglgWWt3maJJjomA7k78MrIhX+bRLONzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467871; c=relaxed/simple; bh=abyUgbir/aWMI7xhQmYY3hJV1MiYdn7JrderiNRcaT0=; h=MIME-Version:Date:From:To:Subject:In-Reply-To:References: Message-ID:Content-Type; b=erofoUdVZ7MAD6d6nnllVw97oKmYPrC/7obKSE2U5v27CyomIc6SQcqtl+cR48ZMnQopEjAjyCYj9XOTLespLyzn+YQwwRnzywn+MVDAxzPRf0FFzt8VdireIflc1/8J3LhBM2C48UF5j5qc9veOqoxurc8HuJu5gCSqowbYkSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=danman.eu; spf=pass smtp.mailfrom=danman.eu; arc=none smtp.client-ip=46.227.180.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=danman.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=danman.eu Received: from mail.danman.eu (localhost [IPv6:::1]) by speedy.danman.eu (Postfix) with ESMTPA id 4C42A24019B; Thu, 23 May 2024 14:37:43 +0200 (CEST) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 23 May 2024 14:37:43 +0200 From: Daniel Kucera To: linux-mmc@vger.kernel.org, ulf.hansson@linaro.org Subject: Re: [PATCH v2] mmc: core: allow detection of locked cards In-Reply-To: <20240523111317.594583-1-linux-mmc@danman.eu> References: <20240523111317.594583-1-linux-mmc@danman.eu> User-Agent: Roundcube Webmail/1.5.0 Message-ID: <333b38e44daa8d6d8e3e173eb754d86e@danman.eu> X-Sender: linux-mmc@danman.eu Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit On 2024-05-23 13:13, linux-mmc@danman.eu wrote: > From: Daniel Kucera > > Locked card will not reply to SEND_SCR or SD_STATUS commands > so it was failing to initialize previously. When skipped, > the card will get initialized and CMD42 can be sent using > ioctl to unlock the card or remove password protection. > Until unlocked, all read/write calls will timeout. > > Signed-off-by: Daniel Kucera > --- > drivers/mmc/core/sd.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c > index 1c8148cdd..0eebfea02 100644 > --- a/drivers/mmc/core/sd.c > +++ b/drivers/mmc/core/sd.c > @@ -928,8 +928,20 @@ int mmc_sd_setup_card(struct mmc_host *host, > struct mmc_card *card, > bool reinit) > { > int err; > + u32 card_status; > > - if (!reinit) { > + err = mmc_send_status(card, &card_status); > + if (err){ > + pr_err("%s: unable to get card status\n", > + mmc_hostname(host)); > + return err; > + } > + > + if (card_status & R1_CARD_IS_LOCKED){ > + pr_warn("%s: card is locked\n", mmc_hostname(host)); > + } > + > + if (!reinit && !(card_status & R1_CARD_IS_LOCKED)) { > /* > * Fetch SCR from card. > */ Please forget this one, it doesn't work.