lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DE550DFB-AD1F-49A2-8100-4B3234427163@kernel.crashing.org>
Date:	Tue, 24 Mar 2009 22:54:12 -0500
From:	Becky Bruce <beckyb@...nel.crashing.org>
To:	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu,
	ian.campbell@...rix.com, jeremy@...p.org
Subject: Re: [PATCH 3/5] swiotlb: swiotlb_bus_to_virt/phys prototype changes


On Mar 24, 2009, at 9:58 PM, FUJITA Tomonori wrote:

> On Tue, 24 Mar 2009 16:28:44 -0500
> Becky Bruce <beckyb@...nel.crashing.org> wrote:
>
>> Make these functions take the hwdev as an argument because on some
>> platforms it contains a per-device offset that is used to convert
>> from bus addresses to/from other types of addresses.
>>
>> Also, make these weak so architectures can override the default
>> behavior (for example, by adding an offset in the hwdev).
>>
>> Signed-off-by: Becky Bruce <beckyb@...nel.crashing.org>
>> ---
>> arch/x86/kernel/pci-swiotlb.c |    2 +-
>> include/linux/swiotlb.h       |    4 +++-
>> lib/swiotlb.c                 |   31 +++++++++++++++++++------------
>> 3 files changed, 23 insertions(+), 14 deletions(-)
>
>> @@ -847,10 +847,14 @@ swiotlb_unmap_sg_attrs(struct device *hwdev,  
>> struct scatterlist *sgl,
>>
>> 	for_each_sg(sgl, sg, nelems, i) {
>> 		if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg)))
>> -			unmap_single(hwdev, swiotlb_bus_to_virt(sg->dma_address),
>> -				     sg->dma_length, dir);
>> +			unmap_single(
>> +				hwdev,
>> +				swiotlb_bus_to_virt(hwdev, sg->dma_address),
>> +				sg->dma_length, dir);
>> 		else if (dir == DMA_FROM_DEVICE)
>> -			dma_mark_clean(swiotlb_bus_to_virt(sg->dma_address), sg- 
>> >dma_length);
>> +			dma_mark_clean(
>> +				swiotlb_bus_to_virt(hwdev, sg->dma_address),
>> +				sg->dma_length);
>> 	}
>
> The coding style looks a bit odd to me. How about something like this?

>
>
> for_each_sg(sgl, sg, nelems, i) {
> 	void *virt = swiotlb_bus_to_virt(hwdev, sg->dma_address),
> 	if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg)))
> 		unmap_single(hwdev, virt, sg->dma_length, dir);
> 	else if (dir == DMA_FROM_DEVICE)
> 		dma_mark_clean(virt, sg->dma_length);

Heh, I was trying to avoid > 80 character lines there, and it ended up  
looking a bit gross.  I originally had *exactly* what you suggest in  
my tree, but changed it, so I'm more than happy to change this back.

>
>
>
>> }
>> EXPORT_SYMBOL(swiotlb_unmap_sg_attrs);
>> @@ -881,10 +885,13 @@ swiotlb_sync_sg(struct device *hwdev, struct  
>> scatterlist *sgl,
>>
>> 	for_each_sg(sgl, sg, nelems, i) {
>> 		if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg)))
>> -			sync_single(hwdev, swiotlb_bus_to_virt(sg->dma_address),
>> +			sync_single(hwdev,
>> +				    swiotlb_bus_to_virt(hwdev, sg->dma_address),
>> 				    sg->dma_length, dir, target);
>> 		else if (dir == DMA_FROM_DEVICE)
>> -			dma_mark_clean(swiotlb_bus_to_virt(sg->dma_address), sg- 
>> >dma_length);
>> +			dma_mark_clean(
>> +				swiotlb_bus_to_virt(hwdev, sg->dma_address),
>> +				sg->dma_length);
>> 	}
>
> Ditto.
>
>
> The rest looks fine to me.

Thanks for the review!

Cheers,
-Becky

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