Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Dear all,

I’m writing SCSI miniport RAID driver.
When I test my RAID Level 0 driver, I found a strange condition

When recevied Srb CDB:2A 00 00 00 01 CD 00 00 40 00 00 00
This command is need to issue to 2 hard drives separately

Issue to 1st hard drive
Srb DataBuffer = 0xAA737000, DataTransferLength = 0x00006600 bytes
BuildSATAPRD: BytesLeft = 0x6600
BuildSATAPRD: VirtualAddress=0xAA737000, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA738000, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA739000, PhysicalAddress.LowPart=0x13089000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[2].DataBase = 0x13089000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73A000, PhysicalAddress.LowPart=0x13E0A000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[3].DataBase = 0x13E0A000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73B000, PhysicalAddress.LowPart=0x1360B000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[4].DataBase = 0x1360B000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73C000, PhysicalAddress.LowPart=0x1324C000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[5].DataBase = 0x1324C000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73D000, PhysicalAddress.LowPart=0x1350D000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[6].DataBase = 0x1350D000, DataBaseU = 0x0

Issue to 2nd hard drive
Srb DataBuffer = 0xAA73D600, DataTransferLength = 0x00001A00 bytes
BuildSATAPRD: BytesLeft = 0x1A00
BuildSATAPRD: VirtualAddress=0xAA73D600, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73E600, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0

Different VirtualAddress=0xAA737000 and VirtualAddress=0xAA73D600
But ScsiPortGetPhysicalAddress return same
PhysicalAddress.LowPart=0x134C7000

Is wrong parameter pass to ScsiPortGetPhysicalAddress?

Ok, you seem to be implying that you have two SRBs. Where are you getting the second one from? Are you changing the DataBuffer and DataTransferLength in the one SRB that got sent to your HwStartIo function? If so, you can’t do that. What arguments are you passing to ScsiPortGetPhysicalAddress?

Without more details it is hard to say what is going wrong.
Jerry.
xxxxx@lists.osr.com wrote: -----

To: "Windows System Software Devs Interest List"
From: ???m??
Sent by: xxxxx@lists.osr.com
Date: 04/09/2006 05:26AM
Subject: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Dear all,

I'm writing SCSI miniport RAID driver.
When I test my RAID Level 0 driver, I found a strange condition

When recevied Srb CDB:2A 00 00 00 01 CD 00 00 40 00 00 00
This command is need to issue to 2 hard drives separately

Issue to 1st hard drive
Srb DataBuffer = 0xAA737000, DataTransferLength = 0x00006600 bytes
BuildSATAPRD: BytesLeft = 0x6600
BuildSATAPRD: VirtualAddress=0xAA737000, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA738000, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA739000, PhysicalAddress.LowPart=0x13089000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[2].DataBase = 0x13089000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73A000, PhysicalAddress.LowPart=0x13E0A000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[3].DataBase = 0x13E0A000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73B000, PhysicalAddress.LowPart=0x1360B000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[4].DataBase = 0x1360B000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73C000, PhysicalAddress.LowPart=0x1324C000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[5].DataBase = 0x1324C000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73D000, PhysicalAddress.LowPart=0x1350D000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[6].DataBase = 0x1350D000, DataBaseU = 0x0

Issue to 2nd hard drive
Srb DataBuffer = 0xAA73D600, DataTransferLength = 0x00001A00 bytes
BuildSATAPRD: BytesLeft = 0x1A00
BuildSATAPRD: VirtualAddress=0xAA73D600, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73E600, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0

Different VirtualAddress=0xAA737000 and VirtualAddress=0xAA73D600
But ScsiPortGetPhysicalAddress return same
PhysicalAddress.LowPart=0x134C7000

Is wrong parameter pass to ScsiPortGetPhysicalAddress?

---
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Jerry,

Thanks for your response.

I did change the DataBuffer and DataTransferLength in the SRB got from HwStartIo.
I allocate a buffer using ScsiPortGetUncachedExtension to copy the SRB got from HwStartIo

If this SRB is need to issue to 2 device separately, driver copy original SRB to SRB1 & SRB2

If SRB->DataBuffer = 0xAA737000, SRB->DataTransferLength = 0x8000

Via calculation

SRB1->DataBuffer = 0xAA737000
SRB1->DataTransferLength = 0x6600

SRB2->DataBuffer = 0xAA73D600 (SRB->DataBuffer + SRB1->DataTransferLength)
SRB2->DataTransferLength = 0x1A00 (SRB->DataTransferLength - SRB1->DataTransferLength)

Depend on the device issued to, the Srb pass to ScsiPortGetPhysicalAddress is SRB1 or SRB2
If Srb = SRB1, VirtualAddress = SRB1->DataBuffer
If Srb = SRB2, VirtualAddress = SRB2->DataBuffer

PhysicalAddress = ScsiPortGetPhysicalAddress(HwDeviceExtension, Srb, VirtualAddress, &length);

Until all devices completed command, driver set SRB->SrbStatus = SRB_STATUS_SUCCESS
Then return control to OS.

Could I change SRB content like above?


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@attotech.com
Sent: Monday, April 10, 2006 2:12 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Ok, you seem to be implying that you have two SRBs. Where are you getting the second one from? Are you changing the DataBuffer and DataTransferLength in the one SRB that got sent to your HwStartIo function? If so, you can’t do that. What arguments are you passing to ScsiPortGetPhysicalAddress?

Without more details it is hard to say what is going wrong.

Jerry.

xxxxx@lists.osr.com wrote: -----

To: “Windows System Software Devs Interest List”
From: ?«?m?
Sent by: xxxxx@lists.osr.com
Date: 04/09/2006 05:26AM
Subject: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Dear all,

I’m writing SCSI miniport RAID driver.
When I test my RAID Level 0 driver, I found a strange condition

When recevied Srb CDB:2A 00 00 00 01 CD 00 00 40 00 00 00
This command is need to issue to 2 hard drives separately

Issue to 1st hard drive
Srb DataBuffer = 0xAA737000, DataTransferLength = 0x00006600 bytes
BuildSATAPRD: BytesLeft = 0x6600
BuildSATAPRD: VirtualAddress=0xAA737000, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA738000, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA739000, PhysicalAddress.LowPart=0x13089000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[2].DataBase = 0x13089000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73A000, PhysicalAddress.LowPart=0x13E0A000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[3].DataBase = 0x13E0A000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73B000, PhysicalAddress.LowPart=0x1360B000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[4].DataBase = 0x1360B000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73C000, PhysicalAddress.LowPart=0x1324C000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[5].DataBase = 0x1324C000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73D000, PhysicalAddress.LowPart=0x1350D000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[6].DataBase = 0x1350D000, DataBaseU = 0x0

Issue to 2nd hard drive
Srb DataBuffer = 0xAA73D600, DataTransferLength = 0x00001A00 bytes
BuildSATAPRD: BytesLeft = 0x1A00
BuildSATAPRD: VirtualAddress=0xAA73D600, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73E600, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0

Different VirtualAddress=0xAA737000 and VirtualAddress=0xAA73D600
But ScsiPortGetPhysicalAddress return same
PhysicalAddress.LowPart=0x134C7000

Is wrong parameter pass to ScsiPortGetPhysicalAddress?


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

1. ScsiPortGetPhysicalAddress is going to compare the virtual address you pass in to the Srb->DataBuffer to see how far into the port driver’s scatter/gather list it has to go to get the physical address you are asking for. For both of the SRBs you have created, that offset is 0, so sure, both calls are going to return the same physical address … one will be right and the other will be wrong.

2. So you are going to need to pass whatever virtual address you want to ScsiPortGetPhysicalAddress but pass in the original, unmodified SRB.
3. Doing RAID in the miniport is the wrong place to do it if you ever want to RAID across two or more adapters. You can make it work to a point by breaking a whole lot of rules and programming around a lot of surprises, but sooner or later you will realize that you still have a lot of problems. You will never get hybernation to work, for example.
Jerry.
xxxxx@lists.osr.com wrote: -----

To: "Windows System Software Devs Interest List"
From: 劉士豪
Sent by: xxxxx@lists.osr.com
Date: 04/09/2006 10:32PM
Subject: RE: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Hi Jerry,
Thanks for your response.
I did change the DataBuffer and DataTransferLength in the SRB got from HwStartIo.
I allocate a buffer using ScsiPortGetUncachedExtension to copy the SRB got from HwStartIo
If this SRB is need to issue to 2 device separately, driver copy original SRB to SRB1 & SRB2
If SRB->DataBuffer = 0xAA737000, SRB->DataTransferLength = 0x8000
Via calculation
SRB1->DataBuffer = 0xAA737000
SRB1->DataTransferLength = 0x6600
SRB2->DataBuffer = 0xAA73D600 ( SRB->DataBuffer + SRB1->DataTransferLength)
SRB2->DataTransferLength = 0x1A00 (SRB->DataTransferLength - SRB1->DataTransferLength)
Depend on the device issued to, the Srb pass to ScsiPortGetPhysicalAddress is SRB1 or SRB2
If Srb = SRB1, VirtualAddress = SRB1->DataBuffer
If Srb = SRB2, VirtualAddress = SRB2->DataBuffer
PhysicalAddress = ScsiPortGetPhysicalAddress(HwDeviceExtension, Srb, VirtualAddress, &length);
Until all devices completed command, driver set SRB->SrbStatus = SRB_STATUS_SUCCESS
Then return control to OS.
Could I change SRB content like above?


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@attotech.com
Sent: Monday, April 10, 2006 2:12 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Ok, you seem to be implying that you have two SRBs. Where are you getting the second one from? Are you changing the DataBuffer and DataTransferLength in the one SRB that got sent to your HwStartIo function? If so, you can't do that. What arguments are you passing to ScsiPortGetPhysicalAddress?
Without more details it is hard to say what is going wrong.
Jerry.
xxxxx@lists.osr.com wrote: -----

To: "Windows System Software Devs Interest List"
From: ???m??
Sent by: xxxxx@lists.osr.com
Date: 04/09/2006 05:26AM
Subject: [ntdev] Usign ScsiPortGetPhysicalAddress, different VirtualAddress same PhysicalAddress

Dear all,

I'm writing SCSI miniport RAID driver.
When I test my RAID Level 0 driver, I found a strange condition

When recevied Srb CDB:2A 00 00 00 01 CD 00 00 40 00 00 00
This command is need to issue to 2 hard drives separately

Issue to 1st hard drive
Srb DataBuffer = 0xAA737000, DataTransferLength = 0x00006600 bytes
BuildSATAPRD: BytesLeft = 0x6600
BuildSATAPRD: VirtualAddress=0xAA737000, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA738000, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA739000, PhysicalAddress.LowPart=0x13089000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[2].DataBase = 0x13089000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73A000, PhysicalAddress.LowPart=0x13E0A000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[3].DataBase = 0x13E0A000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73B000, PhysicalAddress.LowPart=0x1360B000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[4].DataBase = 0x1360B000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73C000, PhysicalAddress.LowPart=0x1324C000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[5].DataBase = 0x1324C000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73D000, PhysicalAddress.LowPart=0x1350D000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[1].SGL[6].DataBase = 0x1350D000, DataBaseU = 0x0

Issue to 2nd hard drive
Srb DataBuffer = 0xAA73D600, DataTransferLength = 0x00001A00 bytes
BuildSATAPRD: BytesLeft = 0x1A00
BuildSATAPRD: VirtualAddress=0xAA73D600, PhysicalAddress.LowPart=0x134C7000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[0].DataBase = 0x134C7000, DataBaseU = 0x0
BuildSATAPRD: VirtualAddress=0xAA73E600, PhysicalAddress.LowPart=0x138C8000,
PhysicalAddress.HighPart=0x0, length=0x1000
BuildSATAPRD: P[0].SGL[1].DataBase = 0x138C8000, DataBaseU = 0x0

Different VirtualAddress=0xAA737000 and VirtualAddress=0xAA73D600
But ScsiPortGetPhysicalAddress return same
PhysicalAddress.LowPart=0x134C7000

Is wrong parameter pass to ScsiPortGetPhysicalAddress?

---
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

--- Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
---
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer