<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/mtd, branch v3.4.72</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/drivers/mtd?h=v3.4.72</id>
<link rel='self' href='https://git.amat.us/linux/atom/drivers/mtd?h=v3.4.72'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2013-12-04T18:50:29Z</updated>
<entry>
<title>mtd: gpmi: fix kernel BUG due to racing DMA operations</title>
<updated>2013-12-04T18:50:29Z</updated>
<author>
<name>Huang Shijie</name>
<email>b32955@freescale.com</email>
</author>
<published>2013-11-11T04:13:45Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1eb9c3425abb5a187ef7b52206eb395aa896151e'/>
<id>urn:sha1:1eb9c3425abb5a187ef7b52206eb395aa896151e</id>
<content type='text'>
commit 7b3d2fb92067bcb29f0f085a9fa9fa64920a6646 upstream.

[1] The gpmi uses the nand_command_lp to issue the commands to NAND chips.
    The gpmi issues a DMA operation with gpmi_cmd_ctrl when it handles
    a NAND_CMD_NONE control command. So when we read a page(NAND_CMD_READ0)
    from the NAND, we may send two DMA operations back-to-back.

    If we do not serialize the two DMA operations, we will meet a bug when

    1.1) we enable CONFIG_DMA_API_DEBUG, CONFIG_DMADEVICES_DEBUG,
         and CONFIG_DEBUG_SG.

    1.2) Use the following commands in an UART console and a SSH console:
         cmd 1: while true;do dd if=/dev/mtd0 of=/dev/null;done
         cmd 1: while true;do dd if=/dev/mmcblk0 of=/dev/null;done

    The kernel log shows below:
    -----------------------------------------------------------------
    kernel BUG at lib/scatterlist.c:28!
    Unable to handle kernel NULL pointer dereference at virtual address 00000000
      .........................
    [&lt;80044a0c&gt;] (__bug+0x18/0x24) from [&lt;80249b74&gt;] (sg_next+0x48/0x4c)
    [&lt;80249b74&gt;] (sg_next+0x48/0x4c) from [&lt;80255398&gt;] (debug_dma_unmap_sg+0x170/0x1a4)
    [&lt;80255398&gt;] (debug_dma_unmap_sg+0x170/0x1a4) from [&lt;8004af58&gt;] (dma_unmap_sg+0x14/0x6c)
    [&lt;8004af58&gt;] (dma_unmap_sg+0x14/0x6c) from [&lt;8027e594&gt;] (mxs_dma_tasklet+0x18/0x1c)
    [&lt;8027e594&gt;] (mxs_dma_tasklet+0x18/0x1c) from [&lt;8007d444&gt;] (tasklet_action+0x114/0x164)
    -----------------------------------------------------------------

    1.3) Assume the two DMA operations is X (first) and Y (second).

         The root cause of the bug:
	   Assume process P issues DMA X, and sleep on the completion
	 @this-&gt;dma_done. X's tasklet callback is dma_irq_callback. It firstly
	 wake up the process sleeping on the completion @this-&gt;dma_done,
	 and then trid to unmap the scatterlist S. The waked process P will
	 issue Y in another ARM core. Y initializes S-&gt;sg_magic to zero
	 with sg_init_one(), while dma_irq_callback is unmapping S at the same
	 time.

	 See the diagram:

                   ARM core 0              |         ARM core 1
	 -------------------------------------------------------------
         (P issues DMA X, then sleep)  --&gt; |
                                           |
         (X's tasklet wakes P)         --&gt; |
                                           |
                                           | &lt;-- (P begin to issue DMA Y)
                                           |
         (X's tasklet unmap the            |
      scatterlist S with dma_unmap_sg) --&gt; | &lt;-- (Y calls sg_init_one() to init
                                           |      scatterlist S)
                                           |

[2] This patch serialize both the X and Y in the following way:
     Unmap the DMA scatterlist S firstly, and wake up the process at the end
     of the DMA callback, in such a way, Y will be executed after X.

     After this patch:

                   ARM core 0              |         ARM core 1
	 -------------------------------------------------------------
         (P issues DMA X, then sleep)  --&gt; |
                                           |
         (X's tasklet unmap the            |
      scatterlist S with dma_unmap_sg) --&gt; |
                                           |
         (X's tasklet wakes P)         --&gt; |
                                           |
                                           | &lt;-- (P begin to issue DMA Y)
                                           |
                                           | &lt;-- (Y calls sg_init_one() to init
                                           |     scatterlist S)
                                           |

Signed-off-by: Huang Shijie &lt;b32955@freescale.com&gt;
Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: nand: hack ONFI for non-power-of-2 dimensions</title>
<updated>2013-12-04T18:50:28Z</updated>
<author>
<name>Brian Norris</name>
<email>computersforpeace@gmail.com</email>
</author>
<published>2013-08-28T01:45:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=b22831e6611bec1fdf84e71d80f7917199212ee8'/>
<id>urn:sha1:b22831e6611bec1fdf84e71d80f7917199212ee8</id>
<content type='text'>
commit 4355b70cf48363c50a9de450b01178c83aba8f6a upstream.

Some bright specification writers decided to write this in the ONFI spec
(from ONFI 3.0, Section 3.1):

  "The number of blocks and number of pages per block is not required to
  be a power of two. In the case where one of these values is not a
  power of two, the corresponding address shall be rounded to an
  integral number of bits such that it addresses a range up to the
  subsequent power of two value. The host shall not access upper
  addresses in a range that is shown as not supported."

This breaks every assumption MTD makes about NAND block/chip-size
dimensions -- they *must* be a power of two!

And of course, an enterprising manufacturer has made use of this lovely
freedom. Exhibit A: Micron MT29F32G08CBADAWP

  "- Plane size: 2 planes x 1064 blocks per plane
   - Device size: 32Gb: 2128 blockss [sic]"

This quickly hits a BUG() in nand_base.c, since the extra dimensions
overflow so we think it's a second chip (on my single-chip setup):

    ONFI param page 0 valid
    ONFI flash detected
    NAND device: Manufacturer ID: 0x2c, Chip ID: 0x44 (Micron MT29F32G08CBADAWP), 4256MiB, page size: 8192, OOB size: 744
    ------------[ cut here ]------------
    kernel BUG at drivers/mtd/nand/nand_base.c:203!
    Internal error: Oops - BUG: 0 [#1] SMP ARM
    [... trim ...]
    [&lt;c02cf3e4&gt;] (nand_select_chip+0x18/0x2c) from [&lt;c02d25c0&gt;] (nand_do_read_ops+0x90/0x424)
    [&lt;c02d25c0&gt;] (nand_do_read_ops+0x90/0x424) from [&lt;c02d2dd8&gt;] (nand_read+0x54/0x78)
    [&lt;c02d2dd8&gt;] (nand_read+0x54/0x78) from [&lt;c02ad2c8&gt;] (mtd_read+0x84/0xbc)
    [&lt;c02ad2c8&gt;] (mtd_read+0x84/0xbc) from [&lt;c02d4b28&gt;] (scan_read.clone.4+0x4c/0x64)
    [&lt;c02d4b28&gt;] (scan_read.clone.4+0x4c/0x64) from [&lt;c02d4c88&gt;] (search_bbt+0x148/0x290)
    [&lt;c02d4c88&gt;] (search_bbt+0x148/0x290) from [&lt;c02d4ea4&gt;] (nand_scan_bbt+0xd4/0x5c0)
    [... trim ...]
    ---[ end trace 0c9363860d865ff2 ]---

So to fix this, just truncate these dimensions down to the greatest
power-of-2 dimension that is less than or equal to the specified
dimension.

Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>vm: convert mtdchar mmap to vm_iomap_memory() helper</title>
<updated>2013-04-26T04:19:56Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2013-04-19T16:53:07Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=b00919cd72ed9753390a9fbb5541cbba12e5e826'/>
<id>urn:sha1:b00919cd72ed9753390a9fbb5541cbba12e5e826</id>
<content type='text'>
commit 8558e4a26b00225efeb085725bc319f91201b239 upstream.

This is my example conversion of a few existing mmap users.  The mtdchar
case is actually disabled right now (and stays disabled), but I did it
because it showed up on my "git grep", and I was familiar with the code
due to fixing an overflow problem in the code in commit 9c603e53d380
("mtdchar: fix offset overflow detection").

Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: Disable mtdchar mmap on MMU systems</title>
<updated>2013-04-17T04:27:27Z</updated>
<author>
<name>David Woodhouse</name>
<email>David.Woodhouse@intel.com</email>
</author>
<published>2012-10-09T14:08:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=06ce3e44cb3152be067f7a637a08df8c577f4620'/>
<id>urn:sha1:06ce3e44cb3152be067f7a637a08df8c577f4620</id>
<content type='text'>
commit f5cf8f07423b2677cebebcebc863af77223a4972 upstream.

This code was broken because it assumed that all MTD devices were map-based.
Disable it for now, until it can be fixed properly for the next merge window.

Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtdchar: fix offset overflow detection</title>
<updated>2013-04-17T04:27:27Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-09-08T19:57:30Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a7d507200f9a0de5b0d516cd67d088fa399ed54a'/>
<id>urn:sha1:a7d507200f9a0de5b0d516cd67d088fa399ed54a</id>
<content type='text'>
commit 9c603e53d380459fb62fec7cd085acb0b74ac18f upstream.

Sasha Levin has been running trinity in a KVM tools guest, and was able
to trigger the BUG_ON() at arch/x86/mm/pat.c:279 (verifying the range of
the memory type).  The call trace showed that it was mtdchar_mmap() that
created an invalid remap_pfn_range().

The problem is that mtdchar_mmap() does various really odd and subtle
things with the vma page offset etc, and uses the wrong types (and the
wrong overflow) detection for it.

For example, the page offset may well be 32-bit on a 32-bit
architecture, but after shifting it up by PAGE_SHIFT, we need to use a
potentially 64-bit resource_size_t to correctly hold the full value.

Also, we need to check that the vma length plus offset doesn't overflow
before we check that it is smaller than the length of the mtdmap region.

This fixes things up and tries to make the code a bit easier to read.

Reported-and-tested-by: Sasha Levin &lt;levinsasha928@gmail.com&gt;
Acked-by: Suresh Siddha &lt;suresh.b.siddha@intel.com&gt;
Acked-by: Artem Bityutskiy &lt;dedekind1@gmail.com&gt;
Cc: David Woodhouse &lt;dwmw2@infradead.org&gt;
Cc: linux-mtd@lists.infradead.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Cc: Brad Spengler &lt;spender@grsecurity.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: nand: gpmi: reset BCH earlier, too, to avoid NAND startup problems</title>
<updated>2013-01-17T16:50:45Z</updated>
<author>
<name>Wolfram Sang</name>
<email>w.sang@pengutronix.de</email>
</author>
<published>2012-12-05T20:46:02Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=b53673dcf8a31a4b2f41fdf2fa168b7c693fd7b3'/>
<id>urn:sha1:b53673dcf8a31a4b2f41fdf2fa168b7c693fd7b3</id>
<content type='text'>
commit 6f2a6a52560ad8d85710aabd92b7a3239b3a6b07 upstream.

It could happen (1 out of 100 times) that NAND did not start up
correctly after warm rebooting, so the kernel could not find the UBI or
DMA timed out due to a stalled BCH. When resetting BCH together with
GPMI, the issue could not be observed anymore (after 10000+ reboots). We
probably need the consistent state already before sending any command to
NAND, even when no ECC is needed. I chose to keep the extra reset for
BCH when changing the flash layout to be on the safe side.

Signed-off-by: Wolfram Sang &lt;w.sang@pengutronix.de&gt;
Acked-by: Huang Shijie &lt;b32955@freescale.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd cs553x_nand: Initialise ecc.strength before nand_scan()</title>
<updated>2013-01-17T16:50:45Z</updated>
<author>
<name>Nathan Williams</name>
<email>nathan@traverse.com.au</email>
</author>
<published>2012-11-21T23:42:52Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=272965fcdaf55d0930dbc594fdfd93cd13fcc8cd'/>
<id>urn:sha1:272965fcdaf55d0930dbc594fdfd93cd13fcc8cd</id>
<content type='text'>
commit d1f3b65d2d6fdb4bf0edd4b67e86e191af48daee upstream.

Loading cs553x_nand with Hynix H27U1G8F2BTR NAND flash causes this bug:

kernel BUG at drivers/mtd/nand/nand_base.c:3345!
invalid opcode: 0000 [#1]
Modules linked in: cs553x_nand(+) vfat fat usb_storage ehci_hcd usbcore usb_comr
Pid: 436, comm: modprobe Not tainted 3.6.7 #1
EIP: 0060:[&lt;c118d205&gt;] EFLAGS: 00010296 CPU: 0
EIP is at nand_scan_tail+0x64c/0x69c
EAX: 00000034 EBX: cea6ed98 ECX: 00000000 EDX: 00000000
ESI: cea6ec00 EDI: cea6ec00 EBP: 20000000 ESP: cdd17e48
 DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
CR0: 8005003b CR2: 0804e119 CR3: 0d850000 CR4: 00000090
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
Process modprobe (pid: 436, ti=cdd16000 task=cdd1c320 task.ti=cdd16000)
Stack:
 c12e962c c118f7ef 00000003 cea6ed98 d014b25c 20000000 fffff007 00000001
 00000000 cdd53b00 d014b000 c1001021 cdd53b00 d01493c0 cdd53b00 cdd53b00
 d01493c0 c1047f83 d014b4a0 00000000 cdd17f9c ce4be454 cdd17f48 cdd1c320
Call Trace:
 [&lt;c118f7ef&gt;] ? nand_scan+0x1b/0x4d
 [&lt;d014b25c&gt;] ? init_module+0x25c/0x2de [cs553x_nand]
 [&lt;d014b000&gt;] ? 0xd014afff
 [&lt;c1001021&gt;] ? do_one_initcall+0x21/0x111
 [&lt;c1047f83&gt;] ? sys_init_module+0xe4/0x1261
 [&lt;c1031207&gt;] ? task_work_run+0x36/0x43
 [&lt;c1265ced&gt;] ? syscall_call+0x7/0xb
Code: fa ff ff c7 86 d8 00 00 00 01 00 00 00 e9 5f fc ff ff 68 f8 26 2e c1 e8 a7
EIP: [&lt;c118d205&gt;] nand_scan_tail+0x64c/0x69c SS:ESP 0068:cdd17e48

Initialising ecc.strength before the call to nand_scan() fixes this.

Signed-off-by: Nathan Williams &lt;nathan@traverse.com.au&gt;
Acked-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Acked-by: Mike Dunn &lt;mikedunn@newsguy.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()</title>
<updated>2012-12-03T19:47:06Z</updated>
<author>
<name>Sachin Kamat</name>
<email>sachin.kamat@linaro.org</email>
</author>
<published>2012-09-25T09:57:13Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=11371ec0a92756cbaa84b86fbbaa3aeae7457658'/>
<id>urn:sha1:11371ec0a92756cbaa84b86fbbaa3aeae7457658</id>
<content type='text'>
commit 5a6ea4af0907f995dc06df21a9c9ef764c7cd3bc upstream.

The pointer returned by kzalloc should be tested for NULL
to avoid potential NULL pointer dereference later. Incorrect
pointer was being tested for NULL. Bug introduced by commit fbcf62a3
(mtd: physmap_of: move parse_obsolete_partitions to become separate
parser).
This patch fixes this bug.

Signed-off-by: Sachin Kamat &lt;sachin.kamat@linaro.org&gt;
Cc: Dmitry Eremin-Solenikov &lt;dbaryshkov@gmail.com&gt;
Cc: Artem Bityutskiy &lt;artem.bityutskiy@intel.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: slram: invalid checking of absolute end address</title>
<updated>2012-12-03T19:47:05Z</updated>
<author>
<name>Jiri Engelthaler</name>
<email>engycz@gmail.com</email>
</author>
<published>2012-09-20T14:49:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=02bbebe27638111d18f63fa7438231def916bd15'/>
<id>urn:sha1:02bbebe27638111d18f63fa7438231def916bd15</id>
<content type='text'>
commit c36a7ff4578ab6294885aef5ef241aeec4cdb1f0 upstream.

Fixed parsing end absolute address.

Signed-off-by: Jiri Engelthaler &lt;engycz@gmail.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver</title>
<updated>2012-10-28T17:14:16Z</updated>
<author>
<name>Brian Norris</name>
<email>computersforpeace@gmail.com</email>
</author>
<published>2012-07-13T16:28:24Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f2a713d25e8b95e065c90af72f461e99427e20f8'/>
<id>urn:sha1:f2a713d25e8b95e065c90af72f461e99427e20f8</id>
<content type='text'>
commit bf7a01bf7987b63b121d572b240c132ec44129c4 upstream.

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It
silently masks off at least one flag that might be set by the driver
(NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly
others.

Really, as long as driver writers exercise a small amount of care with
NAND_* options, this mask is not necessary at all; it was only here to
prevent certain options from accidentally being set by the driver. But the
original thought turns out to be a bad idea occasionally. Thus, kill it.

Note, this patch fixes some major gpmi-nand breakage.

Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Tested-by: Huang Shijie &lt;shijie8@gmail.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
