ARM: Qualify enabling of swiotlb_init()
PATCH 1/1 ARM: Qualify enabling of swiotlb_init()
We do not need a SWIOTLB unless we have DRAM that is addressable beyond the arm_dma_limit. Compare max_pfn with arm_dma_pfn_limit to determine whether we do need a SWIOTLB to be initialized.
--- arch/arm/mm/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mm/init.c +5 -1
@@ -301,7 +301,11 @@ static void __init free_highpages(void)void __init mem_init (void ) {#ifdef CONFIG_ARM_LPAE -swiotlb_init (1 ); +if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit) +swiotlb_init (1 ); +else + swiotlb_force =SWIOTLB_NO_FORCE ;#endif set_max_mapnr (pfn_to_page (max_pfn) - mem_map);
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
arch/arm/mm/init.c static void __init free_highpages(void) · line 305
Quoted 3 lines · Florian Fainelli
#ifdef
CONFIG_ARM_LPAEarch/arm/mm/init.c +2
-0+if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit)
Does arm_dma_pfn_limit do the right thing even with the weirdest remapping ranges? Maybe a commen here would be useful.
arch/arm/mm/init.c static void __init free_highpages(void) · line 308
Quoted 3 lines
arch/arm/mm/init.c +3
-0+swiotlb_init (1 ); + else + swiotlb_force =SWIOTLB_NO_FORCE ;
Konrad: what do you think of setting swiotlb_force to SWIOTLB_NO_FORCE and only switching it to SWIOTLB_NORMAL when swiotlb_init* is called? That kind makes more sense than forcing the callers to do it.
While we're at it, I think swiotlb_force should probably be renamed to swiotlb_mode or somethng like that.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 7 lines · Christoph Hellwig
arch/arm/mm/init.c static void __init free_highpages(void) · line 305
Quoted 3 lines · Florian Fainelli
#ifdef
CONFIG_ARM_LPAEarch/arm/mm/init.c +2
-0+if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit)Does
arm_dma_pfn_limitdo the right thing even with the weirdest remapping ranges? Maybe a commen here would be useful.
It gets assigned to either 0xffffffff or PHYS_OFFSET + arm_dma_zone_size
- 1 which is obtained from the machine descriptor, so I expect it to do the right thing, it works for a Pi 4 in 32-bit mode for instance. This is conditional upon enabling CONFIG_ZONE_DMA for ARM, and will otherwise keep its original value of 0, so this should be safe AFAICT.
Quoted 11 lines
arch/arm/mm/init.c static void __init free_highpages(void) · line 308
Quoted 4 lines
arch/arm/mm/init.c +3
-0+swiotlb_init (1 ); + else + swiotlb_force =SWIOTLB_NO_FORCE ;Konrad: what do you think of setting
swiotlb_forcetoSWIOTLB_NO_FORCEand only switching it toSWIOTLB_NORMALwhen swiotlb_init* is called? That kind makes more sense than forcing the callers to do it.While we're at it, I think
swiotlb_forceshould probably be renamed toswiotlb_modeor somethng like that.
Agreed.
Signature · 5 lines
Florian _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 16 lines · Christoph Hellwig
arch/arm/mm/init.c static void __init free_highpages(void) · line 305
Quoted 3 lines · Florian Fainelli
#ifdef
CONFIG_ARM_LPAEarch/arm/mm/init.c +2
-0+if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit)Does
arm_dma_pfn_limitdo the right thing even with the weirdest remapping ranges? Maybe a commen here would be useful.arch/arm/mm/init.c static void __init free_highpages(void) · line 308
Quoted 3 lines
arch/arm/mm/init.c +3
-0+swiotlb_init (1 ); + else + swiotlb_force =SWIOTLB_NO_FORCE ;Konrad: what do you think of setting
swiotlb_forcetoSWIOTLB_NO_FORCEand only switching it toSWIOTLB_NORMALwhen swiotlb_init* is called? That kind makes more sense than forcing the callers to do it.
Quoted 2 lines
While we're at it, I think
swiotlb_forceshould probably be renamed toswiotlb_modeor somethng like that.
swiotlb_mode sounds good.
Also it got me thinking - ARM on Xen at some point was a bit strange, so not sure how the logic works here, Stefano?
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 16 lines · Christoph Hellwig
arch/arm/mm/init.c static void __init free_highpages(void) · line 305
Quoted 3 lines · Florian Fainelli
#ifdef
CONFIG_ARM_LPAEarch/arm/mm/init.c +2
-0+if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit)Does
arm_dma_pfn_limitdo the right thing even with the weirdest remapping ranges? Maybe a commen here would be useful.arch/arm/mm/init.c static void __init free_highpages(void) · line 308
Quoted 3 lines
arch/arm/mm/init.c +3
-0+swiotlb_init (1 ); + else + swiotlb_force =SWIOTLB_NO_FORCE ;Konrad: what do you think of setting
swiotlb_forcetoSWIOTLB_NO_FORCEand only switching it toSWIOTLB_NORMALwhen swiotlb_init* is called? That kind makes more sense than forcing the callers to do it.
Quoted 7 lines
Quoted 2 lines
While we're at it, I think
swiotlb_forceshould probably be renamed toswiotlb_modeor somethng like that.
swiotlb_modesounds good.Also it got me thinking - ARM on Xen at some point was a bit strange, so not sure how the logic works here, Stefano?
There is nothing strange in regards to swiotlb_force. swiotlb_force is only used in swiotlb-xen map_page to figure out whether:
- we actually have to use the swiotlb bounce buffer (this is the swiotlb_xen == SWIOTLB_FORCE case)
- or we can use the provided page directly for dma if other conditions are met (dma_capable, !range_straddles_page_boundary, ...)
I don't think that switching to "swiotlb_mode" would cause any issues.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 29 lines · Stefano Stabellini
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 16 lines · Christoph Hellwig
arch/arm/mm/init.c static void __init free_highpages(void) · line 305
Quoted 3 lines · Florian Fainelli
#ifdef
CONFIG_ARM_LPAEarch/arm/mm/init.c +2
-0+if (swiotlb_force ==SWIOTLB_FORCE || + max_pfn > arm_dma_pfn_limit)Does
arm_dma_pfn_limitdo the right thing even with the weirdest remapping ranges? Maybe a commen here would be useful.arch/arm/mm/init.c static void __init free_highpages(void) · line 308
Quoted 3 lines
arch/arm/mm/init.c +3
-0+swiotlb_init (1 ); + else + swiotlb_force =SWIOTLB_NO_FORCE ;Konrad: what do you think of setting
swiotlb_forcetoSWIOTLB_NO_FORCEand only switching it toSWIOTLB_NORMALwhen swiotlb_init* is called? That kind makes more sense than forcing the callers to do it.Quoted 7 lines
Quoted 2 lines
While we're at it, I think
swiotlb_forceshould probably be renamed toswiotlb_modeor somethng like that.
swiotlb_modesounds good.Also it got me thinking - ARM on Xen at some point was a bit strange, so not sure how the logic works here, Stefano?
There is nothing strange in regards to
swiotlb_force.swiotlb_forceis only used in swiotlb-xenmap_pageto figure out whether:
Quoted 8 lines
- we actually have to use the swiotlb bounce buffer (this is the
swiotlb_xen==SWIOTLB_FORCEcase)
- or we can use the provided page directly for dma if other conditions are met (dma_capable, !range_straddles_page_boundary, ...)I don't think that switching to "
swiotlb_mode" would cause any issues.
Should I toss this in Russell's patch tracker or do you need me to make some changes to the patch?
Signature · 5 lines
Florian _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 2 lines · Florian Fainelli
Should I toss this in Russell's patch tracker or do you need me to make some changes to the patch?
Due to all the other changes in this area I don't think anything but the swiotlb tree makes much sense here.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Florian Fainelli
Should I toss this in Russell's patch tracker or do you need me to make some changes to the patch?
Due to all the other changes in this area I don't think anything but the swiotlb tree makes much sense here.
I've put them all on
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git
devel/for-linus-5.13
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · Florian Fainelli
Should I toss this in Russell's patch tracker or do you need me to make some changes to the patch?
Quoted 7 lines
Quoted 2 lines
Due to all the other changes in this area I don't think anything but the swiotlb tree makes much sense here.
I've put them all on
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git
devel/for-linus-5.13
Thanks! Did you also want to queue up this one:
https://lore.kernel.org/lkml/[email protected]/
Signature · 5 lines
Florian _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu