lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1206047178.26345.80.camel@localhost>
Date:	Thu, 20 Mar 2008 14:06:18 -0700
From:	Joe Perches <joe@...ches.com>
To:	Roel Kluin <12o3l@...cali.nl>
Cc:	khc@...waw.pl, lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drivers/net/wan/wanxl.c: time_before(timeout, jiffies)
	-> jiffies, timeout

On Thu, 2008-03-20 at 21:23 +0100, Roel Kluin wrote:
> > -	while ((stat = readl(card->plx + PLX_MAILBOX_0)) != 0) {
> > -		if (time_before(timeout, jiffies)) {
> > -			printk(KERN_WARNING "wanXL %s: timeout waiting for"
> > -			       " PUTS to complete\n", pci_name(pdev));
> > -			wanxl_pci_remove_one(pdev);
> > -			return -ENODEV;
> > -		}
> > -
> > -		switch(stat & 0xC0) {
> > -		case 0x00:	/* hmm - PUTS completed with non-zero code? */
> > -		case 0x80:	/* PUTS still testing the hardware */
> > -			break;
> > -
> > -		default:
> > -			printk(KERN_WARNING "wanXL %s: PUTS test 0x%X"
> > +	if (TEST_UNTIL_TIMEOUT(((stat = readl(card->plx + PLX_MAILBOX_0)) != 0),
> > +			       20 * HZ)) {
> > +		printk(KERN_WARNING "wanXL %s: PUTS test 0x%X"
> >  			       " failed\n", pci_name(pdev), stat & 0x30);
> >  			wanxl_pci_remove_one(pdev);
> >  			return -ENODEV;
> 
> Doesn't this change behavior for (stat & 0xC0) != 0x00 or 0x80?

Probably, I didn't look at it too much.  Feel free to fix it.

The patch was just to demonstrate the statement expression macro
and show the lack of schedules() in some of the loops.

Maybe the statement expression macro should optionally schedule too:

#define TEST_UNTIL_TIMEOUT(test, hz, schedule)		\
({							\
	typeof(test) t;					\
	unsigned long timeout = jiffies + (hz);		\
	do {						\
		t = (test);				\
		if (t)					\
			break;				\
		if ((schedule))				\
			schedule();			\
	} while (time_before(jiffies, timeout));	\
	t;						\
})

cheers, Joe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