public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix idiocy in asd_init_lseq_mdp()
@ 2006-09-25  1:57 Al Viro
  2006-09-25  6:52 ` Luben Tuikov
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Al Viro @ 2006-09-25  1:57 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-scsi, linux-kernel

To whoever had written that code:

a) priority of >> is higher than that of &
b) priority of typecast is higher than that of any binary operator
c) learn the fscking C

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/scsi/aic94xx/aic94xx_seq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index d9b6da5..56e4b3b 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -764,7 +764,7 @@ static void asd_init_lseq_mdp(struct asd
 	asd_write_reg_word(asd_ha, LmSEQ_FIRST_INV_SCB_SITE(lseq),
 			   (u16)last_scb_site_no+1);
 	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
-			    (u16) LmM0INTEN_MASK & 0xFFFF0000 >> 16);
+			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
 	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
 			    (u16) LmM0INTEN_MASK & 0xFFFF);
 	asd_write_reg_byte(asd_ha, LmSEQ_LINK_RST_FRM_LEN(lseq), 0);
-- 
1.4.2.GIT


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25  1:57 [PATCH] fix idiocy in asd_init_lseq_mdp() Al Viro
@ 2006-09-25  6:52 ` Luben Tuikov
  2006-09-25  6:54 ` Luben Tuikov
  2006-09-25 14:47 ` Douglas Gilbert
  2 siblings, 0 replies; 11+ messages in thread
From: Luben Tuikov @ 2006-09-25  6:52 UTC (permalink / raw)
  To: Al Viro, Linus Torvalds; +Cc: linux-scsi, linux-kernel

--- Al Viro <viro@ftp.linux.org.uk> wrote:
> To whoever had written that code:
> 
> a) priority of >> is higher than that of &
> b) priority of typecast is higher than that of any binary operator
> c) learn the fscking C

"whoever" would be Bottomley or someone at LTC.

My code in that spot has:
asd_write_reg_dword(asd_ha, LmSEQ_INTEN_SAVE(lseq),
			    (u32) LmM0INTEN_MASK);

> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  drivers/scsi/aic94xx/aic94xx_seq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
> index d9b6da5..56e4b3b 100644
> --- a/drivers/scsi/aic94xx/aic94xx_seq.c
> +++ b/drivers/scsi/aic94xx/aic94xx_seq.c
> @@ -764,7 +764,7 @@ static void asd_init_lseq_mdp(struct asd
>  	asd_write_reg_word(asd_ha, LmSEQ_FIRST_INV_SCB_SITE(lseq),
>  			   (u16)last_scb_site_no+1);
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
> -			    (u16) LmM0INTEN_MASK & 0xFFFF0000 >> 16);
> +			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
>  			    (u16) LmM0INTEN_MASK & 0xFFFF);
>  	asd_write_reg_byte(asd_ha, LmSEQ_LINK_RST_FRM_LEN(lseq), 0);
> -- 
> 1.4.2.GIT
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25  1:57 [PATCH] fix idiocy in asd_init_lseq_mdp() Al Viro
  2006-09-25  6:52 ` Luben Tuikov
@ 2006-09-25  6:54 ` Luben Tuikov
  2006-09-25 14:47 ` Douglas Gilbert
  2 siblings, 0 replies; 11+ messages in thread
From: Luben Tuikov @ 2006-09-25  6:54 UTC (permalink / raw)
  To: Al Viro, Linus Torvalds; +Cc: linux-scsi, linux-kernel

--- Al Viro <viro@ftp.linux.org.uk> wrote:
> To whoever had written that code:
> 
> a) priority of >> is higher than that of &
> b) priority of typecast is higher than that of any binary operator
> c) learn the fscking C

"whoever" would be Bottomley or someone at LTC.

My code in that spot has:
     asd_write_reg_dword(asd_ha, LmSEQ_INTEN_SAVE(lseq),
	        		    (u32) LmM0INTEN_MASK);

    Luben

> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  drivers/scsi/aic94xx/aic94xx_seq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
> index d9b6da5..56e4b3b 100644
> --- a/drivers/scsi/aic94xx/aic94xx_seq.c
> +++ b/drivers/scsi/aic94xx/aic94xx_seq.c
> @@ -764,7 +764,7 @@ static void asd_init_lseq_mdp(struct asd
>  	asd_write_reg_word(asd_ha, LmSEQ_FIRST_INV_SCB_SITE(lseq),
>  			   (u16)last_scb_site_no+1);
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
> -			    (u16) LmM0INTEN_MASK & 0xFFFF0000 >> 16);
> +			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
>  			    (u16) LmM0INTEN_MASK & 0xFFFF);
>  	asd_write_reg_byte(asd_ha, LmSEQ_LINK_RST_FRM_LEN(lseq), 0);
> -- 
> 1.4.2.GIT
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25  1:57 [PATCH] fix idiocy in asd_init_lseq_mdp() Al Viro
  2006-09-25  6:52 ` Luben Tuikov
  2006-09-25  6:54 ` Luben Tuikov
@ 2006-09-25 14:47 ` Douglas Gilbert
  2006-09-25 14:59   ` Al Viro
  2006-09-25 17:16   ` Luben Tuikov
  2 siblings, 2 replies; 11+ messages in thread
