Re: [PATCH] arch: metag: kernel: dma.c: check 'pud' whether is NULL in dma_alloc_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/14/2013 07:51 PM, James Hogan wrote:
> On 14/11/13 11:46, Xishi Qiu wrote:
>> On 2013/11/14 18:24, James Hogan wrote:
>>
>>> On 14/11/13 09:35, Chen Gang wrote:
>>>> On 11/14/2013 05:18 PM, James Hogan wrote:
>>>>> On Thursday 14 November 2013 16:11:21 Chen Gang wrote:
>>>>>> Like another p?d_alloc(), pud_alloc() also may fail, so need check it.
>>>>>>
>>>>>> Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
>>>>>
>>>>> NAK.
>>>>>
>>>>> pud_alloc folds to pud_offset on Meta so it cannot fail.
>>>>>
>>>>
>>>> If so, can pmd_alloc() be fail?
>>>
>>> No. pmd_alloc folds to pmd_offset so it also cannot fail, and the
>>> existing !pmd check is dead code. The following would be better.
>>>
>>> Cheers
>>> James
>>>
>>
>> Hi James,
>>
>> __PAGETABLE_PUD_FOLDED and __PAGETABLE_PMD_FOLDED are defined,
>> so __pud_alloc() and __pmd_alloc() always return 0, 
>> and pud_offset() just return (pud_t *)pgd, pmd_offset() just return (pmd_t *)pud,
>> is that right?
> 
> Yes exactly (although technically __pud_alloc() and __pmd_alloc() would
> never get called due to pgd_none() and pud_none() returning 0, but it
> makes little difference).
> 

Thank all of you (originally, I did not notice about "linux/mm.h"
include "asm/pgtable.h" -- which maybe be a common sense).

:-)

> Cheers
> James
> 
>>
>>> >From 85a386a9c7df666b1f438435be8a89581bc7e8b3 Mon Sep 17 00:00:00 2001
>>> From: James Hogan <james.hogan@xxxxxxxxxx>
>>> Date: Thu, 14 Nov 2013 10:14:37 +0000
>>> Subject: [PATCH 1/1] metag: dma: remove dead code in dma_alloc_init()
>>>
>>> Meta has 2 levels of page table so the pmd folds into the pud which
>>> folds into the pgd. Therefore the !pmd check in dma_alloc_init() is dead
>>> code since it essentially checks whether:
>>>   (init_mm->pgd + 0x770) == 0
>>>
>>> Remove the check.
>>>
>>> Reported-by: Chen Gang <gang.chen@xxxxxxxxxxx>
>>> Signed-off-by: James Hogan <james.hogan@xxxxxxxxxx>
>>> ---
>>>  arch/metag/kernel/dma.c | 5 -----
>>>  1 file changed, 5 deletions(-)
>>>
>>> diff --git a/arch/metag/kernel/dma.c b/arch/metag/kernel/dma.c
>>> index 8c00dedadc54..78205dbc2b86 100644
>>> --- a/arch/metag/kernel/dma.c
>>> +++ b/arch/metag/kernel/dma.c
>>> @@ -401,11 +401,6 @@ static int __init dma_alloc_init(void)
>>>  		pgd = pgd_offset(&init_mm, CONSISTENT_START);
>>>  		pud = pud_alloc(&init_mm, pgd, CONSISTENT_START);
>>>  		pmd = pmd_alloc(&init_mm, pud, CONSISTENT_START);
>>> -		if (!pmd) {
>>> -			pr_err("%s: no pmd tables\n", __func__);
>>> -			ret = -ENOMEM;
>>> -			break;
>>> -		}
>>>  		WARN_ON(!pmd_none(*pmd));
>>>  
>>>  		pte = pte_alloc_kernel(pmd, CONSISTENT_START);
>>
>>
> 
> 
> 


-- 
Chen Gang
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux Wireless]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux