All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@altlinux.ru>
To: Bastiaan Jacques <b.jacques@planet.nl>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH/RFC] ahci: add support for VIA VT8251
Date: Tue, 11 Apr 2006 21:41:18 +0400	[thread overview]
Message-ID: <20060411214118.12653818.vsu@altlinux.ru> (raw)
In-Reply-To: <200604111915.45564.b.jacques@planet.nl>

[-- Attachment #1: Type: text/plain, Size: 4144 bytes --]

On Tue, 11 Apr 2006 19:15:45 +0200 Bastiaan Jacques wrote:

> This patch adds AHCI support for the VIA VT8251 chipset. The patch does so by:
> 	1) Adding the PCI device ID.
> 	2) Adding a workaround in ahci_probe_reset() for a VIA hardware bug.
> 
> Signed-off-by: Bastiaan Jacques <b.jacques@planet.nl>
> ---
> 
> The patch is based upon the patch[1] provided by VIA. With the softreset and 
> probing work that has been merged, this patch has become much simpler.
> 
> I am happy to report that without the workaround in ahci_probe_reset(), the 
> chipset works quite well; both my SATA drives are recognised. However, 
> softreset does not work (but hardreset does), and ata_std_probeinit delays, 
> for my primary SATA drive/port,  due to the "busy" bug. A Command List 
> Override will unbusy the drive/port.
> 
> Since the CLO sequence also appears in ahci_softreset(), I have moved that 
> code into a new ahci_clo() function.
> 
> This patch is against 2.6.17-rc1 (and -mm2).
> 
> This patch has only been tested by yours truly. Whilst I am waiting for 
> feedback from other people, I am sending this patch to solicit comments.
> 
> NOTE: My email client cuts off some lines (of context) in my patch because 
> they are longer than 78 characters. Therefore, I am making the patch 
> available from my web server [2], as well.
> 
> Bastiaan
> 
> [1] http://lkml.org/lkml/2005/12/11/204
> [2] http://mirrors.pagefault.net/linux-via-ahci-latest.patch
> 
> --- drivers/scsi/ahci.c.orig	2006-04-11 18:58:32.000000000 +0200
> +++ drivers/scsi/ahci.c	2006-04-11 12:44:41.000000000 +0200
> @@ -297,6 +297,8 @@
>  	  board_ahci }, /* ATI SB600 non-raid */
>  	{ PCI_VENDOR_ID_ATI, 0x4381, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
>  	  board_ahci }, /* ATI SB600 raid */
> +	{ PCI_VENDOR_ID_VIA, 0x3349, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> +	  board_ahci }, /* VT8251 */

You can add a separate host type (e.g., board_via_vt8251_ahci), and then
add an entry for this type to ahci_port_info[].  The entry would have a
special flag in .host_flags, but the same .port_ops, so there will not
be excessive duplication like in the original vendor patch.

Look like other drivers which need workarounds for hardware bugs (e.g.,
sata_sil) do this.

>  	{ }	/* terminate list */
>  };
> 
> @@ -535,6 +537,17 @@
>  	return -1;
>  }
> 
> +static void ahci_clo(struct ata_port *ap)
> +{
> +	void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
> +	u32 tmp;
> +
> +	tmp = readl(port_mmio + PORT_CMD);
> +	tmp |= PORT_CMD_CLO;
> +	writel(tmp, port_mmio + PORT_CMD);
> +	readl(port_mmio + PORT_CMD); /* flush */
> +}
> +
>  static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int 
> *class)
>  {
>  	struct ahci_host_priv *hpriv = ap->host_set->private_data;
> @@ -565,7 +578,6 @@
>  	/* check BUSY/DRQ, perform Command List Override if necessary */
>  	ahci_tf_read(ap, &tf);
>  	if (tf.command & (ATA_BUSY | ATA_DRQ)) {
> -		u32 tmp;
> 

The following empty line should probably be deleted too.

>  		if (!(hpriv->cap & HOST_CAP_CLO)) {
>  			rc = -EIO;
> @@ -573,10 +585,7 @@
>  			goto fail_restart;
>  		}
> 
> -		tmp = readl(port_mmio + PORT_CMD);
> -		tmp |= PORT_CMD_CLO;
> -		writel(tmp, port_mmio + PORT_CMD);
> -		readl(port_mmio + PORT_CMD); /* flush */
> +		ahci_clo(ap);
> 
>  		if (ahci_poll_register(port_mmio + PORT_CMD, PORT_CMD_CLO, 0x0,
>  				       1, 500)) {
> @@ -695,6 +704,16 @@
> 
>  static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes)
>  {
> +	struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
> +
> +	/* Workaround for VIA VT8251 "busy" bug */
> +	if (pdev->device == 0x3349) {

After adding a separate host type and a host flag this will be:

	if (ap->flags & AHCI_FLAG_RESET_NEEDS_CLO) {

> +		if (ata_busy_wait(ap, ATA_BUSY, 1000) & ATA_BUSY) {
> +			/* ATA_BUSY hasn't cleared, so send a CLO */
> +			ahci_clo(ap);
> +		}
> +	}
> +
>  	return ata_drive_probe_reset(ap, ata_std_probeinit,
>  				     ahci_softreset, ahci_hardreset,
>  				     ahci_postreset, classes);

[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2006-04-11 17:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-11 17:15 [PATCH/RFC] ahci: add support for VIA VT8251 Bastiaan Jacques
2006-04-11 17:41 ` Sergey Vlasov [this message]
2006-04-11 20:10   ` Bastiaan Jacques
2006-04-11 22:16 ` Jeff Garzik
2006-04-12  0:42 ` Tejun Heo
2006-04-12 19:10   ` Bastiaan Jacques
2006-04-12 19:25     ` Jeff Garzik
2006-04-12 20:59       ` Bastiaan Jacques
2006-04-12 21:46         ` Jeff Garzik
2006-04-12 22:19           ` [PATCH 2.6.17-rc1-mm2 1/1] " Bastiaan Jacques
2006-04-12 22:25             ` Bastiaan Jacques
2006-04-12 22:27             ` Jeff Garzik
2006-04-13  0:08               ` Bastiaan Jacques
2006-04-13  3:23                 ` Tejun Heo
2006-04-17 12:19               ` [PATCH libata-dev.git upstream " Bastiaan Jacques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060411214118.12653818.vsu@altlinux.ru \
    --to=vsu@altlinux.ru \
    --cc=b.jacques@planet.nl \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.