From: Douglas Gilbert @ 2006-09-25 14:47 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-scsi, linux-kernel

Al Viro wrote:
> To whoever had written that code:
> 
> a) priority of >> is higher than that of &
> b) priority of typecast is higher than that of any binary operator
> c) learn the fscking C

Al,
On the assumption that you have hardware that uses this
driver, did you notice any improvement with your patch
applied?

Several of us have reported a degenerate mode, that
I term as "tmf timeout", in which a aic94xx based card
becomes inoperable. Alas, the same hardware running another
OS does not exhibit that problem (or at least not as much).

> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  drivers/scsi/aic94xx/aic94xx_seq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
> index d9b6da5..56e4b3b 100644
> --- a/drivers/scsi/aic94xx/aic94xx_seq.c
> +++ b/drivers/scsi/aic94xx/aic94xx_seq.c
> @@ -764,7 +764,7 @@ static void asd_init_lseq_mdp(struct asd
>  	asd_write_reg_word(asd_ha, LmSEQ_FIRST_INV_SCB_SITE(lseq),
>  			   (u16)last_scb_site_no+1);
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
> -			    (u16) LmM0INTEN_MASK & 0xFFFF0000 >> 16);
> +			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
>  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
>  			    (u16) LmM0INTEN_MASK & 0xFFFF);
>  	asd_write_reg_byte(asd_ha, LmSEQ_LINK_RST_FRM_LEN(lseq), 0);

BTW Luben was pointing out that the call you patched
and the following call can be combined into a less
trouble prone asd_write_reg_dword() call.

Doug Gilbert


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 14:47 ` Douglas Gilbert
@ 2006-09-25 14:59   ` Al Viro
  2006-09-25 17:16   ` Luben Tuikov
  1 sibling, 0 replies; 11+ messages in thread
From: Al Viro @ 2006-09-25 14:59 UTC (permalink / raw)
  To: Douglas Gilbert; +Cc: linux-scsi, linux-kernel

> Several of us have reported a degenerate mode, that
> I term as "tmf timeout", in which a aic94xx based card
> becomes inoperable. Alas, the same hardware running another
> OS does not exhibit that problem (or at least not as much).

> >  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
> > -			    (u16) LmM0INTEN_MASK & 0xFFFF0000 >> 16);
> > +			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
> >  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
> >  			    (u16) LmM0INTEN_MASK & 0xFFFF);
> >  	asd_write_reg_byte(asd_ha, LmSEQ_LINK_RST_FRM_LEN(lseq), 0);
 
> BTW Luben was pointing out that the call you patched
> and the following call can be combined into a less
> trouble prone asd_write_reg_dword() call.

In that case there's another bug - we should write upper 16 bits to
addr + 2, not the lower ones.

IOW, the old code was
	broken attempt to write upper 16 bits to addr (ends up writing _lower_
16 bits)
	writing lower 16 bits to addr + 2

With this patch we get the first call do what it clearly intended to do
(unless it's a deliberate obfuscation from hell).  _IF_ we really want
to write the damn thing little-endian, the order should be reverted on
top of that.  I.e.
  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq),
  			    (u16) LmM0INTEN_MASK & 0xFFFF);
  	asd_write_reg_word(asd_ha, LmSEQ_INTEN_SAVE(lseq) + 2,
			    (u16) ((LmM0INTEN_MASK & 0xFFFF0000) >> 16));
or, indeed, asd_write_reg_dword().

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 14:47 ` Douglas Gilbert
  2006-09-25 14:59   ` Al Viro
@ 2006-09-25 17:16   ` Luben Tuikov
  2006-09-25 17:39     ` Al Viro
  1 sibling, 1 reply; 11+ messages in thread
From: Luben Tuikov @ 2006-09-25 17:16 UTC (permalink / raw)
  To: dougg, Al Viro; +Cc: linux-scsi, linux-kernel

--- Douglas Gilbert <dougg@torque.net> wrote:
> Al Viro wrote:
> > To whoever had written that code:
> > 
> > a) priority of >> is higher than that of &
> > b) priority of typecast is higher than that of any binary operator
> > c) learn the fscking C
[...]
> BTW Luben was pointing out that the call you patched
> and the following call can be combined into a less
> trouble prone asd_write_reg_dword() call.

More than that -- I looked at the history of that
file/line and the code as I had written it _never_ had
that broken cast and shift mess.

"Someone" changed that after I submitted the code to lkml/lsml.

    Luben


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 17:16   ` Luben Tuikov
@ 2006-09-25 17:39     ` Al Viro
  2006-09-25 17:43       ` James Bottomley
  0 siblings, 1 reply; 11+ messages in thread
