31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

09 Feb, 2019

1 commit

  • Clang warns several times in the scsi subsystem (trimmed for brevity):

    drivers/scsi/hpsa.c:6209:7: warning: overflow converting case value to
    switch condition type (2147762695 to 18446744071562347015) [-Wswitch]
    case CCISS_GETBUSTYPES:
    ^
    drivers/scsi/hpsa.c:6208:7: warning: overflow converting case value to
    switch condition type (2147762694 to 18446744071562347014) [-Wswitch]
    case CCISS_GETHEARTBEAT:
    ^

    The root cause is that the _IOC macro can generate really large numbers,
    which don't fit into type 'int', which is used for the cmd parameter in
    the ioctls in scsi_host_template. My research into how GCC and Clang are
    handling this at a low level didn't prove fruitful. However, looking at
    the rest of the kernel tree, all ioctls use an 'unsigned int' for the
    cmd parameter, which will fit all of the _IOC values in the scsi/ata
    subsystems.

    Make that change because none of the ioctls expect a negative value for
    any command, it brings the ioctls inline with the reset of the kernel,
    and it removes ambiguity, which is never good when dealing with compilers.

    Link: https://github.com/ClangBuiltLinux/linux/issues/85
    Link: https://github.com/ClangBuiltLinux/linux/issues/154
    Link: https://github.com/ClangBuiltLinux/linux/issues/157
    Signed-off-by: Nathan Chancellor
    Acked-by: Bradley Grove
    Acked-by: Don Brace
    Reviewed-by: Bart Van Assche
    Tested-by: Nick Desaulniers
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Nathan Chancellor
     

18 May, 2018

1 commit

  • AFUs can only process a single AFU command at a time. This is enforced with
    a global mutex situated within the AFU send routine. As this mutex has a
    global scope, it has the potential to unnecessarily block commands destined
    for other AFUs.

    Instead of using a global mutex, transition the mutex to be per-AFU. This
    will allow commands to only be blocked by siblings of the same AFU.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     

19 Apr, 2018

4 commits

  • The following Oops can occur when there is heavy I/O traffic and the host is
    reset by a tool such as sg_reset.

    [c000200fff3fbc90] c00800001690117c process_cmd_doneq+0x104/0x500
    [cxlflash] (unreliable)
    [c000200fff3fbd80] c008000016901648 cxlflash_rrq_irq+0xd0/0x150 [cxlflash]
    [c000200fff3fbde0] c000000000193130 __handle_irq_event_percpu+0xa0/0x310
    [c000200fff3fbea0] c0000000001933d8 handle_irq_event_percpu+0x38/0x90
    [c000200fff3fbee0] c000000000193494 handle_irq_event+0x64/0xb0
    [c000200fff3fbf10] c000000000198ea0 handle_fasteoi_irq+0xc0/0x230
    [c000200fff3fbf40] c00000000019182c generic_handle_irq+0x4c/0x70
    [c000200fff3fbf60] c00000000001794c __do_irq+0x7c/0x1c0
    [c000200fff3fbf90] c00000000002a390 call_do_irq+0x14/0x24
    [c000200e5828fab0] c000000000017b2c do_IRQ+0x9c/0x130
    [c000200e5828fb00] c000000000009b04 h_virt_irq_common+0x114/0x120

    When a context is reset, the pending commands are flushed and the AFU is
    notified. Before the AFU handles this request there could be command
    completion interrupts queued to PHB which are yet to be delivered to the
    context. In this scenario, a context could receive an interrupt for a command
    that has been flushed, leading to a possible crash when the memory for the
    flushed command is accessed.

    To resolve this problem, a boolean will indicate if the hardware queue is
    ready to process interrupts or not. This can be evaluated in the interrupt
    handler before proessing an interrupt.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • The SISLite specification has been updated for OCXL to support communicating
    data to generate AFU interrupts to the AFU. This includes a new capability bit
    that is advertised for OCXL AFUs and new registers to hold the object handle
    and translation PASID of each interrupt. For Power, the object handle is the
    mapped trigger page. Note that because these mappings are kernel only, the
    PASID of a kernel context must be used to satisfy the translation.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • Checkpatch throws a warning when the argument identifier names are not
    included in the function definitions.

    To avoid these warnings, argument identifiers are added in the existing
    function definitions.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • The number of interrupts requested for user contexts are stored in the context
    specific structures and utilized to manage the interrupts. For the master
    contexts, this number is only used once and therefore not saved.

    To prepare for future commits where the number of interrupts will be required
    in more than one place, preserve the value in the master context structure.

    [mkp: typo in comment]

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     

11 Jan, 2018

3 commits

  • As staging to support future accelerator transports, add a shim layer
    such that the underlying services the cxlflash driver requires can be
    conditional upon the accelerator infrastructure.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • The CXL-specific work structure used to request the number of interrupts
    currently resides as a nested member of both the context information and
    hardware queue structures. It is used to cache values (specifically the
    number of interrupts) required by the CXL layer when starting a context.

    To facilitate staging that will ultimately allow the cxlflash core to
    become agnostic of the underlying accelerator transport, remove these
    embedded work structures.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Convert cxl-specific pointers to generic cookies to facilitate future
    enhancements.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     

27 Jun, 2017

11 commits

  • The SCSI core now zeroes the per-command private data area prior to
    calling into the LLD. Replace the clearing operation that takes place
    when the private command data reference is obtained with a routine that
    performs common initializations. The zeroing that takes place in the
    device reset path remains intact as the private command data associated
    with the specified SCSI command is not guaranteed to be cleared.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • The cxlflash driver supports performing a write-same16 to scrub virtual
    luns when they are released by a user. To date, AFUs for adapters that
    are supported by cxlflash do not have the capability to unmap as part of
    the WS operation. This can lead to fragmented flash devices which results
    in performance degradation.

    Future AFUs can optionally support unmap write-same commands and reflects
    this support via the context control register. This provides userspace
    applications with direct visibility such that they need not depend on a
    host API.

    Detect unmap support during cxlflash initialization by reading the context
    control register associated with the primary hardware queue. Update the
    existing write_same16() routine to set the unmap bit in the CDB when unmap
    is supported by the host.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Adopt the SISLite AFU debug capability to allow future CXL Flash
    adapters the ability to better debug AFU issues. Update the SISLite
    header with the changes necessary to support AFU debug operations
    and create a host ioctl interface for user debug software. Also
    update the cxlflash documentation to describe this new host ioctl.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Adopt the SISLite AFU LUN provisioning capability to allow future CXL
    Flash adapters the ability to better manage storage. Update the SISLite
    header with the changes necessary to support LUN provision operations
    and create a host ioctl interface for user LUN management software. Also
    update the cxlflash documentation to describe this new host ioctl.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • The existing AFU capability checking infrastructure is closely tied to
    the command mode capability bits. In order to support new capabilities,
    refactor the existing infrastructure to be more generic.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • The cxlflash driver currently lacks host management interface. Future
    devices supported by cxlflash will provide a variety of host-wide
    management functions. Examples include LUN provisioning, hardware debug
    support, and firmware download.

    In order to provide a way to manage the device, a character device will
    be created during probe of each adapter. This device will support a set of
    ioctls defined in the SISLite specification from which administrators can
    manage the adapter.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • When the AFU is reset in an error path, pending scsi commands can be
    silently dropped without completion or a formal abort. This puts the onus
    on the cxlflash driver to notify mid-layer and indicating that the command
    can be retried.

    Once the card has been quiesced, the hardware send queue lock is acquired
    to prevent any data movement while the pending commands are processed.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • Currently, there is no book keeping of the pending scsi commands in the
    cxlflash driver. This lack of tracking in-flight requests is too
    restrictive and requires a heavy-hammer reset each time an adapter error is
    encountered. Additionally, it does not allow for commands to be properly
    retried.

    In order to avoid this problem and to better handle error path command
    cleanup, introduce a linked list for each hardware queue that tracks
    pending commands.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • A context reset failure indicates the AFU is in a bad state. At present,
    when such a situation occurs, no further action is taken. This leaves the
    adapter in an unusable state with no recoverable actions.

    To avoid this situation, context reset failures will be escalated to a host
    reset operation. This will be done asynchronously to allow the acting
    thread to return to the user with a failure.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • Per the SISLite specification, context_reset() writes 0x1 to the LSB of the
    reset register. When the AFU processes this reset request, it is expected
    to clear the bit after reset is complete. The current implementation simply
    checks that the entire value read back is not 1, instead of masking off the
    LSB and evaluating it for a change to 0. Should the AFU manipulate other
    bits during the reset (reading back a value of 0xF for example), successful
    completion will be prematurely indicated given the existing logic.

    Additionally, in the event that the context reset operation fails, there
    does not currently exist a way to provide feedback to the initiator of the
    reset. This poses a problem for the rare case that a context reset fails as
    the caller will proceed on the assumption that all is well.

    To remedy these issues, refactor the context reset routine to only mask off
    the LSB when evaluating for success and return status to the caller. Also
    update the context reset handler parameters to pass a hardware queue
    reference instead of a single command to better reflect that the entire
    queue associated with the context is impacted by the reset.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • Currently there are separate spin locks for the two supported I/O queueing
    models. This makes it difficult to serialize with paths outside the enqueue
    path.

    As a design simplification and to support serialization with enqueue
    operations, move to only a single lock that is used for enqueueing
    regardless of the queueing model.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     

