I am sponsoring the following fasttrack for Mark Johnson, requesting patch
binding and a timeout of 10/16/2007.
-Chris
Template Version: @(#)sac_nextcase 1.64 07/13/07 SMI
1. Introduction
1.1 Project/Component Working Name:
bp_copyin()/bp_copyout()
1.2 Name of Document Author/Supplier:
Author: Mark Johnson
1.3 Date of This Document:
Tue Oct 9 10:36:08 MDT 2007
4. Technical Description
4.1 Introduction
This case introduces two new buf interfaces, and is the second of
two fasttracks to address st tape driver performance on x86.
dma-max-arch scsi capability
bp_copyin()/bp_copyout()
There is a recently escalated bug outstanding for this issue.
6567168 s10 x86 st tape driver performance issue
http://monaco.sfbay/detail.jsf?cr=6567168
4.2 Background
Most tape drives cannot handle partial DMAs. An entire tape block
must be transferred in a single DMA.
For our SPARC based systems, this is relatively simple. Since
these systems have an IOMMU, the only real consideration is the
underlying HBA's maximum DMA size, which is returned via the
'dma-max' scsi capability.
For current x86 bases systems, this becomes more complicated. Not
only can the maximum DMA be limited by the underlying HBA's maximum
DMA size, but it can also be limited by the DMA engines
scatter/gather list constraints (if the memory is completely
fragmented).
Today on x86, the st tape driver will allocate physically
contiguous memory and then bp_mapin/bcopy/bp_mapout all transfers
where the tape blocksize is greater than 64KBytes.
There are two parts to the solution. The first is to provide a way
for the st driver to query what the DMA constraints of the HBA are,
taking the sgllen into account. The second is to provide a 64-bit
optimized bp copy for block sizes which are too large to fit within
the HBA's sgllen constraints, but are within the HBA's maximum DMA
size.
For example, the ST driver may find out that the maximum DMA
supported by the HBA ('dma-max') is 4M and the maximum DMA supported
by the HBA/system is 1M ('dma-max-arch'). The st driver can then
allow any blocksize <= 1M to go directly to the HBA and then use
the optimized copy for block sizes greater than 1M and less than or
equal to 4M. Today it does an un-optimized copy for block sizes
greater than 64K.
This case addresses the second part of the problem. It provides two
new general purpose buf routines to copy data in and out of bufs.
These routines are supported on all architectures.
Some implementation notes of interest. The routines will first look
to see if the buf has already been mapped info kernel VA space. If
not, they implement an optimized copy on 64-bit kernels using seg
kpm.
4.3 Interface Table
INTERFACE COMMITMENT LEVEL COMMENT
bp_copyin(9F) Committed optimize bp_mapin, bcopy,
bp_copyout(9F) Committed bp_mapout.
4.4 Man page changes
See below.
6. Resources and Schedule
6.4. Steering Committee requested information
6.4.1. Consolidation C-team Name:
ON
6.5. ARC review type: FastTrack
6.6. ARC Exposure: open
A.1 man page for bp_copyin(9F)
Kernel Functions for Drivers bp_copyin(9F)
NAME
bp_copyin - copy from a kernel virtual address to a buf
SYNOPSIS
#include <sys/types.h>
#include <sys/buf.h>
int bp_copyin(caddr_t vaddr, struct buf *bp,
offset_t offset, size_t size);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
vaddr Kernel virtual address to copy from.
bp Pointer to the buffer header structure to copy to.
offset Offset into bp where to start copying.
size Size of copy.
DESCRIPTION
bp_copyin() copies 'size' bytes starting from kernel virtual
address 'vaddr' to 'offset' bytes into the memory associated
with 'bp'. The 'offset' only applies to 'bp'.
RETURN VALUES
Under normal conditions, 0 is returned to indicate a
successful copy. Otherwise, -1 is returned if 'bp' references
invalid pages.
CONTEXT
bp_copyin() can be called from user or kernel context only.
SEE ALSO
bp_copyout(9F), buf(9S), ddi_copyin(9F), bp_mapin(9F),
bp_mapout(9F).
A.2 man page for bp_copyout(9F)
Kernel Functions for Drivers bp_copyout(9F)
NAME
bp_copyout - copy from a buf to a kernel virtual address
SYNOPSIS
#include <sys/types.h>
#include <sys/buf.h>
int bp_copyout(struct buf *bp, caddr_t vaddr,
offset_t offset, size_t size);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
bp Pointer to the buffer header structure to copy from.
vaddr Kernel virtual address to copy to.
offset Offset into bp where to start copying.
size Size of copy.
DESCRIPTION
bp_copyput() copies 'size' bytes starting at 'offset' bytes
into the memory associated with 'bp' to the destination
address kernel virtual address 'vaddr'. The 'offset' only
applies to 'bp'.
RETURN VALUES
Under normal conditions, 0 is returned to indicate a
successful copy. Otherwise, -1 is returned if 'bp' references
invalid pages.
CONTEXT
bp_copyout() can be called from user or kernel context only.
SEE ALSO
bp_copyin(9F), buf(9S), ddi_copyout(9F), bp_mapin(9F),
bp_mapout(9F).