public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Mark Haverkamp <markh@osdl.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	James Bottomley <James.Bottomley@steeleye.com>,
	Mark Salyzyn <mark_salyzyn@adaptec.com>
Subject: Re: [PATCH 3/3] 2.6.0 aacraid driver update
Date: Mon, 06 Oct 2003 17:48:58 -0400	[thread overview]
Message-ID: <3F81E34A.1040201@pobox.com> (raw)
In-Reply-To: <1065475285.17021.79.camel@markh1.pdx.osdl.net>

Mark Haverkamp wrote:
> @@ -194,8 +208,17 @@
>  			if (pci_enable_device(dev))
>  				continue;
>  			pci_set_master(dev);
> -			pci_set_dma_mask(dev, 0xFFFFFFFFULL);
>  
> +			if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
> +				ret = pci_set_dma_mask(dev, 0x7FFFFFFFULL);
> +			else
> +				ret = pci_set_dma_mask(dev, 0xFFFFFFFFULL);
> +
> +			if (ret) {
> +				printk(KERN_WARNING "aacraid: Can't set DMA mask.\n");
> +				continue;
> +			}
> +				
>  			if((dev->subsystem_vendor != aac_drivers[index].subsystem_vendor) || 
>  			   (dev->subsystem_device != aac_drivers[index].subsystem_device))
>  					continue;

This probe loop is fairly yucky, and this last 'if' test shows it's 
unnecessary.

Use the last field in struct pci_device_id to provide an index into a 
pci-id-specific info table.

And overall, let the PCI API do this sort of looping for you.



> +static irqreturn_t aac_rkt_intr(int irq, void *dev_id, struct pt_regs *regs)
> +{
> +	struct aac_dev *dev = dev_id;
> +	unsigned long bellbits;
> +	u8 intstat, mask;
> +	intstat = rkt_readb(dev, MUnit.OISR);
> +	/*
> +	 *	Read mask and invert because drawbridge is reversed.
> +	 *	This allows us to only service interrupts that have 
> +	 *	been enabled.
> +	 */
> +	mask = ~(rkt_readb(dev, MUnit.OIMR));

Don't keep reading this infrequently-changing interrupt mask from 
hardware...  Save an IO and cache that.  Is that possible?



> +	/*
> +	 *	Wait up to 30 seconds
> +	 */
> +	while (time_before(jiffies, start+30*HZ)) 
> +	{
> +		udelay(5);	/* Delay 5 microseconds to let Mon960 get info. */
> +		/*
> +		 *	Mon960 will set doorbell0 bit when it has completed the command.
> +		 */
> +		if (rkt_readl(dev, OutboundDoorbellReg) & OUTBOUNDDOORBELL_0) {
> +			/*
> +			 *	Clear the doorbell.
> +			 */
> +			rkt_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0);
> +			ok = 1;
> +			break;
> +		}
> +		/*
> +		 *	Yield the processor in case we are slow 
> +		 */
> +		set_current_state(TASK_UNINTERRUPTIBLE);
> +		schedule_timeout(1);

hmmm... why not simply call yield() here instead?  I think yield() is 
closer to the intent you wish to achieve...

Also note that you udelay() _before_ your first readb().  This could be 
a PCI posting bug.



> +	/*
> +	 *	Map in the registers from the adapter.
> +	 */
> +	if((dev->regs.rkt = (struct rkt_registers *)ioremap((unsigned long)dev->scsi_host_ptr->base, 8192))==NULL)
> +	{	
> +		printk(KERN_WARNING "aacraid: unable to map i960.\n" );
> +		return -1;
> +	}

Make the line length of this 'if' test shorter, and in the process make 
the code more readable, by splitting this operation into two lines:  the 
ioremap(), and the 'if' test for NULL.

The above is an excellent example of why people should _not_ combine 
assignment and 'if' tests... it just obfuscates the code.

	Jeff




  reply	other threads:[~2003-10-06 21:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-06 21:21 [PATCH 3/3] 2.6.0 aacraid driver update Mark Haverkamp
2003-10-06 21:48 ` Jeff Garzik [this message]
2003-10-06 21:59   ` Matthew Wilcox
2003-10-06 22:06     ` 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=3F81E34A.1040201@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mark_salyzyn@adaptec.com \
    --cc=markh@osdl.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