<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/mtd/ubi/wl.c, branch linux-4.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.9.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-11-10T09:23:59Z</updated>
<entry>
<title>ubi: check kthread_should_stop() after the setting of task state</title>
<updated>2020-11-10T09:23:59Z</updated>
<author>
<name>Zhihao Cheng</name>
</author>
<published>2020-06-01T09:12:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=63a84e3a98298aa27576f1e5d322b5815dafa09a'/>
<id>urn:sha1:63a84e3a98298aa27576f1e5d322b5815dafa09a</id>
<content type='text'>
commit d005f8c6588efcfbe88099b6edafc6f58c84a9c1 upstream.

A detach hung is possible when a race occurs between the detach process
and the ubi background thread. The following sequences outline the race:

  ubi thread: if (list_empty(&amp;ubi-&gt;works)...

  ubi detach: set_bit(KTHREAD_SHOULD_STOP, &amp;kthread-&gt;flags)
              =&gt; by kthread_stop()
              wake_up_process()
              =&gt; ubi thread is still running, so 0 is returned

  ubi thread: set_current_state(TASK_INTERRUPTIBLE)
              schedule()
              =&gt; ubi thread will never be scheduled again

  ubi detach: wait_for_completion()
              =&gt; hung task!

To fix that, we need to check kthread_should_stop() after we set the
task state, so the ubi thread will either see the stop bit and exit or
the task state is reset to runnable such that it isn't scheduled out
indefinitely.

Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Fixes: 801c135ce73d5df1ca ("UBI: Unsorted Block Images")
Reported-by: syzbot+853639d0cb16c31c7a14@syzkaller.appspotmail.com
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mtd: ubi: wl: Fix error return code in ubi_wl_init()</title>
<updated>2018-09-19T20:47:16Z</updated>
<author>
<name>Wei Yongjun</name>
</author>
<published>2018-01-18T14:05:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3fe958010928c6e5e6dee1e9cff9bd47939ea808'/>
<id>urn:sha1:3fe958010928c6e5e6dee1e9cff9bd47939ea808</id>
<content type='text'>
commit 7233982ade15eeac05c6f351e8d347406e6bcd2f upstream.

Fix to return error code -ENOMEM from the kmem_cache_alloc() error
handling case instead of 0, as done elsewhere in this function.

Fixes: f78e5623f45b ("ubi: fastmap: Erase outdated anchor PEBs during
attach")
Signed-off-by: Wei Yongjun &lt;weiyongjun1@huawei.com&gt;
Reviewed-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Cc: Ben Hutchings &lt;ben.hutchings@codethink.co.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ubi: fastmap: Cancel work upon detach</title>
<updated>2018-07-03T09:23:14Z</updated>
<author>
<name>Richard Weinberger</name>
</author>
<published>2018-05-16T20:17:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9eb99e738beb405cb69ce0c244e6bb0ee9666588'/>
<id>urn:sha1:9eb99e738beb405cb69ce0c244e6bb0ee9666588</id>
<content type='text'>
commit 6e7d80161066c99d12580d1b985cb1408bb58cf1 upstream.

Ben Hutchings pointed out that 29b7a6fa1ec0 ("ubi: fastmap: Don't flush
fastmap work on detach") does not really fix the problem, it just
reduces the risk to hit the race window where fastmap work races against
free()'ing ubi-&gt;volumes[].

The correct approach is making sure that no more fastmap work is in
progress before we free ubi data structures.
So we cancel fastmap work right after the ubi background thread is
stopped.
By setting ubi-&gt;thread_enabled to zero we make sure that no further work
tries to wake the thread.

Fixes: 29b7a6fa1ec0 ("ubi: fastmap: Don't flush fastmap work on detach")
Fixes: 74cdaf24004a ("UBI: Fastmap: Fix memory leaks while closing the WL sub-system")
Cc: stable@vger.kernel.org
Cc: Ben Hutchings &lt;ben.hutchings@codethink.co.uk&gt;
Cc: Martin Townsend &lt;mtownsend1973@gmail.com&gt;

Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ubi: fastmap: Erase outdated anchor PEBs during attach</title>
<updated>2018-02-17T12:21:14Z</updated>
<author>
<name>Sascha Hauer</name>
</author>
<published>2017-12-05T15:01:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=84f9d8536c8bf440d84093eb749290d88f7e1d76'/>
<id>urn:sha1:84f9d8536c8bf440d84093eb749290d88f7e1d76</id>
<content type='text'>
commit f78e5623f45bab2b726eec29dc5cefbbab2d0b1c upstream.

The fastmap update code might erase the current fastmap anchor PEB
in case it doesn't find any new free PEB. When a power cut happens
in this situation we must not have any outdated fastmap anchor PEB
on the device, because that would be used to attach during next
boot.
The easiest way to make that sure is to erase all outdated fastmap
anchor PEBs synchronously during attach.

Signed-off-by: Sascha Hauer &lt;s.hauer@pengutronix.de&gt;
Reviewed-by: Richard Weinberger &lt;richard@nod.at&gt;
Fixes: dbb7d2a88d2a ("UBI: Add fastmap core")
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ubi: Fix races around ubi_refill_pools()</title>
<updated>2016-10-02T20:54:01Z</updated>
<author>
<name>Richard Weinberger</name>
</author>
<published>2016-08-24T12:36:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2e8f08deabbc7eefe4c5838aaa6aa9a23a8acf2e'/>
<id>urn:sha1:2e8f08deabbc7eefe4c5838aaa6aa9a23a8acf2e</id>
<content type='text'>
When writing a new Fastmap the first thing that happens
is refilling the pools in memory.
At this stage it is possible that new PEBs from the new pools
get already claimed and written with data.
If this happens before the new Fastmap data structure hits the
flash and we face power cut the freshly written PEB will not
scanned and unnoticed.

Solve the issue by locking the pools until Fastmap is written.

Cc: &lt;stable@vger.kernel.org&gt;
Fixes: dbb7d2a88d ("UBI: Add fastmap core")
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
<entry>
<title>ubi: Deal with interrupted erasures in WL</title>
<updated>2016-10-02T20:49:54Z</updated>
<author>
<name>Richard Weinberger</name>
</author>
<published>2016-08-24T12:36:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2365418879e9abf12ea9def7f9f3caf0dfa7ffb0'/>
<id>urn:sha1:2365418879e9abf12ea9def7f9f3caf0dfa7ffb0</id>
<content type='text'>
When Fastmap is used we can face here an -EBADMSG
since Fastmap cannot know about unmaps.
If the erasure was interrupted the PEB may show ECC
errors and UBI would go to ro-mode as it assumes
that the PEB was check during attach time, which is
not the case with Fastmap.

Cc: &lt;stable@vger.kernel.org&gt;
Fixes: dbb7d2a88d ("UBI: Add fastmap core")
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
<entry>
<title>UBI: introduce the VID buffer concept</title>
<updated>2016-10-02T20:48:14Z</updated>
<author>
<name>Boris Brezillon</name>
</author>
<published>2016-09-16T14:59:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3291b52f9ff0acc80a8ee3f92a960db937dccecb'/>
<id>urn:sha1:3291b52f9ff0acc80a8ee3f92a960db937dccecb</id>
<content type='text'>
Currently, all VID headers are allocated and freed using the
ubi_zalloc_vid_hdr() and ubi_free_vid_hdr() function. These functions
make sure to align allocation on ubi-&gt;vid_hdr_alsize and adjust the
vid_hdr pointer to match the ubi-&gt;vid_hdr_shift requirements.
This works fine, but is a bit convoluted.
Moreover, the future introduction of LEB consolidation (needed to support
MLC/TLC NANDs) will allows a VID buffer to contain more than one VID
header.

Hence the creation of a ubi_vid_io_buf struct to attach extra information
to the VID header.

We currently only store the actual pointer of the underlying buffer, but
will soon add the number of VID headers contained in the buffer.

Signed-off-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
<entry>
<title>ubi: Rework Fastmap attach base code</title>
<updated>2016-07-29T21:32:42Z</updated>
<author>
<name>Richard Weinberger</name>
</author>
<published>2016-06-14T08:12:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fdf10ed710c0aa177e8dfcd84e65e4e5e8e0956b'/>
<id>urn:sha1:fdf10ed710c0aa177e8dfcd84e65e4e5e8e0956b</id>
<content type='text'>
Introduce a new list to the UBI attach information
object to be able to deal better with old and corrupted
Fastmap eraseblocks.
Also move more Fastmap specific code into fastmap.c.

Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
<entry>
<title>UBI: Set free_count to zero before walking through erase list</title>
<updated>2016-05-24T13:24:33Z</updated>
<author>
<name>Heiko Schocher</name>
</author>
<published>2016-04-22T10:06:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=73b0cd57fcd07201b138214f9a2353f76dd9ae2c'/>
<id>urn:sha1:73b0cd57fcd07201b138214f9a2353f76dd9ae2c</id>
<content type='text'>
Set free_count to zero before walking through ai-&gt;erase list
in wl_init().

Found in U-Boot as U-Boot has no workqueue/threads, it immediately
calls erase_worker(), which increase for each erased block
free_count. Without this patch, free_count gets after
this initialized to zero in wl_init(), so the free_count
variable always has the maybe wrong value 0 in U-Boot.

Signed-off-by: Heiko Schocher &lt;hs@denx.de&gt;
Reviewed-by: Boris Brezillon &lt;boris.brezillon@free-electrons.com&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
<entry>
<title>mtd: ubi: wl: avoid erasing a PEB which is empty</title>
<updated>2016-01-10T11:33:11Z</updated>
<author>
<name>Sebastian Siewior</name>
</author>
<published>2015-11-26T20:23:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=34b89df90374b631692132640c6b3dbef52f808d'/>
<id>urn:sha1:34b89df90374b631692132640c6b3dbef52f808d</id>
<content type='text'>
wear_leveling_worker() currently unconditionally puts a PEB on erase in
the error case even it just been taken from the free_list and never
used.
In case the PEB was never used it can be put back on the free list
saving a precious erase cycle.

v1…v2:
	- to_leb_clean -&gt; dst_leb_clean
	- use the nested option for ensure_wear_leveling()
	- do_sync_erase() can't go -ENOMEM so we can just go into
	  RO-mode now.

Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Richard Weinberger &lt;richard@nod.at&gt;
</content>
</entry>
</feed>
