* [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table
@ 2015-07-20 10:45 Alexey Kardashevskiy
2015-07-21 5:11 ` David Gibson
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2015-07-20 10:45 UTC (permalink / raw)
To: linuxppc-dev
Cc: Alexey Kardashevskiy, David Gibson, Michael Ellerman,
Paul Mackerras, linux-kernel
The existing code stores the amount of memory allocated for a TCE table.
At the moment it uses @offset which is a virtual offset in the TCE table
which is only correct for a one level tables and it does not include
memory allocated for intermediate levels. When multilevel TCE table is
requested, WARN_ON in tce_iommu_create_table() prints a warning.
This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages()
to count actually allocated memory.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
I was sure I sent it already but could not find it anywhere so reposting.
Sorry if it is a duplicate.
---
arch/powerpc/platforms/powernv/pci-ioda.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 5738d31..85cbc96 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2220,7 +2220,7 @@ static void pnv_pci_ioda_setup_opal_tce_kill(struct pnv_phb *phb)
static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift,
unsigned levels, unsigned long limit,
- unsigned long *current_offset)
+ unsigned long *current_offset, unsigned long *total_allocated)
{
struct page *tce_mem = NULL;
__be64 *addr, *tmp;
@@ -2236,6 +2236,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift,
}
addr = page_address(tce_mem);
memset(addr, 0, allocated);
+ *total_allocated += allocated;
--levels;
if (!levels) {
@@ -2245,7 +2246,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift,
for (i = 0; i < entries; ++i) {
tmp = pnv_pci_ioda2_table_do_alloc_pages(nid, shift,
- levels, limit, current_offset);
+ levels, limit, current_offset, total_allocated);
if (!tmp)
break;
@@ -2267,7 +2268,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
struct iommu_table *tbl)
{
void *addr;
- unsigned long offset = 0, level_shift;
+ unsigned long offset = 0, level_shift, total_allocated = 0;
const unsigned window_shift = ilog2(window_size);
unsigned entries_shift = window_shift - page_shift;
unsigned table_shift = max_t(unsigned, entries_shift + 3, PAGE_SHIFT);
@@ -2286,7 +2287,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
/* Allocate TCE table */
addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
- levels, tce_table_size, &offset);
+ levels, tce_table_size, &offset, &total_allocated);
/* addr==NULL means that the first level allocation failed */
if (!addr)
@@ -2308,7 +2309,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
page_shift);
tbl->it_level_size = 1ULL << (level_shift - 3);
tbl->it_indirect_levels = levels - 1;
- tbl->it_allocated_size = offset;
+ tbl->it_allocated_size = total_allocated;
pr_devel("Created TCE table: ws=%08llx ts=%lx @%08llx\n",
window_size, tce_table_size, bus_offset);
--
2.4.0.rc3.8.gfb3e7d5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table
2015-07-20 10:45 [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table Alexey Kardashevskiy
@ 2015-07-21 5:11 ` David Gibson
2015-07-21 6:24 ` Michael Ellerman
2015-07-31 4:13 ` [kernel] " Michael Ellerman
2 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2015-07-21 5:11 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: linuxppc-dev, Michael Ellerman, Paul Mackerras, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 869 bytes --]
On Mon, Jul 20, 2015 at 08:45:51PM +1000, Alexey Kardashevskiy wrote:
> The existing code stores the amount of memory allocated for a TCE table.
> At the moment it uses @offset which is a virtual offset in the TCE table
> which is only correct for a one level tables and it does not include
> memory allocated for intermediate levels. When multilevel TCE table is
> requested, WARN_ON in tce_iommu_create_table() prints a warning.
>
> This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages()
> to count actually allocated memory.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table
2015-07-20 10:45 [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table Alexey Kardashevskiy
2015-07-21 5:11 ` David Gibson
@ 2015-07-21 6:24 ` Michael Ellerman
2015-07-23 9:45 ` Alexey Kardashevskiy
2015-07-31 4:13 ` [kernel] " Michael Ellerman
2 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2015-07-21 6:24 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: linuxppc-dev, David Gibson, Paul Mackerras, linux-kernel
On Mon, 2015-07-20 at 20:45 +1000, Alexey Kardashevskiy wrote:
> The existing code stores the amount of memory allocated for a TCE table.
> At the moment it uses @offset which is a virtual offset in the TCE table
> which is only correct for a one level tables and it does not include
> memory allocated for intermediate levels. When multilevel TCE table is
> requested, WARN_ON in tce_iommu_create_table() prints a warning.
>
> This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages()
> to count actually allocated memory.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> I was sure I sent it already but could not find it anywhere so reposting.
> Sorry if it is a duplicate.
Stable?
cheers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table
2015-07-21 6:24 ` Michael Ellerman
@ 2015-07-23 9:45 ` Alexey Kardashevskiy
0 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2015-07-23 9:45 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, David Gibson, Paul Mackerras, linux-kernel
On 07/21/2015 04:24 PM, Michael Ellerman wrote:
> On Mon, 2015-07-20 at 20:45 +1000, Alexey Kardashevskiy wrote:
>> The existing code stores the amount of memory allocated for a TCE table.
>> At the moment it uses @offset which is a virtual offset in the TCE table
>> which is only correct for a one level tables and it does not include
>> memory allocated for intermediate levels. When multilevel TCE table is
>> requested, WARN_ON in tce_iommu_create_table() prints a warning.
>>
>> This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages()
>> to count actually allocated memory.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> I was sure I sent it already but could not find it anywhere so reposting.
>> Sorry if it is a duplicate.
>
> Stable?
No, this is for DDW patchset I recently posted and which did not get to any
release yet.
--
Alexey
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table
2015-07-20 10:45 [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table Alexey Kardashevskiy
2015-07-21 5:11 ` David Gibson
2015-07-21 6:24 ` Michael Ellerman
@ 2015-07-31 4:13 ` Michael Ellerman
2 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2015-07-31 4:13 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev
Cc: Alexey Kardashevskiy, Paul Mackerras, linux-kernel, David Gibson
On Mon, 2015-20-07 at 10:45:51 UTC, Alexey Kardashevskiy wrote:
> The existing code stores the amount of memory allocated for a TCE table.
> At the moment it uses @offset which is a virtual offset in the TCE table
> which is only correct for a one level tables and it does not include
> memory allocated for intermediate levels. When multilevel TCE table is
> requested, WARN_ON in tce_iommu_create_table() prints a warning.
>
> This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages()
> to count actually allocated memory.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/3ba3a73e9f204ce7904c
cheers
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-31 4:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 10:45 [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table Alexey Kardashevskiy
2015-07-21 5:11 ` David Gibson
2015-07-21 6:24 ` Michael Ellerman
2015-07-23 9:45 ` Alexey Kardashevskiy
2015-07-31 4:13 ` [kernel] " Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).