From patchwork Fri Jun 5 17:42:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cooper X-Patchwork-Id: 6557141 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D5FB3C0020 for ; Fri, 5 Jun 2015 18:01:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2998204D8 for ; Fri, 5 Jun 2015 18:01:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E51C206D0 for ; Fri, 5 Jun 2015 18:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754841AbbFESB3 (ORCPT ); Fri, 5 Jun 2015 14:01:29 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:37070 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754837AbbFESBZ (ORCPT ); Fri, 5 Jun 2015 14:01:25 -0400 X-IronPort-AV: E=Sophos;i="5.13,560,1427785200"; d="scan'208";a="66844848" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw1-out.broadcom.com with ESMTP; 05 Jun 2015 11:48:22 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 5 Jun 2015 11:01:21 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.235.1; Fri, 5 Jun 2015 11:01:21 -0700 Received: from stbsrv-and-3.and.broadcom.com (unknown [10.28.16.21]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 2C40642F84; Fri, 5 Jun 2015 10:41:42 -0700 (PDT) From: Al Cooper To: , , CC: Abbas Raza , Al Cooper , "Chris Ball" Subject: [PATCH V3 8/8] According to SD Physical Layer Specifications: Locked cards respond to (and execute) all commands in the "basic" command class (class 0), ACMD41, CMD16 and "lock card" command class. Thus, the host is allowed to reset, initialize, select, query for status, etc., but not to access data on the card. Date: Fri, 5 Jun 2015 13:42:27 -0400 Message-ID: <1433526147-25941-9-git-send-email-alcooperx@gmail.com> X-Mailer: git-send-email 1.8.4.474.g128a96c In-Reply-To: <1433526147-25941-1-git-send-email-alcooperx@gmail.com> References: <1433526147-25941-1-git-send-email-alcooperx@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Abbas Raza But when a locked card is inserted into system having no key added for this card, following errors are observed until the card is removed [ 36.955193] mmc0: card is locked. [ 36.959746] mmc (null): Error, request_key -2 [ 36.964622] mmc0: Cannot find matching key [ 36.968765] mmc0: Card unlock failed. [ 36.972717] mmc0: new SDHC card at address 0002 [ 36.977747] mmcblk0: mmc0:0002 00000 7.41 GiB [ 36.989596] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 36.999630] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.009604] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.019574] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.029548] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.039514] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.046729] end_request: I/O error, dev mmcblk0, sector 15556480 [ 37.052813] Buffer I/O error on device mmcblk0, logical block 1944560 [ 37.062139] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.072106] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 37.082072] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 ............. [ 46.249273] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 46.259247] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 46.269215] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 46.279183] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 [ 46.289151] mmcblk0: timed out sending r/w cmd command, card status 0x2400900 As a workaround, skip all the regular block io operations if the card is locked. One can unlock the card after system boot by following below steps 1) Add key for this card. 2) Unlock the card using sysfs attribute 'unlock_retry' for this card. Cc: Al Cooper Cc: Chris Ball Signed-off-by: Abbas Raza --- drivers/mmc/card/block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 5650748..79c8861 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2026,6 +2026,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) /* claim host only for the first request */ mmc_get_card(card); + if (mmc_card_locked(card)) { + if (req) + blk_end_request_all(req, 0); + ret = 0; + goto out; + } + ret = mmc_blk_part_switch(card, md); if (ret) { if (req) {