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 this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

23 Jan, 2019

1 commit

  • When a host driver sets a maximum segment size we should not only propagate
    that setting to the block layer, which can merge segments, but also to the
    DMA mapping layer which can merge segments as well.

    Fixes: 50c2e9107f ("scsi: introduce a max_segment_size host_template parameters")
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Christoph Hellwig
     

19 Dec, 2018

1 commit

  • Most SCSI drivers want to enable "clustering", that is merging of
    segments so that they might span more than a single page. Remove the
    ENABLE_CLUSTERING define, and require drivers to explicitly set
    DISABLE_CLUSTERING to disable this feature.

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

    Christoph Hellwig
     

01 Jun, 2015

1 commit


31 Jan, 2015

1 commit

  • [Bart van Asche:] SCSI core never sets cmd->sc_data_direction to
    DMA_BIDIRECTIONAL; scsi_bidi_cmnd(cmd) should be used instead to
    test for a bidirectional command.

    [Christoph Hellwig:] Bidirectional commands won't ever be queued
    anyway, unless a LLD or transport driver sets QUEUE_FLAG_BIDI.

    So, simply remove the respective queuecommand check in the SBP-2
    transport driver.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

11 Dec, 2014

3 commits

  • firewire-core uses fw_card.lock to protect topology data and transaction
    data. firewire-sbp2 uses fw_card.lock for entirely unrelated purposes.

    Introduce a sbp2_target.lock to firewire-sbp2 and replace all
    fw_card.lock uses in the driver. fw_card.lock is now entirely private
    to firewire-core. This has no immediate advantage apart from making it
    clear in the code that firewire-sbp2 does not interact with the core
    via the core lock.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • Users of card->lock Calling context
    ------------------------------------------------------------------------
    sbp2_status_write AR-req handler, tasklet
    complete_transaction AR-resp or AT-req handler, tasklet
    sbp2_send_orb among else scsi host .queuecommand, which may
    be called in some sort of atomic context
    sbp2_cancel_orbs sbp2_send_management_orb/
    sbp2_{login,reconnect,remove},
    worklet or process
    sbp2_scsi_abort, scsi eh thread
    sbp2_allow_block sbp2_login, worklet
    sbp2_conditionally_block among else complete_command_orb, tasklet
    sbp2_conditionally_unblock sbp2_{login,reconnect}, worklet
    sbp2_unblock sbp2_{login,remove}, worklet or process

    Drop the IRQ flags saving from sbp2_cancel_orbs,
    sbp2_conditionally_unblock, and sbp2_unblock.
    It was already omitted in sbp2_allow_block.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • The assertion in the comment in sbp2_allow_block() is no longer true.
    Or maybe it never was true. At least now, the sole caller of
    sbp2_allow_block(), sbp2_login, can run concurrently to one of
    sbp2_unblock()'s callers, sbp2_remove.

    sbp2_login is performed by sbp2_logical_unit.work.
    sbp2_remove is performed by fw_device.work.
    sbp2_remove cancels sbp2_logical_unit.work, but only after it called
    sbp2_unblock.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

07 Mar, 2014

1 commit

  • PREPARE_[DELAYED_]WORK() are being phased out. They have few users
    and a nasty surprise in terms of reentrancy guarantee as workqueue
    considers work items to be different if they don't have the same work
    function.

    firewire core-device and sbp2 have been been multiplexing work items
    with multiple work functions. Introduce fw_device_workfn() and
    sbp2_lu_workfn() which invoke fw_device->workfn and
    sbp2_logical_unit->workfn respectively and always use the two
    functions as the work functions and update the users to set the
    ->workfn fields instead of overriding work functions using
    PREPARE_DELAYED_WORK().

    This fixes a variety of possible regressions since a2c1c57be8d9
    "workqueue: consider work function when searching for busy work items"
    due to which fw_workqueue lost its required non-reentrancy property.

    Signed-off-by: Tejun Heo
    Acked-by: Stefan Richter
    Cc: linux1394-devel@lists.sourceforge.net
    Cc: stable@vger.kernel.org # v3.9+
    Cc: stable@vger.kernel.org # v3.8.2+
    Cc: stable@vger.kernel.org # v3.4.60+
    Cc: stable@vger.kernel.org # v3.2.40+

    Tejun Heo
     

15 Dec, 2013

1 commit

  • Commit 54b2b50c20a6 "[SCSI] Disable WRITE SAME for RAID and virtual
    host adapter drivers" disabled WRITE SAME support for all SBP-2 attached
    targets. But as described in the changelog of commit b0ea5f19d3d8
    "firewire: sbp2: allow WRITE SAME and REPORT SUPPORTED OPERATION CODES",
    it is not required to blacklist WRITE SAME.

    Bring the feature back by reverting the sbp2.c hunk of commit 54b2b50c20a6.

    Signed-off-by: Stefan Richter
    Cc: stable@kernel.org

    Stefan Richter
     

29 Nov, 2013

1 commit

  • Some host adapters do not pass commands through to the target disk
    directly. Instead they provide an emulated target which may or may not
    accurately report its capabilities. In some cases the physical device
    characteristics are reported even when the host adapter is processing
    commands on the device's behalf. This can lead to adapter firmware hangs
    or excessive I/O errors.

    This patch disables WRITE SAME for devices connected to host adapters
    that provide an emulated target. Driver writers can disable WRITE SAME
    by setting the no_write_same flag in the host adapter template.

    [jejb: fix up rejections due to eh_deadline patch]
    Signed-off-by: Martin K. Petersen
    Cc: stable@kernel.org
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

10 Jun, 2013

1 commit

  • FireWire upper layer drivers are converted from generic
    struct driver.probe() and .remove()
    to bus-specific
    struct fw_driver.probe() and .remove().

    The new .probe() adds a const struct ieee1394_device_id *id argument,
    indicating the entry in the driver's device identifiers table which
    matched the fw_unit to be probed. This new argument is used by the
    snd-firewire-speakers driver to look up device-specific parameters and
    methods. There is at least one other FireWire audio driver currently in
    development in which this will be useful too.

    The new .remove() drops the unused error return code.

    Although all in-tree drivers are being converted to the new methods,
    support for the old methods is left in place in this commit. This
    allows public developer trees to merge this commit and then move to the
    new fw_driver methods.

    Signed-off-by: Stefan Richter
    Acked-by: Clemens Ladisch (for sound/firewire/)
    Cc: Peter Hurley (for drivers/staging/fwserial/)

    Stefan Richter
     

29 Apr, 2013

3 commits


03 Dec, 2012

1 commit

  • The commits
    3c6bdaeab4fd "[SCSI] Add a report opcode helper"
    5db44863b6eb "[SCSI] sd: Implement support for WRITE SAME"
    introduced in-kernel uses of the mentioned commands but cautiously
    blacklisted them for any IEEE 1394 (SBP-2/3) targets and some other
    transports.

    I looked through a range of SBP devices and found that the blacklist
    flags can be removed:

    The kernel never attempts these commands if the device's INQUIRY
    data claim a SCSI revision of less than 0x05. This is the case with
    all SBP devices that I checked, except for three more recent devices
    which claimed a revision of 0x05 i.e. conformance with SPC-3 (two
    devices based on the OXUF936QSE chip but having different firmwares,
    one based on OXUF934DSB.)

    I tried "sg_opcodes" from sg3_utils on several older and newer devices
    and did not encounter any apparent firmware bugs with it. All devices
    returned Illegal Request/ Invalid command operation code and carried on.
    I furthermore tried "sg_write_same -U" on the OXUF934DSB device with the
    same result. Alas I did not have a TRIM enabled SSD available for these
    tests. All of the bridges were correctly identified by the kernel as
    "fully provisioned", CD-ROM devices aside.

    The kernel won't issue WRITE SAME to fully provisioned devices, nor
    would it attempt REPORT SUPPORTED OPERATION CODES or WRITE SAME with
    UNMAP bit on devices which do not claim conformance to SPC-3 or later.

    Hence let's remove the no_report_opcodes and no_write_same blacklist
    flags so that these commands can be used on newer targets with
    respective capabilities. I guess the Linux sbp-target could be such a
    target.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

14 Nov, 2012

