16 Dec, 2009

2 commits

  • gcc is not convinced that the floppy.c ioctl has sufficient bound checks:

    In function `copy_from_user',
    inlined from `fd_copyin' at drivers/block/floppy.c:3080,
    inlined from `fd_ioctl' at drivers/block/floppy.c:3503:
    arch/x86/include/asm/uaccess_32.h:211:
    warning: call to `copy_from_user_overflow' declared with attribute
    warning: copy_from_user buffer size is not provably correct

    And frankly, as a human I have a hard time proving the same more or less
    (the size comes from the ioctl argument. humpf. maybe. the code isn't
    very nice)

    This patch adds an explicit check to make 100% sure it's safe, better than
    finding out later that there indeed was a gap.

    [akpm@linux-foundation.org: add WARN_ON()]
    Signed-off-by: Arjan van de Ven
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     
  • Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

22 Sep, 2009

1 commit


15 Sep, 2009

1 commit

  • Gets rid of the following warning:
    Platform driver 'floppy' needs updating - please use dev_pm_ops

    [rjw: Fixed up the definition of floppy_pm_ops.]

    Signed-off-by: Frans Pop
    Signed-off-by: Andrew Morton
    Signed-off-by: Rafael J. Wysocki

    Frans Pop
     

01 Jul, 2009

1 commit

  • A crappy macro prevents us unlocking on a fail path.

    Expand the macro and unlock appropriatelly.

    Signed-off-by: Jiri Slaby
    Cc: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Slaby
     

11 Jun, 2009

1 commit

  • Based on Ingo Molnar's patch from 2006, this makes the floppy work after
    resume from hibernation, at least on my machine.

    This fix resets the floppy controller on resume. It was experimentally
    determined to bring the controller back to life - we don't really know why
    it works.

    floppy_init() does the same thing at boot/modprobe time.

    Signed-off-by: Ondrej Zary
    Cc: "Rafael J. Wysocki"
    Cc: Ingo Molnar
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Jens Axboe

    Ondrej Zary
     

11 May, 2009

4 commits

  • Till now block layer allowed two separate modes of request execution.
    A request is always acquired from the request queue via
    elv_next_request(). After that, drivers are free to either dequeue it
    or process it without dequeueing. Dequeue allows elv_next_request()
    to return the next request so that multiple requests can be in flight.

    Executing requests without dequeueing has its merits mostly in
    allowing drivers for simpler devices which can't do sg to deal with
    segments only without considering request boundary. However, the
    benefit this brings is dubious and declining while the cost of the API
    ambiguity is increasing. Segment based drivers are usually for very
    old or limited devices and as converting to dequeueing model isn't
    difficult, it doesn't justify the API overhead it puts on block layer
    and its more modern users.

    Previous patches converted all block low level drivers to dequeueing
    model. This patch completes the API transition by...

    * renaming elv_next_request() to blk_peek_request()

    * renaming blkdev_dequeue_request() to blk_start_request()

    * adding blk_fetch_request() which is combination of peek and start

    * disallowing completion of queued (not started) requests

    * applying new API to all LLDs

    Renamings are for consistency and to break out of tree code so that
    it's apparent that out of tree drivers need updating.

    [ Impact: block request issue API cleanup, no functional change ]

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Cc: James Bottomley
    Cc: Mike Miller
    Cc: unsik Kim
    Cc: Paul Clements
    Cc: Tim Waugh
    Cc: Geert Uytterhoeven
    Cc: David S. Miller
    Cc: Laurent Vivier
    Cc: Jeff Garzik
    Cc: Jeremy Fitzhardinge
    Cc: Grant Likely
    Cc: Adrian McMenamin
    Cc: Stephen Rothwell
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Cc: Alex Dubov
    Cc: Pierre Ossman
    Cc: David Woodhouse
    Cc: Markus Lidel
    Cc: Stefan Weinhuber
    Cc: Martin Schwidefsky
    Cc: Pete Zaitcev
    Cc: FUJITA Tomonori
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • plat-omap/mailbox, floppy, viocd, mspro_block, i2o_block and
    mmc/card/queue are already pretty close to dequeueing model and can be
    converted with simple changes. Convert them.

    While at it,

    * xen-blkfront: !fs check moved downwards to share dequeue call with
    normal path.

    * mspro_block: __blk_end_request(..., blk_rq_cur_byte()) converted to
    __blk_end_request_cur()

    * mmc/card/queue: loop of __blk_end_request() converted to
    __blk_end_request_all()

    [ Impact: dequeue in-flight request ]

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Cc: Jeremy Fitzhardinge
    Cc: Stephen Rothwell
    Cc: Alex Dubov
    Cc: Markus Lidel
    Cc: Pierre Ossman
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • With the previous changes, the followings are now guaranteed for all
    requests in any valid state.

    * blk_rq_sectors() == blk_rq_bytes() >> 9
    * blk_rq_cur_sectors() == blk_rq_cur_bytes() >> 9

    Clean up accessor usages. Notable changes are

    * nbd,i2o_block: end_all used instead of explicit byte count
    * scsi_lib: unnecessary conditional on request type removed

    [ Impact: cleanup ]

    Signed-off-by: Tejun Heo
    Cc: Paul Clements
    Cc: Pete Zaitcev
    Cc: Alex Dubov
    Cc: Markus Lidel
    Cc: David Woodhouse
    Cc: James Bottomley
    Cc: Boaz Harrosh
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • With recent cleanups, there is no place where low level driver
    directly manipulates request fields. This means that the 'hard'
    request fields always equal the !hard fields. Convert all
    rq->sectors, nr_sectors and current_nr_sectors references to
    accessors.

    While at it, drop superflous blk_rq_pos() < 0 test in swim.c.

    [ Impact: use pos and nr_sectors accessors ]

    Signed-off-by: Tejun Heo
    Acked-by: Geert Uytterhoeven
    Tested-by: Grant Likely
    Acked-by: Grant Likely
    Tested-by: Adrian McMenamin
    Acked-by: Adrian McMenamin
    Acked-by: Mike Miller
    Cc: James Bottomley
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Cc: Eric Moore
    Cc: Alan Stern
    Cc: FUJITA Tomonori
    Cc: Pete Zaitcev
    Cc: Stephen Rothwell
    Cc: Paul Clements
    Cc: Tim Waugh
    Cc: Jeff Garzik
    Cc: Jeremy Fitzhardinge
    Cc: Alex Dubov
    Cc: David Woodhouse
    Cc: Martin Schwidefsky
    Cc: Dario Ballabio
    Cc: David S. Miller
    Cc: Rusty Russell
    Cc: unsik Kim
    Cc: Laurent Vivier
    Signed-off-by: Jens Axboe

    Tejun Heo
     

03 Apr, 2009

1 commit

  • The missing device table means that the floppy module is not auto-loaded,
    even when the appropriate PNP device (0700) is found.

    We don't actually use the table in the module, since the device doesn't
    have a struct pnp_driver, but it's sufficient to cause an alias in the
    module that udev/modprobe will use.

    Signed-off-by: Scott James Remnant
    Signed-off-by: Tim Gardner
    Cc: Bjorn Helgaas
    Cc: Philippe De Muyter
    Acked-by: Kay Sievers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Scott James Remnant
     

25 Mar, 2009

1 commit


19 Feb, 2009

1 commit

  • The floppy driver requests an I/O port it doesn't need, and sometimes this
    causes a conflict with a motherboard device reported by PNPBIOS.

    This patch makes the floppy driver request and release only the ports it
    actually uses. It also factors out the request/release stuff and the
    io-ports list so they're all in one place now.

    The current floppy driver uses only these ports:

    0x3f2 (FD_DOR)
    0x3f4 (FD_STATUS)
    0x3f5 (FD_DATA)
    0x3f7 (FD_DCR/FD_DIR)

    but it requests 0x3f2-0x3f5 and 0x3f7, which includes the unused port
    0x3f3.

    Some BIOSes report 0x3f3 as a motherboard resource. The PNP system driver
    reserves that, which causes a conflict when the floppy driver requests
    0x3f2-0x3f5 later.

    Philippe reported that this conflict broke the floppy driver between
    2.6.11 and 2.6.22. His PNPBIOS reports these devices:

    $ cat 00:07/id 00:07/resources # motherboard device
    PNP0c02
    state = active
    io 0x80-0x80
    io 0x10-0x1f
    io 0x22-0x3f
    io 0x44-0x5f
    io 0x90-0x9f
    io 0xa2-0xbf
    io 0x3f0-0x3f1
    io 0x3f3-0x3f3

    $ cat 00:03/id 00:03/resources # floppy device
    PNP0700
    state = active
    io 0x3f4-0x3f5
    io 0x3f2-0x3f2

    Reference:
    http://lkml.org/lkml/2009/1/31/162

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: Philippe De Muyter
    Reported-by: Philippe De Muyter
    Tested-by: Philippe De Muyter
    Cc: Adam M Belay
    Cc: Robert Hancock
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Philippe De Muyter
     

15 Nov, 2008

1 commit


21 Oct, 2008

4 commits

  • Signed-off-by: Al Viro

    Al Viro
     
  • To keep the size of changesets sane we split the switch by drivers;
    to keep the damn thing bisectable we do the following:
    1) rename the affected methods, add ones with correct
    prototypes, make (few) callers handle both. That's this changeset.
    2) for each driver convert to new methods. *ALL* drivers
    are converted in this series.
    3) kill the old (renamed) methods.

    Note that it _is_ a flagday; all in-tree drivers are converted and by the
    end of this series no trace of old methods remain. The only reason why
    we do that this way is to keep the damn thing bisectable and allow per-driver
    debugging if anything goes wrong.

    New methods:
    open(bdev, mode)
    release(disk, mode)
    ioctl(bdev, mode, cmd, arg) /* Called without BKL */
    compat_ioctl(bdev, mode, cmd, arg)
    locked_ioctl(bdev, mode, cmd, arg) /* Called with BKL, legacy */

    Signed-off-by: Al Viro

    Al Viro
     
  • store needed information in f_mode

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     

15 Oct, 2008

1 commit


09 Oct, 2008

2 commits

  • The current floppy_struct allows floppies to number sectors starting
    from 0 or 1. This patch allows arbitrary first-sector numbers - for
    example, 0xC1 for Amstrad CPC disks.

    This extends the existing 1-bit field (FD_ZEROBASED, bit 2 of stretch)
    to 8 bits (FD_SECTMASK, bits 2 to 9).

    Currently 0x00 denotes a first sector number of 1, and 0x01 denotes a
    first sector number of 0. We extend this by interpreting FD_SECTMASK
    as the first sector number with the LSB flipped.

    Signed-off-by: Keith Wansbrough
    Cc: Alain Knaff
    Cc: Michael Kerrisk
    Cc: Karel Zak
    Signed-off-by: Andrew Morton
    Signed-off-by: Jens Axboe

    Keith Wansbrough
     
  • The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
    (d)) but is perhaps more readable.

    An extract of the semantic patch that makes this change is as follows:
    (http://www.emn.fr/x-info/coccinelle/)

    //
    @haskernel@
    @@

    #include

    @depends on haskernel@
    expression n,d;
    @@

    (
    - (n + d - 1) / d
    + DIV_ROUND_UP(n,d)
    |
    - (n + (d - 1)) / d
    + DIV_ROUND_UP(n,d)
    )

    @depends on haskernel@
    expression n,d;
    @@

    - DIV_ROUND_UP((n),d)
    + DIV_ROUND_UP(n,d)

    @depends on haskernel@
    expression n,d;
    @@

    - DIV_ROUND_UP(n,(d))
    + DIV_ROUND_UP(n,d)
    //

    Signed-off-by: Julia Lawall
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Jens Axboe

    Julia Lawall
     

23 Sep, 2008

1 commit


29 Apr, 2008

1 commit


14 Mar, 2008

1 commit

  • Floppy rmmod locks up when no such hardware was initialized, since there is
    nobody to wake the remove code up. Remove the completion, because release is
    called during platform_unregister anyway.

    Signed-off-by: Jiri Slaby
    Cc: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Slaby
     

28 Jan, 2008

1 commit

  • This patch converts floppy to use blk_end_request interfaces.
    Related 'uptodate' arguments are converted to 'error'.

    As a result, the interface of internal function, floppy_end_request(),
    is changed.

    Signed-off-by: Kiyoshi Ueda
    Signed-off-by: Jun'ichi Nomura
    Signed-off-by: Jens Axboe

    Kiyoshi Ueda
     

17 Oct, 2007

4 commits

  • The floppy drive is slow. These days I see absolutely no good reason why the
    floppy driver should try to gain a tiny bit of speed by telling gcc to
    optimize access to some variables via the register keyword. Better to just
    leave gcc free to do whatever optimizations it deduces to be sane and not
    hamper it by telling it that some variables in the floppy driver are special
    and need to be fast (they don't).

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • A good initial step for a cleanup seems to me to be getting rid of old dead
    code. This stuff is either commented out or inside '#if 0' so it is not
    currently in use at all, let's just get rid of it once and for all. That's a
    few lines less to deal with.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • Yes, some of this will likely be replaced in later patches, but I do not see
    anyone else coming out of the woodwork with any patches for this driver, so
    I'll ignore comments about churn. I want to get this driver cleaned up, and
    if I'm going to do so I want to start with this basic style cleanup to reduce
    the reading pain a bit.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • The floppy driver is already written to be able to operate in virtual DMA
    mode. Thus it can easily be adjusted to tolerate failure from
    fd_request_dma() as long as virtual DMA mode is not disallowed.

    Signed-off-by: Jan Beulich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     

10 Oct, 2007

2 commits

  • As bi_end_io is only called once when the reqeust is complete,
    the 'size' argument is now redundant. Remove it.

    Now there is no need for bio_endio to subtract the size completed
    from bi_size. So don't do that either.

    While we are at it, change bi_end_io to return void.

    Signed-off-by: Neil Brown
    Signed-off-by: Jens Axboe

    NeilBrown
     
  • Every usage of rq_for_each_bio wraps a usage of
    bio_for_each_segment, so these can be combined into
    rq_for_each_segment.

    We define "struct req_iterator" to hold the 'bio' and 'index' that
    are needed for the double iteration.

    Signed-off-by: Neil Brown

    Various compile fixes by me...

    Signed-off-by: Jens Axboe

    NeilBrown
     

24 Jul, 2007

1 commit


24 May, 2007

1 commit

  • Another coverity patch i forgot to resend, original thread here
    http://marc.info/?l=linux-kernel&m=115144559823592&w=2

    In case drive == N_DRIVE, we get one past the drive_params array.

    Signed-off-by: Eric Sesterhenn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sesterhenn / Snakebyte
     

09 May, 2007

1 commit


21 Feb, 2007

1 commit

  • If one of clear_bit, change_bit or set_bit is defined as a do { } while (0)
    function usage of these functions in parenthesis like

    (foo_bit(23, &var))

    while be expaned to something like

    (do { ... } while (0)}).

    resulting in a build error. This patch removes the useless parenthesis.

    Signed-off-by: Ralf Baechle
    Cc: Trond Myklebust
    Cc: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ralf Baechle
     

22 Nov, 2006

3 commits

  • Pass the work_struct pointer to the work function rather than context data.
    The work function can use container_of() to work out the data.

    For the cases where the container of the work_struct may go away the moment the
    pending bit is cleared, it is made possible to defer the release of the
    structure by deferring the clearing of the pending bit.

    To make this work, an extra flag is introduced into the management side of the
    work_struct. This governs auto-release of the structure upon execution.

    Ordinarily, the work queue executor would release the work_struct for further
    scheduling or deallocation by clearing the pending bit prior to jumping to the
    work function. This means that, unless the driver makes some guarantee itself
    that the work_struct won't go away, the work function may not access anything
    else in the work_struct or its container lest they be deallocated.. This is a
    problem if the auxiliary data is taken away (as done by the last patch).

    However, if the pending bit is *not* cleared before jumping to the work
    function, then the work function *may* access the work_struct and its container
    with no problems. But then the work function must itself release the
    work_struct by calling work_release().

    In most cases, automatic release is fine, so this is the default. Special
    initiators exist for the non-auto-release case (ending in _NAR).

    Signed-Off-By: David Howells

    David Howells
     
  • Reclaim a word from the size of the work_struct by folding the pending bit and
    the wq_data pointer together. This shouldn't cause misalignment problems as
    all pointers should be at least 4-byte aligned.

    Signed-Off-By: David Howells

    David Howells
     
  • Define a type for the work function prototype. It's not only kept in the
    work_struct struct, it's also passed as an argument to several functions.

    This makes it easier to change it.

    Signed-Off-By: David Howells

    David Howells
     

05 Oct, 2006

1 commit

  • Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
    of passing regs around manually through all ~1800 interrupt handlers in the
    Linux kernel.

    The regs pointer is used in few places, but it potentially costs both stack
    space and code to pass it around. On the FRV arch, removing the regs parameter
    from all the genirq function results in a 20% speed up of the IRQ exit path
    (ie: from leaving timer_interrupt() to leaving do_IRQ()).

    Where appropriate, an arch may override the generic storage facility and do
    something different with the variable. On FRV, for instance, the address is
    maintained in GR28 at all times inside the kernel as part of general exception
    handling.

    Having looked over the code, it appears that the parameter may be handed down
    through up to twenty or so layers of functions. Consider a USB character
    device attached to a USB hub, attached to a USB controller that posts its
    interrupts through a cascaded auxiliary interrupt controller. A character
    device driver may want to pass regs to the sysrq handler through the input
    layer which adds another few layers of parameter passing.

    I've build this code with allyesconfig for x86_64 and i386. I've runtested the
    main part of the code on FRV and i386, though I can't test most of the drivers.
    I've also done partial conversion for powerpc and MIPS - these at least compile
    with minimal configurations.

    This will affect all archs. Mostly the changes should be relatively easy.
    Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

    struct pt_regs *old_regs = set_irq_regs(regs);

    And put the old one back at the end:

    set_irq_regs(old_regs);

    Don't pass regs through to generic_handle_irq() or __do_IRQ().

    In timer_interrupt(), this sort of change will be necessary:

    - update_process_times(user_mode(regs));
    - profile_tick(CPU_PROFILING, regs);
    + update_process_times(user_mode(get_irq_regs()));
    + profile_tick(CPU_PROFILING);

    I'd like to move update_process_times()'s use of get_irq_regs() into itself,
    except that i386, alone of the archs, uses something other than user_mode().

    Some notes on the interrupt handling in the drivers:

    (*) input_dev() is now gone entirely. The regs pointer is no longer stored in
    the input_dev struct.

    (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
    something different depending on whether it's been supplied with a regs
    pointer or not.

    (*) Various IRQ handler function pointers have been moved to type
    irq_handler_t.

    Signed-Off-By: David Howells
    (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)

    David Howells
     

01 Oct, 2006

1 commit

  • Right now ->flags is a bit of a mess: some are request types, and
    others are just modifiers. Clean this up by splitting it into
    ->cmd_type and ->cmd_flags. This allows introduction of generic
    Linux block message types, useful for sending generic Linux commands
    to block devices.

    Signed-off-by: Jens Axboe

    Jens Axboe