linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: "zhao, forrest" <forrest.zhao@intel.com>
Cc: jeff@garzik.org, hare@suse.de, axboe@suse.de, jeremy@goop.org,
	lkml@rtr.ca, linux-ide@vger.kernel.org
Subject: Re: [PATCH 3/6] The definition of ahci_port_standby() and ahci_port_spinup()
Date: Sat, 3 Jun 2006 22:23:54 +0900	[thread overview]
Message-ID: <20060603132354.GC25958@htj.dyndns.org> (raw)
In-Reply-To: <1149234328.13451.56.camel@forrest26.sh.intel.com>

On Fri, Jun 02, 2006 at 03:45:28PM +0800, zhao, forrest wrote:
> +static int ahci_port_standby(void __iomem *port_mmio, u32 cap)
> +{
> +	u32 tmp, scontrol, sstatus;
> +
> +	tmp = readl(port_mmio + PORT_CMD);
> +	/*
> +	 * AHCI Rev1.1 Section 5.3.2.3:
> +	 * Software is only allowed to program the PxCMD.FRE,
> +	 * PxCMD.POD, PxSCTL.DET, and PxCMD.SUD register bits
> +	 * when PxCMD.ST is set to '0'
> +	 */
> +	if (tmp & PORT_CMD_START)
> +		return -EBUSY;

Same here.

> +	if (cap & HOST_CAP_SSC) {
> +		/*
> +		 * Enable transitions to slumber mode
> +		 */
> +		scontrol = readl(port_mmio + PORT_SCR_CTL);
> +		if ((scontrol & 0x0f00) > 0x100) {
> +			scontrol &= ~0xf00;
> +			writel(scontrol, port_mmio + PORT_SCR_CTL);
> +		}
> +		/*
> +		 * Put device into slumber mode
> +		 */
> +		tmp |= PORT_CMD_ICC_SLUMBER;
> +		writel(tmp, port_mmio + PORT_CMD);
> +		tmp = readl(port_mmio + PORT_CMD);
> +
> +		/*
> +		 * Actually, we should wait for the device to
> +		 * enter slumber mode by checking
> +		 * sstatus & 0xf00 == 6
> +		 */
> +		sstatus = readl(port_mmio + PORT_SCR_STAT);
> +	}

AHCI rev1.1 says at the beginning of 8.3.3 HBA D3 state,

"After the interface and device have been put into a low power state,
the HBA may be put into a low power state."

But, it also says the following at the end of 8.2

"Note: The Phy is not required to be in a Slumber state when the
device is in a D1, D2 or D3 state, nor is it required to be in a
Slumber state when the HBA is in a D3 state.  While this may be the
likely condition of the interface when the devices connected to the
interface are in a low power state, it is not requirement, and the
interface shall break out of these states on a power management
event."

My gut feeling is that above SLUMBER/SCR listen code is not strictly
necessary, but I don't know whether we should keep or drop it.

> + 
> +	/*
> +	 * Put device into listen mode
> +	 */
> +	scontrol = readl(port_mmio + PORT_SCR_CTL);
> +	scontrol &= ~0xf;
> +	writel(scontrol, port_mmio + PORT_SCR_CTL);

Above code is to put the HBA into listening mode, right?  If so,
please put above code into the following if block and update comment.

> + 
> +	tmp = readl(port_mmio + PORT_CMD);
> +	if (cap & HOST_CAP_SSS) {

Why not use hpriv->cap?

> +		/*
> +		 * Spin down the device for staggered spin-up support
> +		 */
> +		tmp &= ~PORT_CMD_SPIN_UP;
> +		writel(tmp, port_mmio + PORT_CMD);
> +		readl(port_mmio + PORT_CMD); /* flush */

Clearing PORT_CMD_SPIN_UP does not spin down the device.  Please
correct the comment.

> +	}
> + 
> +	return 0;
> +}
> +
> +static int ahci_port_spinup(void __iomem *port_mmio, u32 cap)
> +{
> +	u32 tmp;
> +
> +	tmp = readl(port_mmio + PORT_CMD);
> +	/*
> +	 * AHCI Rev1.1 Section 5.3.2.3:
> +	 * Software is only allowed to program the PxCMD.FRE,
> +	 * PxCMD.POD, PxSCTL.DET, and PxCMD.SUD register bits
> +	 * when PxCMD.ST is set to '0'
> +	 */
> +	if (tmp & PORT_CMD_START)
> +		return -EBUSY;

Ditto...

> +	/*
> +	 * Power on device if supported
> +	 */
> +	if (tmp & PORT_CMD_CPD) {
> +		tmp |= PORT_CMD_POWER_ON;
> +		writel(tmp, port_mmio + PORT_CMD);
> +		tmp = readl(port_mmio + PORT_CMD);
> +	}

IMGO, it would be better to add cold presence detection support after
we have such hardware and test the code on it.

> +	/*
> +	 * Spin up device
> +	 */
> +	if (cap & HOST_CAP_SSS) {
> +		tmp |= PORT_CMD_SPIN_UP;
> +		writel(tmp, port_mmio + PORT_CMD);
> +		tmp = readl(port_mmio + PORT_CMD);
> +	}
> +
> +	if ((tmp & PORT_CMD_ICC_MASK) != PORT_CMD_ICC_ACTIVE) {
> +		tmp |= PORT_CMD_ICC_ACTIVE;
> +		writel(tmp, port_mmio + PORT_CMD);
> +		tmp = readl(port_mmio + PORT_CMD);
> +	}

Again, I think it's better to do things like above unconditionally.
ie. Just tell the controller to transit to active.

-- 
tejun

  parent reply	other threads:[~2006-06-03 13:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-02  7:45 [PATCH 3/6] The definition of ahci_port_standby() and ahci_port_spinup() zhao, forrest
2006-06-02  8:14 ` Hannes Reinecke
2006-06-02  9:01   ` zhao, forrest
2006-06-03 13:23 ` Tejun Heo [this message]
2006-06-03 19:16   ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2006-06-06 10:17 zhao, forrest
2006-06-29  8:19 zhao, forrest
2006-07-10  3:35 zhao, forrest
2006-07-11  6:38 zhao, forrest
2006-07-13  5:38 zhao, forrest

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=20060603132354.GC25958@htj.dyndns.org \
    --to=htejun@gmail.com \
    --cc=axboe@suse.de \
    --cc=forrest.zhao@intel.com \
    --cc=hare@suse.de \
    --cc=jeff@garzik.org \
    --cc=jeremy@goop.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=lkml@rtr.ca \
    /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).