1. 18 4月, 2008 13 次提交
    • T
      libata: stop overloading port_info->private_data · 887125e3
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      887125e3
    • T
      libata: make ata_pci_init_one() not use ops->irq_handler and pi->sht · 1bd5b715
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      1bd5b715
    • T
      libata: implement and use ops inheritance · 029cfd6b
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      029cfd6b
    • T
      libata: implement and use SHT initializers · 68d1d07b
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      68d1d07b
    • T
      libata: normalize port_info, port_operations and sht tables · 6bd99b4e
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      6bd99b4e
    • T
      libata: implement and use ata_noop_irq_clear() · 358f9a77
      Tejun Heo 提交于
      ->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: NTejun Heo <htejun@gmail.com>
      358f9a77
    • T
      libata: reorganize ata_port_operations · c1bc899f
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      c1bc899f
    • T
      libata: PCI device should be powered up before being accessed · f08048e9
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      f08048e9
    • T
      libata: kill ata_ehi_schedule_probe() · b558eddd
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      b558eddd
    • T
      libata: kill ATA_LFLAG_SKIP_D2H_BSY · 8cebf274
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      8cebf274
    • T
      libata: kill ATA_EHI_RESUME_LINK · 672b2d65
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      672b2d65
    • T
      libata: kill ATA_LFLAG_HRST_TO_RESUME · d692abd9
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      d692abd9
    • T
      libata: prefer hardreset · cf480626
      Tejun Heo 提交于
      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: NTejun Heo <htejun@gmail.com>
      cf480626
  2. 17 4月, 2008 7 次提交
  3. 16 4月, 2008 20 次提交