Skip to content

Commit

Permalink
Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
Browse files Browse the repository at this point in the history
* 'sg' of git://git.kernel.dk/linux-2.6-block:
  sparc64: zero out dma_length
  fvr32: fixup dma-mapping for new sg layout
  sh/sh64: fixup dma-mapping for new sg layout
  Fix sctp compile
  m68knommu: remove sg_address()
  frv: update comment in scatterlist to reflect new setup
  blackfin: remove sg_address()
  arm: sg fallout
  mips: sg_page() fallout
  alpha: sg_virt() fallout
  intel-iommu: fix sg_page()
  parisc: fix sg_page() fallout
  ide: build fix
  net: fix xfrm build - missing scatterlist.h include
  [BLOCK] blk_rq_map_sg: force clear termination bit
  [BLOCK] Don't clear sg_dma_len/addr() in blk_rq_map_sg()
  s390 zfcp: sg fixups
  powerpc: Fix fallout from sg_page() changes
  IB/ehca: Fix sg_page() fallout
  arm: build fix
  • Loading branch information
Linus Torvalds committed Oct 23, 2007
2 parents 101e4d9 + cb92ae8 commit ba1c28a
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 51 deletions.
1 change: 1 addition & 0 deletions arch/alpha/kernel/pci_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/bootmem.h>
#include <linux/scatterlist.h>
#include <linux/log2.h>

#include <asm/io.h>
Expand Down
1 change: 1 addition & 0 deletions arch/arm/common/dmabounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/list.h>
#include <linux/scatterlist.h>

#include <asm/cacheflush.h>

Expand Down
1 change: 1 addition & 0 deletions arch/mips/mm/dma-default.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/scatterlist.h>

#include <asm/cache.h>
#include <asm/io.h>
Expand Down
1 change: 1 addition & 0 deletions arch/parisc/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/scatterlist.h>

#include <asm/cacheflush.h>
#include <asm/dma.h> /* for DMA_CHUNK_SIZE */
Expand Down
5 changes: 5 additions & 0 deletions arch/sparc64/kernel/iommu_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents)
dma_sg->dma_address = dent_addr;
dma_sg->dma_length = dent_len;

if (dma_sg != sg) {
dma_sg = next_sg(dma_sg);
dma_sg->dma_length = 0;
}

return ((unsigned long) dent_addr +
(unsigned long) dent_len +
(IO_PAGE_SIZE - 1UL)) >> IO_PAGE_SHIFT;
Expand Down
16 changes: 13 additions & 3 deletions block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1351,11 +1351,21 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
new_segment:
if (!sg)
sg = sglist;
else
else {
/*
* If the driver previously mapped a shorter
* list, we could see a termination bit
* prematurely unless it fully inits the sg
* table on each mapping. We KNOW that there
* must be more entries here or the driver
* would be buggy, so force clear the
* termination bit to avoid doing a full
* sg_init_table() in drivers for each command.
*/
sg->page_link &= ~0x02;
sg = sg_next(sg);
}

sg_dma_len(sg) = 0;
sg_dma_address(sg) = 0;
sg_set_page(sg, bvec->bv_page);
sg->length = nbytes;
sg->offset = bvec->bv_offset;
Expand Down
1 change: 1 addition & 0 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <linux/spinlock.h>
#include <linux/kmod.h>
#include <linux/pci.h>
#include <linux/scatterlist.h>

#include <asm/byteorder.h>
#include <asm/irq.h>
Expand Down
6 changes: 3 additions & 3 deletions drivers/infiniband/hw/ehca/ehca_mrmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ static int ehca_set_pagebuf_user1(struct ehca_mr_pginfo *pginfo,
list_for_each_entry_continue(
chunk, (&(pginfo->u.usr.region->chunk_list)), list) {
for (i = pginfo->u.usr.next_nmap; i < chunk->nmap; ) {
pgaddr = page_to_pfn(chunk->page_list[i].page)
pgaddr = page_to_pfn(sg_page(&chunk->page_list[i]))
<< PAGE_SHIFT ;
*kpage = phys_to_abs(pgaddr +
(pginfo->next_hwpage *
Expand Down Expand Up @@ -1832,7 +1832,7 @@ static int ehca_check_kpages_per_ate(struct scatterlist *page_list,
{
int t;
for (t = start_idx; t <= end_idx; t++) {
u64 pgaddr = page_to_pfn(page_list[t].page) << PAGE_SHIFT;
u64 pgaddr = page_to_pfn(sg_page(&page_list[t])) << PAGE_SHIFT;
ehca_gen_dbg("chunk_page=%lx value=%016lx", pgaddr,
*(u64 *)abs_to_virt(phys_to_abs(pgaddr)));
if (pgaddr - PAGE_SIZE != *prev_pgaddr) {
Expand Down Expand Up @@ -1867,7 +1867,7 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo,
chunk, (&(pginfo->u.usr.region->chunk_list)), list) {
for (i = pginfo->u.usr.next_nmap; i < chunk->nmap; ) {
if (nr_kpages == kpages_per_hwpage) {
pgaddr = ( page_to_pfn(chunk->page_list[i].page)
pgaddr = ( page_to_pfn(sg_page(&chunk->page_list[i]))
<< PAGE_SHIFT );
*kpage = phys_to_abs(pgaddr);
if ( !(*kpage) ) {
Expand Down
1 change: 1 addition & 0 deletions drivers/parisc/ccio-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/reboot.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/scatterlist.h>

#include <asm/byteorder.h>
#include <asm/cache.h> /* for L1_CACHE_BYTES */
Expand Down
1 change: 1 addition & 0 deletions drivers/parisc/sba_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/pci.h>
#include <linux/scatterlist.h>

#include <asm/byteorder.h>
#include <asm/io.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ static void intel_free_coherent(struct device *hwdev, size_t size,
free_pages((unsigned long)vaddr, order);
}

#define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset)
#define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg)))
static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
int nelems, int dir)
{
Expand Down Expand Up @@ -2010,7 +2010,7 @@ static int intel_nontranslate_map_sg(struct device *hddev,
struct scatterlist *sg;

for_each_sg(sglist, sg, nelems, i) {
BUG_ON(!sg->page);
BUG_ON(!sg_page(sg));
sg->dma_address = virt_to_bus(SG_ENT_VIRT_ADDRESS(sg));
sg->dma_length = sg->length;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/s390/scsi/zfcp_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
retval = -ENOMEM;
goto out;
}
sg_init_table(sg_list->sg, sg_list->count);

for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
sg->length = min(size, PAGE_SIZE);
Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/scsi/zfcp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
static inline void *
zfcp_sg_to_address(struct scatterlist *list)
{
return (void *) (page_address(list->page) + list->offset);
return sg_virt(list);
}

/**
Expand All @@ -74,7 +74,7 @@ zfcp_sg_to_address(struct scatterlist *list)
static inline void
zfcp_address_to_sg(void *address, struct scatterlist *list)
{
list->page = virt_to_page(address);
sg_set_page(list, virt_to_page(address));
list->offset = ((unsigned long) address) & (PAGE_SIZE - 1);
}

Expand Down
10 changes: 6 additions & 4 deletions drivers/s390/scsi/zfcp_erp.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,15 @@ zfcp_erp_adisc(struct zfcp_port *port)
if (send_els == NULL)
goto nomem;

send_els->req = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
if (send_els->req == NULL)
goto nomem;
sg_init_table(send_els->req, 1);

send_els->resp = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
if (send_els->resp == NULL)
goto nomem;
sg_init_table(send_els->resp, 1);

address = (void *) get_zeroed_page(GFP_ATOMIC);
if (address == NULL)
Expand Down Expand Up @@ -363,7 +365,7 @@ zfcp_erp_adisc(struct zfcp_port *port)
retval = -ENOMEM;
freemem:
if (address != NULL)
__free_pages(send_els->req->page, 0);
__free_pages(sg_page(send_els->req), 0);
if (send_els != NULL) {
kfree(send_els->req);
kfree(send_els->resp);
Expand Down Expand Up @@ -437,7 +439,7 @@ zfcp_erp_adisc_handler(unsigned long data)

out:
zfcp_port_put(port);
__free_pages(send_els->req->page, 0);
__free_pages(sg_page(send_els->req), 0);
kfree(send_els->req);
kfree(send_els->resp);
kfree(send_els);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ps3rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd *cmd, void *buf)

req_len = fin = 0;
scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) {
kaddr = kmap_atomic(sg_page(sgpnt->page), KM_IRQ0);
kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0);
len = sgpnt->length;
if ((req_len + len) > buflen) {
len = buflen - req_len;
Expand Down
10 changes: 5 additions & 5 deletions include/asm-arm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <linux/mm.h> /* need struct page */

#include <asm/scatterlist.h>
#include <linux/scatterlist.h>

/*
* DMA-consistent mapping functions. These allocate/free a region of
Expand Down Expand Up @@ -274,8 +274,8 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
for (i = 0; i < nents; i++, sg++) {
char *virt;

sg->dma_address = page_to_dma(dev, sg->page) + sg->offset;
virt = page_address(sg->page) + sg->offset;
sg->dma_address = page_to_dma(dev, sg_page(sg)) + sg->offset;
virt = sg_virt(sg);

if (!arch_is_coherent())
dma_cache_maint(virt, sg->length, dir);
Expand Down Expand Up @@ -371,7 +371,7 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
int i;

for (i = 0; i < nents; i++, sg++) {
char *virt = page_address(sg->page) + sg->offset;
char *virt = sg_virt(sg);
if (!arch_is_coherent())
dma_cache_maint(virt, sg->length, dir);
}
Expand All @@ -384,7 +384,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
int i;

for (i = 0; i < nents; i++, sg++) {
char *virt = page_address(sg->page) + sg->offset;
char *virt = sg_virt(sg);
if (!arch_is_coherent())
dma_cache_maint(virt, sg->length, dir);
}
Expand Down
7 changes: 3 additions & 4 deletions include/asm-avr32/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
for (i = 0; i < nents; i++) {
char *virt;

sg[i].dma_address = page_to_bus(sg[i].page) + sg[i].offset;
virt = page_address(sg[i].page) + sg[i].offset;
sg[i].dma_address = page_to_bus(sg_page(&sg[i])) + sg[i].offset;
virt = sg_virt(&sg[i]);
dma_cache_sync(dev, virt, sg[i].length, direction);
}

Expand Down Expand Up @@ -327,8 +327,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int i;

for (i = 0; i < nents; i++) {
dma_cache_sync(dev, page_address(sg[i].page) + sg[i].offset,
sg[i].length, direction);
dma_cache_sync(dev, sg_virt(&sg[i]), sg[i].length, direction);
}
}

Expand Down
1 change: 0 additions & 1 deletion include/asm-blackfin/scatterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct scatterlist {
* returns, or alternatively stop on the first sg_dma_len(sg) which
* is 0.
*/
#define sg_address(sg) (page_address((sg)->page) + (sg)->offset)
#define sg_dma_address(sg) ((sg)->dma_address)
#define sg_dma_len(sg) ((sg)->length)

Expand Down
8 changes: 4 additions & 4 deletions include/asm-frv/scatterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
#include <asm/types.h>

/*
* Drivers must set either ->address or (preferred) ->page and ->offset
* Drivers must set either ->address or (preferred) page and ->offset
* to indicate where data must be transferred to/from.
*
* Using ->page is recommended since it handles highmem data as well as
* Using page is recommended since it handles highmem data as well as
* low mem. ->address is restricted to data which has a virtual mapping, and
* it will go away in the future. Updating to ->page can be automated very
* it will go away in the future. Updating to page can be automated very
* easily -- something like
*
* sg->address = some_ptr;
*
* can be rewritten as
*
* sg->page = virt_to_page(some_ptr);
* sg_set_page(virt_to_page(some_ptr));
* sg->offset = (unsigned long) some_ptr & ~PAGE_MASK;
*
* and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
Expand Down
1 change: 0 additions & 1 deletion include/asm-m68knommu/scatterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct scatterlist {
unsigned int length;
};

#define sg_address(sg) (page_address((sg)->page) + (sg)->offset)
#define sg_dma_address(sg) ((sg)->dma_address)
#define sg_dma_len(sg) ((sg)->length)

Expand Down
2 changes: 1 addition & 1 deletion include/asm-parisc/scatterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct scatterlist {
__u32 iova_length; /* bytes mapped */
};

#define sg_virt_addr(sg) ((unsigned long)(page_address(sg->page) + sg->offset))
#define sg_virt_addr(sg) ((unsigned long)sg_virt(sg))
#define sg_dma_address(sg) ((sg)->iova)
#define sg_dma_len(sg) ((sg)->iova_length)

Expand Down
10 changes: 5 additions & 5 deletions include/asm-powerpc/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
BUG_ON(direction == DMA_NONE);

for_each_sg(sgl, sg, nents, i) {
BUG_ON(!sg->page);
__dma_sync_page(sg->page, sg->offset, sg->length, direction);
sg->dma_address = page_to_bus(sg->page) + sg->offset;
BUG_ON(!sg_page(sg));
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
sg->dma_address = page_to_bus(sg_page(sg)) + sg->offset;
}

return nents;
Expand Down Expand Up @@ -328,7 +328,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
BUG_ON(direction == DMA_NONE);

for_each_sg(sgl, sg, nents, i)
__dma_sync_page(sg->page, sg->offset, sg->length, direction);
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
}

static inline void dma_sync_sg_for_device(struct device *dev,
Expand All @@ -341,7 +341,7 @@ static inline void dma_sync_sg_for_device(struct device *dev,
BUG_ON(direction == DMA_NONE);

for_each_sg(sgl, sg, nents, i)
__dma_sync_page(sg->page, sg->offset, sg->length, direction);
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
}

static inline int dma_mapping_error(dma_addr_t dma_addr)
Expand Down
12 changes: 5 additions & 7 deletions include/asm-sh/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __ASM_SH_DMA_MAPPING_H

#include <linux/mm.h>
#include <asm/scatterlist.h>
#include <linux/scatterlist.h>
#include <asm/cacheflush.h>
#include <asm/io.h>

Expand Down Expand Up @@ -85,10 +85,9 @@ static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,

for (i = 0; i < nents; i++) {
#if !defined(CONFIG_PCI) || defined(CONFIG_SH_PCIDMA_NONCOHERENT)
dma_cache_sync(dev, page_address(sg[i].page) + sg[i].offset,
sg[i].length, dir);
dma_cache_sync(dev, sg_virt(&sg[i]), sg[i].length, dir);
#endif
sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
sg[i].dma_address = sg_phys(&sg[i]);
}

return nents;
Expand Down Expand Up @@ -138,10 +137,9 @@ static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg,

for (i = 0; i < nelems; i++) {
#if !defined(CONFIG_PCI) || defined(CONFIG_SH_PCIDMA_NONCOHERENT)
dma_cache_sync(dev, page_address(sg[i].page) + sg[i].offset,
sg[i].length, dir);
dma_cache_sync(dev, sg_virt(&sg[i]), sg[i].length, dir);
#endif
sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
sg[i].dma_address = sg_phys(&sg[i]);
}
}

Expand Down
Loading

0 comments on commit ba1c28a

Please sign in to comment.