[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210510084406.GA1093@lst.de>
Date: Mon, 10 May 2021 10:44:06 +0200
From: Christoph Hellwig <hch@....de>
To: Chanho Park <chanho61.park@...sung.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Christoph Hellwig <hch@....de>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
Bumyong Lee <bumyong.lee@...sung.com>
Subject: Re: [PATCH] swiotlb: manipulate orig_addr when tlb_addr has offset
On Mon, May 10, 2021 at 05:30:57PM +0900, Chanho Park wrote:
> +static unsigned int swiotlb_align_offset(struct device *dev, u64 addr);
Please just move swiotlb_align_offset up to avoid the forward declaration.
> /*
> * Bounce: copy the swiotlb buffer from or back to the original dma location
> */
> @@ -346,10 +347,17 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size
> size_t alloc_size = mem->slots[index].alloc_size;
> unsigned long pfn = PFN_DOWN(orig_addr);
> unsigned char *vaddr = phys_to_virt(tlb_addr);
> + unsigned int tlb_offset;
>
> if (orig_addr == INVALID_PHYS_ADDR)
> return;
>
> + tlb_offset = (unsigned int)tlb_addr & (IO_TLB_SIZE - 1);
> + tlb_offset -= swiotlb_align_offset(dev, orig_addr);
Nit: I'd write this as:
tlb_offset = (tlb_addr & (IO_TLB_SIZE - 1)) -
swiotlb_align_offset(dev, orig_addr);
as there is no need for the cast, and just having a single assignment
is easier to follow.
Powered by blists - more mailing lists