--- /dev/null
+From 121264827656f5f06328b17983c796af17dc5949 Mon Sep 17 00:00:00 2001
+From: Zhenyu Wang <zhenyuw@linux.intel.com>
+Date: Mon, 14 Sep 2009 10:47:06 +0800
+Subject: agp/intel: remove restore in resume
+
+From: Zhenyu Wang <zhenyuw@linux.intel.com>
+
+commit 121264827656f5f06328b17983c796af17dc5949 upstream.
+
+As early pci resume has already restored config for host
+bridge and graphics device, don't need to restore it again,
+This removes an original order hack for graphics device restore.
+
+This fixed the resume hang issue found by Alan Stern on 845G,
+caused by extra config restore on graphics device.
+
+Cc: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Signed-off-by: Dave Airlie <airlied@linux.ie>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/char/agp/intel-agp.c | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+--- a/drivers/char/agp/intel-agp.c
++++ b/drivers/char/agp/intel-agp.c
+@@ -2299,15 +2299,6 @@ static int agp_intel_resume(struct pci_d
+ struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
+ int ret_val;
+
+- pci_restore_state(pdev);
+-
+- /* We should restore our graphics device's config space,
+- * as host bridge (00:00) resumes before graphics device (02:00),
+- * then our access to its pci space can work right.
+- */
+- if (intel_private.pcidev)
+- pci_restore_state(intel_private.pcidev);
+-
+ if (bridge->driver == &intel_generic_driver)
+ intel_configure();
+ else if (bridge->driver == &intel_850_driver)
--- /dev/null
+From 3355443ad7601991affa5992b0d53870335af765 Mon Sep 17 00:00:00 2001
+From: Bob Copeland <me@bobcopeland.com>
+Date: Sat, 4 Jul 2009 21:03:13 -0400
+Subject: ath5k: write PCU registers on initial reset
+
+From: Bob Copeland <me@bobcopeland.com>
+
+commit 3355443ad7601991affa5992b0d53870335af765 upstream.
+
+"Ath5k: unify resets"
+introduced a regression into 2.6.28 where the PCU registers are never
+initialized, due to ath5k_reset() always passing true for change_channel.
+We subsequently program a lot of these registers but several may start
+in an unknown state.
+
+Reported-by: Forrest Zhang <forrest@hifulltech.com>
+Signed-off-by: Bob Copeland <me@bobcopeland.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/net/wireless/ath5k/base.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/ath5k/base.c
++++ b/drivers/net/wireless/ath5k/base.c
+@@ -2623,7 +2623,7 @@ ath5k_reset(struct ath5k_softc *sc, stru
+ sc->curchan = chan;
+ sc->curband = &sc->sbands[chan->band];
+ }
+- ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, true);
++ ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, chan != NULL);
+ if (ret) {
+ ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret);
+ goto err;
--- /dev/null
+From 9f0ab4a3f0fdb1ff404d150618ace2fa069bb2e1 Mon Sep 17 00:00:00 2001
+From: Roland McGrath <roland@redhat.com>
+Date: Tue, 8 Sep 2009 19:49:40 -0700
+Subject: binfmt_elf: fix PT_INTERP bss handling
+
+From: Roland McGrath <roland@redhat.com>
+
+commit 9f0ab4a3f0fdb1ff404d150618ace2fa069bb2e1 upstream.
+
+In fs/binfmt_elf.c, load_elf_interp() calls padzero() for .bss even if
+the PT_LOAD has no PROT_WRITE and no .bss. This generates EFAULT.
+
+Here is a small test case. (Yes, there are other, useful PT_INTERP
+which have only .text and no .data/.bss.)
+
+ ----- ptinterp.S
+ _start: .globl _start
+ nop
+ int3
+ -----
+ $ gcc -m32 -nostartfiles -nostdlib -o ptinterp ptinterp.S
+ $ gcc -m32 -Wl,--dynamic-linker=ptinterp -o hello hello.c
+ $ ./hello
+ Segmentation fault # during execve() itself
+
+ After applying the patch:
+ $ ./hello
+ Trace trap # user-mode execution after execve() finishes
+
+If the ELF headers are actually self-inconsistent, then dying is fine.
+But having no PROT_WRITE segment is perfectly normal and correct if
+there is no segment with p_memsz > p_filesz (i.e. bss). John Reiser
+suggested checking for PROT_WRITE in the bss logic. I think it makes
+most sense to simply apply the bss logic only when there is bss.
+
+This patch looks less trivial than it is due to some reindentation.
+It just moves the "if (last_bss > elf_bss) {" test up to include the
+partial-page bss logic as well as the more-pages bss logic.
+
+Reported-by: John Reiser <jreiser@bitwagon.com>
+Signed-off-by: Roland McGrath <roland@redhat.com>
+Signed-off-by: James Morris <jmorris@namei.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/binfmt_elf.c | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+--- a/fs/binfmt_elf.c
++++ b/fs/binfmt_elf.c
+@@ -501,22 +501,22 @@ static unsigned long load_elf_interp(str
+ }
+ }
+
+- /*
+- * Now fill out the bss section. First pad the last page up
+- * to the page boundary, and then perform a mmap to make sure
+- * that there are zero-mapped pages up to and including the
+- * last bss page.
+- */
+- if (padzero(elf_bss)) {
+- error = -EFAULT;
+- goto out_close;
+- }
++ if (last_bss > elf_bss) {
++ /*
++ * Now fill out the bss section. First pad the last page up
++ * to the page boundary, and then perform a mmap to make sure
++ * that there are zero-mapped pages up to and including the
++ * last bss page.
++ */
++ if (padzero(elf_bss)) {
++ error = -EFAULT;
++ goto out_close;
++ }
+
+- /* What we have mapped so far */
+- elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
++ /* What we have mapped so far */
++ elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
+
+- /* Map the last of the bss segment */
+- if (last_bss > elf_bss) {
++ /* Map the last of the bss segment */
+ down_write(¤t->mm->mmap_sem);
+ error = do_brk(elf_bss, last_bss - elf_bss);
+ up_write(¤t->mm->mmap_sem);
--- /dev/null
+From fcc6cb0c13555e78c2d47257b6d1b5e59b0c419a Mon Sep 17 00:00:00 2001
+From: Bob Copeland <me@bobcopeland.com>
+Date: Tue, 1 Sep 2009 18:12:11 -0400
+Subject: cfg80211: fix looping soft lockup in find_ie()
+
+From: Bob Copeland <me@bobcopeland.com>
+
+commit fcc6cb0c13555e78c2d47257b6d1b5e59b0c419a upstream.
+
+The find_ie() function uses a size_t for the len parameter, and
+directly uses len as a loop variable. If any received packets
+are malformed, it is possible for the decrease of len to overflow,
+and since the result is unsigned, the loop will not terminate.
+Change it to a signed int so the loop conditional works for
+negative values.
+
+This fixes the following soft lockup:
+
+[38573.102007] BUG: soft lockup - CPU#0 stuck for 61s! [phy0:2230]
+[38573.102007] Modules linked in: aes_i586 aes_generic fuse af_packet ipt_REJECT xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_state iptable_filter ip_tables x_tables acpi_cpufreq binfmt_misc dm_mirror dm_region_hash dm_log dm_multipath dm_mod kvm_intel kvm uinput i915 arc4 ecb drm snd_hda_codec_idt ath5k snd_hda_intel hid_apple mac80211 usbhid appletouch snd_hda_codec snd_pcm ath cfg80211 snd_timer i2c_algo_bit ohci1394 video snd processor ieee1394 rfkill ehci_hcd sg sky2 backlight snd_page_alloc uhci_hcd joydev output ac thermal button battery sr_mod applesmc cdrom input_polldev evdev unix [last unloaded: scsi_wait_scan]
+[38573.102007] irq event stamp: 2547724535
+[38573.102007] hardirqs last enabled at (2547724534): [<c1002ffc>] restore_all_notrace+0x0/0x18
+[38573.102007] hardirqs last disabled at (2547724535): [<c10038f4>] apic_timer_interrupt+0x28/0x34
+[38573.102007] softirqs last enabled at (92950144): [<c103ab48>] __do_softirq+0x108/0x210
+[38573.102007] softirqs last disabled at (92950274): [<c1348e74>] _spin_lock_bh+0x14/0x80
+[38573.102007]
+[38573.102007] Pid: 2230, comm: phy0 Tainted: G W (2.6.31-rc7-wl #8) MacBook1,1
+[38573.102007] EIP: 0060:[<f8ea2d50>] EFLAGS: 00010292 CPU: 0
+[38573.102007] EIP is at cmp_ies+0x30/0x180 [cfg80211]
+[38573.102007] EAX: 00000082 EBX: 00000000 ECX: ffffffc1 EDX: d8efd014
+[38573.102007] ESI: ffffff7c EDI: 0000004d EBP: eee2dc50 ESP: eee2dc3c
+[38573.102007] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
+[38573.102007] CR0: 8005003b CR2: d8efd014 CR3: 01694000 CR4: 000026d0
+[38573.102007] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
+[38573.102007] DR6: ffff0ff0 DR7: 00000400
+[38573.102007] Call Trace:
+[38573.102007] [<f8ea2f8d>] cmp_bss+0xed/0x100 [cfg80211]
+[38573.102007] [<f8ea33e4>] cfg80211_bss_update+0x84/0x410 [cfg80211]
+[38573.102007] [<f8ea3884>] cfg80211_inform_bss_frame+0x114/0x180 [cfg80211]
+[38573.102007] [<f97255ff>] ieee80211_bss_info_update+0x4f/0x180 [mac80211]
+[38573.102007] [<f972b118>] ieee80211_rx_bss_info+0x88/0xf0 [mac80211]
+[38573.102007] [<f9739297>] ? ieee802_11_parse_elems+0x27/0x30 [mac80211]
+[38573.102007] [<f972b224>] ieee80211_rx_mgmt_probe_resp+0xa4/0x1c0 [mac80211]
+[38573.102007] [<f972bc59>] ieee80211_sta_rx_queued_mgmt+0x919/0xc50 [mac80211]
+[38573.102007] [<c1009707>] ? sched_clock+0x27/0xa0
+[38573.102007] [<c1009707>] ? sched_clock+0x27/0xa0
+[38573.102007] [<c105ffd0>] ? mark_held_locks+0x60/0x80
+[38573.102007] [<c1348be5>] ? _spin_unlock_irqrestore+0x55/0x70
+[38573.102007] [<c134baa5>] ? sub_preempt_count+0x85/0xc0
+[38573.102007] [<c1348bce>] ? _spin_unlock_irqrestore+0x3e/0x70
+[38573.102007] [<c12c1c0f>] ? skb_dequeue+0x4f/0x70
+[38573.102007] [<f972c021>] ieee80211_sta_work+0x91/0xb80 [mac80211]
+[38573.102007] [<c1009707>] ? sched_clock+0x27/0xa0
+[38573.102007] [<c134baa5>] ? sub_preempt_count+0x85/0xc0
+[38573.102007] [<c10479af>] worker_thread+0x18f/0x320
+[38573.102007] [<c104794e>] ? worker_thread+0x12e/0x320
+[38573.102007] [<c1348be5>] ? _spin_unlock_irqrestore+0x55/0x70
+[38573.102007] [<f972bf90>] ? ieee80211_sta_work+0x0/0xb80 [mac80211]
+[38573.102007] [<c104cbb0>] ? autoremove_wake_function+0x0/0x50
+[38573.102007] [<c1047820>] ? worker_thread+0x0/0x320
+[38573.102007] [<c104c854>] kthread+0x84/0x90
+[38573.102007] [<c104c7d0>] ? kthread+0x0/0x90
+[38573.102007] [<c1003ab7>] kernel_thread_helper+0x7/0x10
+
+Signed-off-by: Bob Copeland <me@bobcopeland.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ net/wireless/scan.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/wireless/scan.c
++++ b/net/wireless/scan.c
+@@ -97,7 +97,7 @@ void cfg80211_bss_expire(struct cfg80211
+ dev->bss_generation++;
+ }
+
+-static u8 *find_ie(u8 num, u8 *ies, size_t len)
++static u8 *find_ie(u8 num, u8 *ies, int len)
+ {
+ while (len > 2 && ies[0] != num) {
+ len -= ies[1] + 2;
--- /dev/null
+From 2195d2818c37bdf263865f1e9effccdd9fc5f9d4 Mon Sep 17 00:00:00 2001
+From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Date: Sat, 12 Sep 2009 12:21:27 +0100
+Subject: fix undefined reference to user_shm_unlock
+
+From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+
+commit 2195d2818c37bdf263865f1e9effccdd9fc5f9d4 upstream.
+
+My 353d5c30c666580347515da609dd74a2b8e9b828 "mm: fix hugetlb bug due to
+user_shm_unlock call" broke the CONFIG_SYSVIPC !CONFIG_MMU build of both
+2.6.31 and 2.6.30.6: "undefined reference to `user_shm_unlock'".
+
+gcc didn't understand my comment! so couldn't figure out to optimize
+away user_shm_unlock() from the error path in the hugetlb-less case, as
+it does elsewhere. Help it to do so, in a language it understands.
+
+Reported-by: Mike Frysinger <vapier@gentoo.org>
+Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ ipc/shm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/ipc/shm.c
++++ b/ipc/shm.c
+@@ -411,7 +411,7 @@ static int newseg(struct ipc_namespace *
+ return error;
+
+ no_id:
+- if (shp->mlock_user) /* shmflg & SHM_HUGETLB case */
++ if (is_file_hugepages(file) && shp->mlock_user)
+ user_shm_unlock(size, shp->mlock_user);
+ fput(file);
+ no_file:
--- /dev/null
+From bc00351edd5c1b84d48c3fdca740fedfce4ae6ce Mon Sep 17 00:00:00 2001
+From: Geoff Levand <geoffrey.levand@am.sony.com>
+Date: Wed, 9 Sep 2009 13:28:05 +0000
+Subject: powerpc/ps3: Workaround for flash memory I/O error
+
+From: Geoff Levand <geoffrey.levand@am.sony.com>
+
+commit bc00351edd5c1b84d48c3fdca740fedfce4ae6ce upstream.
+
+A workaround for flash memory I/O errors when the PS3 internal
+hard disk has not been formatted for OtherOS use.
+
+This error condition mainly effects 'Live CD' users who have not
+formatted the PS3's internal hard disk for OtherOS.
+
+Fixes errors similar to these when using the ps3-flash-util
+or ps3-boot-game-os programs:
+
+ ps3flash read failed 0x2050000
+ os_area_header_read: read error: os_area_header: Input/output error
+ main:627: os_area_read_hp error.
+ ERROR: can't change boot flag
+
+Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
+Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/ps3/ps3stor_lib.c | 65 +++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 62 insertions(+), 3 deletions(-)
+
+--- a/drivers/ps3/ps3stor_lib.c
++++ b/drivers/ps3/ps3stor_lib.c
+@@ -23,6 +23,65 @@
+ #include <asm/lv1call.h>
+ #include <asm/ps3stor.h>
+
++/*
++ * A workaround for flash memory I/O errors when the internal hard disk
++ * has not been formatted for OtherOS use. Delay disk close until flash
++ * memory is closed.
++ */
++
++static struct ps3_flash_workaround {
++ int flash_open;
++ int disk_open;
++ struct ps3_system_bus_device *disk_sbd;
++} ps3_flash_workaround;
++
++static int ps3stor_open_hv_device(struct ps3_system_bus_device *sbd)
++{
++ int error = ps3_open_hv_device(sbd);
++
++ if (error)
++ return error;
++
++ if (sbd->match_id == PS3_MATCH_ID_STOR_FLASH)
++ ps3_flash_workaround.flash_open = 1;
++
++ if (sbd->match_id == PS3_MATCH_ID_STOR_DISK)
++ ps3_flash_workaround.disk_open = 1;
++
++ return 0;
++}
++
++static int ps3stor_close_hv_device(struct ps3_system_bus_device *sbd)
++{
++ int error;
++
++ if (sbd->match_id == PS3_MATCH_ID_STOR_DISK
++ && ps3_flash_workaround.disk_open
++ && ps3_flash_workaround.flash_open) {
++ ps3_flash_workaround.disk_sbd = sbd;
++ return 0;
++ }
++
++ error = ps3_close_hv_device(sbd);
++
++ if (error)
++ return error;
++
++ if (sbd->match_id == PS3_MATCH_ID_STOR_DISK)
++ ps3_flash_workaround.disk_open = 0;
++
++ if (sbd->match_id == PS3_MATCH_ID_STOR_FLASH) {
++ ps3_flash_workaround.flash_open = 0;
++
++ if (ps3_flash_workaround.disk_sbd) {
++ ps3_close_hv_device(ps3_flash_workaround.disk_sbd);
++ ps3_flash_workaround.disk_open = 0;
++ ps3_flash_workaround.disk_sbd = NULL;
++ }
++ }
++
++ return 0;
++}
+
+ static int ps3stor_probe_access(struct ps3_storage_device *dev)
+ {
+@@ -90,7 +149,7 @@ int ps3stor_setup(struct ps3_storage_dev
+ int error, res, alignment;
+ enum ps3_dma_page_size page_size;
+
+- error = ps3_open_hv_device(&dev->sbd);
++ error = ps3stor_open_hv_device(&dev->sbd);
+ if (error) {
+ dev_err(&dev->sbd.core,
+ "%s:%u: ps3_open_hv_device failed %d\n", __func__,
+@@ -166,7 +225,7 @@ fail_free_irq:
+ fail_sb_event_receive_port_destroy:
+ ps3_sb_event_receive_port_destroy(&dev->sbd, dev->irq);
+ fail_close_device:
+- ps3_close_hv_device(&dev->sbd);
++ ps3stor_close_hv_device(&dev->sbd);
+ fail:
+ return error;
+ }
+@@ -193,7 +252,7 @@ void ps3stor_teardown(struct ps3_storage
+ "%s:%u: destroy event receive port failed %d\n",
+ __func__, __LINE__, error);
+
+- error = ps3_close_hv_device(&dev->sbd);
++ error = ps3stor_close_hv_device(&dev->sbd);
+ if (error)
+ dev_err(&dev->sbd.core,
+ "%s:%u: ps3_close_hv_device failed %d\n", __func__,
input-joydev-decouple-axis-and-button-map-ioctls-from-input-constants.patch
sg-fix-oops-in-the-error-path-in-sg_build_indirect.patch
+agp-intel-remove-restore-in-resume.patch
+ath5k-write-pcu-registers-on-initial-reset.patch
+binfmt_elf-fix-pt_interp-bss-handling.patch
+cfg80211-fix-looping-soft-lockup-in-find_ie.patch
+fix-undefined-reference-to-user_shm_unlock.patch
+powerpc-ps3-workaround-for-flash-memory-i-o-error.patch
+tpm-fixup-boot-probe-timeout-for-tpm_tis-driver.patch
+udf-use-device-size-when-drive-reported-bogus-number-of-written-blocks.patch
--- /dev/null
+From ec57935837a78f9661125b08a5d08b697568e040 Mon Sep 17 00:00:00 2001
+From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
+Date: Wed, 9 Sep 2009 17:22:18 -0600
+Subject: TPM: Fixup boot probe timeout for tpm_tis driver
+
+From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
+
+commit ec57935837a78f9661125b08a5d08b697568e040 upstream.
+
+When probing the device in tpm_tis_init the call request_locality
+uses timeout_a, which wasn't being initalized until after
+request_locality. This results in request_locality falsely timing
+out if the chip is still starting. Move the initialization to before
+request_locality.
+
+This probably only matters for embedded cases (ie mine), a BIOS likely
+gets the TPM into a state where this code path isn't necessary.
+
+Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
+Acked-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
+Signed-off-by: James Morris <jmorris@namei.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/char/tpm/tpm_tis.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/drivers/char/tpm/tpm_tis.c
++++ b/drivers/char/tpm/tpm_tis.c
+@@ -450,6 +450,12 @@ static int tpm_tis_init(struct device *d
+ goto out_err;
+ }
+
++ /* Default timeouts */
++ chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
++ chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
++ chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
++ chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
++
+ if (request_locality(chip, 0) != 0) {
+ rc = -ENODEV;
+ goto out_err;
+@@ -457,12 +463,6 @@ static int tpm_tis_init(struct device *d
+
+ vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
+
+- /* Default timeouts */
+- chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+- chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+- chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+- chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+-
+ dev_info(dev,
+ "1.2 TPM (device-id 0x%X, rev-id %d)\n",
+ vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
--- /dev/null
+From 24a5d59f3477bcff4c069ff4d0ca9a3e037d0235 Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Thu, 18 Jun 2009 12:33:16 +0200
+Subject: udf: Use device size when drive reported bogus number of written blocks
+
+From: Jan Kara <jack@suse.cz>
+
+commit 24a5d59f3477bcff4c069ff4d0ca9a3e037d0235 upstream.
+
+Some drives report 0 as the number of written blocks when there are some blocks
+recorded. Use device size in such case so that we can automagically mount such
+media.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/udf/lowlevel.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/fs/udf/lowlevel.c
++++ b/fs/udf/lowlevel.c
+@@ -56,7 +56,12 @@ unsigned long udf_get_last_block(struct
+ struct block_device *bdev = sb->s_bdev;
+ unsigned long lblock = 0;
+
+- if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
++ /*
++ * ioctl failed or returned obviously bogus value?
++ * Try using the device size...
++ */
++ if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock) ||
++ lblock == 0)
+ lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
+
+ if (lblock)