1. 17 Apr, 2008 20 commits
    • Tejun Heo's avatar
      libata: reorganize SFF related stuff · 624d5c51
      Tejun Heo authored
      * Move SFF related functions from libata-core.c to libata-sff.c.
      
        ata_[bmdma_]sff_port_ops, ata_devchk(), ata_dev_try_classify(),
        ata_std_dev_select(), ata_tf_to_host(), ata_busy_sleep(),
        ata_wait_after_reset(), ata_wait_ready(), ata_bus_post_reset(),
        ata_bus_softreset(), ata_bus_reset(), ata_std_softreset(),
        sata_std_hardreset(), ata_fill_sg(), ata_fill_sg_dumb(),
        ata_qc_prep(), ata_dump_qc_prep(), ata_data_xfer(),
        ata_data_xfer_noirq(), ata_pio_sector(), ata_pio_sectors(),
        atapi_send_cdb(), __atapi_pio_bytes(), atapi_pio_bytes(),
        ata_hsm_ok_in_wq(), ata_hsm_qc_complete(), ata_hsm_move(),
        ata_pio_task(), ata_qc_issue_prot(), ata_host_intr(),
        ata_interrupt(), ata_std_ports()
      
      * Make ata_pio_queue_task() global as it's now called from
        libata-sff.c.
      
      * Move SFF related stuff in include/linux/libata.h and
        drivers/ata/libata.h into one place.  While at it, move timing
        constants into the global enum definition and fortify comments a
        bit.
      
      This patch strictly moves stuff around and as such doesn't cause any
      functional difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      624d5c51
    • Tejun Heo's avatar
      libata: reorder functions in libata-sff.c · 272f7884
      Tejun Heo authored
      Reorder functions in drivers/ata/libata-sff.c such that functions
      generally follow ops table order and init functions come last.  This
      is in preparation of SFF cleanup.
      
      This patch strictly moves stuff around and as such doesn't cause any
      functional difference.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      272f7884
    • Tejun Heo's avatar
      libata: drop ata_dev_select() from ata_dev_read_id · 21572ea5
      Tejun Heo authored
      There is no reason to issue device select in read_id, it will be done
      by ops->qc_issue() when IDENTIFY[_PACKET] is issued via
      ata_exec_internal().
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
      21572ea5
    • Tejun Heo's avatar
      libata: make reset related methods proper port operations · a1efdaba
      Tejun Heo authored
      Currently reset methods are not specified directly in the
      ata_port_operations table.  If a LLD wants to use custom reset
      methods, it should construct and use a error_handler which uses those
      reset methods.  It's done this way for two reasons.
      
      First, the ops table already contained too many methods and adding
      four more of them would noticeably increase the amount of necessary
      boilerplate code all over low level drivers.
      
      Second, as ->error_handler uses those reset methods, it can get
      confusing.  ie. By overriding ->error_handler, those reset ops can be
      made useless making layering a bit hazy.
      
      Now that ops table uses inheritance, the first problem doesn't exist
      anymore.  The second isn't completely solved but is relieved by
      providing default values - most drivers can just override what it has
      implemented and don't have to concern itself about higher level
      callbacks.  In fact, there currently is no driver which actually
      modifies error handling behavior.  Drivers which override
      ->error_handler just wraps the standard error handler only to prepare
      the controller for EH.  I don't think making ops layering strict has
      any noticeable benefit.
      
      This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
      their PMP counterparts propoer ops.  Default ops are provided in the
      base ops tables and drivers are converted to override individual reset
      methods instead of creating custom error_handler.
      
      * ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
        aren't accessible.  sata_promise doesn't need to use separate
        error_handlers for PATA and SATA anymore.
      
      * softreset is broken for sata_inic162x and sata_sx4.  As libata now
        always prefers hardreset, this doesn't really matter but the ops are
        forced to NULL using ATA_OP_NULL for documentation purpose.
      
      * pata_hpt374 needs to use different prereset for the first and second
        PCI functions.  This used to be done by branching from
        hpt374_error_handler().  The proper way to do this is to use
        separate ops and port_info tables for each function.  Converted.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      a1efdaba
    • Tejun Heo's avatar
      libata: kill port_info->sht and ->irq_handler · 95947193
      Tejun Heo authored
      libata core layer doesn't care about sht or ->irq_handler.  Those are
      only of interest to the LLD during initialization.  This is confusing
      and has caused several drivers to have duplicate unused initializers
      for these fields.
      
      Currently only sata_nv uses these fields.  Make sata_nv use
      ->private_data, which is supposed to carry LLD-specific information,
      instead and kill ->sht and ->irq_handler.  nv_pi_priv structure is
      defined and struct literals are used to initialize private_data.
      Notational overhead is negligible.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      95947193
    • Tejun Heo's avatar
      libata: stop overloading port_info->private_data · 887125e3
      Tejun Heo authored
      port_info->private_data is currently used for two purposes - to record
      private data about the port_info or to specify host->private_data to
      use when allocating ata_host.
      
      This overloading is confusing and counter-intuitive in that
      port_info->private_data becomes host->private_data instead of
      port->private_data.  In addition, port_info and host don't correspond
      to each other 1-to-1.  Currently, the first non-NULL
      port_info->private_data is used.
      
      This patch makes port_info->private_data just be what it is -
      private_data for the port_info where LLD can jot down extra info.
      libata no longer sets host->private_data to the first non-NULL
      port_info->private_data, @host_priv argument is added to
      ata_pci_init_one() instead.  LLDs which use ata_pci_init_one() can use
      this argument to pass in pointer to host private data.  LLDs which
      don't should use init-register model anyway and can initialize
      host->private_data directly.
      
      Adding @host_priv instead of using init-register model for LLDs which
      use ata_pci_init_one() is suggested by Alan Cox.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      887125e3
    • Tejun Heo's avatar
      libata: make ata_pci_init_one() not use ops->irq_handler and pi->sht · 1bd5b715
      Tejun Heo authored
      ata_pci_init_one() is the only function which uses ops->irq_handler
      and pi->sht.  Other initialization functions take the same information
      as arguments.  This causes confusion and duplicate unused entries in
      structures.
      
      Make ata_pci_init_one() take sht as an argument and use ata_interrupt
      implicitly.  All current users use ata_interrupt and if different irq
      handler is necessary open coding ata_pci_init_one() using
      ata_prepare_sff_host() and ata_activate_sff_host can be done under ten
      lines including error handling and driver which requires custom
      interrupt handler is likely to require custom initialization anyway.
      
      As ata_pci_init_one() was the last user of ops->irq_handler, this
      patch also kills the field.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      1bd5b715
    • Tejun Heo's avatar
      libata: implement and use ops inheritance · 029cfd6b
      Tejun Heo authored
      libata lets low level drivers build ata_port_operations table and
      register it with libata core layer.  This allows low level drivers
      high level of flexibility but also burdens them with lots of
      boilerplate entries.
      
      This becomes worse for drivers which support related similar
      controllers which differ slightly.  They share most of the operations
      except for a few.  However, the driver still needs to list all
      operations for each variant.  This results in large number of
      duplicate entries, which is not only inefficient but also error-prone
      as it becomes very difficult to tell what the actual differences are.
      
      This duplicate boilerplates all over the low level drivers also make
      updating the core layer exteremely difficult and error-prone.  When
      compounded with multi-branched development model, it ends up
      accumulating inconsistencies over time.  Some of those inconsistencies
      cause immediate problems and fixed.  Others just remain there dormant
      making maintenance increasingly difficult.
      
      To rectify the problem, this patch implements ata_port_operations
      inheritance.  To allow LLDs to easily re-use their own ops tables
      overriding only specific methods, this patch implements poor man's
      class inheritance.  An ops table has ->inherits field which can be set
      to any ops table as long as it doesn't create a loop.  When the host
      is started, the inheritance chain is followed and any operation which
      isn't specified is taken from the nearest ancestor which has it
      specified.  This operation is called finalization and done only once
      per an ops table and the LLD doesn't have to do anything special about
      it other than making the ops table non-const such that libata can
      update it.
      
      libata provides four base ops tables lower drivers can inherit from -
      base, sata, pmp, sff and bmdma.  To avoid overriding these ops
      accidentaly, these ops are declared const and LLDs should always
      inherit these instead of using them directly.
      
      After finalization, all the ops table are identical before and after
      the patch except for setting .irq_handler to ata_interrupt in drivers
      which didn't use to.  The .irq_handler doesn't have any actual effect
      and the field will soon be removed by later patch.
      
      * sata_sx4 is still using old style EH and currently doesn't take
        advantage of ops inheritance.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      029cfd6b
    • Tejun Heo's avatar
      libata: implement and use SHT initializers · 68d1d07b
      Tejun Heo authored
      libata lets low level drivers build scsi_host_template and register it
      to the SCSI layer.  This allows low level drivers high level of
      flexibility but also burdens them with lots of boilerplate entries.
      
      This patch implements SHT initializers which can be used to initialize
      all the boilerplate entries in a sht.  Three variants of them are
      implemented - BASE, BMDMA and NCQ - for different types of drivers.
      Note that entries can be overriden by putting individual initializers
      after the helper macro.
      
      All sht tables are identical before and after this patch.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      68d1d07b
    • Tejun Heo's avatar
      libata: normalize port_info, port_operations and sht tables · 6bd99b4e
      Tejun Heo authored
      Over the time, port info, ops and sht structures developed quite a bit
      of inconsistencies.  This patch updates drivers.
      
      * Enable/disable_pm callbacks added to all ahci ops tables.
      
      * Every driver for SFF controllers now uses ata_sff_port_start()
        instead of ata_port_start() unless the driver has custom
        implementation.
      
      * Every driver for SFF controllers now uses ata_pci_default_filter()
        unless the driver has custom implementation.
      
      * Removed an odd port_info->sht initialization from ata_piix.c.
        Likely a merge byproduct.
      
      * A port which has ATA_FLAG_SATA set doesn't need to set cable_detect
        to ata_cable_sata().  Remove it from via and mv port ops.
      
      * Some drivers had unnecessary .max_sectors initialization which is
        ignored and was missing .slave_destroy callback.  Fixed.
      
      * Removed unnecessary sht initializations port_info's.
      
      * Removed onsolete scsi device suspend/resume callbacks from
        pata_bf54x.
      
      * No reason to set ata_pci_default_filter() and bmdma functions for
        PIO-only drivers.  Remove those callbacks and replace
        ata_bmdma_irq_clear with ata_noop_irq_clear.
      
      * pata_platform sets port_start to ata_dummy_ret0.  port_start can
        just be set to NULL.
      
      * sata_fsl supports NCQ but was missing qc_defer.  Fixed.
      
      * pata_rb600_cf implements dummy port_start.  Removed.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      6bd99b4e
    • Tejun Heo's avatar
      libata: implement and use ata_noop_irq_clear() · 358f9a77
      Tejun Heo authored
      ->irq_clear() is used to clear IRQ bit of a SFF controller and isn't
      useful for drivers which don't use libata SFF HSM implementation.
      However, it's a required callback and many drivers implement their own
      noop version as placeholder.  This patch implements ata_noop_irq_clear
      and use it to replace those custom placeholders.
      
      Also, SFF drivers which don't support BMDMA don't need to use
      ata_bmdma_irq_clear().  It becomes noop if BMDMA address isn't
      initialized.  Convert them to use ata_noop_irq_clear().
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      358f9a77
    • Tejun Heo's avatar
      libata: reorganize ata_port_operations · c1bc899f
      Tejun Heo authored
      Over the time, ops in ata_port_operations has become a bit confusing.
      Reorganize.  SFF/BMDMA ops are separated into separate a group as they
      will be taken out of ata_port_operations later.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      c1bc899f
    • Tejun Heo's avatar
      libata: PCI device should be powered up before being accessed · f08048e9
      Tejun Heo authored
      PCI device should be powered up or powered up before its PCI regsiters
      are accessed.  Although PCI configuration register access is allowed
      in D3hot, PCI device is free to reset its status when transiting from
      D3hot to D0 causing configuration data to change.
      
      Many libata SFF drivers which use ata_pci_init_one() read and update
      configuration registers before calling ata_pci_init_one() which
      enables the PCI device.  Also, in resume paths, some drivers access
      registers without resuming the PCI device.
      
      This patch adds a call to pcim_enable_device() in init path if
      register is accessed before calling ata_pci_init_one() and make resume
      paths first resume PCI devices, access PCI configuration regiters then
      resume ATA host.
      
      While at it...
      
      * cmd640 was strange in that it set ->resume even when CONFIG_PM is
        not.  This is by-product of minimal build fix.  Updated.
      
      * In cs5530, Don't BUG() on reinit failure.  Just whine and fail
        resume.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      f08048e9
    • Tejun Heo's avatar
      libata: kill ata_ehi_schedule_probe() · b558eddd
      Tejun Heo authored
      ata_ehi_schedule_probe() was created to hide details of link-resuming
      reset magic.  Now that all the softreset workarounds are gone,
      scheduling probe is very simple - set probe_mask and request RESET.
      Kill ata_ehi_schedule_probe() and open code it.  This also increases
      consistency as ata_ehi_schedule_probe() couldn't cover individual
      device probings so they were open-coded even when the helper existed.
      
      While at it, define ATA_ALL_DEVICES as mask of all possible devices on
      a link and always use it when requesting probe on link level for
      simplicity and consistency.  Setting extra bits in the probe_mask
      doesn't hurt anybody.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      b558eddd
    • Tejun Heo's avatar
      libata: kill ATA_LFLAG_SKIP_D2H_BSY · 8cebf274
      Tejun Heo authored
      Some controllers can't reliably record the initial D2H FIS after SATA
      link is brought online for whatever reason.  Advanced controllers
      which don't have traditional TF register based interface often have
      this problem as they don't really have the TF registers to update
      while the controller and link are being initialized.
      
      SKIP_D2H_BSY works around the problem by skipping the wait for device
      readiness before issuing SRST, so for such controllers libata issues
      SRST blindly and hopes for the best.
      
      Now that libata defaults to hardreset, this workaround is no longer
      necessary.  For controllers which have support for hardreset, SRST is
      never issued by itself.  It is only issued as follow-up SRST for
      device classification and PMP initialization, so there's no need to
      wait for it from prereset.
      
      Kill ATA_LFLAG_SKIP_D2H_BSY.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      8cebf274
    • Tejun Heo's avatar
      libata: kill ATA_EHI_RESUME_LINK · 672b2d65
      Tejun Heo authored
      ATA_EHI_RESUME_LINK has two functions - promote reset to hardreset if
      ATA_LFLAG_HRST_TO_RESUME is set and preventing EH from shortcutting
      reset action when probing is requested.  The former is gone now and
      the latter can easily be achieved by making EH to perform at least one
      reset if reset is requested, which also makes more sense than
      depending on RESUME_LINK flag.
      
      As ATA_EHI_RESUME_LINK was the only EHI reset modifier, this also
      kills reset modifier handling.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      672b2d65
    • Tejun Heo's avatar
      libata: kill ATA_LFLAG_HRST_TO_RESUME · d692abd9
      Tejun Heo authored
      Now that hardreset is the preferred method of resetting, there's no
      need for ATA_LFLAG_HRST_TO_RESUME flag.  Kill it.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      d692abd9
    • Tejun Heo's avatar
      libata: prefer hardreset · cf480626
      Tejun Heo authored
      When both soft and hard resets are available, libata preferred
      softreset till now.  The logic behind it was to be softer to devices;
      however, this doesn't really help much.  Rationales for the change:
      
      * BIOS may freeze lock certain things during boot and softreset can't
        unlock those.  This by itself is okay but during operation PHY event
        or other error conditions can trigger hardreset and the device may
        end up with different configuration.
      
        For example, after a hardreset, previously unlockable HPA can be
        unlocked resulting in different device size and thus revalidation
        failure.  Similar condition can occur during or after resume.
      
      * Certain ATAPI devices require hardreset to recover after certain
        error conditions.  On PATA, this is done by issuing the DEVICE RESET
        command.  On SATA, COMRESET has equivalent effect.  The problem is
        that DEVICE RESET needs its own execution protocol.
      
        For SFF controllers with bare TF access, it can be easily
        implemented but more advanced controllers (e.g. ahci and sata_sil24)
        require specialized implementations.  Simply using hardreset solves
        the problem nicely.
      
      * COMRESET initialization sequence is the norm in SATA land and many
        SATA devices don't work properly if only SRST is used.  For example,
        some PMPs behave this way and libata works around by always issuing
        hardreset if the host supports PMP.
      
        Like the above example, libata has developed a number of mechanisms
        aiming to promote softreset to hardreset if softreset is not going
        to work.  This approach is time consuming and error prone.
      
        Also, note that, dependingon how you read the specs, it could be
        argued that PMP fan-out ports require COMRESET to start operation.
        In fact, all the PMPs on the market except one don't work properly
        if COMRESET is not issued to fan-out ports after PMP reset.
      
      * COMRESET is an integral part of SATA connection and any working
        device should be able to handle COMRESET properly.  After all, it's
        the way to signal hardreset during reboot.  This is the most used
        and recommended (at least by the ahci spec) method of resetting
        devices.
      
      So, this patch makes libata prefer hardreset over softreset by making
      the following changes.
      
      * Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
        ATA_EH_{SOFT|HARD}RESET used to be used.  ATA_EH_{SOFT|HARD}RESET is
        now only used to tell prereset whether soft or hard reset will be
        issued.
      
      * Strip out now unneeded promote-to-hardreset logics from
        ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
        other places.
      Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
      cf480626
    • Linus Torvalds's avatar
      Linux 2.6.25 · 4b119e21
      Linus Torvalds authored
      4b119e21
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6 · c970d5a3
      Linus Torvalds authored
      * git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6:
        it821x: do not describe noraid parameter with its value
        Pb1200/DBAu1200: fix bad IDE resource size
        Au1200: IDE driver build fix
        Au1200: kill IDE driver function prototypes
        avr32 mustn't select HAVE_IDE
      c970d5a3
  2. 16 Apr, 2008 20 commits