From appli.appli.se!appli.se!owner-amiga-mach@appli.se Thu Oct 22 14:43:01 1992
Received: by bruce (5.57/1.34)
	id AA13355; Thu, 22 Oct 92 14:42:22 +1000
Received: by mail.swip.net (5.65c8/1.2)
	id AA23435; Thu, 22 Oct 1992 05:41:42 +0100
Received: by appli.appli.se (/\=-/\ Smail3.1.17.5 #17.26)
	id <m0mhuZS-0000qMC@appli.appli.se>; Thu, 22 Oct 92 06:54 MDT
Received: by appli.appli.se (/\=-/\ Smail3.1.17.5 #17.26)
	id <m0mhuZQ-0000b6C@appli.appli.se>; Thu, 22 Oct 92 06:54 MDT
Return-Path: <amiga.physik.unizh.ch!godzilla>
Received: by appli.appli.se (/\=-/\ Smail3.1.17.5 #17.26)
	id <m0mhuZC-00006YC@appli.appli.se>; Thu, 22 Oct 92 06:54 MDT
Received: from amiga.physik.unizh.ch by mail.swip.net (5.65c8/1.2)
	id AA21503; Thu, 22 Oct 1992 02:48:27 +0100
Received: by amiga.physik.unizh.ch id AA22991
  (5.65c8/IDA-1.4.4 for amiga-mach@appli.se); Thu, 22 Oct 1992 01:45:22 GMT
Received: by godzilla.uucp id AA00671
  (5.65c8/IDA-1.4.4 for amiga-mach@appli.se); Thu, 22 Oct 1992 02:40:36 +0100
Message-Id: <199210220140.AA00671@godzilla.uucp>
Subject: Re: SCSI IO success (was: My MAXTOR SCSI disk needs special treatment,
To: amiga-mach@appli.se (The AmigaMach mailing list)
Date: Thu, 22 Oct 92 2:40:46 MET
From: Markus Wild <godzilla!mw@amiga.physik.unizh.ch>
Reply-To: <wild@amiga.physik.unizh.ch>
X-Mailer: ELM [version 2.3 PL11 913261353]
Content-Type: text
Content-Length: 4508
Sender: owner-amiga-mach@appli.se
Status: OR

> Too bad, it must be something else.  BUT... it seems I don't need this
> MODE SELECT command!  I just commented it out and...

Well, blush, I found the bug(s)... a3000_dma.c had several small but important
bugs, the one that caused the above problem is easy.. The function that
returns the number of bytes to transfer returned TRUE instead of the count..

Apply this diff to a3000_dma.c, and things should look much better... :

*** a3000_dma.c	Thu Oct 22 00:42:28 1992
--- /home/mw/a3000_dma.c	Thu Oct 22 00:40:32 1992
***************
*** 199,204 ****
--- 199,207 ----
        io_req_t	   ior = tgt->ior;
        register int len = ior->io_count;
  
+       printf ("SCSI ABOUT TO WRITE TO DISK!!\n");
+       gimmeabreak();
+ 
        tgt->transient_state.out_count = len;
  
        /* avoid leaks ?? */
***************
*** 209,215 ****
  	  tgt->transient_state.out_count = len;
  	}
  
!       tgt->transient_state.dma_offset = 0;
      } 
    else 
      {
--- 212,219 ----
  	  tgt->transient_state.out_count = len;
  	}
  
!       /* see start_cmd & start_dataout */
!       tgt->transient_state.dma_offset = 1;
      } 
    else 
      {
***************
*** 354,360 ****
  }
  
  
! boolean_t
  a3000_dma_start_dataout (dma, tgt, regp, cmd)
      opaque_t		   dma;
      register target_info_t *tgt;
--- 358,365 ----
  }
  
  
! /* boolean_t */
! int
  a3000_dma_start_dataout (dma, tgt, regp, cmd)
      opaque_t		   dma;
      register target_info_t *tgt;
***************
*** 362,373 ****
  {
    register char	*dma_ptr;
  
!   /* since we don't transmit the CDB explicitly, make sure no code depends
!      on such dma stuff */
    if (tgt->transient_state.dma_offset)
!     panic ("a3000_dma_start_dataout");
  
-   dma_ptr = tgt->ior->io_data;
    if (! dma_ptr)
      panic ("a3000_dma_start_dataout no data_ptr!");
  
--- 367,379 ----
  {
    register char	*dma_ptr;
  
!   /* see dma_map, we have set dma_offset to 1 if transferring from ior, else
!      we're transferring from the command buffer */
    if (tgt->transient_state.dma_offset)
!     dma_ptr = tgt->ior->io_data;
!   else
!     dma_ptr = tgt->cmd_ptr + tgt->transient_state.cmd_count;
  
    if (! dma_ptr)
      panic ("a3000_dma_start_dataout no data_ptr!");
  
***************
*** 376,382 ****
    tgt->transient_state.dma_offset = 0;
    tgt->dma_ptr = dma_ptr;
  
!   return TRUE;
  }
  
  int
--- 382,391 ----
    tgt->transient_state.dma_offset = 0;
    tgt->dma_ptr = dma_ptr;
  
! /*  return TRUE;*/
!   /* since we're using start_dataout as part of start_cmd, return the 
!      transfer length the SBIC should be loaded with */
!   return tgt->transient_state.out_count;
  }
  
  int
***************
*** 477,483 ****
      opaque_t	  dma;
      target_info_t *tgt;
  {
!   /* Nothing needed */
    return FALSE;
  }
  
--- 486,495 ----
      opaque_t	  dma;
      target_info_t *tgt;
  {
!   /* we have to stop DMA here, as the A3000-DMAC doesn't have a notion
!      of a transfer length */
!   a3000_stop_dma ();
! 
    return FALSE;
  }
  

> *******************************************************************
> ***								***
> ***			SCSI Read works !!!!!                   ***
> ***								***
> *******************************************************************

Hmm... it doesn't on my system ;-( Granted, I have disconnect enabled (;-)),
but the problem lies deeper... I did apply your changes to pcb.c, but I
think something in the scheduler is still broken. When I disable the
calling of iowait() in scsi_go_and_wait() and just have the driver busy
loop until the command is finished, I get rather far (I could test some
of the disconnect/reconnect protocol), however, if I allow Mach to enter
iowait, the system freezes. I think this must have something to do with
task-scheduling, as iowait sooner or later calls thread_block() which forces
a context switch. So, since things work for you, what did you do what you
didn't tell us;-) ?

As a sidenote to the above diff, I think I know now why SIM crashed.. one
of the bugs in the DMA driver resulted in a panic, this panic must just
have happend while MACH was in spl7, so SIM was called with all interrupts
disabled, and I could imagine it didn't like this situation...

So.. anxious to learn what magic tweaks the kernel needs.. ;-)

-Markus
-- 
Markus M. Wild    -  wild@nessie.cs.id.ethz.ch  |  wild@amiga.physik.unizh.ch 
Vital papers will demonstrate their vitality by spontaneously moving
from where you left them to where you can't find them.

