libata-eh.c (da917d69d0ea63f5390716cba6e77f490ce96df9) libata-eh.c (ae791c05694d7391ee9261a0450a50f7e95aedfd)
1/*
2 * libata-eh.c - libata error handling
3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
7 *
8 * Copyright 2006 Tejun Heo <htejun@gmail.com>

--- 1892 unchanged lines hidden (view full) ---

1901 if (classes[dev->devno] == ATA_DEV_UNKNOWN)
1902 classes[dev->devno] = ATA_DEV_NONE;
1903 }
1904 }
1905
1906 return 0;
1907}
1908
1/*
2 * libata-eh.c - libata error handling
3 *
4 * Maintained by: Jeff Garzik <jgarzik@pobox.com>
5 * Please ALWAYS copy linux-ide@vger.kernel.org
6 * on emails.
7 *
8 * Copyright 2006 Tejun Heo <htejun@gmail.com>

--- 1892 unchanged lines hidden (view full) ---

1901 if (classes[dev->devno] == ATA_DEV_UNKNOWN)
1902 classes[dev->devno] = ATA_DEV_NONE;
1903 }
1904 }
1905
1906 return 0;
1907}
1908
1909static int ata_eh_followup_srst_needed(int rc, int classify,
1909static int ata_eh_followup_srst_needed(struct ata_link *link,
1910 int rc, int classify,
1910 const unsigned int *classes)
1911{
1911 const unsigned int *classes)
1912{
1913 if (link->flags & ATA_LFLAG_NO_SRST)
1914 return 0;
1912 if (rc == -EAGAIN)
1913 return 1;
1914 if (rc != 0)
1915 return 0;
1915 if (rc == -EAGAIN)
1916 return 1;
1917 if (rc != 0)
1918 return 0;
1916 if (classify && classes[0] == ATA_DEV_UNKNOWN)
1919 if (classify && !(link->flags & ATA_LFLAG_ASSUME_CLASS) &&
1920 classes[0] == ATA_DEV_UNKNOWN)
1917 return 1;
1918 return 0;
1919}
1920
1921int ata_eh_reset(struct ata_link *link, int classify,
1922 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
1923 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
1924{

--- 10 unchanged lines hidden (view full) ---

1935 /* about to reset */
1936 ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK);
1937
1938 /* Determine which reset to use and record in ehc->i.action.
1939 * prereset() may examine and modify it.
1940 */
1941 action = ehc->i.action;
1942 ehc->i.action &= ~ATA_EH_RESET_MASK;
1921 return 1;
1922 return 0;
1923}
1924
1925int ata_eh_reset(struct ata_link *link, int classify,
1926 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
1927 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
1928{

--- 10 unchanged lines hidden (view full) ---

1939 /* about to reset */
1940 ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK);
1941
1942 /* Determine which reset to use and record in ehc->i.action.
1943 * prereset() may examine and modify it.
1944 */
1945 action = ehc->i.action;
1946 ehc->i.action &= ~ATA_EH_RESET_MASK;
1943 if (softreset && (!hardreset || (!sata_set_spd_needed(link) &&
1947 if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) &&
1948 !sata_set_spd_needed(link) &&
1944 !(action & ATA_EH_HARDRESET))))
1945 ehc->i.action |= ATA_EH_SOFTRESET;
1946 else
1947 ehc->i.action |= ATA_EH_HARDRESET;
1948
1949 if (prereset) {
1950 rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT);
1951 if (rc) {

--- 46 unchanged lines hidden (view full) ---

1998 if (reset == hardreset)
1999 ehc->i.flags |= ATA_EHI_DID_HARDRESET;
2000 else
2001 ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
2002
2003 rc = ata_do_reset(link, reset, classes, deadline);
2004
2005 if (reset == hardreset &&
1949 !(action & ATA_EH_HARDRESET))))
1950 ehc->i.action |= ATA_EH_SOFTRESET;
1951 else
1952 ehc->i.action |= ATA_EH_HARDRESET;
1953
1954 if (prereset) {
1955 rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT);
1956 if (rc) {

--- 46 unchanged lines hidden (view full) ---

2003 if (reset == hardreset)
2004 ehc->i.flags |= ATA_EHI_DID_HARDRESET;
2005 else
2006 ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
2007
2008 rc = ata_do_reset(link, reset, classes, deadline);
2009
2010 if (reset == hardreset &&
2006 ata_eh_followup_srst_needed(rc, classify, classes)) {
2011 ata_eh_followup_srst_needed(link, rc, classify, classes)) {
2007 /* okay, let's do follow-up softreset */
2008 reset = softreset;
2009
2010 if (!reset) {
2011 ata_link_printk(link, KERN_ERR,
2012 "follow-up softreset required "
2013 "but no softreset avaliable\n");
2014 rc = -EINVAL;
2015 goto out;
2016 }
2017
2018 ata_eh_about_to_do(link, NULL, ATA_EH_RESET_MASK);
2019 rc = ata_do_reset(link, reset, classes, deadline);
2020
2012 /* okay, let's do follow-up softreset */
2013 reset = softreset;
2014
2015 if (!reset) {
2016 ata_link_printk(link, KERN_ERR,
2017 "follow-up softreset required "
2018 "but no softreset avaliable\n");
2019 rc = -EINVAL;
2020 goto out;
2021 }
2022
2023 ata_eh_about_to_do(link, NULL, ATA_EH_RESET_MASK);
2024 rc = ata_do_reset(link, reset, classes, deadline);
2025
2021 if (rc == 0 && classify &&
2022 classes[0] == ATA_DEV_UNKNOWN) {
2026 if (rc == 0 && classify && classes[0] == ATA_DEV_UNKNOWN &&
2027 !(link->flags & ATA_LFLAG_ASSUME_CLASS)) {
2023 ata_link_printk(link, KERN_ERR,
2024 "classification failed\n");
2025 rc = -EINVAL;
2026 goto out;
2027 }
2028 }
2029
2028 ata_link_printk(link, KERN_ERR,
2029 "classification failed\n");
2030 rc = -EINVAL;
2031 goto out;
2032 }
2033 }
2034
2035 /* if we skipped follow-up srst, clear rc */
2036 if (rc == -EAGAIN)
2037 rc = 0;
2038
2030 if (rc && try < ARRAY_SIZE(ata_eh_reset_timeouts)) {
2031 unsigned long now = jiffies;
2032
2033 if (time_before(now, deadline)) {
2034 unsigned long delta = deadline - jiffies;
2035
2036 ata_link_printk(link, KERN_WARNING, "reset failed "
2037 "(errno=%d), retrying in %u secs\n",

--- 8 unchanged lines hidden (view full) ---

2046 if (hardreset)
2047 reset = hardreset;
2048 goto retry;
2049 }
2050
2051 if (rc == 0) {
2052 u32 sstatus;
2053
2039 if (rc && try < ARRAY_SIZE(ata_eh_reset_timeouts)) {
2040 unsigned long now = jiffies;
2041
2042 if (time_before(now, deadline)) {
2043 unsigned long delta = deadline - jiffies;
2044
2045 ata_link_printk(link, KERN_WARNING, "reset failed "
2046 "(errno=%d), retrying in %u secs\n",

--- 8 unchanged lines hidden (view full) ---

2055 if (hardreset)
2056 reset = hardreset;
2057 goto retry;
2058 }
2059
2060 if (rc == 0) {
2061 u32 sstatus;
2062
2054 /* After the reset, the device state is PIO 0 and the
2055 * controller state is undefined. Record the mode.
2056 */
2057 ata_link_for_each_dev(dev, link)
2063 ata_link_for_each_dev(dev, link) {
2064 /* After the reset, the device state is PIO 0
2065 * and the controller state is undefined.
2066 * Record the mode.
2067 */
2058 dev->pio_mode = XFER_PIO_0;
2059
2068 dev->pio_mode = XFER_PIO_0;
2069
2070 if (ata_link_offline(link))
2071 continue;
2072
2073 /* apply class override and convert UNKNOWN to NONE */
2074 if (link->flags & ATA_LFLAG_ASSUME_ATA)
2075 classes[dev->devno] = ATA_DEV_ATA;
2076 else if (link->flags & ATA_LFLAG_ASSUME_SEMB)
2077 classes[dev->devno] = ATA_DEV_SEMB_UNSUP; /* not yet */
2078 else if (classes[dev->devno] == ATA_DEV_UNKNOWN)
2079 classes[dev->devno] = ATA_DEV_NONE;
2080 }
2081
2060 /* record current link speed */
2061 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2062 link->sata_spd = (sstatus >> 4) & 0xf;
2063
2064 if (postreset)
2065 postreset(link, classes);
2066
2067 /* reset successful, schedule revalidation */

--- 547 unchanged lines hidden ---
2082 /* record current link speed */
2083 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2084 link->sata_spd = (sstatus >> 4) & 0xf;
2085
2086 if (postreset)
2087 postreset(link, classes);
2088
2089 /* reset successful, schedule revalidation */

--- 547 unchanged lines hidden ---