linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Shane Huang <shane.huang@amd.com>
Cc: jgarzik@pobox.com, linux-ide@vger.kernel.org
Subject: Re: [PATCH] SB600 SATA controller PMP support
Date: Mon, 09 Jun 2008 14:10:10 +0900	[thread overview]
Message-ID: <484CBB32.4080808@gmail.com> (raw)
In-Reply-To: <1212547888.5722.5.camel@chunhao-desktop>

Hello, Shane.

I think it's in the right direction.  Just a few nits.

Shane Huang wrote:
> +static int ahci_sb600_check_ready(struct ata_link *link)
> +{
> +	void __iomem *port_mmio = ahci_port_base(link->ap);
> +

Please kill this empty line inbetween variable declarations.

> +	u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
> +	u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
> +
> +	if (irq_status & PORT_IRQ_BAD_PMP)
> +		return -EIO;
> +
> +	return ata_check_ready(status);
> +}
> +
> +static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
> +			     int pmp, unsigned long deadline,
> +			     int (*check_ready)(struct ata_link *link))

Why take @class if not used?

>  {
>  	struct ata_port *ap = link->ap;
> -	int pmp = sata_srst_pmp(link);
>  	const char *reason = NULL;
>  	unsigned long now, msecs;
>  	struct ata_taskfile tf;
> @@ -1312,15 +1333,12 @@
>  	ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0);
>  
>  	/* wait for link to become ready */
> -	rc = ata_wait_after_reset(link, deadline, ahci_check_ready);
> +	rc = ata_wait_after_reset(link, deadline, check_ready);
>  	/* link occupied, -ENODEV too is an error */
>  	if (rc) {
>  		reason = "device not ready";
>  		goto fail;
>  	}
> -	*class = ahci_dev_classify(ap);
> -
> -	DPRINTK("EXIT, class=%u\n", *class);

Or maybe you can leave this part in ahci_do_softreset()?

> +static int ahci_softreset(struct ata_link *link, unsigned int *class,
> +			  unsigned long deadline)
> +{
> +	struct ata_port *ap = link->ap;
> +	int pmp = sata_srst_pmp(link);
> +	int rc;
> +
> +	DPRINTK("ENTER\n");
> +
> +	rc = ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready);
> +	if (!rc) {
> +		*class = ahci_dev_classify(ap);
> +		DPRINTK("EXIT, class=%u\n", *class);
> +	}
> +	return rc;
> +}
> +
> +static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
> +				unsigned long deadline)
> +{
> +	struct ata_port *ap = link->ap;
> +	void __iomem *port_mmio = ahci_port_base(ap);
> +	int pmp = sata_srst_pmp(link);
> +	int rc;
> +	u32 irq_sts;
> +
> +	DPRINTK("ENTER\n");
> +
> +	rc = ahci_do_softreset(link, class, pmp, deadline,
> +				ahci_sb600_check_ready);
> +
> +	/* Soft reset fails on some ATI chips with IPMS set when PMP
> +	   is enabled but SATA HDD/ODD is connected to SATA port,
> +	   do soft reset again to port 0. */

Please use

/* Blah... blah
 * blah
 */

Or

/*
 * Blah blah
 * blah
 */

> +	if (rc == -EIO) {
> +		irq_sts = readl(port_mmio + PORT_IRQ_STAT);
> +		if (irq_sts & PORT_IRQ_BAD_PMP) {
> +			ata_link_printk(link, KERN_WARNING,
> +					"softreset failed, try again\n");

Please use a bit more detailed message.

> +			rc = ahci_do_softreset(link, class, 0, deadline,
> +						ahci_check_ready);
> +		}
> +	}
> +
> +	if (!rc) {
> +		*class = ahci_dev_classify(ap);
> +		DPRINTK("EXIT, class=%u\n", *class);
> +	}
> +	return rc;
> +}

I think it's better to organize functions in the following order.

 ahci_do_softreset()
 ahci_ready()
 ahci_softreset()
 ahci_sb600_ready()
 ahci_sb600_softreset()

W/ explanation on how sb600_ready and sb600_softreset are different.
Please at least add why BAD_PMP quick exit path is necessary in
ahci_sb600_ready().

Thanks.

-- 
tejun

  reply	other threads:[~2008-06-09  5:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-04  2:51 [PATCH] SB600 SATA controller PMP support Shane Huang
2008-06-09  5:10 ` Tejun Heo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-10  7:52 Shane Huang
2008-06-13  6:42 ` Jeff Garzik

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=484CBB32.4080808@gmail.com \
    --to=htejun@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=shane.huang@amd.com \
    /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).