From patchwork Wed Mar 7 14:12:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Parsons X-Patchwork-Id: 145286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EF421B6EEA for ; Thu, 8 Mar 2012 01:13:53 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1S5Hbr-0000Rm-NS; Wed, 07 Mar 2012 14:12:55 +0000 Received: from nm9.bullet.mail.ird.yahoo.com ([77.238.189.35]) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1S5Hbn-0000QU-TT for linux-mtd@lists.infradead.org; Wed, 07 Mar 2012 14:12:52 +0000 Received: from [77.238.189.57] by nm9.bullet.mail.ird.yahoo.com with NNFMP; 07 Mar 2012 14:12:50 -0000 Received: from [212.82.108.118] by tm10.bullet.mail.ird.yahoo.com with NNFMP; 07 Mar 2012 14:12:50 -0000 Received: from [127.0.0.1] by omp1027.mail.ird.yahoo.com with NNFMP; 07 Mar 2012 14:12:50 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 813125.32323.bm@omp1027.mail.ird.yahoo.com Received: (qmail 51772 invoked by uid 60001); 7 Mar 2012 14:12:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1331129570; bh=XK7fXPxqPam+1KNx4aop+o6uRoC5sSbFeHrGuds1dzo=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Lms5dPMl3lTBzO9F9jRrxWvDK0Ed5QiKg0mFDdDQhNyBmxCD0QbatK/6FA9lVZkHJh70y1skwbLAVMGvZBIj5WPyW7YhZvJab2brYv8gVjiRaa8uEA1Pbwob/OrNhog/lD+SG7VXCrXS42PQ/TmdHXwEHOd3kzeYzdkyBxV2wXA= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=n9TF/4W1/u3QxktRyQzQIPBmEx3Jty6tpVgQqHd/MLzoQaTcOP5knm3aWUOaYoWbzvCmxSojkZQDjH9gqs7qsAmwqDAu/WkAjqg3vtV9iugoKh6jMTZKBvQ1xSxNUZ9bglOzlnwNrWmmH4lu4RqU8lzHWlMAy8Tn83ckj+rxhMM=; X-YMail-OSG: 4vsSU2EVM1kZE3OVMnusb4d6eZ3jgkWDnN3gVRAvkt7A6FF md.4EiiIm.F.hhvNkXWTO6TD62zo9yeE5Nc1saPGKWf4On3PTkbVdJVO7wpM 3xwyFQI8PDlXli35Ppb49PmS_4k_kdviAgHv_wdVpHcGe2c61QKQyD6nsPHh qiDdcd6kDPos0oATSs3q52SEQ5TsUIJleyvEACJdA5mU4d8qdri6R6GbifrB 5dNWiW4QNfzJuBPe_qcZv8KCuSlvaV2gMg0dskDKfltCJ9C7ybbHMPHFpjC4 8ja1m0EGSFljbOIsZy2LvaAJJK_Sa7T.QMZYrc561wydEey_vu9pI8zmWppB QaQl5crLml1zXi3uLCE8jSY5lyhPMEK0KJZkNebWNvnT6S7RZhrMg0vGYVAU L3dng0tb1DWgzeJWNZ5f5.eflCP0SZvCOASPrk3WWM_8Un5OtWE12MhG1ArT MxVDgV6g- Received: from [31.185.155.94] by web29016.mail.ird.yahoo.com via HTTP; Wed, 07 Mar 2012 14:12:50 GMT X-Mailer: YahooMailClassic/15.0.5 YahooMailWebService/0.8.116.338427 Message-ID: <1331129570.47213.YahooMailClassic@web29016.mail.ird.yahoo.com> Date: Wed, 7 Mar 2012 14:12:50 +0000 (GMT) From: Paul Parsons Subject: [PATCH 4/6] mtd: maps: l440gx: Add reference counter to set_vpp() To: linux-mtd@lists.infradead.org MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lost.distance[at]yahoo.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [77.238.189.35 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: dwmw2@infradead.org, joakim.tjernlund@transmode.se, philipp.zabel@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch is part of a set which fixes unnecessary flash erase and write errors resulting from the MTD CFI driver turning off vpp while an erase is in progress. This patch allows l440gx_set_vpp() calls to be nested by adding a reference counter. Signed-off-by: Paul Parsons diff -uprN clean-3.3-rc6/drivers/mtd/maps/l440gx.c linux-3.3-rc6/drivers/mtd/maps/l440gx.c --- clean-3.3-rc6/drivers/mtd/maps/l440gx.c 2012-03-04 01:08:09.000000000 +0000 +++ linux-3.3-rc6/drivers/mtd/maps/l440gx.c 2012-03-06 16:38:29.795134347 +0000 @@ -27,17 +27,21 @@ static struct mtd_info *mymtd; /* Is this really the vpp port? */ +static DEFINE_SPINLOCK(l440gx_vpp_lock); +static int l440gx_vpp_refcnt; static void l440gx_set_vpp(struct map_info *map, int vpp) { - unsigned long l; + unsigned long flags; - l = inl(VPP_PORT); + spin_lock_irqsave(&l440gx_vpp_lock, flags); if (vpp) { - l |= 1; + if (++l440gx_vpp_refcnt == 1) /* first nested 'on' */ + outl(inl(VPP_PORT) | 1, VPP_PORT); } else { - l &= ~1; + if (--l440gx_vpp_refcnt == 0) /* last nested 'off' */ + outl(inl(VPP_PORT) & ~1, VPP_PORT); } - outl(l, VPP_PORT); + spin_unlock_irqrestore(&l440gx_vpp_lock, flags); } static struct map_info l440gx_map = {