From: Al Viro @ 2006-09-25 17:39 UTC (permalink / raw)
  To: Luben Tuikov; +Cc: dougg, linux-scsi, linux-kernel

On Mon, Sep 25, 2006 at 10:16:34AM -0700, Luben Tuikov wrote:
> --- Douglas Gilbert <dougg@torque.net> wrote:
> > Al Viro wrote:
> > > To whoever had written that code:
> > > 
> > > a) priority of >> is higher than that of &
> > > b) priority of typecast is higher than that of any binary operator
> > > c) learn the fscking C
> [...]
> > BTW Luben was pointing out that the call you patched
> > and the following call can be combined into a less
> > trouble prone asd_write_reg_dword() call.
> 
> More than that -- I looked at the history of that
> file/line and the code as I had written it _never_ had
> that broken cast and shift mess.

Far more interesting question: where does the hardware expect to see the
upper 16 bits of that 32bit value?  Which one it is - LmSEQ_INTEN_SAVE(lseq)
ori LmSEQ_INTEN_SAVE(lseq) + 2?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 17:39     ` Al Viro
@ 2006-09-25 17:43       ` James Bottomley
  2006-09-25 18:29         ` Mike Anderson
  2006-09-25 19:14         ` Luben Tuikov
  0 siblings, 2 replies; 11+ messages in thread
From: James Bottomley @ 2006-09-25 17:43 UTC (permalink / raw)
  To: Hammer, Jack, Al Viro; +Cc: Luben Tuikov, dougg, linux-scsi, linux-kernel

On Mon, 2006-09-25 at 18:39 +0100, Al Viro wrote:
> Far more interesting question: where does the hardware expect to see
> the
> upper 16 bits of that 32bit value?  Which one it is -
> LmSEQ_INTEN_SAVE(lseq)
> ori LmSEQ_INTEN_SAVE(lseq) + 2?

I don't honestly know.  The change was made as part of a slew of changes
by Robert Tarte at Adaptec to make the driver run on Big Endian
platforms.  I've copied Jack Hammer who's now looking after it in the
hope that he can enlighten us.

James



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 17:43       ` James Bottomley
@ 2006-09-25 18:29         ` Mike Anderson
  2006-09-25 19:14         ` Luben Tuikov
  1 sibling, 0 replies; 11+ messages in thread
From: Mike Anderson @ 2006-09-25 18:29 UTC (permalink / raw)
  To: James Bottomley
  Cc: Hammer, Jack, Al Viro, Luben Tuikov, dougg, linux-scsi,
	linux-kernel

James Bottomley <James.Bottomley@SteelEye.com> wrote:
> On Mon, 2006-09-25 at 18:39 +0100, Al Viro wrote:
> > Far more interesting question: where does the hardware expect to see
> > the
> > upper 16 bits of that 32bit value?  Which one it is -
> > LmSEQ_INTEN_SAVE(lseq)
> > ori LmSEQ_INTEN_SAVE(lseq) + 2?
> 
> I don't honestly know.  The change was made as part of a slew of changes
> by Robert Tarte at Adaptec to make the driver run on Big Endian
> platforms.  I've copied Jack Hammer who's now looking after it in the
> hope that he can enlighten us.

This was not Rob. I sent this bad code out in a roll up of support for
non-x86 systems (and bad process for not running sparse on the
patch which passed the buck onto someone else to find).

I think it might have been for an IA64 offset issue someone was seeing. I
cannot find the original mail on the issue in my mail archives.

I will try and track down a IA64 system to see if we can verify this is
really needed. If not we should revert back to the original dword
implementation. 

-andmike
--
Michael Anderson
andmike@us.ibm.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] fix idiocy in asd_init_lseq_mdp()
  2006-09-25 17:43       ` James Bottomley
  2006-09-25 18:29         ` Mike Anderson
@ 2006-09-25 19:14         ` Luben Tuikov
  1 sibling, 0 replies; 11+ messages in thread
