From patchwork Mon Jun 29 10:20:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 29267 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by bilbo.ozlabs.org (Postfix) with ESMTP id 1DFA1B707C for ; Mon, 29 Jun 2009 20:20:52 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756879AbZF2KUY (ORCPT ); Mon, 29 Jun 2009 06:20:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753300AbZF2KUY (ORCPT ); Mon, 29 Jun 2009 06:20:24 -0400 Received: from rv-out-0506.google.com ([209.85.198.226]:64641 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756879AbZF2KUW (ORCPT ); Mon, 29 Jun 2009 06:20:22 -0400 Received: by rv-out-0506.google.com with SMTP id f6so1239662rvb.1 for ; Mon, 29 Jun 2009 03:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type; bh=cGREDHkWu44VwAXkwdQWBfIIWcf0YJL5cd4bPC8zIiE=; b=TSyxG6nEWSBI7sBz5ZEJqri13PksegJcw/cY1AKbgg9s+u7aq3wQzUIEU+aWlEk850 FOfp4OEnnv0fM/rvXucDelnCCQl+4mwIXtOO7jMGH23v9aASHmmkYOBisJ2TxsU4GDuI V8IBsLhg6xroit5YzUeXcKOZon8ubvnoxoCks= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; b=YoZa2z/K5VUn3LZnGTsvfq1bqnkp/dKPt5bfnxPmOe8vTzCHmwWem03eT5yUDg/kRV VEe6LEH9ALVBs6npFRbdp/lk127BKH5MmIos9BLG6BhAsUa2thmaQ0KBT6WKwmz0T9CD 4SgWSwEFYvu2dybeR0Wf4RDCbbox8JnQGZnjM= Received: by 10.141.27.16 with SMTP id e16mr1361846rvj.256.1246270824549; Mon, 29 Jun 2009 03:20:24 -0700 (PDT) Received: from htj.dyndns.org ([211.179.206.32]) by mx.google.com with ESMTPS id l31sm1565365rvb.43.2009.06.29.03.20.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 29 Jun 2009 03:20:23 -0700 (PDT) Received: from [127.0.0.2] (htj.dyndns.org [127.0.0.2]) by htj.dyndns.org (Postfix) with ESMTPSA id ADE0940231A87; Mon, 29 Jun 2009 19:20:18 +0900 (KST) Message-ID: <4A489562.8080404@gmail.com> Date: Mon, 29 Jun 2009 19:20:18 +0900 From: Tejun Heo User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Marc Bowes CC: Robert Hancock , James Bottomley , linux-ide@vger.kernel.org Subject: Re: SATA: link online but device misclassified References: <1244746872.3998.88.camel@mulgrave.site> <1245165697.3965.40.camel@mulgrave.site> <4A3AEC08.4060507@gmail.com> <4A3B0D49.8070802@gmail.com> <4A3CD738.1080105@gmail.com> In-Reply-To: X-Enigmail-Version: 0.95.7 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Marc Bowes wrote: > Ok. Just keep me informed :) Please test the attached patch and report the resulting boot log. Oh and please turn on CONFIG_PRINTK_TIME. Thanks. drivers/ata/ahci.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/ata/libata-eh.c | 15 +++++++++++---- include/linux/libata.h | 1 + 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 2141a31..58cf5f7 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -2677,6 +2677,48 @@ static bool ahci_broken_suspend(struct pci_dev *pdev) return !ver || strcmp(ver, dmi->driver_data) < 0; } +static bool ahci_broken_online(struct pci_dev *pdev) +{ +#define ENCODE_BUSDEVFN(bus, slot, func) \ + (void *)(unsigned long)(((bus) << 8) | PCI_DEVFN((slot), (func))) + static const struct dmi_system_id sysids[] = { + /* + * There are several gigabyte boards which use + * SIMG5723s configured as hardware RAID. Certain + * 5723 firmware revisions shipped there keep the link + * online but fail to answer properly to SRST or + * IDENTIFY when no device is attached downstream + * causing libata to retry quite a few times leading + * to excessive detection delay. + * + * As these firmwares respond to the second reset try + * with invalid device signature, considering unknown + * sig as offline works around the problem acceptably. + */ + { + .ident = "EP45-DQ6", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, + "Gigabyte Technology Co., Ltd."), + DMI_MATCH(DMI_BOARD_NAME, + "EP45-DQ6"), + }, + .driver_data = ENCODE_BUSDEVFN(0x0a, 0x00, 0), + }, + { } /* terminate list */ + }; +#undef ENCODE_BUSDEVFN + const struct dmi_system_id *dmi = dmi_first_match(sysids); + unsigned int val; + + if (!dmi) + return false; + + val = (unsigned long)dmi->driver_data; + + return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff); +} + static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; @@ -2788,6 +2830,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) "BIOS update required for suspend/resume\n"); } + if (ahci_broken_online(pdev)) { + pi.link_flags |= ATA_LFLAG_UNK_IS_OFFLINE; + dev_info(&pdev->dev, + "online status unreliable, applying workaround\n"); + } + /* CAP.NP sometimes indicate the index of the last enabled * port, at other times, that of the last possible port, so * determining the maximum port number requires looking at diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 94919ad..cfc98c3 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2595,16 +2595,23 @@ int ata_eh_reset(struct ata_link *link, int classify, } if (classify && nr_unknown) { - if (try < max_tries) { + bool unk_is_offline = link->flags & ATA_LFLAG_UNK_IS_OFFLINE; + + if (!unk_is_offline && try < max_tries) { ata_link_printk(link, KERN_WARNING, "link online but " "device misclassified, retrying\n"); failed_link = link; rc = -EAGAIN; goto fail; } - ata_link_printk(link, KERN_WARNING, - "link online but device misclassified, " - "device detection might fail\n"); + if (unk_is_offline) + ata_link_printk(link, KERN_INFO, + "link online but device misclassified, " + "treating as offline\n"); + else + ata_link_printk(link, KERN_WARNING, + "link online but device misclassified, " + "device detection might fail\n"); } /* reset successful, schedule revalidation */ diff --git a/include/linux/libata.h b/include/linux/libata.h index 3d501db..934e805 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -172,6 +172,7 @@ enum { ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ + ATA_LFLAG_UNK_IS_OFFLINE = (1 << 8), /* treat unknown sig as offline */ /* struct ata_port flags */ ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */