From patchwork Fri Aug 7 07:05:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shane Huang X-Patchwork-Id: 30914 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 6219BB70C4 for ; Fri, 7 Aug 2009 17:06:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756622AbZHGHGP (ORCPT ); Fri, 7 Aug 2009 03:06:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756849AbZHGHGP (ORCPT ); Fri, 7 Aug 2009 03:06:15 -0400 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:58322 "EHLO VA3EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756622AbZHGHGO (ORCPT ); Fri, 7 Aug 2009 03:06:14 -0400 Received: from mail91-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 8.1.340.0; Fri, 7 Aug 2009 07:06:14 +0000 Received: from mail91-va3 (localhost.localdomain [127.0.0.1]) by mail91-va3-R.bigfish.com (Postfix) with ESMTP id A4FDB440224; Fri, 7 Aug 2009 07:06:14 +0000 (UTC) X-SpamScore: -1 X-BigFish: VPS-1(zz168aJ936eMa4a4kzz1202hzzz32i203h6bh43j64h) X-Spam-TCS-SCL: 3:0 Received: by mail91-va3 (MessageSwitch) id 1249628763119331_18637; Fri, 7 Aug 2009 07:06:03 +0000 (UCT) Received: from svlb1extmailp02.amd.com (unknown [139.95.251.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail91-va3.bigfish.com (Postfix) with ESMTP id EDB6EB88051; Fri, 7 Aug 2009 07:06:02 +0000 (UTC) Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n7775vAp020508; Fri, 7 Aug 2009 00:06:00 -0700 X-WSS-ID: 0KNZVPX-03-8XS-01 Received: from SSVLEXBH2.amd.com (ssvlexbh2.amd.com [139.95.53.183]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2B82888493D; Fri, 7 Aug 2009 00:05:57 -0700 (PDT) Received: from ssvlexmb2.amd.com ([139.95.53.7]) by SSVLEXBH2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 7 Aug 2009 00:05:58 -0700 Received: from storexbh1.amd.com ([10.1.1.17]) by ssvlexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 7 Aug 2009 00:05:58 -0700 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 7 Aug 2009 03:05:57 -0400 Received: from 10.237.82.10 ([10.237.82.10]) by sshaexmb1.amd.com ([10.237.2.11]) with Microsoft Exchange Server HTTP-DAV ; Fri, 7 Aug 2009 07:05:53 +0000 Received: from zm-desktop by sshaexmb1.amd.com; 07 Aug 2009 15:05:53 +0800 Subject: [PATCH] kill @force_restart and refine CLO for ahci_kick_engine() From: Shane Huang Reply-To: shane.huang@amd.com To: jgarzik@pobox.com CC: linux-ide@vger.kernel.org, tj@kernel.org, "Huang, Shane" Organization: AMD Date: Fri, 7 Aug 2009 15:05:52 +0800 Message-ID: <1249628752.3413.6.camel@zm-desktop> MIME-Version: 1.0 X-Mailer: Evolution 2.26.1 X-OriginalArrivalTime: 07 Aug 2009 07:05:57.0289 (UTC) FILETIME=[83099190:01CA172D] Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org This patch refines ahci_kick_engine() after discussion with Tejun about FBS(FIS-based switching) support preparation: a. Kill @force_restart and always kick the engine. The only case where @force_restart is zero is when it's called from ahci_p5wdh_hardreset() Actually at that point, BSY is pretty much guaranteed to be set. b. If PMP is attached, ignore busy and always do CLO. (AHCI-1.3 9.2) Signed-off-by: Shane Huang Cc: Tejun Heo Acked-by: Tejun Heo --- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -ruN a/drivers/ata/ahci.c b/drivers/ata/ahci.c --- a/drivers/ata/ahci.c 2009-07-29 14:38:39.000000000 +0800 +++ b/drivers/ata/ahci.c 2009-08-06 17:36:59.000000000 +0800 @@ -1578,7 +1578,7 @@ pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); } -static int ahci_kick_engine(struct ata_port *ap, int force_restart) +static int ahci_kick_engine(struct ata_port *ap) { void __iomem *port_mmio = ahci_port_base(ap); struct ahci_host_priv *hpriv = ap->host->private_data; @@ -1586,18 +1586,16 @@ u32 tmp; int busy, rc; - /* do we need to kick the port? */ - busy = status & (ATA_BUSY | ATA_DRQ); - if (!busy && !force_restart) - return 0; - /* stop engine */ rc = ahci_stop_engine(ap); if (rc) goto out_restart; - /* need to do CLO? */ - if (!busy) { + /* need to do CLO? + * always do CLO if PMP is attached (AHCI-1.3 9.2) + */ + busy = status & (ATA_BUSY | ATA_DRQ); + if (!busy && !sata_pmp_attached(ap)) { rc = 0; goto out_restart; } @@ -1645,7 +1643,7 @@ tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1, 1, timeout_msec); if (tmp & 0x1) { - ahci_kick_engine(ap, 1); + ahci_kick_engine(ap); return -EBUSY; } } else @@ -1667,7 +1665,7 @@ DPRINTK("ENTER\n"); /* prepare for SRST (AHCI-1.1 10.4.1) */ - rc = ahci_kick_engine(ap, 1); + rc = ahci_kick_engine(ap); if (rc && rc != -EOPNOTSUPP) ata_link_printk(link, KERN_WARNING, "failed to reset engine (errno=%d)\n", rc); @@ -1873,7 +1871,7 @@ rc = ata_wait_after_reset(link, jiffies + 2 * HZ, ahci_check_ready); if (rc) - ahci_kick_engine(ap, 0); + ahci_kick_engine(ap); } return rc; } @@ -2254,7 +2252,7 @@ /* make DMA engine forget about the failed command */ if (qc->flags & ATA_QCFLAG_FAILED) - ahci_kick_engine(ap, 1); + ahci_kick_engine(ap); } static void ahci_pmp_attach(struct ata_port *ap)