From patchwork Thu Jul 15 09:29:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 58969 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 71F62B6F0E for ; Thu, 15 Jul 2010 19:29:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932886Ab0GOJ3K (ORCPT ); Thu, 15 Jul 2010 05:29:10 -0400 Received: from hera.kernel.org ([140.211.167.34]:54341 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932874Ab0GOJ3K (ORCPT ); Thu, 15 Jul 2010 05:29:10 -0400 Received: from htj.dyndns.org (localhost [127.0.0.1]) by hera.kernel.org (8.14.4/8.14.3) with ESMTP id o6F9T7WL008918; Thu, 15 Jul 2010 09:29:08 GMT X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.95.2 at hera.kernel.org Received: from [192.168.1.169] (unknown [82.113.61.70]) by htj.dyndns.org (Postfix) with ESMTPSA id 3809210043C02; Thu, 15 Jul 2010 11:29:07 +0200 (CEST) Message-ID: <4C3ED4E2.9080806@kernel.org> Date: Thu, 15 Jul 2010 11:29:06 +0200 From: Tejun Heo User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1 MIME-Version: 1.0 To: Paul Check CC: linux-ide@vger.kernel.org Subject: Re: Intermittent SATA link down SStatus 0 References: <4B5D26EF.4030709@kernel.org> <12193ff15b0deef3609ea93f54e5b485.squirrel@thechecks.ca> <13096cdf5e0e6704e30364a746e60467.squirrel@thechecks.ca> <8276efbfebcbfc3e58033ab8d5996d9d.squirrel@thechecks.ca> <4C3DACFF.2060504@kernel.org> <0d9ccbbb9ed0fb46dc9497888cd92c6e.squirrel@thechecks.ca> <4C3E4A04.5030000@kernel.org> <6cb5020f769580a1f431ed5bb8709b6a.squirrel@thechecks.ca> <4C3ED2C3.9050907@kernel.org> In-Reply-To: <4C3ED2C3.9050907@kernel.org> X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.3 (hera.kernel.org [127.0.0.1]); Thu, 15 Jul 2010 09:29:08 +0000 (UTC) Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On 07/15/2010 11:20 AM, Tejun Heo wrote: > Hmm... it looks like SStatus and SControl are swapped here. Maybe > there's a race condition in SIDPR code. I'll look into it a bit more. So, something like this. Can you please apply the patch and see whether the problem goes away? Thanks. diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 7409f98..3971bc0 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -158,6 +158,7 @@ struct piix_map_db { struct piix_host_priv { const int *map; u32 saved_iocfg; + spinlock_t sidpr_lock; /* FIXME: remove once locking in EH is fixed */ void __iomem *sidpr; }; @@ -951,12 +952,15 @@ static int piix_sidpr_scr_read(struct ata_link *link, unsigned int reg, u32 *val) { struct piix_host_priv *hpriv = link->ap->host->private_data; + unsigned long flags; if (reg >= ARRAY_SIZE(piix_sidx_map)) return -EINVAL; + spin_lock_irqsave(&hpriv->sidpr_lock, flags); piix_sidpr_sel(link, reg); *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA); + spin_unlock_irqrestore(&hpriv->sidpr_lock, flags); return 0; } @@ -964,12 +968,15 @@ static int piix_sidpr_scr_write(struct ata_link *link, unsigned int reg, u32 val) { struct piix_host_priv *hpriv = link->ap->host->private_data; + unsigned long flags; if (reg >= ARRAY_SIZE(piix_sidx_map)) return -EINVAL; + spin_lock_irqsave(&hpriv->sidpr_lock, flags); piix_sidpr_sel(link, reg); iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); + spin_unlock_irqrestore(&hpriv->sidpr_lock, flags); return 0; } @@ -1566,6 +1573,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev, hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); if (!hpriv) return -ENOMEM; + spin_lock_init(&hpriv->sidpr_lock); /* Save IOCFG, this will be used for cable detection, quirk * detection and restoration on detach. This is necessary