• Albert Lee's avatar
    [PATCH] libata: Fix zero sg_dma_len() on 64-bit platform · 32529e01
    Albert Lee authored
    When testing ATAPI PIO data transfer on the ppc64 platform,  __atapi_pio_bytes() got zero when
    sg_dma_len() is used. I checked the <asm-ppc64/scatterlish.h>, the struct scatterlist is defined as:
    
    struct scatterlist {
    	struct page *page;
    	unsigned int offset;
    	unsigned int length;
    
    	/* For TCE support */
    	u32 dma_address;
    	u32 dma_length;
    };
    
    #define sg_dma_address(sg)	((sg)->dma_address)
    #define sg_dma_len(sg)		((sg)->dma_length)
    
    So, if the scatterlist is not DMA mapped, sg_dma_len() will return zero on ppc64.
    The same problem should occur on the x86-64 platform.
    On the i386 platform, sg_dma_len() returns sg->length, that's why the problem does not occur on an i386.
    
    Changes:
    - Use sg->length if the scatterlist is not DMA mapped (yet).
    Signed-off-by: default avatarAlbert Lee <albertcc@tw.ibm.com>
    32529e01
libata-core.c 92.5 KB