linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Cc: linux-ide@vger.kernel.org, arjan@linux.intel.com
Subject: Re: [patch 1/2] ahci: Dont start port DMA engines unless a device is present
Date: Sat, 12 Apr 2008 00:21:24 -0400	[thread overview]
Message-ID: <480038C4.1080300@garzik.org> (raw)
In-Reply-To: <20080325152807.321a8338@appleyard>

Kristen Carlson Accardi wrote:
> According to the AHCI spec, you should not set PxCMD.ST unless
> a functional device is present, as determined by PxTFD.STS.BSY=0,
> PxTFD.STS.DRQ=0, and PxSSTS.DET = 3.
> 
> Signed-off-by:  Kristen Carlson Accardi <kristen.c.accardi@intel.com>
> 
> Index: linux-2.6.25-rc3/drivers/ata/ahci.c
> ===================================================================
> --- linux-2.6.25-rc3.orig/drivers/ata/ahci.c
> +++ linux-2.6.25-rc3/drivers/ata/ahci.c
> @@ -783,11 +783,40 @@ static int ahci_scr_write(struct ata_por
>  	return -EINVAL;
>  }
>  
> +static int ahci_is_device_present(struct ata_port *ap)
> +{
> +	void __iomem *port_mmio = ahci_port_base(ap);
> +	u8 status;
> +
> +	/* Make sure PxTFD.STS.BSY and PxTFD.STS.DRQ are 0 */
> +	status = ahci_check_status(ap);
> +	if (status & (ATA_BUSY | ATA_DRQ))
> +		return 0;
> +
> +	/* Make sure PxSSTS.DET is 3h */
> +	status = readl(port_mmio + PORT_SCR_STAT);
> +	status &= 0xf;
> +	if ((status & 0xf) != 3)
> +		return 0;
> +	return 1;
> +}
> +
>  static void ahci_start_engine(struct ata_port *ap)
>  {
>  	void __iomem *port_mmio = ahci_port_base(ap);
>  	u32 tmp;
>  
> +	/*
> +	 * See AHCI specification 1.2 section 10.1.2
> +	 *
> +	 * Software shall not set PxCMD.ST to '1' until it is
> + 	 * determined that a functional device is present on
> + 	 * the port, as determined by PxTFD.STS.BSY = '0',
> + 	 * PxTFD.STS.DRQ = '0', PxSSTS.DET = 3h
> + 	 */
> +	if (!ahci_is_device_present(ap))
> +		return;
> +
>  	/* start DMA */
>  	tmp = readl(port_mmio + PORT_CMD);

This seems incomplete?

If we wish to maintain this invariant, which seems like a good idea and 
the right thing to do, then this patch fails to cover the hotplug case, 
correct?

	Jeff




  reply	other threads:[~2008-04-12  4:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080325221646.567639335@intel.com>
2008-03-25 22:28 ` [patch 1/2] ahci: Dont start port DMA engines unless a device is present Kristen Carlson Accardi
2008-04-12  4:21   ` Jeff Garzik [this message]
2008-03-25 22:28 ` [patch 2/2] libata: power off unused ports Kristen Carlson Accardi
2008-03-28  7:43   ` Andi Kleen
2008-03-28 17:00     ` Kristen Carlson Accardi
2008-04-12  4:28   ` Jeff Garzik
2008-04-14 23:11     ` Kristen Carlson Accardi
2008-04-15 19:02       ` Mark Lord
2008-04-24 17:45         ` Kristen Carlson Accardi

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=480038C4.1080300@garzik.org \
    --to=jeff@garzik.org \
    --cc=arjan@linux.intel.com \
    --cc=kristen.c.accardi@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).