14 Apr, 2017

12 commits

  • As an enhancement to distribute requests to multiple hardware queues, add the
    infrastructure to hash a SCSI command into a particular hardware queue.
    Support the following scenarios when deriving which queue to use: single
    queue, tagging when SCSI-MQ enabled, and simple hash via CPU ID when SCSI-MQ
    is disabled. Rather than altering the existing send API, the derived hardware
    queue is stored in the AFU command where it can be used for sending a command
    to the chosen hardware queue.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • As staging for supporting multiple hardware queues, add an attribute to show
    and set the current number of hardware queues for the host. Support specifying
    a hard limit or a CPU affinitized value. This will allow the number of
    hardware queues to be tuned by a system administrator.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Introduce multiple hardware queues to improve legacy I/O path performance.
    Each hardware queue is comprised of a master context and associated I/O
    resources. The hardware queues are initially implemented as a static array
    embedded in the AFU. This will be transitioned to a dynamic allocation in a
    later series to improve the memory footprint of the driver.

    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • As a general cleanup, address all reasonable checkpatch warnings and
    errors. These include enforcement of comment styles and including named
    identifiers in function prototypes.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Validation statements to enforce assumptions about specific defines are not
    being evaluated by the compiler due to the fact that they reside in a routine
    that is not used. To activate them, call the routine as part of module
    initialization. As an additional, related cleanup, remove the now-defunct
    CXLFLASH_NUM_CMDS.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • An EEH during probe can lead to a crash as the recovery thread races with the
    probe thread. To avoid this issue, introduce new states to fence out EEH
    recovery until probe has completed. Also ensure the reset wait queue is
    flushed during device removal to avoid orphaned threads.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Update the SISlite header to support 4 ports as outlined in the SISlite
    specification. Address fallout from structure renames and refreshed
    organization throughout the driver. Determine the number of ports supported by
    a card from the global port selection mask register reset value.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • As staging to support FC-related updates to the SISlite specification,
    introduce helper routines to obtain references to FC resources that exist
    within the global map. This will allow changes to the underlying global map
    structure without impacting existing code paths.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • At present, the cxlflash driver only supports hardware with two FC ports. The
    code was initially designed with this assumption and is dependent on having
    two FC ports - adding more ports will break logic within the driver.

    To mitigate this issue, remove the existing port assumptions and transition
    the code to support more than two ports. As a side effect, clarify the
    interpretation of the DK_CXLFLASH_ALL_PORTS_ACTIVE flag.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Transition from a static number of FC ports to a value that is derived during
    probe. For now, a static value is used but this will later be based on the
    type of card being configured.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Currently, RRQ processing takes place on hardware interrupt context. This can
    be a heavy burden in some environments due to the overhead encountered while
    completing RRQ entries. In an effort to improve system performance, use the
    IRQ polling API to schedule this processing on softirq context.

    This function will be disabled by default until starting values can be
    established for the hardware supported by this driver.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • As further staging to support processing the HRRQ by other means, access to
    the HRRQ needs to be serialized by a disabled lock. This will allow safe
    access in other non-hardware interrupt contexts. In an effort to minimize the
    period where interrupts are disabled, support is added to queue up commands
    harvested from the RRQ such that they can be processed with hardware
    interrupts enabled. While this doesn't offer any improvement with processing
    on a hardware interrupt it will help when IRQ polling is supported and the
    command completions can execute on softirq context.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     

