From patchwork Sat Nov 17 20:44:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shane Huang X-Patchwork-Id: 199851 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 4148D2C008E for ; Sat, 17 Nov 2012 23:43:28 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751741Ab2KQMnZ (ORCPT ); Sat, 17 Nov 2012 07:43:25 -0500 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:54035 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751715Ab2KQMnY (ORCPT ); Sat, 17 Nov 2012 07:43:24 -0500 Received: from mail162-tx2-R.bigfish.com (10.9.14.238) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 14.1.225.23; Sat, 17 Nov 2012 12:43:24 +0000 Received: from mail162-tx2 (localhost [127.0.0.1]) by mail162-tx2-R.bigfish.com (Postfix) with ESMTP id DA2B84A020B; Sat, 17 Nov 2012 12:43:23 +0000 (UTC) X-Forefront-Antispam-Report: CIP:163.181.249.108; KIP:(null); UIP:(null); IPV:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VPS0(zzzz1de0h1202h1d1ah1d2ahzz8275bh8275dhz2dh668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1155h) Received: from mail162-tx2 (localhost.localdomain [127.0.0.1]) by mail162-tx2 (MessageSwitch) id 1353156200883116_26286; Sat, 17 Nov 2012 12:43:20 +0000 (UTC) Received: from TX2EHSMHS012.bigfish.com (unknown [10.9.14.240]) by mail162-tx2.bigfish.com (Postfix) with ESMTP id C9BAB100047; Sat, 17 Nov 2012 12:43:20 +0000 (UTC) Received: from ausb3twp01.amd.com (163.181.249.108) by TX2EHSMHS012.bigfish.com (10.9.99.112) with Microsoft SMTP Server id 14.1.225.23; Sat, 17 Nov 2012 12:43:20 +0000 X-WSS-ID: 0MDMU06-01-4HZ-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Axway MailGate 3.8.1) with ESMTP id 22DF31028016; Sat, 17 Nov 2012 06:43:17 -0600 (CST) Received: from SAUSEXDAG06.amd.com (163.181.55.7) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.192.1; Sat, 17 Nov 2012 06:42:54 -0600 Received: from SCYBEXDAG01.amd.com (10.34.11.11) by sausexdag06.amd.com (163.181.55.7) with Microsoft SMTP Server (TLS) id 14.2.318.4; Sat, 17 Nov 2012 06:43:18 -0600 Received: from shane-PUMORI.amd.com (10.237.73.77) by SCYBEXDAG01.amd.com (10.34.11.11) with Microsoft SMTP Server id 14.1.323.3; Sat, 17 Nov 2012 20:43:15 +0800 From: Shane Huang To: Jeff Garzik CC: , Shane Huang Subject: [PATCH] libata: check SATA_SETTINGS log with HW Feature Ctrl Date: Sun, 18 Nov 2012 04:44:41 +0800 Message-ID: <1353185081-11349-1-git-send-email-shane.huang@amd.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org NCQ capability was used to check availability of SATA Settings page from Identify Device Data Log, which contains DevSlp timing variables. It does not work on some HDDs and leads to error messages. IDENTIFY word 78 bit 5(Hardware Feature Control) should be used. Quoting SATA spec 3.1: If Hardware Feature Control is supported, then: a) IDENTIFY DEVICE data word 78 bit 5 (see 13.2.1.18) shall be set to one; b) the SET FEATURES Select Hardware Feature Control subcommand shall be supported (see 13.3.8); c) page 08h of the Identify Device Data log (see 13.7.7) shall be supported; This patch is not tested on SATA HDD with DevSlp supported. Reported-by: Borislav Petkov Signed-off-by: Shane Huang --- drivers/ata/libata-core.c | 3 +-- include/linux/ata.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3cc7096..4c9a58b 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2330,9 +2330,8 @@ int ata_dev_configure(struct ata_device *dev) /* Obtain SATA Settings page from Identify Device Data Log, * which contains DevSlp timing variables etc. - * Exclude old devices with ata_id_has_ncq() */ - if (ata_id_has_ncq(dev->id)) { + if (ata_id_has_hw_feature_ctrl(dev->id)) { err_mask = ata_read_log_page(dev, ATA_LOG_SATA_ID_DEV_DATA, ATA_LOG_SATA_SETTINGS, diff --git a/include/linux/ata.h b/include/linux/ata.h index 408da95..18cbb93 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -593,6 +593,7 @@ static inline int ata_is_data(u8 prot) #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) #define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4)) #define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8)) +#define ata_id_has_hw_feature_ctrl(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 5)) static inline bool ata_id_has_hipm(const u16 *id) {