2 commits

  • Implement support for WRITE SAME(10) and WRITE SAME(16) in the SCSI disk
    driver.

    - We set the default maximum to 0xFFFF because there are several
    devices out there that only support two-byte block counts even with
    WRITE SAME(16). We only enable transfers bigger than 0xFFFF if the
    device explicitly reports MAXIMUM WRITE SAME LENGTH in the BLOCK
    LIMITS VPD.

    - max_write_same_blocks can be overriden per-device basis in sysfs.

    - The UNMAP discovery heuristics remain unchanged but the discard
    limits are tweaked to match the "real" WRITE SAME commands.

    - In the error handling logic we now distinguish between WRITE SAME
    with and without UNMAP set.

    The discovery process heuristics are:

    - If the device reports a SCSI level of SPC-3 or greater we'll issue
    READ SUPPORTED OPERATION CODES to find out whether WRITE SAME(16) is
    supported. If that's the case we will use it.

    - If the device supports the block limits VPD and reports a MAXIMUM
    WRITE SAME LENGTH bigger than 0xFFFF we will use WRITE SAME(16).

    - Otherwise we will use WRITE SAME(10) unless the target LBA is beyond
    0xFFFFFFFF or the block count exceeds 0xFFFF.

    - no_write_same is set for ATA, FireWire and USB.

    Signed-off-by: Martin K. Petersen
    Reviewed-by: Mike Snitzer
    Reviewed-by: Jeff Garzik
    Signed-off-by: James Bottomley

    Martin K. Petersen
     
  • The REPORT SUPPORTED OPERATION CODES command can be used to query
    whether a given opcode is supported by a device. Add a helper function
    that allows us to look up commands.

    We only issue RSOC if the device reports compliance with SPC-3 or
    later. But to err on the side of caution we disable the command for ATA,
    FireWire and USB.

    Signed-off-by: Martin K. Petersen
    Acked-by: Mike Snitzer
    Signed-off-by: James Bottomley

    Martin K. Petersen
     

22 May, 2012

4 commits


29 Mar, 2012

1 commit


23 Mar, 2012

1 commit

  • Pull IEEE 1394 (FireWire) subsystem updates post v3.3 from Stefan Richter:

    - Some SBP-2 initiator fixes, side product from ongoing work on a target.

    - Reintroduction of an isochronous I/O feature of the older ieee1394 driver
    stack (flush buffer completions); it was evidently rarely used but not
    actually unused. Matching libraw1394 code is already available.

    - Be sure to prefix all kernel log messages with device name or card name,
    and other logging related cleanups.

    - Misc other small cleanups, among them a small API change that affects
    sound/firewire/ too. Clemens Ladisch is aware of it.

    * tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394: (26 commits)
    firewire: allow explicit flushing of iso packet completions
    firewire: prevent dropping of completed iso packet header data
    firewire: ohci: factor out iso completion flushing code
    firewire: ohci: simplify iso header pointer arithmetic
    firewire: ohci: optimize control bit checks
    firewire: ohci: remove unused excess_bytes field
    firewire: ohci: copy_iso_headers(): make comment match the code
    firewire: cdev: fix IR multichannel event documentation
    firewire: ohci: fix too-early completion of IR multichannel buffers
    firewire: ohci: move runtime debug facility out of #ifdef
    firewire: tone down some diagnostic log messages
    firewire: sbp2: replace a GFP_ATOMIC allocation
    firewire: sbp2: Fix SCSI sense data mangling
    firewire: sbp2: Ignore SBP-2 targets on the local node
    firewire: sbp2: Take into account Unit_Unique_ID
    firewire: nosy: Use the macro DMA_BIT_MASK().
    firewire: core: convert AR-req handler lock from _irqsave to _bh
    firewire: core: fix race at address_handler unregistration
    firewire: core: remove obsolete comment
    firewire: core: prefix log messages with card name
    ...

    Linus Torvalds
     

11 Mar, 2012

1 commit

  • sbp2_send_management_orb() is called by sbp2_login, sbp2_reconnect, and
    sbp2_remove, all which are able to sleep during memory allocations.
    Actually, sbp2_send_management_orb() itself is a sleeping function.

    Login and remove could allocate with GFP_KERNEL but reconnect needs
    GFP_NOIO to ensure progress in low memory situations.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

23 Feb, 2012

4 commits

  • SCSI sense data in SBP-2/3 is carried in an unusual format that means we
    have to un-mangle it on our end before we pass it to the SCSI subsystem.
    Currently our un-mangling code doesn't quite follow the SBP-2 standard
    in that we always assume Current and never Deferred error types, we
    never set the VALID bit, and we mishandle the FILEMARK, EOM and ILI
    bits.

    This patch fixes the sense un-mangling to correctly handle those and
    follow the spec.

    Signed-off-by: Chris Boot
    Signed-off-by: Stefan Richter

    Chris Boot
     
  • The firewire-sbp2 module tries to login to an SBP-2/3 target even when
    it is running on the local node, which fails because of the inability to
    fetch data from DMA mapped regions using firewire transactions on the
    local node. It also doesn't make much sense to have the initiator and
    target on the same node, so this patch prevents this behaviour.

    Signed-off-by: Chris Boot
    Signed-off-by: Stefan Richter (changed the comment)

    Chris Boot
     
  • If the target's unit directory contains a Unit_Unique_ID entry, we
    should use that as the target's GUID for identification purposes. The
    SBP-2 standards document says:

    "Although the node unique ID (EUI-64) present in the bus information
    block is sufficient to uniquely identify nodes attached to Serial Bus,
    it is insufficient to identify a target when a vendor implements a
    device with multiple Serial Bus node connections. In this case initiator
    software requires information by which a particular target may be
    uniquely identified, regardless of the Serial Bus access path used."

    [ IEEE T10 P1155D Revision 4, Section 7.6 (page 51) ] and
    [ IEEE T10 P1467D Revision 5, Section 7.9 (page 74) ]

    Signed-off-by: Chris Boot
    Signed-off-by: Stefan Richter

    Chris Boot
     
  • Commit eba9ebaaa26d "firewire: sbp2: use dev_printk API" changed
    messages from e.g.
    firewire_sbp2: fw3.0: logged in to LUN 0000 (0 retries)
    to
    sbp2 fw3.0: logged in to LUN 0000 (0 retries)
    because the driver calls itself as "sbp2" when registering with driver
    core and with SCSI core. This is of course confusing, so switch to the
    name "firewire_sbp2" for driver core in order to match what lsmod and
    /sys/module/ show. So we are back to
    firewire_sbp2 fw3.0: logged in to LUN 0000 (0 retries)
    in the kernel log.

    This also changes
    /sys/bus/firewire/drivers/sbp2
    /sys/bus/firewire/devices/fw3.0/driver -> [...]/sbp2
    /sys/module/firewire_sbp2/drivers/firewire:sbp2
    to
    /sys/bus/firewire/drivers/firewire_sbp2
    /sys/bus/firewire/devices/fw3.0/driver -> [...]/firewire_sbp2
    /sys/module/firewire_sbp2/drivers/firewire:firewire_sbp2

    but "cat /sys/class/scsi_host/host27/proc_name" stays "sbp2" just in
    case that proc_name is used by any userland.

    The transport detection in lsscsi is not affected. (Tested with lsscsi
    version 0.25.) Udev's /dev/disk/by-id and by-path symlinks are not
    affected either.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

16 Jan, 2012

1 commit


13 Jan, 2012

1 commit


09 Oct, 2011

1 commit


17 Sep, 2011

3 commits

  • sbp2_release_target() is folded into its primary user, sbp2_remove().
    The only other caller, a failure path in sbp2_probe(), now uses
    sbp2_remove(). This adds unnecessary cancel_delayed_work_sync() calls
    to that failure path but results in less code and text.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • Implement sbp2_queue_work(), which is now a very simple accessor to one
    of the struct sbp2_logical_unit members, right after the definition of
    struct sbp2_logical_unit.

    Put the sbp2_reconnect() implementation right after the sbp2_login()
    implementation. They are both part of the SBP-2 access protocol.

    Implement the driver methods sbp2_probe(), spp2_update(), sbp2_remove()
    in this order, reflecting the lifetime of an SBP-2 target.

    Place the sbp2_release_target() implementation right next to
    sbp2_remove() which is its primary user, and after sbp2_probe() which is
    the counterpart to sbp2_release_target().

    There are no changes to the implementations here, or at least not meant
    to be.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • Since commit 0278ccd9d53e07c4e699432b2fed9de6c56f506c "firewire: sbp2:
    fix panic after rmmod with slow targets", the lifetime of an sbp2_target
    instance does no longer extent past the return of sbp2_remove().
    Therefore it is no longer necessary to call fw_unit_get/put() and
    fw_device_get/put() in sbp2_probe/remove().

    Furthermore, said commit also ensures that lu->work is not going to be
    executed or requeued at a time when the sbp2_target is no longer in use.
    Hence there is no need for sbp2_target reference counting for lu->work.

    Other concurrent contexts:

    - Processes which access the sysfs of the SCSI host device or of one
    of its subdevices are safe because these interfaces are all removed
    by scsi_remove_device/host() in sbp2_release_target().

    - SBP-2 command block ORB transactions are finished when
    scsi_remove_device() in sbp2_release_target() returns.

    - SBP-2 management ORB transactions are finished when
    cancel_delayed_work_sync(&lu->work) before sbp2_release_target()
    returns.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

23 Aug, 2011

1 commit

  • If firewire-sbp2 starts a login to a target that doesn't complete ORBs
    in a timely manner (and has to retry the login), and the module is
    removed before the operation times out, you end up with a null-pointer
    dereference and a kernel panic.

    [SR: This happens because sbp2_target_get/put() do not maintain
    module references. scsi_device_get/put() do, but at occasions like
    Chris describes one, nobody holds a reference to an SBP-2 sdev.]

    This patch cancels pending work for each unit in sbp2_remove(), which
    hopefully means there are no extra references around that prevent us
    from unloading. This fixes my crash.

    Signed-off-by: Chris Boot
    Signed-off-by: Stefan Richter

    Chris Boot
     

11 May, 2011

3 commits

  • The struct sbp2_logical_unit.work items can all be executed in parallel
    but are not reentrant. Furthermore, reconnect or re-login work must be
    executed in a WQ_MEM_RECLAIM workqueue.

    Hence replace the old single-threaded firewire-sbp2 workqueue by a
    concurrency-managed but non-reentrant workqueue with rescuer.
    firewire-core already maintains one, hence use this one.

    In earlier versions of this change, I observed occasional failures of
    parallel INQUIRY to an Initio INIC-2430 FireWire 800 to dual IDE bridge.
    More testing indicates that parallel INQUIRY is not actually a problem,
    but too quick successions of logout and login + INQUIRY, e.g. a quick
    sequence of cable plugout and plugin, can result in failed INQUIRY.
    This does not seem to be something that should or could be addressed by
    serialization.

    Another dual-LU device to which I currently have access to, an
    OXUF924DSB FireWire 800 to dual SATA bridge with firmware from MacPower,
    has been successfully tested with this too.

    This change is beneficial to environments with two or more FireWire
    storage devices, especially if they are located on the same bus.
    Management tasks that should be performed as soon and as quickly as
    possible, especially reconnect, are no longer held up by tasks on other
    devices that may take a long time, especially login with INQUIRY and sd
    or sr driver probe.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • We do not need slab allocations for ORB pointer write transactions
    anymore in order to satisfy streaming DMA mapping constraints, thanks to
    commit da28947e7e36 "firewire: ohci: avoid separate DMA mapping for
    small AT payloads".

    (Besides, the slab-allocated buffers that firewire-sbp2 used to provide
    for 8-byte write requests were still not fully portable since they
    shared a cacheline with unrelated CPU-accessed data.)

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • firewire-sbp2 already takes care for internal serialization where
    required (ORB list accesses), and it does not use cmd->serial_number
    internally. Hence it is safe to not grab the shost lock around
    queuecommand.

    While we are at housekeeping, drop a redundant struct member:
    sbp2_command_orb.done is set once in a hot path and dereferenced once in
    a hot path. We can as well dereference sbp2_command_orb.cmd->scsi_done
    instead.

    Signed-off-by: Stefan Richter

    Stefan Richter
     

20 Mar, 2011

1 commit