12 Jan, 2017

2 commits

  • When processing an AFU asynchronous interrupt, if the action results in an
    operation that requires off level processing (a link reset for example),
    the worker thread is scheduled. In the meantime a reset event (i.e.: EEH)
    could unmap the AFU to recover. This results in an Oops when the worker
    thread tries to access the AFU mapping.

    [c000000f17e03b90] d000000007cd5978 cxlflash_worker_thread+0x268/0x550
    [c000000f17e03c40] c00000000011883c process_one_work+0x1dc/0x680
    [c000000f17e03ce0] c000000000118e80 worker_thread+0x1a0/0x520
    [c000000f17e03d80] c000000000126174 kthread+0xf4/0x100
    [c000000f17e03e30] c00000000000a47c ret_from_kernel_thread+0x5c/0xe0

    In an effort to avoid this, a mapcount was introduced in
    commit b45cdbaf9f7f ("cxlflash: Resolve oops in wait_port_offline")
    but due to the race condition described above, this solution is incomplete.

    In order to fully resolve this problem and to simplify things, this commit
    removes the mapcount solution. Instead, the scheduled worker thread is
    cancelled after interrupts have been disabled and prior to the mapping
    being freed.

    Fixes: b45cdbaf9f7f ("cxlflash: Resolve oops in wait_port_offline")
    Signed-off-by: Uma Krishnan
    Acked-by: Matthew R. Ochs
    Signed-off-by: Martin K. Petersen

    Uma Krishnan
     
  • The SISLite specification outlines a new queuing model to improve
    over the MMIO-based IOARRIN model that exists today. This new model
    uses a submission queue that exists in host memory and is shared with
    the device. Each entry in the queue is an IOARCB that describes a
    transfer request. When requests are submitted, IOARCBs ('current'
    position tracked in host software) are populated and the submission
    queue tail pointer is then updated via MMIO to make the device aware
    of the requests.

    Signed-off-by: Matthew R. Ochs
    Signed-off-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     

01 Dec, 2016

5 commits

  • Currently, when sending a SCSI command, the pointer is stored in a
    reserved field of the AFU command descriptor for retrieval once the
    SCSI command has completed. In order to support new descriptor formats
    that make use of the reserved field, the pointer is migrated to outside
    the descriptor where it can still be found during completion processing.

    Signed-off-by: Matthew R. Ochs
    Acked-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • As staging for supporting hardware with a different queuing mechanism,
    move the send_cmd() and context_reset() routines to function pointers
    that are configured when the AFU is initialized. In addition, rename
    the existing routines to better reflect the queue model they support.

    Signed-off-by: Matthew R. Ochs
    Acked-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • The original design of the cxlflash driver required AFU commands
    to convey state information across multiple threads. The IOASA
    "host use" byte was used to track if a command was done, errored,
    or timed out. A per-command spin lock was used to serialize access
    to this byte. As this is no longer required with the introduction
    of completions and various refactoring over time, the spin lock,
    state tracking, and associated code can be removed. To support the
    simplification, the wait_resp() routine is refactored to return a
    success or failure. Additionally, as the simplification to the
    AFU internal command routine, explicit assignments of AFU command
    fields to zero are removed as the memory is zeroed upon allocation.

    Signed-off-by: Matthew R. Ochs
    Acked-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • With the removal of the static private command pool, the ability to
    'complete' outstanding commands was lost. While not an issue for the
    commands originating outside the driver, internal AFU commands are
    synchronous and therefore have a timeout associated with them. To
    avoid a stale memory access, the tear down sequence needs to ensure
    that there are not any active commands before proceeding. As these
    internal AFU commands are rare events, the simplest way to accomplish
    this is detecting the activity and waiting for it to timeout.

    Signed-off-by: Matthew R. Ochs
    Acked-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs
     
  • Clean up and remove the remaining private command pool infrastructure
    that is no longer required.

    Signed-off-by: Matthew R. Ochs
    Acked-by: Uma Krishnan
    Signed-off-by: Martin K. Petersen

    Matthew R. Ochs