WHDC PowerPoint Template Notes & Handouts

Slides:



Advertisements
Similar presentations
Device Virtualization Architecture
Advertisements

Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Windows Debugging Demystified
AHCI: ATAport Miniport Example. Outline AHCI Features Goals Basics AHCI ATA Miniport Design Philosophy Memory Structures and Resources Enumeration IO.
Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.
How to Add WMI Interfaces to SCSIPort and Storport Miniports
© Microsoft Corporation1 Windows Kernel Internals I/O Architecture *David B. Probert, Ph.D. Windows Kernel Development Microsoft Corporation.
ATA Miniport Nuts and Bolts
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
WHDC PowerPoint Template Notes & Handouts
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Bob “GRIZZY” Griswold Senior Program Manager, WHEG Microsoft Corporation.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
How to Write an ATAport Miniport
I/O Software CS 537 – Introduction to Operating Systems.
CSCE451/851 Introduction to Operating Systems
Input/Output (I/O) Important OS function – control I/O
Chapter 13: I/O Systems.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Interrupts and exceptions
Chapter Objectives In this chapter, you will learn:
CS 6560: Operating Systems Design
Crash Dump Analysis - Santosh Kumar Singh.
Operating Systems (CS 340 D)
Chapter 2: System Structures
Day 08 Processes.
Day 09 Processes.
CSE451 I/O Systems and the Full I/O Path Autumn 2002
Effective Data-Race Detection for the Kernel
Microsoft Build /12/2018 5:05 AM Using non-volatile memory (NVDIMM-N) as byte-addressable storage in Windows Server 2016 Tobias Klima Program Manager.
Introduction to Computers
CS703 - Advanced Operating Systems
I/O Manager, 64-bit Porting, and New Driver Models
CONFIGURING HARDWARE DEVICE & START UP PROCESS
Chapter 3: Windows7 Part 2.
Computer System Overview
CPSC 457 Operating Systems
Module 2: Computer-System Structures
Processor Fundamentals
Chapter 3: Windows7 Part 2.
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Direct Memory Access Disk and Network transfers: awkward timing:
Today’s agenda Hardware architecture and runtime system
Chapter 33: Virtual Machines
Process Description and Control
CSE 451: Operating Systems Spring 2008 Module 15 I/O
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
CSE 451: Operating Systems Spring 2007 Module 15 I/O
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Module 2: Computer-System Structures
CSC3050 – Computer Architecture
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
OS Components and Structure
CS 143A Principles of Operating Systems
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
Chapter 13: I/O Systems.
Chapter 33: Virtual Machines
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Writing SCSIPORT Miniport Drivers Sid Sidhartha Software Design Engineer Windows Driver Experience sidharth@microsoft.com

WHDC PowerPoint Template Notes & Handouts Contents WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSIPORT Architecture overview SCSI Miniport model PNP/Power handling for miniport I/O handling for miniport Common Miniport Errors Debugging SCSI Miniports Resources

Need For SCSI Miniports WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Windows Device Driver Model is complex PNP/POWER handling for bus drivers is involved Storage vendors need to focus on writing hardware specific code, not on Windows intricacies A WDM storage driver needs to handle performance, queuing, forward progress under low memory conditions and complex synchronization problems

Advantages Of A Miniport model WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 No synchronization issues No PNP/Power complexity Simple interface to help concentrate on actually programming the hardware Miniport shielded from OS changes

Miniport Synchronization WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSIPORTStartIO Interrupt Levels Level 14 USB Miniport Level 13 Level 12 Level 11 HwStartIO Level 10

Miniport Synchronization Issues WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Advantages Miniport becomes simple to write No synchronization primitives needed Disadvantages Every time any Miniport routine is called, all interrupts at that level are blocked Polling by calling “StallExecution” is not desirable

WHDC PowerPoint Template Notes & Handouts PNP Support WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Interrupts, ports, memory for the adapter are provided to the miniport during startup and restart During a Disable/Stop, port ensures disconnecting the interrupt, freeing the resources, etc. Port supports hot plug by providing SCSIPORTNotification (BusChangeDetected) call SCSI inquiry command is used to discover LUNs Port generates unique PNP-ID-based on inquiry string

WHDC PowerPoint Template Notes & Handouts PNP Gotchas WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSIPORTNotification (BusChangeDetected) is not a synchronous call The dead LUN could get lot of IO before finally being removed from the OS The whole bus is scanned again and all the devices inquired Device enumeration is an expensive operation

WHDC PowerPoint Template Notes & Handouts POWER Support WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Port provides idle detection support for disk LUNS are powered on/off by START_STOP_UNIT Command Power to the adapter is controlled by HwScsiAdapterControl call Port driver manages all S-D IRP translations and calls miniport only during adapter start and shutdown

WHDC PowerPoint Template Notes & Handouts IO: DMA Support WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Miniport is shielded from OS DMA routines Miniport is provided with a physically contiguous common buffer that may be shared between CPU and bus-master HBA Simple interface to obtain physical address of the common buffer A per request storage area is also allocated for the Miniport

