Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3548122yba; Tue, 23 Apr 2019 05:52:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeKwjdy4rJf1kbOKd95nV2OY+wOjg0t1vaabe7OnjcnWciQa+mYsQ/Y/vSIe/WSWUY/c6E X-Received: by 2002:a17:902:e4:: with SMTP id a91mr25522496pla.2.1556023934731; Tue, 23 Apr 2019 05:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556023934; cv=none; d=google.com; s=arc-20160816; b=Ftkrz+eivvRAVmBT6rg6eqh1oFq465AWSrDIla2EOWSkbzfxr/b/MT2c6EixGGwi3s vgxHbY6+VY/Yf26pPFXjiueHRQllvWBpCk6WZnNk2kkZ7qwQ2QRpmRxg7mMyr+E2Wdtk TMHU0jOJ+T6k29V8KFDfq870gNm5c/p+OfCQ01u3I7AItfC8i54sH34GRHbkP7irax+r yZ2n0yffICP6WSZ1nopKZP4NzqRz+MRps8LlLrOmXBZ5/nPajE46EDXTqKdbiJkXfTFS 2LeY9qtVGz59EaOobLUaoukFiePSlR3sFEPlftoFIUi8BlxqfxR8FLvqtn1oa8wRKHc7 ft6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dmGN8x9EEcfKPEOD8dWs64ViH0Y1wnNH0XCNWju842c=; b=CGS6t+Ksyl5R3lf4F4Vv8H+dzOS13LGhzQagFPi1uh0AYjWR3qp1ZlGemWCqMK61z5 Uc/xiiNQyldBHmHiEDcdVPaoYwyY0midPVkIMI52yb5j1wieX/m0T8H6dhpi3sUP6FjO Q+AiSqW66cYWRFDAwlKKmEhd2OEih64pvzvkHBM2Q/VsOjAbur8aMJ5B3T/ldEE+AK9s pr6itY/1NYNNCEGzvtUg/hG/J7IAkLQD32c06BsiQ5kmwz7dX+ce7qBtxuNDsdUjLLko i2USN8ml29dKthdVP9Kk5WfKCL3WRtNGiX5wptziILPKOW3tQojqdgpvV/zV+H5any9s 8r6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intenta.de header.s=dkim1 header.b="H/DWDGIF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intenta.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si15551934plv.329.2019.04.23.05.51.59; Tue, 23 Apr 2019 05:52:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intenta.de header.s=dkim1 header.b="H/DWDGIF"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intenta.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbfDWMvC (ORCPT + 99 others); Tue, 23 Apr 2019 08:51:02 -0400 Received: from mail.intenta.de ([178.249.25.132]:32912 "EHLO mail.intenta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfDWMvC (ORCPT ); Tue, 23 Apr 2019 08:51:02 -0400 X-Greylist: delayed 319 seconds by postgrey-1.27 at vger.kernel.org; Tue, 23 Apr 2019 08:51:01 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=intenta.de; s=dkim1; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:CC:To:From:Date; bh=dmGN8x9EEcfKPEOD8dWs64ViH0Y1wnNH0XCNWju842c=; b=H/DWDGIFbxgYzNB8uPjtE00wvSIZ4WUF8DgHHfAWTfEBBb3btOAonlu3bqq7TH5qiM8clJOJwmPfDVazzqyxjOZmEwiA1yU3w8A4wzICCOXJVTFgl9aA3kj0A6edYabTSsdjhbhUWcUj+mlHZbSNxbBuG4POthHRt2Rz7UApApSr0V6k6JZMeeXToMfKLOC39/jVbAl52ijbTLYZA6sW/0BXwMmG41s8+ovemwU5g7TQ+OeP/D0XF68wLGSZx63PbEn3q9kjR9ZpzbkZuj7ZCqiipjYuWHf6ClQ8JHYeJW3q7DWVp8sutXefOx/i7RL46KDxd+rnkGv8cMTFx9gQyQ==; X-CTCH-RefID: str=0001.0A0C020B.5CBF08E8.0043,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 Date: Tue, 23 Apr 2019 14:45:27 +0200 From: Helmut Grohne To: Naga Sureshkumar Relli CC: , , , , , , , , , Subject: Re: [LINUX PATCH v14] mtd: rawnand: pl353: Add basic driver for arm pl353 smc nand interface Message-ID: <20190423124525.axaprwy4qofbqfhj@laureti-dev> References: <1555326613-26739-1-git-send-email-naga.sureshkumar.relli@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1555326613-26739-1-git-send-email-naga.sureshkumar.relli@xilinx.com> User-Agent: NeoMutt/20170113 (1.7.2) X-ClientProxiedBy: ICSMA002.intenta.de (10.10.16.48) To ICSMA002.intenta.de (10.10.16.48) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org WARNING: This driver might brick the hardware. See below. Hi Naga, On Mon, Apr 15, 2019 at 04:40:13PM +0530, Naga Sureshkumar Relli wrote: > Changes in v14: > - Removed legacy hooks as per Miquel comments Thank you for the update. > +static inline int pl353_wait_for_dev_ready(struct nand_chip *chip) > +{ > + unsigned long timeout = jiffies + PL353_NAND_DEV_BUSY_TIMEOUT; > + > + do { > + if (pl353_smc_get_nand_int_status_raw()) { > + pl353_smc_clr_nand_int(); > + break; A closing brace is missing here. This causes a compilation failure. > + > + cpu_relax(); You previously used cond_resched (via nand_wait_ready) here. Why did you change it to cpu_relax()? > + } while (!time_after_eq(jiffies, timeout)); > + > + if (time_after_eq(jiffies, timeout)) { > + pr_err("%s timed out\n", __func__); > + return -ETIMEDOUT; > + } > + > + return 0; > +} > +static int pl353_nand_read_page_hwecc(struct nand_chip *chip, > + u8 *buf, int oob_required, int page) > +{ > + int i, stat, eccsize = chip->ecc.size; > + int eccbytes = chip->ecc.bytes; > + int eccsteps = chip->ecc.steps; > + u8 *p = buf; > + u8 *ecc_calc = chip->ecc.calc_buf; > + u8 *ecc = chip->ecc.code_buf; > + unsigned int max_bitflips = 0; > + u8 *oob_ptr; > + u32 ret; > + unsigned long data_phase_addr; > + unsigned long nand_offset = (unsigned long __force)xnfc->regs; The variable xnfc is undeclared here. Consider swapping the line with the next one. > + struct pl353_nand_controller *xnfc = to_pl353_nand(chip); > + struct mtd_info *mtd = nand_to_mtd(chip); After loading the driver, the device does not work. The dmesg output is: nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xda nand: Micron MT29F2G08ABAEAWP nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 Bad block table not found for chip 0 Bad block table not found for chip 0 Scanning device for bad blocks nand_bbt: error while writing BBT block -524 nand_bbt: error while writing BBT block -524 nand_bbt: error while writing BBT block -524 nand_bbt: error while writing BBT block -524 No space left to write bad block table nand_bbt: error while writing bad block table -28 pl353-nand e1000000.flash: could not scan the nand chip pl353-nand: probe of e1000000.flash failed with error -28 After trying the driver, the flash chip was bricked. Neither the old driver nor the uboot-xlnx driver nor the Xilinx fsbl are able to talk to the chip afterwards. This behaviour persists even after a full power cycle. I'll try reinitializing the flash chip next. I've only seen this behaviour once, so there is a slight chance that the cause is something else. Helmut