* Re: [PATCH] edac: mpc85xx: add support for mpc83xx memory controller
From: Ira W. Snyder @ 2009-07-09 21:38 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, bluesmoke-devel, Dave Jiang
In-Reply-To: <C720C7F4-B3FE-4C98-B04A-EE4F0BD40D5E@kernel.crashing.org>
On Thu, Jul 09, 2009 at 03:15:29PM -0500, Kumar Gala wrote:
>
> On Jul 9, 2009, at 2:35 PM, Ira W. Snyder wrote:
>
>> On Thu, Jul 09, 2009 at 01:25:43PM -0500, Kumar Gala wrote:
>>>
>>> On Jul 9, 2009, at 1:17 PM, Ira W. Snyder wrote:
>>>
>>>> On Thu, Jul 09, 2009 at 12:58:53PM -0500, Kumar Gala wrote:
>>>>>> Hello Kumar,
>>>>>>
>>>>>> I must not understand something going on here. Your proposed code
>>>>>> doesn't work at all on my board. The
>>>>>> /sys/devices/system/edac/mc/mc0/size_mb doesn't come out
>>>>>> correctly.
>>>>>
>>>>> What does it come out as? How much memory do you have in the
>>>>> system?
>>>>>
>>>>
>>>> The size_mb shows as 0 with your code. See the explanation below.
>>>> With
>>>> my code it shows as 256MB, as expected.
>>>>
>>>> I have 256MB memory in the system.
>>>>
>>>>>> The attached patch DOES work on my board, but I'm confident
>>>>>> that it
>>>>>> does
>>>>>> NOT work on a system with PAGE_SIZE != 4096. Any idea what I did
>>>>>> wrong?
>>>>>>
>>>>>> If I'm reading things correctly:
>>>>>> csrow->first_page full address of the first page (NOT pfn)
>>>>>> csrow->last_page full address of the last page (NOT pfn)
>>>>>> csrow->nr_pages number of pages
>>>>>>
>>>>>> The EDAC subsystem does csrow->nr_pages * PAGE_SIZE to get the
>>>>>> size_mb
>>>>>> sysfs value.
>>>>>>
>>>>>> If csrow->first_page and csrow->last_page ARE supposed to be the
>>>>>> pfn,
>>>>>> then I think the original code got it wrong, and the
>>>>>> calculation for
>>>>>> csrow->nr_pages needs to be changed.
>>>>>>
>>>>>> Thanks,
>>>>>> Ira
>>>>>
>>>>> [snip]
>>>>>
>>>>>> /************************ MC SYSFS parts
>>>>>> ***********************************/
>>>>>>
>>>>>> @@ -790,18 +792,19 @@ static void __devinit
>>>>>> mpc85xx_init_csrows(struct
>>>>>> mem_ctl_info *mci)
>>>>>> csrow = &mci->csrows[index];
>>>>>> cs_bnds = in_be32(pdata->mc_vbase + MPC85XX_MC_CS_BNDS_0 +
>>>>>> (index * MPC85XX_MC_CS_BNDS_OFS));
>>>>>> - start = (cs_bnds & 0xfff0000) << 4;
>>>>>> - end = ((cs_bnds & 0xfff) << 20);
>>>>>> - if (start)
>>>>>> - start |= 0xfffff;
>>>>>> - if (end)
>>>>>> - end |= 0xfffff;
>>>>>
>>>>> can you printk what cs_bnds values are in your setup.
>>>>>
>>>>
>>>> I am only using a single chip select. CS0_BNDS (register 0xe0002000)
>>>> is
>>>> 0x0000000F.
>>>>
>>>>>> +
>>>>>> + start = (cs_bnds & 0xffff0000) >> 16;
>>>>>> + end = (cs_bnds & 0x0000ffff);
>>>>>>
>>>>
>>>> This is the same in both our versions.
>>>>
>>>> start == 0x0
>>>> end == 0xF
>>>>
>>>>>> if (start == end)
>>>>>> continue; /* not populated */
>>>>>>
>>>>>> - csrow->first_page = start >> PAGE_SHIFT;
>>>>>> - csrow->last_page = end >> PAGE_SHIFT;
>>>>>> + start <<= PAGE_SHIFT;
>>>>>> + end <<= PAGE_SHIFT;
>>>>>> + end |= (1 << PAGE_SHIFT) - 1;
>>>>>> +
>>>>
>>>> MY VERSION
>>>>
>>>> start == 0x0
>>>> end == 0xffff
>>>>
>>>> first_page == 0x0
>>>> last_page == 0xffff
>>>>
>>>> YOUR VERSION (<<= (20 - PAGE_SHIFT), etc.)
>>>
>>> My math was wrong it should be ( <<= (24 - PAGE_SHIFT) )
>>>
>>> With that I think things work out.
>>>
>>
>> Yep, that works out great. This solution is much better than my
>> original
>> code. The 83xx doesn't need to be special-cased anymore.
>>
>> I checked the math for a 85xx with 64GB of memory. Assuming it uses
>> 64K
>> pages (PAGE_SHIFT == 16), then everything works out.
>
> Does the math work for a 64GB system w/4K pages?
>
Yes, the math works there too. I just double-checked by hand. The v2
patch should work fine on both the 83xx and 85xx (both 4K and 64K
pages).
Thanks again for the help on this one.
Ira
^ permalink raw reply
* question on powerpc pthread mutexes and memory barriers
From: Chris Friesen @ 2009-07-09 21:19 UTC (permalink / raw)
To: linuxppc-dev
Hi all,
This probably isn't the right place to ask about this, but does anyone
know where the implied memory barrier happens for pthread mutexes in the
uncontended case? I'm looking at the glibc code and I don't see any
barrier instructions for mutexes, only semaphores and spinlocks.
Thanks,
Chris
^ permalink raw reply
* Re: question on powerpc pthread mutexes and memory barriers
From: Chris Friesen @ 2009-07-09 22:42 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <4A565EEB.9020607@nortel.com>
Chris Friesen wrote:
> Hi all,
>
> This probably isn't the right place to ask about this, but does anyone
> know where the implied memory barrier happens for pthread mutexes in the
> uncontended case? I'm looking at the glibc code and I don't see any
> barrier instructions for mutexes, only semaphores and spinlocks.
Bad form to follow up on my own question, but I tracked it down. The
barriers are there hidden in the atomic macros.
Sorry for the noise.
Chris
^ permalink raw reply
* Re: [PATCH v2] edac: mpc85xx: add support for mpc83xx memory controller
From: Doug Thompson @ 2009-07-09 23:24 UTC (permalink / raw)
To: bluesmoke-devel, Dave Jiang, Kumar Gala, linuxppc-dev,
Ira W. Snyder
Ok, is this the one you want me to push upstream?=0A=0Adoug t=0A=0A=0A--- O=
n Thu, 7/9/09, Ira W. Snyder <iws@ovro.caltech.edu> wrote:=0A=0AFrom: Ira W=
. Snyder <iws@ovro.caltech.edu>=0ASubject: [PATCH v2] edac: mpc85xx: add su=
pport for mpc83xx memory controller=0ATo: bluesmoke-devel@lists.sourceforge=
.net, "Dave Jiang" <djiang@mvista.com>, "Kumar Gala" <galak@kernel.crashing=
.org>, linuxppc-dev@ozlabs.org=0ADate: Thursday, July 9, 2009, 1:40 PM=0A=
=0AAdd support for the Freescale MPC83xx memory controller to the existing=
=0Adriver for the Freescale MPC85xx memory controller. The only difference=
=0Abetween the two processors are in the CS_BNDS register parsing code, whi=
ch=0Ahas been changed so it will work on both processors.=0A=0AThe L2 cache=
controller does not exist on the MPC83xx, but the OF subsystem=0Awill not =
use the driver if the device is not present in the OF device tree.=0A=0ASig=
ned-off-by: Ira W. Snyder <iws@ovro.caltech.edu>=0A---=0A=0AKumar, I had to=
change the nr_pages calculation to make the math work=0Aout. I checked it =
on my board and did the math by hand for a 64GB 85xx=0Ausing 64K pages. In =
both cases, nr_pages * PAGE_SIZE comes out to the=0Acorrect value. Thanks f=
or the help.=0A=0Av1 -> v2:=0A=A0 * Use PAGE_SHIFT to parse cs_bnds regardl=
ess of board type=0A=A0 * Remove special-casing for the 83xx processor=0A=
=0A drivers/edac/Kconfig=A0 =A0 =A0 =A0 |=A0 =A0 6 +++---=0A drivers/edac/m=
pc85xx_edac.c |=A0=A0=A028 +++++++++++++++++++---------=0A 2 files changed,=
22 insertions(+), 12 deletions(-)=0A=0Adiff --git a/drivers/edac/Kconfig b=
/drivers/edac/Kconfig=0Aindex 4339b1a..78303f9 100644=0A--- a/drivers/edac/=
Kconfig=0A+++ b/drivers/edac/Kconfig=0A@@ -176,11 +176,11 @@ config EDAC_I5=
100=0A =A0=A0=A0 =A0 San Clemente MCH.=0A =0A config EDAC_MPC85XX=0A-=A0=A0=
=A0 tristate "Freescale MPC85xx"=0A-=A0=A0=A0 depends on EDAC_MM_EDAC && FS=
L_SOC && MPC85xx=0A+=A0=A0=A0 tristate "Freescale MPC83xx / MPC85xx"=0A+=A0=
=A0=A0 depends on EDAC_MM_EDAC && FSL_SOC && (PPC_83xx || MPC85xx)=0A =A0=
=A0=A0 help=0A =A0=A0=A0 =A0 Support for error detection and correction on =
the Freescale=0A-=A0=A0=A0 =A0 MPC8560, MPC8540, MPC8548=0A+=A0=A0=A0 =A0 M=
PC8349, MPC8560, MPC8540, MPC8548=0A =0A config EDAC_MV64X60=0A =A0=A0=A0 t=
ristate "Marvell MV64x60"=0Adiff --git a/drivers/edac/mpc85xx_edac.c b/driv=
ers/edac/mpc85xx_edac.c=0Aindex b4f5c63..ba2a264 100644=0A--- a/drivers/eda=
c/mpc85xx_edac.c=0A+++ b/drivers/edac/mpc85xx_edac.c=0A@@ -43,7 +43,9 @@ st=
atic u32 orig_pci_err_en;=0A #endif=0A =0A static u32 orig_l2_err_disable;=
=0A+#ifdef CONFIG_MPC85xx=0A static u32 orig_hid1[2];=0A+#endif=0A =0A /***=
********************* MC SYSFS parts ***********************************/=
=0A =0A@@ -790,19 +792,20 @@ static void __devinit mpc85xx_init_csrows(stru=
ct mem_ctl_info *mci)=0A =A0=A0=A0 =A0=A0=A0 csrow =3D &mci->csrows[index];=
=0A =A0=A0=A0 =A0=A0=A0 cs_bnds =3D in_be32(pdata->mc_vbase + MPC85XX_MC_CS=
_BNDS_0 +=0A =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 (index * MPC85XX_M=
C_CS_BNDS_OFS));=0A-=A0=A0=A0 =A0=A0=A0 start =3D (cs_bnds & 0xfff0000) << =
4;=0A-=A0=A0=A0 =A0=A0=A0 end =3D ((cs_bnds & 0xfff) << 20);=0A-=A0=A0=A0 =
=A0=A0=A0 if (start)=0A-=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 start |=3D 0xfffff;=
=0A-=A0=A0=A0 =A0=A0=A0 if (end)=0A-=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 end |=3D =
0xfffff;=0A+=0A+=A0=A0=A0 =A0=A0=A0 start =3D (cs_bnds & 0xffff0000) >> 16;=
=0A+=A0=A0=A0 =A0=A0=A0 end=A0=A0=A0=3D (cs_bnds & 0x0000ffff);=0A =0A =A0=
=A0=A0 =A0=A0=A0 if (start =3D=3D end)=0A =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 con=
tinue;=A0=A0=A0 /* not populated */=0A =0A+=A0=A0=A0 =A0=A0=A0 start <<=3D =
(24 - PAGE_SHIFT);=0A+=A0=A0=A0 =A0=A0=A0 end=A0=A0=A0<<=3D (24 - PAGE_SHIF=
T);=0A+=A0=A0=A0 =A0=A0=A0 end=A0 =A0 |=3D (1 << (24 - PAGE_SHIFT)) - 1;=0A=
+=0A =A0=A0=A0 =A0=A0=A0 csrow->first_page =3D start >> PAGE_SHIFT;=0A =A0=
=A0=A0 =A0=A0=A0 csrow->last_page =3D end >> PAGE_SHIFT;=0A-=A0=A0=A0 =A0=
=A0=A0 csrow->nr_pages =3D csrow->last_page + 1 - csrow->first_page;=0A+=A0=
=A0=A0 =A0=A0=A0 csrow->nr_pages =3D end + 1 - start;=0A =A0=A0=A0 =A0=A0=
=A0 csrow->grain =3D 8;=0A =A0=A0=A0 =A0=A0=A0 csrow->mtype =3D mtype;=0A =
=A0=A0=A0 =A0=A0=A0 csrow->dtype =3D DEV_UNKNOWN;=0A@@ -986,6 +989,7 @@ sta=
tic struct of_device_id mpc85xx_mc_err_of_match[] =3D {=0A =A0=A0=A0 { .com=
patible =3D "fsl,mpc8560-memory-controller", },=0A =A0=A0=A0 { .compatible =
=3D "fsl,mpc8568-memory-controller", },=0A =A0=A0=A0 { .compatible =3D "fsl=
,mpc8572-memory-controller", },=0A+=A0=A0=A0 { .compatible =3D "fsl,mpc8349=
-memory-controller", },=0A =A0=A0=A0 {},=0A };=0A =0A@@ -1001,13 +1005,13 @=
@ static struct of_platform_driver mpc85xx_mc_err_driver =3D {=0A =A0=A0=A0=
=A0=A0=A0 =A0=A0=A0},=0A };=0A =0A-=0A+#ifdef CONFIG_MPC85xx=0A static voi=
d __init mpc85xx_mc_clear_rfxe(void *data)=0A {=0A =A0=A0=A0 orig_hid1[smp_=
processor_id()] =3D mfspr(SPRN_HID1);=0A =A0=A0=A0 mtspr(SPRN_HID1, (orig_h=
id1[smp_processor_id()] & ~0x20000));=0A }=0A-=0A+#endif=0A =0A static int =
__init mpc85xx_mc_init(void)=0A {=0A@@ -1040,26 +1044,32 @@ static int __in=
it mpc85xx_mc_init(void)=0A =A0=A0=A0 =A0=A0=A0 printk(KERN_WARNING EDAC_MO=
D_STR "PCI fails to register\n");=0A #endif=0A =0A+#ifdef CONFIG_MPC85xx=0A=
=A0=A0=A0 /*=0A =A0=A0=A0=A0=A0* need to clear HID1[RFXE] to disable machi=
ne check int=0A =A0=A0=A0=A0=A0* so we can catch it=0A =A0=A0=A0=A0=A0*/=0A=
=A0=A0=A0 if (edac_op_state =3D=3D EDAC_OPSTATE_INT)=0A =A0=A0=A0 =A0=A0=
=A0 on_each_cpu(mpc85xx_mc_clear_rfxe, NULL, 0);=0A+#endif=0A =0A =A0=A0=A0=
return 0;=0A }=0A =0A module_init(mpc85xx_mc_init);=0A =0A+#ifdef CONFIG_M=
PC85xx=0A static void __exit mpc85xx_mc_restore_hid1(void *data)=0A {=0A =
=A0=A0=A0 mtspr(SPRN_HID1, orig_hid1[smp_processor_id()]);=0A }=0A+#endif=
=0A =0A static void __exit mpc85xx_mc_exit(void)=0A {=0A+#ifdef CONFIG_MPC8=
5xx=0A =A0=A0=A0 on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0);=0A+#endif=
=0A #ifdef CONFIG_PCI=0A =A0=A0=A0 of_unregister_platform_driver(&mpc85xx_p=
ci_err_driver);=0A #endif=0A-- =0A1.5.4.3=0A=0A=0A-------------------------=
-----------------------------------------------------=0AEnter the BlackBerr=
y Developer Challenge=A0 =0AThis is your chance to win up to $100,000 in pr=
izes! For a limited time, =0Avendors submitting new applications to BlackBe=
rry App World(TM) will have=0Athe opportunity to enter the BlackBerry Devel=
oper Challenge. See full prize=A0 =0Adetails at: http://p.sf.net/sfu/Challe=
nge=0A_______________________________________________=0Abluesmoke-devel mai=
ling list=0Abluesmoke-devel@lists.sourceforge.net=0Ahttps://lists.sourcefor=
ge.net/lists/listinfo/bluesmoke-devel=0A
^ permalink raw reply
* [PATCH 15/15] x86: remove unused swiotlb_phys_to_bus() and swiotlb_bus_to_phys()
From: FUJITA Tomonori @ 2009-07-10 1:05 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
phys_to_dma() and dma_to_phys() are used instead of
swiotlb_phys_to_bus() and swiotlb_bus_to_phys().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/kernel/pci-swiotlb.c | 10 ----------
1 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 165bd7f..e8a3501 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -13,16 +13,6 @@
int swiotlb __read_mostly;
-dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
-{
- return paddr;
-}
-
-phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
-{
- return baddr;
-}
-
static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags)
{
--
1.6.0.6
^ permalink raw reply related
* [PATCH 11/15] remove is_buffer_dma_capable()
From: FUJITA Tomonori @ 2009-07-10 1:05 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
is_buffer_dma_capable() was replaced with dma_capable().
is_buffer_dma_capable() tells if a buffer is dma-capable or
not. However, it doesn't take a pointer to struct device so it doesn't
work for POWERPC.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
include/linux/dma-mapping.h | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 07dfd46..c0f6c3c 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -98,11 +98,6 @@ static inline int is_device_dma_capable(struct device *dev)
return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
}
-static inline int is_buffer_dma_capable(u64 mask, dma_addr_t addr, size_t size)
-{
- return addr + size <= mask;
-}
-
#ifdef CONFIG_HAS_DMA
#include <asm/dma-mapping.h>
#else
--
1.6.0.6
^ permalink raw reply related
* [PATCH 14/15] powerpc: remove unused swiotlb_phys_to_bus() and swiotlb_bus_to_phys()
From: FUJITA Tomonori @ 2009-07-10 1:05 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
phys_to_dma() and dma_to_phys() are used instead of
swiotlb_phys_to_bus() and swiotlb_bus_to_phys().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/powerpc/kernel/dma-swiotlb.c | 11 -----------
1 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index a3bbe02..e8a57de 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -24,17 +24,6 @@
int swiotlb __read_mostly;
unsigned int ppc_swiotlb_enable;
-dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
-{
- return paddr + get_dma_direct_offset(hwdev);
-}
-
-phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
-
-{
- return baddr - get_dma_direct_offset(hwdev);
-}
-
/*
* Determine if an address is reachable by a pci device, or if we must bounce.
*/
--
1.6.0.6
^ permalink raw reply related
* [PATCH 07/15] ia64: add dma_capable() to replace is_buffer_dma_capable()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
dma_capable() eventually replaces is_buffer_dma_capable(), which tells
if a memory area is dma-capable or not. The problem of
is_buffer_dma_capable() is that it doesn't take a pointer to struct
device so it doesn't work for POWERPC.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/ia64/include/asm/dma-mapping.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 5a61b5c..88d0f86 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -69,6 +69,14 @@ dma_set_mask (struct device *dev, u64 mask)
return 0;
}
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+ if (!dev->dma_mask)
+ return 0;
+
+ return addr + size <= *dev->dma_mask;
+}
+
extern int dma_get_cache_alignment(void);
static inline void
--
1.6.0.6
^ permalink raw reply related
* [00/15] swiotlb cleanup
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
- removes unused (and unnecessary) hooks in swiotlb.
- adds dma_capable() and converts swiotlb to use it. It can be used to
know if a memory area is dma capable or not. I added
is_buffer_dma_capable() for the same purpose long ago but it turned
out that the function doesn't work on POWERPC.
This can be applied cleanly to linux-next, -mm, and mainline. This
patchset touches multiple architectures (ia64, powerpc, x86) so I
guess that -mm is appropriate for this patchset (I don't care much
what tree would merge this though).
This is tested on x86 but only compile tested on POWERPC and IA64.
Thanks,
=
arch/ia64/include/asm/dma-mapping.h | 18 ++++++
arch/powerpc/include/asm/dma-mapping.h | 23 +++++++
arch/powerpc/kernel/dma-swiotlb.c | 48 +---------------
arch/x86/include/asm/dma-mapping.h | 18 ++++++
arch/x86/kernel/pci-dma.c | 2 +-
arch/x86/kernel/pci-gart_64.c | 5 +-
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 25 --------
include/linux/dma-mapping.h | 5 --
include/linux/swiotlb.h | 11 ----
lib/swiotlb.c | 102 +++++++++-----------------------
11 files changed, 92 insertions(+), 167 deletions(-)
^ permalink raw reply
* [PATCH 05/15] x86: add dma_capable() to replace is_buffer_dma_capable()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
dma_capable() eventually replaces is_buffer_dma_capable(), which tells
if a memory area is dma-capable or not. The problem of
is_buffer_dma_capable() is that it doesn't take a pointer to struct
device so it doesn't work for POWERPC.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/include/asm/dma-mapping.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 1c3f943..adac59c 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -55,6 +55,14 @@ extern int dma_set_mask(struct device *dev, u64 mask);
extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_addr, gfp_t flag);
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+ if (!dev->dma_mask)
+ return 0;
+
+ return addr + size <= *dev->dma_mask;
+}
+
static inline void
dma_cache_sync(struct device *dev, void *vaddr, size_t size,
enum dma_data_direction dir)
--
1.6.0.6
^ permalink raw reply related
* [PATCH 08/15] powerpc: add dma_capable() to replace is_buffer_dma_capable()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
dma_capable() eventually replaces is_buffer_dma_capable(), which tells
if a memory area is dma-capable or not. The problem of
is_buffer_dma_capable() is that it doesn't take a pointer to struct
device so it doesn't work for POWERPC.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/powerpc/include/asm/dma-mapping.h | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index b44aaab..6ff1f85 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -424,6 +424,19 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
#endif
}
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+ struct dma_mapping_ops *ops = get_dma_ops(dev);
+
+ if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size))
+ return 0;
+
+ if (!dev->dma_mask)
+ return 0;
+
+ return addr + size <= *dev->dma_mask;
+}
+
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#ifdef CONFIG_NOT_COHERENT_CACHE
--
1.6.0.6
^ permalink raw reply related
* [PATCH 06/15] x86: replace is_buffer_dma_capable() with dma_capable
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/kernel/pci-dma.c | 2 +-
arch/x86/kernel/pci-gart_64.c | 5 ++---
arch/x86/kernel/pci-nommu.c | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 1a041bc..3c945c0 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -147,7 +147,7 @@ again:
return NULL;
addr = page_to_phys(page);
- if (!is_buffer_dma_capable(dma_mask, addr, size)) {
+ if (addr + size > dma_mask) {
__free_pages(page, get_order(size));
if (dma_mask < DMA_BIT_MASK(32) && !(flag & GFP_DMA)) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index d2e56b8..98a827e 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -190,14 +190,13 @@ static void iommu_full(struct device *dev, size_t size, int dir)
static inline int
need_iommu(struct device *dev, unsigned long addr, size_t size)
{
- return force_iommu ||
- !is_buffer_dma_capable(*dev->dma_mask, addr, size);
+ return force_iommu || !dma_capable(dev, addr, size);
}
static inline int
nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
{
- return !is_buffer_dma_capable(*dev->dma_mask, addr, size);
+ return !dma_capable(dev, addr, size);
}
/* Map a single continuous physical area into the IOMMU.
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 71d412a..c0a4222 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -14,7 +14,7 @@
static int
check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
{
- if (hwdev && !is_buffer_dma_capable(*hwdev->dma_mask, bus, size)) {
+ if (hwdev && !dma_capable(hwdev, bus, size)) {
if (*hwdev->dma_mask >= DMA_BIT_MASK(32))
printk(KERN_ERR
"nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
--
1.6.0.6
^ permalink raw reply related
* [PATCH 02/15] swiotlb: remove unused swiotlb_alloc()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
Nobody uses swiotlb_alloc().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/kernel/pci-swiotlb.c | 5 -----
include/linux/swiotlb.h | 2 --
lib/swiotlb.c | 8 ++------
3 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 0ac7cd5..ea675cf 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -13,11 +13,6 @@
int swiotlb __read_mostly;
-void *swiotlb_alloc(unsigned order, unsigned long nslabs)
-{
- return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
-}
-
dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
{
return paddr;
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 94db704..6bc5094 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -23,8 +23,6 @@ struct scatterlist;
extern void
swiotlb_init(void);
-extern void *swiotlb_alloc(unsigned order, unsigned long nslabs);
-
extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
phys_addr_t address);
extern phys_addr_t swiotlb_bus_to_phys(struct device *hwdev,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 9edfdd4..3c4c21c 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -114,11 +114,6 @@ setup_io_tlb_npages(char *str)
__setup("swiotlb=", setup_io_tlb_npages);
/* make io_tlb_overflow tunable too? */
-void * __weak swiotlb_alloc(unsigned order, unsigned long nslabs)
-{
- return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
-}
-
dma_addr_t __weak swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
{
return paddr;
@@ -240,7 +235,8 @@ swiotlb_late_init_with_default_size(size_t default_size)
bytes = io_tlb_nslabs << IO_TLB_SHIFT;
while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
- io_tlb_start = swiotlb_alloc(order, io_tlb_nslabs);
+ io_tlb_start = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
+ order);
if (io_tlb_start)
break;
order--;
--
1.6.0.6
^ permalink raw reply related
* [PATCH 01/15] swiotlb: remove unused swiotlb_alloc_boot()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
Nobody uses swiotlb_alloc_boot().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/kernel/pci-swiotlb.c | 5 -----
include/linux/swiotlb.h | 2 --
lib/swiotlb.c | 7 +------
3 files changed, 1 insertions(+), 13 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 6af96ee..0ac7cd5 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -13,11 +13,6 @@
int swiotlb __read_mostly;
-void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
-{
- return alloc_bootmem_low_pages(size);
-}
-
void *swiotlb_alloc(unsigned order, unsigned long nslabs)
{
return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index cb1a663..94db704 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -14,7 +14,6 @@ struct scatterlist;
*/
#define IO_TLB_SEGSIZE 128
-
/*
* log of the size of each IO TLB slab. The number of slabs is command line
* controllable.
@@ -24,7 +23,6 @@ struct scatterlist;
extern void
swiotlb_init(void);
-extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs);
extern void *swiotlb_alloc(unsigned order, unsigned long nslabs);
extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index bffe6d7..9edfdd4 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -114,11 +114,6 @@ setup_io_tlb_npages(char *str)
__setup("swiotlb=", setup_io_tlb_npages);
/* make io_tlb_overflow tunable too? */
-void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
-{
- return alloc_bootmem_low_pages(size);
-}
-
void * __weak swiotlb_alloc(unsigned order, unsigned long nslabs)
{
return (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
@@ -189,7 +184,7 @@ swiotlb_init_with_default_size(size_t default_size)
/*
* Get IO TLB memory from the low pages
*/
- io_tlb_start = swiotlb_alloc_boot(bytes, io_tlb_nslabs);
+ io_tlb_start = alloc_bootmem_low_pages(bytes);
if (!io_tlb_start)
panic("Cannot allocate SWIOTLB buffer");
io_tlb_end = io_tlb_start + bytes;
--
1.6.0.6
^ permalink raw reply related
* [PATCH 10/15] powerpc: remove unncesary swiotlb_arch_address_needs_mapping
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
swiotlb doesn't use swiotlb_arch_address_needs_mapping(); it uses
dma_capalbe(). We can remove unnecessary
swiotlb_arch_address_needs_mapping().
We can remove swiotlb_addr_needs_map() and is_buffer_dma_capable() in
swiotlb_pci_addr_needs_map() too; dma_capable() handles the features
that both provide.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/powerpc/kernel/dma-swiotlb.c | 27 +--------------------------
1 files changed, 1 insertions(+), 26 deletions(-)
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 41534ae..a3bbe02 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -36,28 +36,11 @@ phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
}
/*
- * Determine if an address needs bounce buffering via swiotlb.
- * Going forward I expect the swiotlb code to generalize on using
- * a dma_ops->addr_needs_map, and this function will move from here to the
- * generic swiotlb code.
- */
-int
-swiotlb_arch_address_needs_mapping(struct device *hwdev, dma_addr_t addr,
- size_t size)
-{
- struct dma_mapping_ops *dma_ops = get_dma_ops(hwdev);
-
- BUG_ON(!dma_ops);
- return dma_ops->addr_needs_map(hwdev, addr, size);
-}
-
-/*
* Determine if an address is reachable by a pci device, or if we must bounce.
*/
static int
swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
{
- u64 mask = dma_get_mask(hwdev);
dma_addr_t max;
struct pci_controller *hose;
struct pci_dev *pdev = to_pci_dev(hwdev);
@@ -69,16 +52,9 @@ swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
if ((addr + size > max) | (addr < hose->dma_window_base_cur))
return 1;
- return !is_buffer_dma_capable(mask, addr, size);
-}
-
-static int
-swiotlb_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
-{
- return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size);
+ return 0;
}
-
/*
* At the moment, all platforms that use this code only require
* swiotlb to be used if we're operating on HIGHMEM. Since
@@ -94,7 +70,6 @@ struct dma_mapping_ops swiotlb_dma_ops = {
.dma_supported = swiotlb_dma_supported,
.map_page = swiotlb_map_page,
.unmap_page = swiotlb_unmap_page,
- .addr_needs_map = swiotlb_addr_needs_map,
.sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
.sync_single_range_for_device = swiotlb_sync_single_range_for_device,
.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
--
1.6.0.6
^ permalink raw reply related
* [PATCH 12/15] x86, IA64, powerpc: add phys_to_dma() and dma_to_phys()
From: FUJITA Tomonori @ 2009-07-10 1:05 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
This adds two functions, phys_to_dma() and dma_to_phys() to x86, IA64
and powerpc. swiotlb uses them. phys_to_dma() converts a physical
address to a dma address. dma_to_phys() does the opposite.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/ia64/include/asm/dma-mapping.h | 10 ++++++++++
arch/powerpc/include/asm/dma-mapping.h | 10 ++++++++++
arch/x86/include/asm/dma-mapping.h | 10 ++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 88d0f86..f91829d 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -77,6 +77,16 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
return addr + size <= *dev->dma_mask;
}
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+ return paddr;
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+ return daddr;
+}
+
extern int dma_get_cache_alignment(void);
static inline void
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 6ff1f85..0c34371 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -437,6 +437,16 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
return addr + size <= *dev->dma_mask;
}
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+ return paddr + get_dma_direct_offset(dev);
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+ return daddr - get_dma_direct_offset(dev);
+}
+
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#ifdef CONFIG_NOT_COHERENT_CACHE
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index adac59c..0ee770d 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -63,6 +63,16 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
return addr + size <= *dev->dma_mask;
}
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+ return paddr;
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+ return daddr;
+}
+
static inline void
dma_cache_sync(struct device *dev, void *vaddr, size_t size,
enum dma_data_direction dir)
--
1.6.0.6
^ permalink raw reply related
* [PATCH 09/15] swiotlb: use dma_capable()
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
This converts swiotlb to use dma_capable() instead of
swiotlb_arch_address_needs_mapping() and is_buffer_dma_capable().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
lib/swiotlb.c | 24 +++++-------------------
1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 1a89c84..a0faeb0 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -130,12 +130,6 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
return swiotlb_phys_to_bus(hwdev, virt_to_phys(address));
}
-int __weak swiotlb_arch_address_needs_mapping(struct device *hwdev,
- dma_addr_t addr, size_t size)
-{
- return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size);
-}
-
static void swiotlb_print_info(unsigned long bytes)
{
phys_addr_t pstart, pend;
@@ -296,12 +290,6 @@ cleanup1:
return -ENOMEM;
}
-static inline int
-address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size)
-{
- return swiotlb_arch_address_needs_mapping(hwdev, addr, size);
-}
-
static int is_swiotlb_buffer(phys_addr_t paddr)
{
return paddr >= virt_to_phys(io_tlb_start) &&
@@ -538,9 +526,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_mask = hwdev->coherent_dma_mask;
ret = (void *)__get_free_pages(flags, order);
- if (ret &&
- !is_buffer_dma_capable(dma_mask, swiotlb_virt_to_bus(hwdev, ret),
- size)) {
+ if (ret && swiotlb_virt_to_bus(hwdev, ret) + size > dma_mask) {
/*
* The allocated memory isn't reachable by the device.
*/
@@ -562,7 +548,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dev_addr = swiotlb_virt_to_bus(hwdev, ret);
/* Confirm address can be DMA'd by device */
- if (!is_buffer_dma_capable(dma_mask, dev_addr, size)) {
+ if (dev_addr + size > dma_mask) {
printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n",
(unsigned long long)dma_mask,
(unsigned long long)dev_addr);
@@ -634,7 +620,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
* we can safely return the device addr and not worry about bounce
* buffering it.
*/
- if (!address_needs_mapping(dev, dev_addr, size) && !swiotlb_force)
+ if (dma_capable(dev, dev_addr, size) && !swiotlb_force)
return dev_addr;
/*
@@ -651,7 +637,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
/*
* Ensure that the address returned is DMA'ble
*/
- if (address_needs_mapping(dev, dev_addr, size))
+ if (!dma_capable(dev, dev_addr, size))
panic("map_single: bounce buffer is not DMA'ble");
return dev_addr;
@@ -798,7 +784,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
dma_addr_t dev_addr = swiotlb_phys_to_bus(hwdev, paddr);
if (swiotlb_force ||
- address_needs_mapping(hwdev, dev_addr, sg->length)) {
+ !dma_capable(hwdev, dev_addr, sg->length)) {
void *map = map_single(hwdev, sg_phys(sg),
sg->length, dir);
if (!map) {
--
1.6.0.6
^ permalink raw reply related
* [PATCH 03/15] swiotlb: remove swiotlb_arch_range_needs_mapping
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
Nobody uses swiotlb_arch_range_needs_mapping().
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/kernel/pci-swiotlb.c | 5 -----
include/linux/swiotlb.h | 2 --
lib/swiotlb.c | 15 ++-------------
3 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index ea675cf..165bd7f 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -23,11 +23,6 @@ phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
return baddr;
}
-int __weak swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
-{
- return 0;
-}
-
static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags)
{
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 6bc5094..a977da2 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -28,8 +28,6 @@ extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
extern phys_addr_t swiotlb_bus_to_phys(struct device *hwdev,
dma_addr_t address);
-extern int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size);
-
extern void
*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 3c4c21c..dc1cd1f 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -141,11 +141,6 @@ int __weak swiotlb_arch_address_needs_mapping(struct device *hwdev,
return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size);
}
-int __weak swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
-{
- return 0;
-}
-
static void swiotlb_print_info(unsigned long bytes)
{
phys_addr_t pstart, pend;
@@ -312,11 +307,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size)
return swiotlb_arch_address_needs_mapping(hwdev, addr, size);
}
-static inline int range_needs_mapping(phys_addr_t paddr, size_t size)
-{
- return swiotlb_force || swiotlb_arch_range_needs_mapping(paddr, size);
-}
-
static int is_swiotlb_buffer(char *addr)
{
return addr >= io_tlb_start && addr < io_tlb_end;
@@ -646,8 +636,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
* we can safely return the device addr and not worry about bounce
* buffering it.
*/
- if (!address_needs_mapping(dev, dev_addr, size) &&
- !range_needs_mapping(phys, size))
+ if (!address_needs_mapping(dev, dev_addr, size) && !swiotlb_force)
return dev_addr;
/*
@@ -810,7 +799,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
phys_addr_t paddr = sg_phys(sg);
dma_addr_t dev_addr = swiotlb_phys_to_bus(hwdev, paddr);
- if (range_needs_mapping(paddr, sg->length) ||
+ if (swiotlb_force ||
address_needs_mapping(hwdev, dev_addr, sg->length)) {
void *map = map_single(hwdev, sg_phys(sg),
sg->length, dir);
--
1.6.0.6
^ permalink raw reply related
* [PATCH 13/15] swiotlb: use phys_to_dma and dma_to_phys
From: FUJITA Tomonori @ 2009-07-10 1:05 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
This converts swiotlb to use phys_to_dma and dma_to_phys instead of
swiotlb_phys_to_bus() and swiotlb_bus_to_phys().
swiotlb_phys_to_bus() and swiotlb_bus_to_phys() are not necessary so
this patch also removes them.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
include/linux/swiotlb.h | 5 -----
lib/swiotlb.c | 22 ++++++----------------
2 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index a977da2..73b1f1c 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -23,11 +23,6 @@ struct scatterlist;
extern void
swiotlb_init(void);
-extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev,
- phys_addr_t address);
-extern phys_addr_t swiotlb_bus_to_phys(struct device *hwdev,
- dma_addr_t address);
-
extern void
*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a0faeb0..de71dba 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -114,20 +114,10 @@ setup_io_tlb_npages(char *str)
__setup("swiotlb=", setup_io_tlb_npages);
/* make io_tlb_overflow tunable too? */
-dma_addr_t __weak swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
-{
- return paddr;
-}
-
-phys_addr_t __weak swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr)
-{
- return baddr;
-}
-
static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
volatile void *address)
{
- return swiotlb_phys_to_bus(hwdev, virt_to_phys(address));
+ return phys_to_dma(hwdev, virt_to_phys(address));
}
static void swiotlb_print_info(unsigned long bytes)
@@ -566,7 +556,7 @@ void
swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
dma_addr_t dev_addr)
{
- phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
+ phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
WARN_ON(irqs_disabled());
if (!is_swiotlb_buffer(paddr))
@@ -611,7 +601,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
struct dma_attrs *attrs)
{
phys_addr_t phys = page_to_phys(page) + offset;
- dma_addr_t dev_addr = swiotlb_phys_to_bus(dev, phys);
+ dma_addr_t dev_addr = phys_to_dma(dev, phys);
void *map;
BUG_ON(dir == DMA_NONE);
@@ -655,7 +645,7 @@ EXPORT_SYMBOL_GPL(swiotlb_map_page);
static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
size_t size, int dir)
{
- phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
+ phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
BUG_ON(dir == DMA_NONE);
@@ -692,7 +682,7 @@ static void
swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
size_t size, int dir, int target)
{
- phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
+ phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
BUG_ON(dir == DMA_NONE);
@@ -781,7 +771,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
for_each_sg(sgl, sg, nelems, i) {
phys_addr_t paddr = sg_phys(sg);
- dma_addr_t dev_addr = swiotlb_phys_to_bus(hwdev, paddr);
+ dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
if (swiotlb_force ||
!dma_capable(hwdev, dev_addr, sg->length)) {
--
1.6.0.6
^ permalink raw reply related
* [PATCH 04/15] swiotlb: remove unnecessary swiotlb_bus_to_virt
From: FUJITA Tomonori @ 2009-07-10 1:04 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64, x86, fujita.tomonori, linuxppc-dev
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
swiotlb_bus_to_virt is unncessary; we can use swiotlb_bus_to_phys and
phys_to_virt instead.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/powerpc/kernel/dma-swiotlb.c | 10 ----------
lib/swiotlb.c | 34 ++++++++++++++++------------------
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 68ccf11..41534ae 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -24,16 +24,6 @@
int swiotlb __read_mostly;
unsigned int ppc_swiotlb_enable;
-void *swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t addr)
-{
- unsigned long pfn = PFN_DOWN(swiotlb_bus_to_phys(hwdev, addr));
- void *pageaddr = page_address(pfn_to_page(pfn));
-
- if (pageaddr != NULL)
- return pageaddr + (addr % PAGE_SIZE);
- return NULL;
-}
-
dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
{
return paddr + get_dma_direct_offset(hwdev);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index dc1cd1f..1a89c84 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -130,11 +130,6 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
return swiotlb_phys_to_bus(hwdev, virt_to_phys(address));
}
-void * __weak swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
-{
- return phys_to_virt(swiotlb_bus_to_phys(hwdev, address));
-}
-
int __weak swiotlb_arch_address_needs_mapping(struct device *hwdev,
dma_addr_t addr, size_t size)
{
@@ -307,9 +302,10 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size)
return swiotlb_arch_address_needs_mapping(hwdev, addr, size);
}
-static int is_swiotlb_buffer(char *addr)
+static int is_swiotlb_buffer(phys_addr_t paddr)
{
- return addr >= io_tlb_start && addr < io_tlb_end;
+ return paddr >= virt_to_phys(io_tlb_start) &&
+ paddr < virt_to_phys(io_tlb_end);
}
/*
@@ -582,11 +578,13 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
void
swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
- dma_addr_t dma_handle)
+ dma_addr_t dev_addr)
{
+ phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
+
WARN_ON(irqs_disabled());
- if (!is_swiotlb_buffer(vaddr))
- free_pages((unsigned long) vaddr, get_order(size));
+ if (!is_swiotlb_buffer(paddr))
+ free_pages((unsigned long)vaddr, get_order(size));
else
/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
do_unmap_single(hwdev, vaddr, size, DMA_TO_DEVICE);
@@ -671,19 +669,19 @@ EXPORT_SYMBOL_GPL(swiotlb_map_page);
static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
size_t size, int dir)
{
- char *dma_addr = swiotlb_bus_to_virt(hwdev, dev_addr);
+ phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
BUG_ON(dir == DMA_NONE);
- if (is_swiotlb_buffer(dma_addr)) {
- do_unmap_single(hwdev, dma_addr, size, dir);
+ if (is_swiotlb_buffer(paddr)) {
+ do_unmap_single(hwdev, phys_to_virt(paddr), size, dir);
return;
}
if (dir != DMA_FROM_DEVICE)
return;
- dma_mark_clean(dma_addr, size);
+ dma_mark_clean(phys_to_virt(paddr), size);
}
void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
@@ -708,19 +706,19 @@ static void
swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
size_t size, int dir, int target)
{
- char *dma_addr = swiotlb_bus_to_virt(hwdev, dev_addr);
+ phys_addr_t paddr = swiotlb_bus_to_phys(hwdev, dev_addr);
BUG_ON(dir == DMA_NONE);
- if (is_swiotlb_buffer(dma_addr)) {
- sync_single(hwdev, dma_addr, size, dir, target);
+ if (is_swiotlb_buffer(paddr)) {
+ sync_single(hwdev, phys_to_virt(paddr), size, dir, target);
return;
}
if (dir != DMA_FROM_DEVICE)
return;
- dma_mark_clean(dma_addr, size);
+ dma_mark_clean(phys_to_virt(paddr), size);
}
void
--
1.6.0.6
^ permalink raw reply related
* removing addr_needs_map in struct dma_mapping_ops
From: FUJITA Tomonori @ 2009-07-10 1:47 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-kernel
I'm trying to convert POWERPC to use asm-generic/dma-mapping-common.h.
POWERPC needs addr_needs_map() in struct dma_mapping_ops for SWIOTLB
support but I want to avoid add addr_needs_map() in struct
dma_map_ops. IIRC, you guys think it as a temporary solution and
talked about defining something like struct dma_data. Then we could
struct dev_archdata {
...
struct dma_data *ddata;
};
or
struct dev_archdata {
...
struct dma_data ddata;
};
struct dma_data needs dma_direct_offset, iommu_table, dma_base, and
dma_window_size, anything else?
Is it acceptable?
^ permalink raw reply
* Re: binutils 2.19 issue with kernel link
From: Alan Modra @ 2009-07-10 4:11 UTC (permalink / raw)
To: Edmar Wienskoski-RA8797
Cc: Scott Wood, linuxppc-dev@ozlabs.org list, bug-binutils
In-Reply-To: <4A5645A9.3080003@freescale.com>
On Thu, Jul 09, 2009 at 02:31:53PM -0500, Edmar Wienskoski-RA8797 wrote:
> Kumar Gala wrote:
>>
>> On Jul 8, 2009, at 11:40 PM, Alan Modra wrote:
>>
>>> On Wed, Jul 08, 2009 at 10:52:59PM -0500, Kumar Gala wrote:
>>>> To further verify this if I switch the -me500 to -mspe and build things
>>>> seem to be ok. This further points at some APU section related bug.
>>>
>>> Like omitting .PPC.EMB.apuinfo from your kernel link script? See the
>>> ld info doc on orphan sections.
>>
>> Ok, not terribly enlightening, but why would .PPC.EMB.apuinfo sections
>> be different than something like .debug sections which we also dont
>> list in the linker script.
Because .PPC.EMB.apuinfo is a note section rather than a debugging
section. Orphan non-alloc note sections will be placed before
.comment or debug sections while orphan debug sections go right to the
end. Now, I'll bet you don't have .comment in your script so it too
is an orphan.
> I understand your arguments, but there is something inconsistent about this.
> If I change the script to be:
> _end3 = . ;
> . = _end3;
> . = ALIGN(PAGE_SIZE);
> _end = . ;
> PROVIDE32 (end = .);
> }
> The result is corrected:
> c067f678 A _end3
> c0680000 A _end
>
> Why the apuinfo section with zero VMA sometimes interfere with "." and
> sometimes not ?
That is weird. You'll need to run ld under gdb to find out. I'd
expect the orphan apuinfo section to be placed before the first
assignment to dot in both cases, or at the end of the script in both
cases, with placement depending on whether you hit an orphan .comment
or debug section before the orphan .PPC.EMB.apuinfo.
The underlying reason is that if you provide a link script that
doesn't mention a section, then ld is free to place that section
anywhere. Quoting from the ld info doc:
"Orphan sections are sections present in the input files which are not
explicitly placed into the output file by the linker script. The
linker will still copy these sections into the output file, but it has
to guess as to where they should be placed. The linker uses a simple
heuristic to do this. It attempts to place orphan sections after
non-orphan sections of the same attribute, such as code vs data,
loadable vs non-loadable, etc. If there is not enough room to do this
then it places at the end of the file.
For ELF targets, the attribute of the section includes section type as
well as section flag."
That's all as expected, and in your case you don't have a section with
the same attribute as .PPC.EMB.apuinfo so it should go to the end.
However, you have multiple orphan sections being added. After the
first of these is added, you have sections after your end symbol
assignments, and when there are assignments it gets tricky. The
relevant part of the ld info doc says:
"Setting symbols to the value of the location counter outside of an
output section statement can result in unexpected values if the linker
needs to place orphan sections. For example, given the following:
SECTIONS
{
start_of_text = . ;
.text: { *(.text) }
end_of_text = . ;
start_of_data = . ;
.data: { *(.data) }
end_of_data = . ;
}
If the linker needs to place some input section, e.g. .rodata, not
mentioned in the script, it might choose to place that section between
.text and .data. You might think the linker should place .rodata on
the blank line in the above script, but blank lines are of no
particular significance to the linker. As well, the linker doesn't
associate the above symbol names with their sections. Instead, it
assumes that all assignments or other statements belong to the
previous output section, except for the special case of an assignment
to '.'. I.e., the linker will place the orphan .rodata section as if
the script was written as follows:
SECTIONS
{
start_of_text = . ;
.text: { *(.text) }
end_of_text = . ;
start_of_data = . ;
.rodata: { *(.rodata) }
.data: { *(.data) }
end_of_data = . ;
}
This may or may not be the script author's intention for the value of
start_of_data. One way to influence the orphan section placement is
to assign the location counter to itself, as the linker assumes that
an assignment to '.' is setting the start address of a following
output section and thus should be grouped with that section. So you
could write:
SECTIONS
{
start_of_text = . ;
.text: { *(.text) }
end_of_text = . ;
. = . ;
start_of_data = . ;
.data: { *(.data) }
end_of_data = . ;
}
Now, the orphan .rodata section will be placed between end_of_text and
start_of_data."
Putting this all together:
a) ld places .comment or some debug section at end
b) ld places .PPC.EMB.apuinfo before the other orphan section, and
thinks your assignments to dot belong with the other orphan, so
.PPC.EMB.apuinfo goes before them.
As no doubt you've already found, you can fix your link script by not
using ". = ALIGN(PAGE_SIZE)"; instead use "sym = ALIGN(PAGE_SIZE)".
Hmm, having said all that, the following linker patch seems reasonable
to me and probably won't break anything else (always some risk).
Please test it for me.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.311
diff -u -p -r1.311 ldlang.c
--- ld/ldlang.c 25 Jun 2009 13:18:46 -0000 1.311
+++ ld/ldlang.c 10 Jul 2009 04:04:57 -0000
@@ -1615,10 +1615,12 @@ output_prev_sec_find (lang_output_sectio
idea is to skip over anything that might be inside a SECTIONS {}
statement in a script, before we find another output section
statement. Assignments to "dot" before an output section statement
- are assumed to belong to it. An exception to this rule is made for
- the first assignment to dot, otherwise we might put an orphan
- before . = . + SIZEOF_HEADERS or similar assignments that set the
- initial address. */
+ are assumed to belong to it, except in two cases; The first
+ assignment to dot, and assignments before non-alloc sections.
+ Otherwise we might put an orphan before . = . + SIZEOF_HEADERS or
+ similar assignments that set the initial address, or we might
+ insert non-alloc note sections among assignments setting end of
+ image symbols. */
static lang_statement_union_type **
insert_os_after (lang_output_section_statement_type *after)
@@ -1662,7 +1664,12 @@ insert_os_after (lang_output_section_sta
continue;
case lang_output_section_statement_enum:
if (assign != NULL)
- where = assign;
+ {
+ asection *s = (*where)->output_section_statement.bfd_section;
+
+ if (s == NULL || (s->flags & SEC_ALLOC) != 0)
+ where = assign;
+ }
break;
case lang_input_statement_enum:
case lang_address_statement_enum:
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply
* Re: binutils 2.19 issue with kernel link
From: Alan Modra @ 2009-07-10 4:15 UTC (permalink / raw)
To: Edmar Wienskoski-RA8797
Cc: Scott Wood, linuxppc-dev@ozlabs.org list, bug-binutils
In-Reply-To: <4A5645A9.3080003@freescale.com>
On Thu, Jul 09, 2009 at 02:31:53PM -0500, Edmar Wienskoski-RA8797 wrote:
> I understand your arguments, but there is something inconsistent about this.
> If I change the script to be:
> _end3 = . ;
> . = _end3;
> . = ALIGN(PAGE_SIZE);
> _end = . ;
> PROVIDE32 (end = .);
> }
> The result is corrected:
> c067f678 A _end3
> c0680000 A _end
>
> Why the apuinfo section with zero VMA sometimes interfere with "." and
> sometimes not ?
I said it was weird in my last email. Not so. The orphan gets placed
between
_end3 = . ;
. = _end3;
So dot is restored after the orphan section sets it.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply
* Re: [00/15] swiotlb cleanup
From: Ingo Molnar @ 2009-07-10 5:12 UTC (permalink / raw)
To: FUJITA Tomonori, Ian Campbell, Jeremy Fitzhardinge
Cc: tony.luck, linux-ia64, x86, linux-kernel, linuxppc-dev,
Joerg Roedel
In-Reply-To: <1247187904-31999-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
* FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> - removes unused (and unnecessary) hooks in swiotlb.
>
> - adds dma_capable() and converts swiotlb to use it. It can be used to
> know if a memory area is dma capable or not. I added
> is_buffer_dma_capable() for the same purpose long ago but it turned
> out that the function doesn't work on POWERPC.
>
> This can be applied cleanly to linux-next, -mm, and mainline. This
> patchset touches multiple architectures (ia64, powerpc, x86) so I
> guess that -mm is appropriate for this patchset (I don't care much
> what tree would merge this though).
>
> This is tested on x86 but only compile tested on POWERPC and IA64.
>
> Thanks,
>
> =
> arch/ia64/include/asm/dma-mapping.h | 18 ++++++
> arch/powerpc/include/asm/dma-mapping.h | 23 +++++++
> arch/powerpc/kernel/dma-swiotlb.c | 48 +---------------
> arch/x86/include/asm/dma-mapping.h | 18 ++++++
> arch/x86/kernel/pci-dma.c | 2 +-
> arch/x86/kernel/pci-gart_64.c | 5 +-
> arch/x86/kernel/pci-nommu.c | 2 +-
> arch/x86/kernel/pci-swiotlb.c | 25 --------
> include/linux/dma-mapping.h | 5 --
> include/linux/swiotlb.h | 11 ----
> lib/swiotlb.c | 102 +++++++++-----------------------
> 11 files changed, 92 insertions(+), 167 deletions(-)
Hm, the functions and facilities you remove here were added as part
of preparatory patches for Xen guest support. You were aware of
them, you were involved in discussions about those aspects with Ian
and Jeremy but still you chose not to Cc: either of them and you
failed to address that aspect in the changelogs.
I'd like the Xen code to become cleaner more than anyone else here i
guess, but patch submission methods like this are not really
helpful. A far better method is to be open about such disagreements,
to declare them, to Cc: everyone who disagrees, and to line out the
arguments in the changelogs as well - instead of just curtly
declaring those APIs 'unused' and failing to Cc: involved parties.
Alas, on the technical level the cleanups themselves look mostly
fine to me. Ian, Jeremy, the changes will alter Xen's use of
swiotlb, but can the Xen side still live with these new methods - in
particular is dma_capable() sufficient as a mechanism and can the
Xen side filter out DMA allocations to make them physically
continuous?
Ben, Tony, Becky, any objections wrt. the PowerPC / IA64 impact? If
everyone agrees i can apply them to the IOMMU tree, test it and push
it out to -next, etc.
Ingo
^ permalink raw reply
* Re: [00/15] swiotlb cleanup
From: FUJITA Tomonori @ 2009-07-10 5:35 UTC (permalink / raw)
To: mingo
Cc: jeremy, tony.luck, linux-ia64, Ian.Campbell, x86, linux-kernel,
fujita.tomonori, linuxppc-dev, joerg.roedel
In-Reply-To: <20090710051236.GA22218@elte.hu>
On Fri, 10 Jul 2009 07:12:36 +0200
Ingo Molnar <mingo@elte.hu> wrote:
>
> * FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
>
> > - removes unused (and unnecessary) hooks in swiotlb.
> >
> > - adds dma_capable() and converts swiotlb to use it. It can be used to
> > know if a memory area is dma capable or not. I added
> > is_buffer_dma_capable() for the same purpose long ago but it turned
> > out that the function doesn't work on POWERPC.
> >
> > This can be applied cleanly to linux-next, -mm, and mainline. This
> > patchset touches multiple architectures (ia64, powerpc, x86) so I
> > guess that -mm is appropriate for this patchset (I don't care much
> > what tree would merge this though).
> >
> > This is tested on x86 but only compile tested on POWERPC and IA64.
> >
> > Thanks,
> >
> > =
> > arch/ia64/include/asm/dma-mapping.h | 18 ++++++
> > arch/powerpc/include/asm/dma-mapping.h | 23 +++++++
> > arch/powerpc/kernel/dma-swiotlb.c | 48 +---------------
> > arch/x86/include/asm/dma-mapping.h | 18 ++++++
> > arch/x86/kernel/pci-dma.c | 2 +-
> > arch/x86/kernel/pci-gart_64.c | 5 +-
> > arch/x86/kernel/pci-nommu.c | 2 +-
> > arch/x86/kernel/pci-swiotlb.c | 25 --------
> > include/linux/dma-mapping.h | 5 --
> > include/linux/swiotlb.h | 11 ----
> > lib/swiotlb.c | 102 +++++++++-----------------------
> > 11 files changed, 92 insertions(+), 167 deletions(-)
>
> Hm, the functions and facilities you remove here were added as part
> of preparatory patches for Xen guest support. You were aware of
> them, you were involved in discussions about those aspects with Ian
> and Jeremy but still you chose not to Cc: either of them and you
> failed to address that aspect in the changelogs.
>
> I'd like the Xen code to become cleaner more than anyone else here i
> guess, but patch submission methods like this are not really
> helpful. A far better method is to be open about such disagreements,
> to declare them, to Cc: everyone who disagrees, and to line out the
> arguments in the changelogs as well - instead of just curtly
> declaring those APIs 'unused' and failing to Cc: involved parties.
>
> Alas, on the technical level the cleanups themselves look mostly
> fine to me. Ian, Jeremy, the changes will alter Xen's use of
> swiotlb, but can the Xen side still live with these new methods - in
> particular is dma_capable() sufficient as a mechanism and can the
> Xen side filter out DMA allocations to make them physically
> continuous?
dma_capable() doesn't work for Xen in the way that Ian hopes.
As I said to him again and again, he tries to use arch code in the
very original way, and it's unacceptable (of course, he disagreed with
it).
I don't think that we need to take account of dom0 support; we don't
have a clear idea about an acceptable dom0 design (it needs to use
swiotlb code? I don't know yet), we don't even know we will have dom0
support in mainline. That's why I didn't CC this patchset to Xen
camp.
I think that it's more reasonable to think about how the code can
works for dom0 support when Xen people come with the new dom0 code.
> Ben, Tony, Becky, any objections wrt. the PowerPC / IA64 impact? If
> everyone agrees i can apply them to the IOMMU tree, test it and push
> it out to -next, etc.
>
> Ingo
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox