24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

12 Mar, 2020

1 commit


21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

19 Dec, 2018

1 commit

  • The same effects can be achieved by setting the dma_boundary to
    PAGE_SIZE - 1 and the max_segment_size to PAGE_SIZE, so shift those
    settings into the drivers. Note that in many cases the setting might
    be bogus, but this keeps the status quo.

    [mkp: fix myrs and myrb]

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Christoph Hellwig
     

26 Aug, 2017

1 commit


25 Aug, 2017

1 commit

  • pnp_device_id are not supposed to change at runtime. All functions
    working with pnp_device_id provided by work with const
    pnp_device_id. So mark the non-const structs as const.

    Signed-off-by: Arvind Yadav
    Acked-by: Finn Thain
    Signed-off-by: Martin K. Petersen

    Arvind Yadav
     

08 Aug, 2017

6 commits

  • Limit PDMA send to 512 B to avoid data corruption on DTC3181E. The
    corruption is always the same: one byte missing at the beginning of a
    128 B block. It happens only with slow Quantum LPS 240 drive, not with
    faster IBM DORS-32160. It's not clear what causes this. Documentation
    for the DTC436 chip has not been made available.

    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • The polling loops in pread() and pwrite() can easily become infinite
    loops and hang the machine.

    Merge the IRQ check into host buffer wait loop and add polling limit.

    Also place a limit on polling for 53C80 registers accessibility.

    [Use NCR5380_poll_politely2() for register polling. Rely on polling for
    gated IRQ rather than polling for phase error, like the algorithm in the
    53c400 datasheet. Move DTC436 workarounds into a separate patch.
    Factor-out common code as wait_for_53c80_access(). Rework the residual
    calculations. -- F.T.]

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • The word "read" may be used to mean "DMA read operation" or "SCSI READ
    command", though a READ command implies writing to memory.

    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • When an IRQ arrives during PDMA transfer, pread() and pwrite() return
    without waiting for the 53C80 registers to be ready and this ends up
    messing up the chip state. This was observed with SONY CDU-55S which is
    slow enough to disconnect during 4096-byte reads.

    IRQ during PDMA is not an error so don't return -1. Instead, store the
    remaining byte count for use by NCR5380_dma_residual().

    [Poll for the BASR_END_DMA_TRANSFER condition rather than remove the
    error message -- F.T.]

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • generic_NCR5380_dma_xfer_len() incorrectly uses cmd->transfersize which
    causes rescan-scsi-bus and CD-ROM access to hang the system. Use
    cmd->SCp.this_residual instead, like other NCR5380 drivers.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     

20 Apr, 2017

1 commit

  • When the kernel is running in secure boot mode, we lock down the kernel to
    prevent userspace from modifying the running kernel image. Whilst this
    includes prohibiting access to things like /dev/mem, it must also prevent
    access by means of configuring driver modules in such a way as to cause a
    device to access or modify the kernel image.

    To this end, annotate module_param* statements that refer to hardware
    configuration and indicate for future reference what type of parameter they
    specify. The parameter parser in the core sees this information and can
    skip such parameters with an error message if the kernel is locked down.
    The module initialisation then runs as normal, but just sees whatever the
    default values for those parameters is.

    Note that we do still need to do the module initialisation because some
    drivers have viable defaults set in case parameters aren't specified and
    some drivers support automatic configuration (e.g. PNP or PCI) in addition
    to manually coded parameters.

    This patch annotates drivers in drivers/scsi/.

    Suggested-by: Alan Cox
    Signed-off-by: David Howells
    cc: "Juergen E. Fischer"
    cc: "James E.J. Bottomley"
    cc: "Martin K. Petersen"
    cc: Dario Ballabio
    cc: Finn Thain
    cc: Michael Schmitz
    cc: Achim Leubner
    cc: linux-scsi@vger.kernel.org

    David Howells
     

01 Feb, 2017

1 commit

  • The NCR5380 wrapper drivers don't export symbols or declarations and
    don't actually need separate header files. Most of these header files
    were removed already; only sun3_scsi.h and g_NCR5380.h remain.

    Move the remaining definitions to the corresponding .c files to improve
    readability and proximity. The #defines which influence the #included
    core driver are no longer mixed up with unrelated #defines and #includes.

    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Tested-by: Michael Schmitz
    Signed-off-by: Martin K. Petersen

    Finn Thain
     

09 Dec, 2016

4 commits

  • Automatically probe the board irq when no irq parameter is provided, to
    simulate PnP. The old default behaviour was to disable the irq.

    Update driver documentation accordingly and add some printk messages to
    make this behaviour visible.

    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • When IRQ_AUTO is used, the interrupt for HP C2502 cards gets disabled.
    Fix this by programming the card for a suitable free irq. The code for
    the free irq search comes from ALSA.

    Also allow IRQ 9 to work (it aliases to IRQ 2 on the card), as per
    Ondrej Zary's patch.

    Suggested-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Use standard probe_irq_on() and probe_irq_off() functions instead of own
    implementation. This prevents warning messages like this in the kernel
    log: genirq: Flags mismatch irq 1. 00000000 (NCR-probe) vs. 00000080
    (i8042)

    Move the IRQ trigger code from NCR5380 to g_NCR5380 where it is used.

    Also clear interrupt flag before and after the probe.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Write and read back mode register to check that a chip is really there.
    If no card is present, reads result in 0xff.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     

12 Nov, 2016

1 commit

  • When a SW-configurable card is specified but not found, the driver
    releases wrong region, causing the following message in kernel log:
    Trying to free nonexistent resource

    Fix it by assigning base earlier.

    Signed-off-by: Ondrej Zary
    Fixes: a8cfbcaec0c1 ("scsi: g_NCR5380: Stop using scsi_module.c")
    Signed-off-by: Finn Thain
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     

09 Nov, 2016

3 commits

  • Apply prototypes to get consistent function signatures for the DMA
    functions implemented in the board-specific drivers. To avoid using
    macros to alter actual parameters, some of those functions are reworked
    slightly.

    This is a step toward the goal of passing the board-specific routines
    to the core driver using an ops struct (as in a platform driver or
    library module).

    This also helps fix some inconsistent types: where the core driver uses
    ints (cmd->SCp.this_residual and hostdata->dma_len) for keeping track of
    transfers, certain board-specific routines used unsigned long.

    While we are fixing these function signatures, pass the hostdata pointer
    to DMA routines instead of a Scsi_Host pointer, for shorter and faster
    code.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Ondrej Zary
    Tested-by: Michael Schmitz
    Acked-by: Russell King
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • The various 5380 drivers inconsistently store register pointers
    either in the Scsi_Host struct "legacy crap" area or in special,
    board-specific members of the NCR5380_hostdata struct. Uniform
    use of the latter struct makes for simpler and faster code (see
    the following patches) and helps to reduce use of the
    NCR5380_implementation_fields macro.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Ondrej Zary
    Tested-by: Michael Schmitz
    Acked-by: Russell King
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Merge the port-mapped IO and memory-mapped IO support (with the help of
    ioport_map) into the g_NCR5380 module and delete g_NCR5380_mmio.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     

30 Sep, 2016

3 commits

  • Convert g_NCR5380 to use scsi_add_host instead of scsi_module.c Use
    pnp_driver and isa_driver to manage cards.

    In order to support multiple cards, new module parameter format is
    introduced. The old parameters are kept for compatibility.

    Signed-off-by: Ondrej Zary
    Acked-by: Finn Thain
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Remove compile-time card type definition GENERIC_NCR5380_OVERRIDE. Then
    remove all code iterating the overrides[] array and reduce it to struct
    card.

    Signed-off-by: Ondrej Zary
    Acked-by: Finn Thain
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Remove deprecated __setup for parsing command line parameters.
    g_NCR5380.* parameters could be used instead.

    This might break existing setups with g_NCR5380 built-in (if there are
    any). But it has to go in order to remove the overrides[] array.

    Signed-off-by: Ondrej Zary
    Acked-by: Finn Thain
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     

12 Apr, 2016

8 commits

  • Update kernel parameter documentation for atari_scsi, mac_scsi and
    g_NCR5380 drivers. Remove duplication.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Adopt the DMA implementation from atari_NCR5380.c. This means that
    atari_scsi and sun3_scsi can make use of the NCR5380.c core driver
    and the atari_NCR5380.c driver fork can be made redundant.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Those wrapper drivers which use DMA define the REAL_DMA macro and
    those which use pseudo DMA define PSEUDO_DMA. These macros need to be
    removed for a number of reasons, not least of which is to have drivers
    share more code.

    Redefine the PDMA send and receive hooks as DMA setup hooks, so that the
    DMA code can be shared by all 5380 wrapper drivers. This will help to
    reunify the forked core driver.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • For those wrapper drivers which only implement Programmed IO, have
    NCR5380_dma_xfer_len() evaluate to zero. That allows PDMA to be easily
    disabled at run-time and so the PSEUDO_DMA macro is no longer needed.

    Also remove the spin counters used for debugging pseudo DMA drivers.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • The only chip that needs the workarounds enabled is an early NMOS
    device. That means that the common case is to disable them.

    Unfortunately the sense of the flag is such that it has to be set
    for the common case.

    Rename the flag so that zero can be used to mean "no errata workarounds
    needed". This simplifies the code.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • Drivers that define PSEUDO_DMA also define NCR5380_dma_xfer_len.
    The core driver must call NCR5380_dma_xfer_len which means
    FLAG_NO_PSEUDO_DMA can be eradicated from the core driver.

    dmx3191d doesn't define PSEUDO_DMA and has no use for FLAG_NO_PSEUDO_DMA,
    so remove it there also.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Michael Schmitz
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     
  • This change brings a number of improvements: fewer macros, better test
    coverage, simpler code and sane Kconfig options. The downside is a small
    chance of incompatibility (which seems unavoidable).

    CONFIG_SCSI_GENERIC_NCR53C400 exists to enable or inhibit pseudo DMA
    transfers when the driver is used with 53C400-compatible cards. Thanks to
    Ondrej Zary's patches, PDMA now works which means it can be enabled
    unconditionally.

    Due to bad design, CONFIG_SCSI_GENERIC_NCR53C400 ties together unrelated
    functionality as it sets both PSEUDO_DMA and BIOSPARAM macros. This patch
    effectively enables PSEUDO_DMA and disables BIOSPARAM.

    The defconfigs and the Kconfig default leave CONFIG_SCSI_GENERIC_NCR53C400
    undefined. Red Hat 9 and CentOS 2.1 were the same. This leaves both
    PSEUDO_DMA and BIOSPARAM disabled. The effect of this patch should be
    better performance from enabling PSEUDO_DMA.

    On the other hand, Debian 4 and SLES 10 had CONFIG_SCSI_GENERIC_NCR53C400
    enabled, so both PSEUDO_DMA and BIOSPARAM were enabled. This patch might
    affect configurations like this by disabling BIOSPARAM. My best guess is
    that this could be a problem only in the vanishingly rare case that
    1) the CHS values stored in the boot device partition table are wrong and
    2) a 5380 card is in use (because PDMA on 53C400 used to be broken).

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Ondrej Zary
    Signed-off-by: Martin K. Petersen

    Finn Thain
     

07 Jan, 2016

7 commits

  • HP C2502 cards (based on 53C400A chips) use different magic numbers for
    software-based I/O address configuration than other cards.
    The configuration is also extended to allow setting the IRQ.

    Move the configuration to a new function magic_configure() and move
    magic the magic numbers into an array. Add new magic numbers for these
    HP cards and hp_c2502 module parameter to use them, e.g.:
    modprobe g_NCR5380 ncr_irq=7 ncr_addr=0x280 hp_c2502=1

    Tested with HP C2502 and DTCT-436P.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • The check for 53C80 registers accessibility was commented out because
    it was broken (inverted). Fix and enable it.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Add I/O register mapping for DTC chips and enable PDMA mode.

    These chips have 16-bit wide HOST BUFFER register and it must be read
    by 16-bit accesses (we lose data otherwise).

    Large PIO transfers crash at least the DTCT-436P chip (all reads result
    in 0xFF) so this patch actually makes it work.

    The chip also crashes when we bang on the C400 host status register too
    heavily after PDMA write - a small udelay is needed.

    Tested on DTCT-436P and verified that it does not break 53C400A.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Add I/O register mapping for NCR53C400A and enable PDMA mode to
    improve performance and fix non-working IRQ.

    Tested with HP C2502 (and user-space enabler).

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Convert compile-time C400_ register mapping to runtime mapping.
    This removes the weird negative register offsets and allows adding
    additional mappings.

    While at it, convert read/write loops into insb/outsb.

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Pseudo-DMA (PDMA) has been broken for ages, resulting in hangs on
    53C400-based cards.

    According to 53C400 datasheet, PDMA transfer length must be a multiple
    of 128. Check if that's true and use PIO if it's not.

    This makes PDMA work on 53C400 (Canon FG2-5202).

    Signed-off-by: Ondrej Zary
    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Ondrej Zary
     
  • Because of the rudimentary design of the chip, it is necessary to poll the
    SCSI bus signals during PIO and this tends to hog the CPU. The driver will
    accept new commands while others execute, and this causes a soft lockup
    because the workqueue item will not terminate until the issue queue is
    emptied.

    When exercising dmx3191d using sequential IO from dd, the driver is sent
    512 KiB WRITE commands and 128 KiB READs. For a PIO transfer, the rate is
    is only about 300 KiB/s, so these are long-running commands. And although
    PDMA may run at several MiB/s, interrupts are disabled for the duration
    of the transfer.

    Fix the unresponsiveness and soft lockup issues by calling cond_resched()
    after each command is completed and by limiting max_sectors for drivers
    that don't implement real DMA.

    Signed-off-by: Finn Thain
    Reviewed-by: Hannes Reinecke
    Tested-by: Ondrej Zary
    Tested-by: Michael Schmitz
    Signed-off-by: Martin K. Petersen

    Finn Thain