From: Luben Tuikov @ 2006-09-25 19:14 UTC (permalink / raw)
  To: James Bottomley, Hammer, Jack, Al Viro
  Cc: Luben Tuikov, dougg, linux-scsi, linux-kernel

--- James Bottomley <James.Bottomley@SteelEye.com> wrote:
> On Mon, 2006-09-25 at 18:39 +0100, Al Viro wrote:
> > Far more interesting question: where does the hardware expect to see
> > the
> > upper 16 bits of that 32bit value?  Which one it is -
> > LmSEQ_INTEN_SAVE(lseq)
> > ori LmSEQ_INTEN_SAVE(lseq) + 2?
> 
> I don't honestly know.  The change was made as part of a slew of changes
> by Robert Tarte at Adaptec to make the driver run on Big Endian
> platforms.  I've copied Jack Hammer who's now looking after it in the
> hope that he can enlighten us.

Al,

I can see that you addressed your message to me, but Bottomley has
stepped in to answer.  I can also see that Bottomley is looking
for an answer from Jack.  To save an off the list correspondence,

I'll go ahead and answer your question addressed to me.

LSEQ_INTEN_SAVE is a 32 bit Little-Endian storage, thus
your original, first email on this subject is correct, and your
supposition that if the storage is 32 bit LE, then my version
is correct, is in itself correct.

No such "changes" (in the HW page writing area) are necessary in order
to make the code run in BE platforms.  My version of my code
(NOT Bottomley's version of my code) has been extensively tested on
BE (PowerPC) platforms, and is working properly.

The version as seen in my code:
	asd_write_reg_dword(asd_ha, LmSEQ_INTEN_SAVE(lseq),
			    (u32) LmM0INTEN_MASK);
is the correct way.

Good luck!
    Luben
P.S. Git tells me that I needed to change two lines only,
in order to make the code run on BE platforms, the git commit
dates Wednesday Sept 28, 2005.  That commit is present on
the GIT repo, then present on http://linux.adaptec.com/sas/.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] fix idiocy in asd_init_lseq_mdp()
@ 2006-09-25 19:56 Hammer, Jack
  0 siblings, 0 replies; 11+ messages in thread
From: Hammer, Jack @ 2006-09-25 19:56 UTC (permalink / raw)
  To: James Bottomley, Al Viro; +Cc: Luben Tuikov, dougg, linux-scsi, linux-kernel

James,

asd_write_reg_dword() is the correct implementation for writing the
LmM0INTEN_MASK to the LmSEQ_INTEN_SAVE register.

Jack 



-----Original Message-----
From: James Bottomley [mailto:James.Bottomley@SteelEye.com] 
Sent: Monday, September 25, 2006 1:43 PM
To: Hammer, Jack; Al Viro
Cc: Luben Tuikov; dougg@torque.net; linux-scsi@vger.kernel.org;
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix idiocy in asd_init_lseq_mdp()

On Mon, 2006-09-25 at 18:39 +0100, Al Viro wrote:
> Far more interesting question: where does the hardware expect to see 
> the upper 16 bits of that 32bit value?  Which one it is -
> LmSEQ_INTEN_SAVE(lseq)
> ori LmSEQ_INTEN_SAVE(lseq) + 2?

I don't honestly know.  The change was made as part of a slew of changes
by Robert Tarte at Adaptec to make the driver run on Big Endian
platforms.  I've copied Jack Hammer who's now looking after it in the
hope that he can enlighten us.

James




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-09-25 19:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-25  1:57 [PATCH] fix idiocy in asd_init_lseq_mdp() Al Viro
2006-09-25  6:52 ` Luben Tuikov
2006-09-25  6:54 ` Luben Tuikov
2006-09-25 14:47 ` Douglas Gilbert
2006-09-25 14:59   ` Al Viro
2006-09-25 17:16   ` Luben Tuikov
2006-09-25 17:39     ` Al Viro
2006-09-25 17:43       ` James Bottomley
2006-09-25 18:29         ` Mike Anderson
2006-09-25 19:14         ` Luben Tuikov
  -- strict thread matches above, loose matches on Subject: below --
2006-09-25 19:56 Hammer, Jack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox