From patchwork Mon May 27 02:41:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 246500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 174BC2C0091 for ; Mon, 27 May 2013 12:44:33 +1000 (EST) Received: from localhost ([::1]:57930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgnQF-00010c-Ay for incoming@patchwork.ozlabs.org; Sun, 26 May 2013 22:44:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgnPy-00010X-0O for qemu-devel@nongnu.org; Sun, 26 May 2013 22:44:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UgnPu-00065J-Fz for qemu-devel@nongnu.org; Sun, 26 May 2013 22:44:13 -0400 Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]:46493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgnPu-00065D-A7 for qemu-devel@nongnu.org; Sun, 26 May 2013 22:44:10 -0400 Received: by mail-pb0-f47.google.com with SMTP id rr4so6263704pbb.34 for ; Sun, 26 May 2013 19:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=fyAlwKvJC+CFaptoIGlRlIZl3lTY9hgmktKawVY1P9U=; b=oCiC3rCBqSvJiTQS6/0Ns5D8uospx0m1rKlO6OTLTMazi4Lm5VJw10rHcRtIsn0RE3 p05X5XHCm7KQKGxtKznXU7qhaHGcOUpCJOxBz7GKr17Tn2PBpmnjrwl/UGr5J4XS6+qA 9piLMcbkXuawgVZ5mqtE7+kE96P16paLfJaVSKyqkgiLJZuJ23RAVfpfge5Y/PbQ4WjY orP8C18274+p3iJF21LAD5to2T6SGysTTFxQvRcPRjncl5DwSBbLki5ZJ3AL6PL/s1BJ uSgpY6Eba/29Tur7NY5LLeg8OPi3o5GtIbBpjlRLFnezqjRMnms7Sdzc4ZDc6L6t5/j9 QidA== X-Received: by 10.68.90.197 with SMTP id by5mr27181924pbb.196.1369622648714; Sun, 26 May 2013 19:44:08 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id tq8sm26502593pbc.30.2013.05.26.19.44.05 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Sun, 26 May 2013 19:44:07 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: qemu-devel@nongnu.org Date: Mon, 27 May 2013 12:41:08 +1000 Message-Id: <3ef0a7fd1b2f3ebb23b4fdeabcc14caf3fad6d71.1369622254.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty X-Gm-Message-State: ALoCoQlRqH3cDDX9jXd/NhGas+utI+FiNTw6+N+DcCOZYk/J3gmgjuez2lJQXUbRf/4+m3QwTrOO X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::22f Cc: peter.maydell@linaro.org, i.mitsyanko@samsung.com, edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH arm-devs v3 1/1] sd/sd.c: Fix "inquiry" ACMD41 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite QEMU models two (of the three) ACMD41 has two modes, "inquiry" and "first". The selection logic for which of the two is incorrect - it compares != 0 for the entire argument value rather than only bits 23:0 as per the spec. Fix. Signed-off-by: Peter Crosthwaite --- Changed since v2: Macroified magic number Added explanatory comment (PMM review) Changed since v1: Total rewrite hw/sd/sd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2e0ef3e..a10313b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -43,6 +43,8 @@ do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0) #define DPRINTF(fmt, ...) do {} while(0) #endif +#define ACMD41_ENQUIRY_MASK 0x00ffffff + typedef enum { sd_r0 = 0, /* no response */ sd_r1, /* normal response command */ @@ -1277,9 +1279,14 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (sd->state) { case sd_idle_state: - /* We accept any voltage. 10000 V is nothing. */ - if (req.arg) + /* We accept any voltage. 10000 V is nothing. + * + * We don't model init delay so just advance straight to ready state + * unless its an enquiry ACMD41 (bits 23:0 == 0). + */ + if (req.arg & ACMD41_ENQUIRY_MASK) { sd->state = sd_ready_state; + } return sd_r3;