From patchwork Wed Apr 3 05:33: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: 233252 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 D7AC72C015C for ; Wed, 3 Apr 2013 16:34:11 +1100 (EST) Received: from localhost ([::1]:38410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNGKo-000766-2p for incoming@patchwork.ozlabs.org; Wed, 03 Apr 2013 01:34:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNGKa-00075O-0i for qemu-devel@nongnu.org; Wed, 03 Apr 2013 01:33:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UNGKZ-0006fp-3j for qemu-devel@nongnu.org; Wed, 03 Apr 2013 01:33:55 -0400 Received: from mail-da0-x232.google.com ([2607:f8b0:400e:c00::232]:61220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNGKY-0006fi-TN for qemu-devel@nongnu.org; Wed, 03 Apr 2013 01:33:55 -0400 Received: by mail-da0-f50.google.com with SMTP id t1so509432dae.9 for ; Tue, 02 Apr 2013 22:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=WjLU3kU4Y524b8GSyZ3iMwuULwcShwXCMrj23EAze3E=; b=mcUVPI27/7kMHSoNUkNEkVsEbBb1kVA+wMbJ1/C1kNeRNn/QhWbglvaU0bqPx6hjyR pT9yztUVzDO9hvnYRBKn0apttdcn8WU77l2c4StkP/FWsXEKuje+l/jFXkAgHQyzFdm0 Lq9+t3ZxCoTCMFsTVemfRYJVPLR5j3FsbXY9VxqoKOOt3wcs8R7US0yGosOLPT6FScLg XbBA71mDR3VAd32ix4aMgteOc75/FTHcaeKSmux2FahQ8B+dVV0oYJqYIP9UlihSWBOt zLoGLHGLhjdkzdihbR9NgdYKJMzbDAudj3biN/maao7LIhevb0g2Ln4LQNzQZhcVHSpf f9KA== X-Received: by 10.68.138.193 with SMTP id qs1mr545061pbb.9.1364967233865; Tue, 02 Apr 2013 22:33:53 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPS id fc8sm5339451pad.21.2013.04.02.22.33.51 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 02 Apr 2013 22:33:52 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2013 15:33:08 +1000 Message-Id: <1364967188-26711-1-git-send-email-peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQmWOwEMzhdjyzSGtrPmiElDZZ30b8QsMV2CcICJSS69/74JfqcByT90e6V7MdvaRdNd5lm5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c00::232 Cc: peter.maydell@linaro.org, Peter Crosthwaite , Wendy Liang , Wendy Liang , dantesu@faraday-tech.com, edgar.iglesias@gmail.com Subject: [Qemu-devel] [PATCH] hw/nand.c: Fix nand erase operation 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: Wendy Liang Usually, nand erase operation has only 2 or 3 address cycles. We need to mask s->addr to zero unset stale high-order bytes in the nand address before using it as the erase address. This fixes the NAND erase operation in Linux. [PC: Generalised to work for any number of address cycles rather than just 3] Signed-off-by: Wendy Liang Signed-off-by: Peter Crosthwaite --- hw/nand.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/nand.c b/hw/nand.c index de3e502..6362093 100644 --- a/hw/nand.c +++ b/hw/nand.c @@ -297,6 +297,7 @@ static void nand_command(NANDFlashState *s) break; case NAND_CMD_BLOCKERASE2: + s->addr &= (1ull << s->addrlen * 8) - 1; if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) s->addr <<= 16; else