From patchwork Tue Oct 11 17:55:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 119056 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 642F7B6EE8 for ; Wed, 12 Oct 2011 05:29:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755398Ab1JKS2p (ORCPT ); Tue, 11 Oct 2011 14:28:45 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:46351 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755374Ab1JKSZ2 (ORCPT ); Tue, 11 Oct 2011 14:25:28 -0400 Received: by mail-bw0-f46.google.com with SMTP id zt4so10123455bkb.19 for ; Tue, 11 Oct 2011 11:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type :content-transfer-encoding:message-id; bh=lXFhWbIFjaPuvUIoq9gU3MOu2WrYimbv9DkXOG+qFTI=; b=Obo3slpypHH/elLQERrDs9IdQu1vLLz/ewEexFgir7L6cixzmRpX9AzWXYaNcwJ6TG AKWjMy+41E1TwhDt2lws2kIJQcartdXDerf5BZS9giDxjHURI2swM6Sl31bTxHFYN2zV Q425EM+EIvcnSkSktIZdXas8ttAntTEuXs/pQ= Received: by 10.204.145.28 with SMTP id b28mr10529395bkv.76.1318357527625; Tue, 11 Oct 2011 11:25:27 -0700 (PDT) Received: from linux-mhg7.site (89-74-122-41.dynamic.chello.pl. [89.74.122.41]) by mx.google.com with ESMTPS id t13sm14351364fae.0.2011.10.11.11.25.25 (version=SSLv3 cipher=OTHER); Tue, 11 Oct 2011 11:25:26 -0700 (PDT) From: Bartlomiej Zolnierkiewicz To: Jeff Garzik Subject: [PATCH] pata_atiixp: add proper ->prereset method Date: Tue, 11 Oct 2011 19:55:09 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.37.6-0.7-desktop-dirty; KDE/4.6.0; x86_64; ; ) Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-Id: <201110111955.09320.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Bartlomiej Zolnierkiewicz Subject: [PATCH] pata_atiixp: add proper ->prereset method Fixes PCI access before PCI resources are allocated. Signed-off-by: Bartlomiej Zolnierkiewicz Acked-by: Alan Cox --- earlier references: https://lkml.org/lkml/2009/11/25/320 drivers/ata/pata_atiixp.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) -- 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 Index: b/drivers/ata/pata_atiixp.c =================================================================== --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c @@ -49,6 +49,31 @@ static int atiixp_cable_detect(struct at static DEFINE_SPINLOCK(atiixp_lock); /** + * atiixp_prereset - perform reset handling + * @link: ATA link + * @deadline: deadline jiffies for the operation + * + * Reset sequence checking enable bits to see which ports are + * active. + */ + +static int atiixp_prereset(struct ata_link *link, unsigned long deadline) +{ + static const struct pci_bits atiixp_enable_bits[] = { + { 0x48, 1, 0x01, 0x00 }, + { 0x48, 1, 0x08, 0x00 } + }; + + struct ata_port *ap = link->ap; + struct pci_dev *pdev = to_pci_dev(ap->host->dev); + + if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) + return -ENOENT; + + return ata_sff_prereset(link, deadline); +} + +/** * atiixp_set_pio_timing - set initial PIO mode data * @ap: ATA interface * @adev: ATA device @@ -221,6 +246,7 @@ static struct ata_port_operations atiixp .bmdma_start = atiixp_bmdma_start, .bmdma_stop = atiixp_bmdma_stop, + .prereset = atiixp_prereset, .cable_detect = atiixp_cable_detect, .set_piomode = atiixp_set_piomode, .set_dmamode = atiixp_set_dmamode, @@ -235,16 +261,7 @@ static int atiixp_init_one(struct pci_de .udma_mask = ATA_UDMA5, .port_ops = &atiixp_port_ops }; - static const struct pci_bits atiixp_enable_bits[] = { - { 0x48, 1, 0x01, 0x00 }, - { 0x48, 1, 0x08, 0x00 } - }; const struct ata_port_info *ppi[] = { &info, &info }; - int i; - - for (i = 0; i < 2; i++) - if (!pci_test_config_bits(pdev, &atiixp_enable_bits[i])) - ppi[i] = &ata_dummy_port_info; return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL, ATA_HOST_PARALLEL_SCAN);