aboutsummaryrefslogtreecommitdiff
path: root/drivers/ata/libata-core.c
AgeCommit message (Collapse)Author
2008-04-17libata: move generic hardreset code from sata_sff_hardreset() to ↵Tejun Heo
sata_link_hardreset() sata_sff_hardreset() contains link readiness wait logic which isn't SFF specific. Move that part into sata_link_hardreset(), which now takes two more parameters - @online and @check_ready. Both are optional. The former is out parameter for link onlineness after reset. The latter is used to wait for link readiness after hardreset. Users of sata_link_hardreset() is updated to use new funtionality and ahci_hardreset() is updated to use sata_link_hardreset() instead of sata_sff_hardreset(). This doesn't really cause any behavior change. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: separate out ata_wait_ready() and implement ata_wait_after_reset()Tejun Heo
Factor out waiting logic (which is common to all ATA controllers) from ata_sff_wait_ready() into ata_wait_ready(). ata_wait_ready() takes @check_ready function pointer and uses it to poll for readiness. This allows non-SFF controllers to use ata_wait_ready() to wait for link readiness. This patch also implements ata_wait_after_reset() - generic version of ata_sff_wait_after_reset() - using ata_wait_ready(). ata_sff_wait_ready() is reimplemented using ata_wait_ready() and ata_sff_check_ready(). Functionality remains the same. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: separate out ata_std_postreset() from ata_sff_postreset()Tejun Heo
Separate out generic ATA portion from ata_sff_postreset() into ata_std_postreset() and implement ata_sff_postreset() using the std version. ata_base_port_ops now has ata_std_postreset() for its postreset and ata_sff_port_ops overrides it to ata_sff_postreset(). This change affects pdc_adma, ahci, sata_fsl and sata_sil24. pdc_adma now specifies postreset to ata_sff_postreset() explicitly. sata_fsl and sata_sil24 now use ata_std_postreset() which makes no difference to them. ahci now calls ata_std_postreset() from its own postreset method, which causes no behavior difference. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: separate out ata_std_prereset() from ata_sff_prereset()Tejun Heo
Separate out generic ATA portion from ata_sff_prereset() into ata_std_prereset() and implement ata_sff_prereset() using the std version. Waiting for device readiness is the only SFF specific part. ata_base_port_ops now has ata_std_prereset() for its prereset and ata_sff_port_ops overrides it to ata_sff_prereset(). This change can affect pdc_adma, ahci, sata_fsl and sata_sil24. pdc_adma implements its own prereset using ata_sff_prereset() and the rest has hardreset and thus are unaffected by this change. This change reflects real world situation. There is no generic way to wait for device readiness for non-SFF controllers and some of them don't have any mechanism for that. Non-sff drivers which don't have hardreset should wrap ata_std_prereset() and wait for device readiness itself but there's no such driver now and isn't likely to be popular in the future either. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: clean up port_ops->sff_irq_clear()Tejun Heo
->sff_irq_clear() is called only from SFF interrupt handler, so there is no reason to initialize it for non-SFF controllers. Also, ata_sff_irq_clear() can handle both BMDMA and non-BMDMA SFF controllers. This patch kills ata_noop_irq_clear() and removes it from base port_ops and sets ->sff_irq_clear to ata_sff_irq_clear() in sff port_ops instead of bmdma port_ops. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: rename SFF port opsTejun Heo
Add sff_ prefix to SFF specific port ops. This rename is in preparation of separating SFF support out of libata core layer. This patch strictly renames ops and doesn't introduce any behavior difference. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: rename SFF functionsTejun Heo
SFF functions have confusing names. Some have sff prefix, some have bmdma, some std, some pci and some none. Unify the naming by... * SFF functions which are common to both BMDMA and non-BMDMA are prefixed with ata_sff_. * SFF functions which are specific to BMDMA are prefixed with ata_bmdma_. * SFF functions which are specific to PCI but apply to both BMDMA and non-BMDMA are prefixed with ata_pci_sff_. * SFF functions which are specific to PCI and BMDMA are prefixed with ata_pci_bmdma_. * Drop generic prefixes from LLD specific routines. For example, bfin_std_dev_select -> bfin_dev_select. The following renames are noteworthy. ata_qc_issue_prot() -> ata_sff_qc_issue() ata_pci_default_filter() -> ata_bmdma_mode_filter() ata_dev_try_classify() -> ata_sff_dev_classify() This rename is in preparation of separating SFF support out of libata core layer. This patch strictly renames functions and doesn't introduce any behavior difference. Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-04-17libata: kill unused ata_flush_cache()Tejun Heo
ata_flush_code() hasn't been in use for quite some time now. Kill it. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: make ata_tf_to_lba[48]() genericTejun Heo
ata_tf_to_lba[48]() currently return LBA in tf + 1 for ata_read_native_max_address(). Make them return LBA and make it global so that it can be used to read LBA off TF for other purposes. ata_read_native_max_address() now adds 1 itself. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: isolate and rework cable logicAlan Cox
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: kill ata_chk_status() call from ata_dev_configure()Tejun Heo
ata_dev_configure() isn't tied to any controller interface except for the probe debug message printing at the end of the function. Kill the message. This is to help separating out SFF support from core layer. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: reorganize SFF related stuffTejun Heo
* 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: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: drop ata_dev_select() from ata_dev_read_idTejun Heo
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: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-17libata: make reset related methods proper port operationsTejun Heo
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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: stop overloading port_info->private_dataTejun 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: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
2008-04-17libata: make ata_pci_init_one() not use ops->irq_handler and pi->shtTejun 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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: implement and use ops inheritanceTejun 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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: implement and use ata_noop_irq_clear()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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: kill ata_ehi_schedule_probe()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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: kill ATA_LFLAG_SKIP_D2H_BSYTejun 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: Tejun Heo <htejun@gmail.com>
2008-04-17libata: prefer hardresetTejun 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: Tejun Heo <htejun@gmail.com>
2008-04-04libata: ATA_12/16 doesn't fall into ATAPI_MISCTejun Heo
SAT passthrus don't really fit into ATAPI_MISC class. SAT passthru commands always transfer multiple of 512 bytes and variable length response is not allowed. This patch creates a separate category - ATAPI_PASS_THRU - for these. This fixes HSM violation on "hdparm -I". Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-04libata: uninline atapi_cmd_type()Tejun Heo
Uninline atapi_cmd_type(). It doesn't really have to be inline and more case will be added which need to access unexported libata variable. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-04-04libata: fix IDENTIFY order in ata_bus_probe()Bartlomiej Zolnierkiewicz
Commit f58229f8060055b08b34008ea08f31de1e2f003c accidentally made ata_bus_probe() not use reverse order probing. Fix it. There currently isn't any PATA driver which uses obsolete ata_bus_probe() path, so this patch is mainly for correctness. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-03-29libata: ATA_EHI_LPM should be ATA_EH_LPMTejun Heo
EH actions are ATA_EH_* not ATA_EHI_*. Rename ATA_EHI_LPM to ATA_EH_LPM. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-03-24libata: improve HPA error handlingTejun Heo
There's no point in retrying and eventually failing device detection when the device rejects READ_NATIVE_MAX[_EXT]. Disable HPA unlocking if READ_NATIVE_MAX[_EXT] is rejected as done when SET_MAX[_EXT] is rejected. This allows some old drives to work even if they aren't blacklisted. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-03-24libata: assume no device is attached if both IDENTIFYs are abortedTejun Heo
This is to fix bugzilla #10254. QSI cdrom attached to pata_sis as secondary master appears as phantom device for the slave. Interestingly, instead of not setting DRQ after IDENTIFY which triggers NODEV_HINT, it aborts both IDENTIFY and IDENTIFY PACKET which makes EH retry. Modify EH such that it assumes no device is attached if both flavors of IDENTIFY are aborted by the device. There really isn't much point in retrying when the device actively aborts the commands. While at it, convert NODEV detection message to ata_dev_printk() to help debugging obscure detection problems. This problem was reported by Jan Bücken. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Jan Bücken <jb.faq@gmx.de> Acked-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-03-10libata: don't allow sysfs read access to force paramTejun Heo
Buffer for force param is deallocated after initialization, so trying to read it via sysfs results in oops. Don't allow read access to the param node. Spotted by Eric Sesterhenn. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-03-10ata: replace remaining __FUNCTION__ occurrencesHarvey Harrison
__FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-25Revert "power_state: get rid of write-only variable in SATA"Jeff Garzik
This reverts commit 559bbe6cbd0d8c68d40076a5f7dc98e3bf5864b2. Michael S. Tsirkin reports that this changes breaks suspend/resume. Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-02-25make atapi_dmadir staticAdrian Bunk
atapi_dmadir can now become static. Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-24libata-core: fix kernel-doc warningRandy Dunlap
Fix libata-core kernel-doc warning: Warning(linux-2.6.25-rc2-git6//drivers/ata/libata-core.c:168): No description found for parameter 'ap' Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-24libata: automatically use DMADIR if drive/bridge requires itTejun Heo
Back in 2.6.17-rc2, a libata module parameter was added for atapi_dmadir. That's nice, but most SATA devices which need it will tell us about it in their IDENTIFY PACKET response, as bit-15 of word-62 of the returned data (as per ATA7, ATA8 specifications). So for those which specify it, we should automatically use the DMADIR bit. Otherwise, disc writing will fail by default on many SATA-ATAPI drives. This patch adds ATA_DFLAG_DMADIR and make ata_dev_configure() set it if atapi_dmadir is set or identify data indicates DMADIR is necessary. atapi_xlat() is converted to check ATA_DFLAG_DMADIR before setting DMADIR. Original patch is from Mark Lord. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Mark Lord <mlord@pobox.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-24power_state: get rid of write-only variable in SATAPavel Machek
power_state is scheduled for removal, and libata uses it in write-only mode. Remove it. Signed-off-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-23PM: Introduce PM_EVENT_HIBERNATE callback stateRafael J. Wysocki
During the last step of hibernation in the "platform" mode (with the help of ACPI) we use the suspend code, including the devices' ->suspend() methods, to prepare the system for entering the ACPI S4 system sleep state. But at least for some devices the operations performed by the ->suspend() callback in that case must be different from its operations during regular suspend. For this reason, introduce the new PM event type PM_EVENT_HIBERNATE and pass it to the device drivers' ->suspend() methods during the last phase of hibernation, so that they can distinguish this case and handle it as appropriate. Modify the drivers that handle PM_EVENT_SUSPEND in a special way and need to handle PM_EVENT_HIBERNATE in the same way. These changes are necessary to fix a hibernation regression related to the i915 driver (ref. http://lkml.org/lkml/2008/2/22/488). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Tested-by: Jeff Chua <jeff.chua.linux@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-20libata: implement libata.force module parameterTejun Heo
This patch implements libata.force module parameter which can selectively override ATA port, link and device configurations including cable type, SATA PHY SPD limit, transfer mode and NCQ. For example, you can say "use 1.5Gbps for all fan-out ports attached to the second port but allow 3.0Gbps for the PMP device itself, oh, the device attached to the third fan-out port chokes on NCQ and shouldn't go over UDMA4" by the following. libata.force=2:1.5g,2.15:3.0g,2.03:noncq,udma4 Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-19libata: implement drain buffersJames Bottomley
This just updates the libata slave configure routine to take advantage of the block layer drain buffers. It also adjusts the size lengths in the atapi code to add the drain buffer to the DMA length so the driver knows it can rely on it. I suspect I should also be checking for AHCI as well as ATA_DEV_ATAPI, but I couldn't see how to do that easily. tj: * atapi_drain_needed() added such that draining is applied to only misc ATAPI commands. * q->bounce_gfp used when allocating drain buffer. * Now duplicate ATAPI PIO drain logic dropped. * ata_dev_printk() used instead of sdev_printk(). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-02-19libata: eliminate the home grown dma padding in favour ofJames Bottomley
that provided by the block layer ATA requires that all DMA transfers begin and end on word boundaries. Because of this, a large amount of machinery grew up in ide to adjust scatterlists on this basis. However, as of 2.5, the block layer has a dma_alignment variable which ensures both the beginning and length of a DMA transfer are aligned on the dma_alignment boundary. Although the block layer does adjust the beginning of the transfer to ensure this happens, it doesn't actually adjust the length, it merely makes sure that space is allocated for transfers beyond the declared length. The upshot of this is that scatterlists may be padded to any size between the actual length and the length adjusted to the dma_alignment safely knowing that memory is allocated in this region. Right at the moment, SCSI takes the default dma_aligment which is on a 512 byte boundary. Note that this aligment only applies to transfers coming in from user space. However, since all kernel allocations are automatically aligned on a minimum of 32 byte boundaries, it is safe to adjust them in this manner as well. tj: * Adjusting sg after padding is done in block layer. Make libata set queue alignment correctly for ATAPI devices and drop broken sg mangling from ata_sg_setup(). * Use request->raw_data_len for ATAPI transfer chunk size. * Killed qc->raw_nbytes. * Separated out killing qc->n_iter. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-02-19libata: update ATAPI overflow drainingTejun Heo
For misc ATAPI commands which transfer variable length data to the host, overflow can occur due to application or hardware bug. Such overflows can be ignored safely as long as overflow data is properly drained. libata HSM implementation has this implemented in __atapi_pio_bytes() and recently updated for 2.6.24-rc but it requires further improvements. Improve drain logic such that... * Report overflow errors using ehi desc mechanism instead of printing directly. * Properly calculate the number of bytes to be drained considering actual number of consumed bytes for partial draining. Signed-off-by: Tejun Heo <htejun@gmail.com> Acked-by: Albert Lee <albertcc@tw.ibm.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-02-19ide/libata: ST310211A has buggy HPA tooMikko Rapeli
Signed-off-by: Mikko Rapeli <mikko.rapeli@teleca.com> Tested-by: Bart Champagne <bart@as35701.net> Cc: Jeff Garzik <jgarzik@pobox.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-15ata: fix sparse warning in libata-core.cHarvey Harrison
rc is used to test the return value and possibly return an error. No need to redeclare inside the loop. drivers/ata/libata-core.c:7089:7: warning: symbol 'rc' shadows an earlier one drivers/ata/libata-core.c:7030:9: originally declared here Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-11libata: ignore deverr on SETXFER if mode is configuredTejun Heo
Some controllers (VIA CX700) raise device error on SETXFER even after mode configuration succeeded. Update ata_dev_set_mode() such that device error is ignored if transfer mode is configured correctly. To implement this, device is revalidated even after device error on SETXFER. This fixes kernel bugzilla bug 8563. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-06libata-core: unblacklist HITACHI drivesDavid Milburn
The HITACHI HDS7250SASUN500G and HITACHI HDS7225SBSUN250 drives do not need to be blacklisted, the NCQ problem has been resolved with the "sata_nv: fix for completion handling" patch. Signed-off-by David Milburn <dmilburn@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-02-03drivers/ata/: Spelling fixesJoe Perches
Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Adrian Bunk <bunk@kernel.org>
2008-01-29libata: Change "write_data" to "rw" for some function documentationsLinus Nilsson
The documentation for ata_data_xfer and ata_data_xfer_noirq had the 'rw' parameter named 'write_data'. Signed-off-by: Linus Nilsson <lajnold@acc.umu.se> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-23libata: factor out ata_pci_activate_sff_host() from ata_pci_one()Tejun Heo
Factor out ata_pci_activate_sff_host() from ata_pci_one(). This does about the same thing as ata_host_activate() but needs to be separate because SFF controllers use different and multiple IRQs in legacy mode. This will be used to make SFF LLD initialization more flexible. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-01-23libata annotations and fixesAl Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2008-01-23libata: make ata_port_queue_task() an internal functionJeff Garzik
ata_port_queue_task() served a single user: ata_pio_task() Rename to ata_pio_queue_task() and un-export it, as nobody outside of libata-core.c uses it. Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-01-23libata/pata_it821x: Improve handling of poorly compatible emulationsAlan Cox
Some it821x RAID firmwares return 0 for the err return off both devices. A similar issue occurs with the slave returning 0 not 1 if you plug a gigabyte sata ramdisk into a controller that fakes two SATA ports as master/slave on an SFF channel. The patch does the following - Allow the 'failed diagnostics' case on both master and slave - Move the HORKAGE_DIAGNOSTIC check after ->dev_config This second change also allows IT821x to fix up a problem where we report drive diagnostic failures when in fact the drive is fine but the microcontroller firmware doesn't appear to get it right. IT821x clears the flag again to avoid giving the user bogus warnings about their disk. The other IT821x change is a bit ugly, we slightly abuse the cable type hook to fiddle with the identify data for the devices. We could add a new hook for this but as we have only one offender and no more seeming likely it seems better to keep libata-core clean. Please let this sit in -mm briefly, just in case the relaxed checking breaks some other emulated interface. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-01-23libata: make qc->nbytes include extra buffersTejun Heo
qc->nbytes didn't use to include extra buffers setup by libata core layer and my be odd. This patch makes qc->nbytes include any extra buffers setup by libata core layer and guaranteed to be aligned on 4 byte boundary. This value is to be used to program the host controller. As this represents the actual length of buffer available to the controller and the controller must be able to deal with short transfers for ATAPI commands which can transfer variable length, this shouldn't break any controllers while making problems like rounding-down and controllers choking up on odd transfer bytes much less likely. The unmodified value is stored in new field qc->raw_nbytes. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>