Re: [PATCH] SCSI driver for VMware's virtual HBA.

James Bottomley
2009-09-01T14:26:47Z

On Mon, 2009-08-31 at 14:53 -0700, Alok Kataria wrote:
> > > diff --git a/drivers/scsi/pvscsi.c b/drivers/scsi/pvscsi.c
> > > new file mode 100644
> > > index 0000000..fc85a3a
> > > --- /dev/null
> > > +++ b/drivers/scsi/pvscsi.c
> > [...]
> > > +static int __devinit pvscsi_allocate_sg(struct pvscsi_adapter *adapter)
> > > +{
> > > + struct pvscsi_ctx *ctx;
> > > + int i;
> > > +
> > > + ctx = adapter->cmd_map;
> > > + BUILD_BUG_ON(sizeof(struct pvscsi_sg_list) > PAGE_SIZE);
> > > +
> > > + for (i = 0; i < adapter->req_depth; ++i, ++ctx) {
> > > + ctx->sgl = pci_alloc_consistent(adapter->dev, PAGE_SIZE,
> > > + &ctx->sglPA);
> >
> > Why do you need coherent memory for the sg list? Surely the use pattern
> > of an SG list is that it follows a predefined ownership model between
> > the driver and the virtual device, thus not really requiring coherent
> > memory?
>
> The SG list needs to be accessed by the hypervisor too, and we need the
> physical address to access it from the hypervisor. We do that using the
> sglPA field right now, which the pci_.. interface returns. Do you think
> something else should be used for that purpose ?

The hypervisor is part of the OS coherency domain ... coherent memory is
designed to be a mailbox access between a device and driver, which I
believe the hypervisor doesn't need.

If all you're looking for is a way to map a page of memory to a physical
address, won't dma_map_single() do that for you? Or, actually, in this
case virt_to_page() might be a better way.

James