IO: Tags And Queue Management WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Tags generated for I/O are on a per Adapter basis Untagged requests cause port to wait for all active I/O on the LUN to complete NextRequest / NextLuRequest, are the mechanisms for Miniport to request more I/O For LUNS that support tagged queuing, use NextLuRequest to maximize throughput

WHDC PowerPoint Template Notes & Handouts I/O: Busy Processing WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSIPORT supports busy processing on a LUN as opposed to adapter Level LUN transitions to a busy state when a SRB is completed with status BUSY All requests to the LUN are stopped, and the busy request is retried after 1s Miniport must call NextRequest in response to every request being returned as Busy

WHDC PowerPoint Template Notes & Handouts I/O: Bus Resets WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Large I/O delays lead to miniport’s HwResetBus routine being called Miniport should ensure completion of all outstanding requests in this routine No more requests are issued to the miniport for a Reset Hold Period (currently 4s) The SCSI bus may also be reset to restart a hung adapter

WHDC PowerPoint Template Notes & Handouts Callbacks WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 MiniPort may request timer callbacks MiniPort may request a callback at DPC level from it’s ISR CallDisableInterrupts / CallEnableInterrupts should be used with care

WHDC PowerPoint Template Notes & Handouts Error Processing WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Set the SrbStatus field wisely Use SCSIPORTLogError to log real adapter/link errors, not LUN failures Update the DataTransferLength field of the SRB appropriately Fill in the SenseData carefully

Important Registry Keys WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 NumberOfRequests TotalSenseDataBytes TimeoutValue DriverParameter(s) ResetHoldTime MaximumSGList

WHDC PowerPoint Template Notes & Handouts Debugging: Tools WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Debugger Extensions scsikd.dll Windows 2000, Windows XP, Windows Server 2003. minipkd.dll Windows Server 2003 only. SCSI Verifier Windows XP and Windows Server 2003 only.

Debugging: SCSI Verifier WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSI verifier is a great debugging and testing aid for miniport developers Verifier thunks calls to miniport for maintaining state Verifier bug-checks with a unique error code in case of rule violations Verifier does advanced error detection like remapping SRB extensions to physically non-contiguous pages

Debugging: Locating Adapters/LUNS WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 0: kd> !object \device\scsi Object: e12a2520 Type: (863d12c8) Directory ObjectHeader: e12a2508 HandleCount: 0 PointerCount: 9 Directory Object: e1001100 Name: Scsi Hash Address Type Name ---- ------- ---- ---- 04 86352040 Device adpu160m1Port3Path0Target6Lun0 11 86353040 Device adpu160m1Port3Path0Target1Lun0 13 86334a70 Device lp6nds351 22 862e6040 Device adpu160m1Port3Path0Target0Lun0

Debugging: Locating Adapters/LUNS WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 0: kd> !minipkd.adapters Adapter \Driver\lp6nds35 DO 86334a70 DevExt 86334b28 Adapter \Driver\adpu160m DO 8633da70 DevExt 8633db28 LUN 862e60f8 @(0,0,0) c ev pnp(00/ff) pow(0,0) DevObj 862e6040 LUN 863530f8 @(0,1,0) c ev p d pnp(00/ff) pow(0,0) DevObj 86353040 LUN 862e50f8 @(0,2,0) c ev pnp(00/ff) pow(0,0) DevObj 862e5040 LUN 863520f8 @(0,6,0) ev pnp(00/ff) pow(0,0) DevObj 86352040 Adapter \Driver\adpu160m DO 86376040 DevExt 863760f8 Flags c - claimed m - missing e - enumerated v - visible p – paging d – dump h - hibernate

WHDC PowerPoint Template Notes & Handouts Common Problems WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Bugcheck 0x7A and 0x77 Hangs and timeouts Reproducible problems Interrupt storms and no interrupts Scatter gather lists

Common Problems: Bug-Check 7A/77 WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Reset due to device/port timeout Selection timeout Controller errors !scsikd.classext displays LUN error log !errlog often identifies useful info

Common Problems: Hangs And Timeouts WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 SCSIPORT DPC not running !pcr, !stacks, !process 0 7 Miniport fails to ask for next request !devobj <FDO>, !scsikd.scsiext Request is stuck in SCSIPORT Waiting for map registers

Common Problems: Interrupts WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Problems No interrupts Interrupt storms What to do… Check if your interrupt is shared Step over ISR to see if hardware is generating interrupt storm

WHDC PowerPoint Template Notes & Handouts Resources WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 Microsoft Windows DDK http://www.microsoft.com/ddk Debugging tools http://www.microsoft.com/ddk/debugging OSR’S NTDEV mailing list http://www.ntdev.org Links http://www.microsoft.com/whdc/hwdev/tech/storage/entstor/default.mspx

WHDC PowerPoint Template Notes & Handouts Saturday, June 16, 2018 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.