Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] arcmsr: simplify assumptions in dma_alloc_coherent()

The code currently computes an offset into a dma_alloc_coherent() area
on the assumption that the alignment is imprecise. In fact, the API
guarantees PAGE_SIZE alignment, so the offset calculation is always
zero: remove it.

[jejb: make description actually descriptive]
Signed-off-by: Tomas henzl <thenzl@redhat.com>
Acked-by: Nick Cheng<nick.cheng@areca.com.tw>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

Tomas Henzl and committed by
James Bottomley
87f76152 8b7eb86f

+5 -7
+5 -7
drivers/scsi/arcmsr/arcmsr_hba.c
··· 441 441 struct CommandControlBlock *ccb_tmp; 442 442 int i = 0, j = 0; 443 443 dma_addr_t cdb_phyaddr; 444 - unsigned long roundup_ccbsize = 0, offset; 444 + unsigned long roundup_ccbsize; 445 445 unsigned long max_xfer_len; 446 446 unsigned long max_sg_entrys; 447 447 uint32_t firm_config_version; 448 + 448 449 for (i = 0; i < ARCMSR_MAX_TARGETID; i++) 449 450 for (j = 0; j < ARCMSR_MAX_TARGETLUN; j++) 450 451 acb->devstate[i][j] = ARECA_RAID_GONE; ··· 455 454 firm_config_version = acb->firm_cfg_version; 456 455 if((firm_config_version & 0xFF) >= 3){ 457 456 max_xfer_len = (ARCMSR_CDB_SG_PAGE_LENGTH << ((firm_config_version >> 8) & 0xFF)) * 1024;/* max 4M byte */ 458 - max_sg_entrys = (max_xfer_len/4096); 457 + max_sg_entrys = (max_xfer_len/4096); 459 458 } 460 459 acb->host->max_sectors = max_xfer_len/512; 461 460 acb->host->sg_tablesize = max_sg_entrys; 462 461 roundup_ccbsize = roundup(sizeof(struct CommandControlBlock) + (max_sg_entrys - 1) * sizeof(struct SG64ENTRY), 32); 463 - acb->uncache_size = roundup_ccbsize * ARCMSR_MAX_FREECCB_NUM + 32; 462 + acb->uncache_size = roundup_ccbsize * ARCMSR_MAX_FREECCB_NUM; 464 463 dma_coherent = dma_alloc_coherent(&pdev->dev, acb->uncache_size, &dma_coherent_handle, GFP_KERNEL); 465 464 if(!dma_coherent){ 466 - printk(KERN_NOTICE "arcmsr%d: dma_alloc_coherent got error \n", acb->host->host_no); 465 + printk(KERN_NOTICE "arcmsr%d: dma_alloc_coherent got error\n", acb->host->host_no); 467 466 return -ENOMEM; 468 467 } 469 468 acb->dma_coherent = dma_coherent; 470 469 acb->dma_coherent_handle = dma_coherent_handle; 471 470 memset(dma_coherent, 0, acb->uncache_size); 472 - offset = roundup((unsigned long)dma_coherent, 32) - (unsigned long)dma_coherent; 473 - dma_coherent_handle = dma_coherent_handle + offset; 474 - dma_coherent = (struct CommandControlBlock *)dma_coherent + offset; 475 471 ccb_tmp = dma_coherent; 476 472 acb->vir2phy_offset = (unsigned long)dma_coherent - (unsigned long)dma_coherent_handle; 477 473 for(i = 0; i < ARCMSR_MAX_FREECCB_NUM; i++){