From patchwork Tue Aug 7 18:20:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Lord X-Patchwork-Id: 175766 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 184B72C009B for ; Wed, 8 Aug 2012 04:20:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756042Ab2HGSUu (ORCPT ); Tue, 7 Aug 2012 14:20:50 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:38027 "EHLO ironport2-out.teksavvy.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753016Ab2HGSUt (ORCPT ); Tue, 7 Aug 2012 14:20:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIBAG6Zu08Y9geI/2dsb2JhbAANN4UtqxuGZwEBBCMEUQEQCyEWCwICCQMCAQIBRQYNAQcBAa8YknuPMIEUA444gR2OZIlX X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="195170240" Received: from 24-246-7-136.cable.teksavvy.com (HELO [10.0.0.7]) ([24.246.7.136]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 07 Aug 2012 14:20:48 -0400 Message-ID: <50215C80.8080601@teksavvy.com> Date: Tue, 07 Aug 2012 14:20:48 -0400 From: Mark Lord User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Barry J Sturgeon CC: linux-ide@vger.kernel.org Subject: Re: sata_mv query References: <006c01cd74ac$a06edf30$e14c9d90$@sturgeon@perpetual-data.com> <50214D56.9090907@teksavvy.com> <50215BC9.2020709@teksavvy.com> In-Reply-To: <50215BC9.2020709@teksavvy.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On 12-08-07 02:17 PM, Mark Lord wrote: .. > Say, here's a thought: We could get rid of (or relocate to upper layers) > the busy-wait by having something similar get called from ata_qc_defer(). > > If you are feeling adventurous, here is a 100% untested patch to do just that. > It looks correct to me, it compiles, but that's all I can say. Whoops.. return codes were reversed. Here's the corrected patch. The attached copy is the better one to use -- my mailer mangles inline patches. --- linux-3.4.4/drivers/ata/sata_mv.c 2012-06-22 14:37:50.000000000 -0400 +++ linux/drivers/ata/sata_mv.c 2012-08-07 14:14:43.554503157 -0400 @@ -1388,6 +1388,17 @@ } } +static int mv_check_for_edma_empty_idle(struct ata_port *ap) +{ + void __iomem *port_mmio = mv_ap_base(ap); + const u32 empty_idle = (EDMA_STATUS_CACHE_EMPTY | EDMA_STATUS_IDLE); + + u32 edma_stat = readl(port_mmio + EDMA_STATUS); + if ((edma_stat & empty_idle) == empty_idle) + return 0; + return ATA_DEFER_PORT; +} + static int mv_qc_defer(struct ata_queued_cmd *qc) { struct ata_link *link = qc->dev->link; @@ -1423,7 +1434,7 @@ * If the port is completely idle, then allow the new qc. */ if (ap->nr_active_links == 0) - return 0; + return mv_check_for_edma_empty_idle(ap); /* * The port is operating in host queuing mode (EDMA) with NCQ