Skip to content
  1. Jan 01, 2019
    • Finn Thain's avatar
      block/swim3: Fix regression on PowerBook G3 · 427c5ce4
      Finn Thain authored
      
      
      As of v4.20, the swim3 driver crashes when loaded on a PowerBook G3
      (Wallstreet).
      
      MacIO PCI driver attached to Gatwick chipset
      MacIO PCI driver attached to Heathrow chipset
      swim3 0.00015000:floppy: [fd0] SWIM3 floppy controller in media bay
      0.00013020:ch-a: ttyS0 at MMIO 0xf3013020 (irq = 16, base_baud = 230400) is a Z85c30 ESCC - Serial port
      0.00013000:ch-b: ttyS1 at MMIO 0xf3013000 (irq = 17, base_baud = 230400) is a Z85c30 ESCC - Infrared port
      macio: fixed media-bay irq on gatwick
      macio: fixed left floppy irqs
      swim3 1.00015000:floppy: [fd1] Couldn't request interrupt
      Unable to handle kernel paging request for data at address 0x00000024
      Faulting instruction address: 0xc02652f8
      Oops: Kernel access of bad area, sig: 11 [#1]
      BE SMP NR_CPUS=2 PowerMac
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.20.0 #2
      NIP:  c02652f8 LR: c026915c CTR: c0276d1c
      REGS: df43ba10 TRAP: 0300   Not tainted  (4.20.0)
      MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 28228288  XER: 00000100
      DAR: 00000024 DSISR: 40000000
      GPR00: c026915c df43bac0 df439060 c0731524 df494700 00000000 c06e1c08 00000001
      GPR08: 00000001 00000000 df5ff220 00001032 28228282 00000000 c0004ca4 00000000
      GPR16: 00000000 00000000 00000000 c073144c dfffe064 c0731524 00000120 c0586108
      GPR24: c073132c c073143c c073143c 00000000 c0731524 df67cd70 df494700 00000001
      NIP [c02652f8] blk_mq_free_rqs+0x28/0xf8
      LR [c026915c] blk_mq_sched_tags_teardown+0x58/0x84
      Call Trace:
      [df43bac0] [c0045f50] flush_workqueue_prep_pwqs+0x178/0x1c4 (unreliable)
      [df43bae0] [c026915c] blk_mq_sched_tags_teardown+0x58/0x84
      [df43bb00] [c02697f0] blk_mq_exit_sched+0x9c/0xb8
      [df43bb20] [c0252794] elevator_exit+0x84/0xa4
      [df43bb40] [c0256538] blk_exit_queue+0x30/0x50
      [df43bb50] [c0256640] blk_cleanup_queue+0xe8/0x184
      [df43bb70] [c034732c] swim3_attach+0x330/0x5f0
      [df43bbb0] [c034fb24] macio_device_probe+0x58/0xec
      [df43bbd0] [c032ba88] really_probe+0x1e4/0x2f4
      [df43bc00] [c032bd28] driver_probe_device+0x64/0x204
      [df43bc20] [c0329ac4] bus_for_each_drv+0x60/0xac
      [df43bc50] [c032b824] __device_attach+0xe8/0x160
      [df43bc80] [c032ab38] bus_probe_device+0xa0/0xbc
      [df43bca0] [c0327338] device_add+0x3d8/0x630
      [df43bcf0] [c0350848] macio_add_one_device+0x444/0x48c
      [df43bd50] [c03509f8] macio_pci_add_devices+0x168/0x1bc
      [df43bd90] [c03500ec] macio_pci_probe+0xc0/0x10c
      [df43bda0] [c02ad884] pci_device_probe+0xd4/0x184
      [df43bdd0] [c032ba88] really_probe+0x1e4/0x2f4
      [df43be00] [c032bd28] driver_probe_device+0x64/0x204
      [df43be20] [c032bfcc] __driver_attach+0x104/0x108
      [df43be40] [c0329a00] bus_for_each_dev+0x64/0xb4
      [df43be70] [c032add8] bus_add_driver+0x154/0x238
      [df43be90] [c032ca24] driver_register+0x84/0x148
      [df43bea0] [c0004aa0] do_one_initcall+0x40/0x188
      [df43bf00] [c0690100] kernel_init_freeable+0x138/0x1d4
      [df43bf30] [c0004cbc] kernel_init+0x18/0x10c
      [df43bf40] [c00121e4] ret_from_kernel_thread+0x14/0x1c
      Instruction dump:
      5484d97e 4bfff4f4 9421ffe0 7c0802a6 bf410008 7c9e2378 90010024 8124005c
      2f890000 419e0078 81230004 7c7c1b78 <81290024> 2f890000 419e0064 81440000
      ---[ end trace 12025ab921a9784c ]---
      
      Reverting commit 8ccb8cb1 ("swim3: convert to blk-mq") resolves the
      problem.
      
      That commit added a struct blk_mq_tag_set to struct floppy_state and
      initialized it with a blk_mq_init_sq_queue() call. Unfortunately, there
      is a memset() in swim3_add_device() that subsequently clears the
      floppy_state struct. That means fs->tag_set->ops is a NULL pointer, and
      it gets dereferenced by blk_mq_free_rqs() which gets called in the
      request_irq() error path. Move the memset() to fix this bug.
      
      BTW, the request_irq() failure for the left mediabay floppy (fd1) is not
      a regression. I don't know why it happens. The right media bay floppy
      (fd0) works fine however.
      
      Reported-and-tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Fixes: 8ccb8cb1 ("swim3: convert to blk-mq")
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      427c5ce4
    • Finn Thain's avatar
      block/swim3: Fix -EBUSY error when re-opening device after unmount · 296dcc40
      Finn Thain authored
      
      
      When the block device is opened with FMODE_EXCL, ref_count is set to -1.
      This value doesn't get reset when the device is closed which means the
      device cannot be opened again. Fix this by checking for refcount <= 0
      in the release method.
      
      Reported-and-tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      296dcc40
    • Finn Thain's avatar
      block/swim3: Remove dead return statement · f3010ec5
      Finn Thain authored
      
      
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f3010ec5
    • Finn Thain's avatar
      block/amiflop: Don't log error message on invalid ioctl · d4d179c3
      Finn Thain authored
      
      
      Cc: linux-m68k@lists.linux-m68k.org
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      d4d179c3
  2. Dec 29, 2018
    • Wenwen Wang's avatar
      gdrom: fix a memory leak bug · 093c4821
      Wenwen Wang authored
      
      
      In probe_gdrom(), the buffer pointed by 'gd.cd_info' is allocated through
      kzalloc() and is used to hold the information of the gdrom device. To
      register and unregister the device, the pointer 'gd.cd_info' is passed to
      the functions register_cdrom() and unregister_cdrom(), respectively.
      However, this buffer is not freed after it is used, which can cause a
      memory leak bug.
      
      This patch simply frees the buffer 'gd.cd_info' in exit_gdrom() to fix the
      above issue.
      
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      093c4821
  3. Dec 23, 2018
  4. Dec 21, 2018
  5. Dec 20, 2018
    • Ming Lei's avatar
      block: save irq state in blkg_lookup_create() · 3a762de5
      Ming Lei authored
      
      
      blkg_lookup_create() may be called from pool_map() in which
      irq state is saved, so we have to do that in blkg_lookup_create().
      
      Otherwise, the following lockdep warning can be triggered:
      
      [  104.258537] ================================
      [  104.259129] WARNING: inconsistent lock state
      [  104.259725] 4.20.0-rc6+ #545 Not tainted
      [  104.260268] --------------------------------
      [  104.260865] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
      [  104.261727] swapper/49/0 [HC0[0]:SC1[1]:HE0:SE0] takes:
      [  104.262444] 00000000db365b5d (&(&pool->lock)->rlock#3){+.?.}, at: thin_endio+0xcf/0x2a3 [dm_thin_pool]
      [  104.263747] {SOFTIRQ-ON-W} state was registered at:
      [  104.264417]   _raw_spin_unlock_irq+0x29/0x4c
      [  104.265014]   blkg_lookup_create+0xdc/0xe6
      [  104.265609]   bio_associate_blkg_from_css+0xd3/0x13f
      [  104.266312]   bio_associate_blkg+0x15a/0x1bb
      [  104.266913]   pool_map+0xe8/0x103 [dm_thin_pool]
      [  104.267572]   __map_bio+0x98/0x29c [dm_mod]
      [  104.268162]   __split_and_process_non_flush+0x29e/0x306 [dm_mod]
      [  104.269003]   __split_and_process_bio+0x16a/0x25b [dm_mod]
      [  104.269971]   __dm_make_request.isra.14+0xdc/0x124 [dm_mod]
      [  104.270973]   generic_make_request+0x3f5/0x68b
      [  104.271676]   process_prepared_mapping+0x166/0x1ef [dm_thin_pool]
      [  104.272531]   schedule_zero+0x239/0x273 [dm_thin_pool]
      [  104.273245]   process_cell+0x60c/0x6f1 [dm_thin_pool]
      [  104.273967]   do_worker+0x60c/0xca8 [dm_thin_pool]
      [  104.274635]   process_one_work+0x4eb/0x834
      [  104.275203]   worker_thread+0x318/0x484
      [  104.275740]   kthread+0x1d1/0x1e1
      [  104.276203]   ret_from_fork+0x3a/0x50
      [  104.276714] irq event stamp: 170003
      [  104.277201] hardirqs last  enabled at (170002): [<ffffffff81bcc33e>] _raw_spin_unlock_irqrestore+0x44/0x6b
      [  104.278535] hardirqs last disabled at (170003): [<ffffffff81bcc1ad>] _raw_spin_lock_irqsave+0x20/0x55
      [  104.280273] softirqs last  enabled at (169978): [<ffffffff810d13d4>] irq_enter+0x4c/0x73
      [  104.281617] softirqs last disabled at (169979): [<ffffffff810d1479>] irq_exit+0x7e/0x11d
      [  104.282744]
      [  104.282744] other info that might help us debug this:
      [  104.283640]  Possible unsafe locking scenario:
      [  104.283640]
      [  104.284452]        CPU0
      [  104.284803]        ----
      [  104.285150]   lock(&(&pool->lock)->rlock#3);
      [  104.285762]   <Interrupt>
      [  104.286130]     lock(&(&pool->lock)->rlock#3);
      [  104.286750]
      [  104.286750]  *** DEADLOCK ***
      [  104.286750]
      [  104.287564] no locks held by swapper/49/0.
      [  104.288129]
      [  104.288129] stack backtrace:
      [  104.288738] CPU: 49 PID: 0 Comm: swapper/49 Not tainted 4.20.0-rc6+ #545
      [  104.289700] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-2.fc27 04/01/2014
      [  104.290858] Call Trace:
      [  104.291204]  <IRQ>
      [  104.291502]  dump_stack+0x9a/0xe6
      [  104.291968]  mark_lock+0x56c/0x7a6
      [  104.292442]  ? check_usage_backwards+0x209/0x209
      [  104.293086]  __lock_acquire+0x400/0x15bf
      [  104.293662]  ? check_chain_key+0x150/0x1aa
      [  104.294236]  lock_acquire+0x1a6/0x1e3
      [  104.294768]  ? thin_endio+0xcf/0x2a3 [dm_thin_pool]
      [  104.295444]  ? _raw_spin_unlock_irqrestore+0x44/0x6b
      [  104.296143]  ? process_prepared_discard_fail+0x36/0x36 [dm_thin_pool]
      [  104.297031]  _raw_spin_lock_irqsave+0x46/0x55
      [  104.297659]  ? thin_endio+0xcf/0x2a3 [dm_thin_pool]
      [  104.298335]  thin_endio+0xcf/0x2a3 [dm_thin_pool]
      [  104.298997]  ? process_prepared_discard_fail+0x36/0x36 [dm_thin_pool]
      [  104.299886]  ? check_flags+0x20a/0x20a
      [  104.300408]  ? lock_acquire+0x1a6/0x1e3
      [  104.300954]  ? process_prepared_discard_fail+0x36/0x36 [dm_thin_pool]
      [  104.301865]  clone_endio+0x1bb/0x22d [dm_mod]
      [  104.302491]  ? disable_write_zeroes+0x20/0x20 [dm_mod]
      [  104.303200]  ? bio_disassociate_blkg+0xc6/0x15f
      [  104.303836]  ? bio_endio+0x2b2/0x2da
      [  104.304349]  clone_endio+0x1f3/0x22d [dm_mod]
      [  104.304978]  ? disable_write_zeroes+0x20/0x20 [dm_mod]
      [  104.305709]  ? bio_disassociate_blkg+0xc6/0x15f
      [  104.306333]  ? bio_endio+0x2b2/0x2da
      [  104.306853]  clone_endio+0x1f3/0x22d [dm_mod]
      [  104.307476]  ? disable_write_zeroes+0x20/0x20 [dm_mod]
      [  104.308185]  ? bio_disassociate_blkg+0xc6/0x15f
      [  104.308817]  ? bio_endio+0x2b2/0x2da
      [  104.309319]  blk_update_request+0x2de/0x4cc
      [  104.309927]  blk_mq_end_request+0x2a/0x183
      [  104.310498]  blk_done_softirq+0x16a/0x1a6
      [  104.311051]  ? blk_softirq_cpu_dead+0xe2/0xe2
      [  104.311653]  ? __lock_is_held+0x2a/0x87
      [  104.312186]  __do_softirq+0x250/0x4e8
      [  104.312705]  irq_exit+0x7e/0x11d
      [  104.313157]  call_function_single_interrupt+0xf/0x20
      [  104.313860]  </IRQ>
      [  104.314163] RIP: 0010:native_safe_halt+0x2/0x3
      [  104.314792] Code: 63 02 df f0 83 44 24 fc 00 48 89 df e8 cc 3f 7a ff 48 8b 03 a8 08 74 0b 65 81 25 9d 31 45 7e ff ff ff 7f 5b 5d 41 5c c3 fb f4 <c3> f4 c3 0f 1f 44 00 00 41 56 41 55 41 54 55 53 e8 a2 0d 5c ff e8
      [  104.317339] RSP: 0018:ffff888106c9fdc0 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff04
      [  104.318390] RAX: 1ffff11020d92100 RBX: 0000000000000000 RCX: ffffffff81159ac7
      [  104.319366] RDX: 1ffffffff05d5e69 RSI: 0000000000000007 RDI: ffff888106c90d1c
      [  104.320339] RBP: 0000000000000000 R08: dffffc0000000000 R09: 0000000000000001
      [  104.321313] R10: ffffed1025d57ba0 R11: ffffed1025d57b9f R12: 1ffff11020d93fbf
      [  104.322328] R13: 0000000000000031 R14: ffff888106c90040 R15: 0000000000000000
      [  104.323307]  ? lockdep_hardirqs_on+0x26b/0x278
      [  104.323927]  default_idle+0xd9/0x1a8
      [  104.324427]  do_idle+0x162/0x2b2
      [  104.324891]  ? arch_cpu_idle_exit+0x28/0x28
      [  104.325467]  ? mark_held_locks+0x28/0x7f
      [  104.326031]  ? _raw_spin_unlock_irqrestore+0x44/0x6b
      [  104.326719]  cpu_startup_entry+0x1d/0x1f
      [  104.327261]  start_secondary+0x2cb/0x308
      [  104.327806]  ? set_cpu_sibling_map+0x8a3/0x8a3
      [  104.328421]  secondary_startup_64+0xa4/0xb0
      
      Fixes: b978962a ("blkcg: update blkg_lookup_create() to do locking")
      Cc: Mike Snitzer <snitzer@redhat.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      3a762de5
    • Jens Axboe's avatar
      dm: don't reuse bio for flushes · dbe3ece1
      Jens Axboe authored
      
      
      DM currently has a statically allocated bio that it uses to issue empty
      flushes. It doesn't submit this bio, it just uses it for maintaining
      state while setting up clones. Multiple users can access this bio at the
      same time. This wasn't previously an issue, even if it was a bit iffy,
      but with the blkg associations it can become one.
      
      We setup the blkg association, then clone bio's and submit, then remove
      the blkg assocation again. But since we can have multiple tasks doing
      this at the same time, against multiple blkg's, then we can either lose
      references to a blkg, or put it twice. The latter causes complaints on
      the percpu ref being <= 0 when released, and can cause use-after-free as
      well. Ming reports that xfstest generic/475 triggers this:
      
      ------------[ cut here ]------------
      percpu ref (blkg_release) <= 0 (0) after switching to atomic
      WARNING: CPU: 13 PID: 0 at lib/percpu-refcount.c:155 percpu_ref_switch_to_atomic_rcu+0x2c9/0x4a0
      
      Switch to just using an on-stack bio for this, and get rid of the
      embedded bio.
      
      Fixes: 5cdf2e3f ("blkcg: associate blkg when associating a device")
      Reported-by: default avatarMing Lei <ming.lei@redhat.com>
      Tested-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      dbe3ece1
  6. Dec 19, 2018