[01/12] drm/ttm: Use ttm_bo_default_io_mem_pfn if io_mem_pfn is NULL

Submitted by Tan Xiaojun on Dec. 24, 2017, 6:14 a.m.

Details

Message ID 1514096068-80414-2-git-send-email-tanxiaojun@huawei.com
State New
Headers show
Series "drm: add check if io_mem_pfn is NULL and cleanup" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Tan Xiaojun Dec. 24, 2017, 6:14 a.m.
From: Michal Srb <msrb@suse.com>

The io_mem_pfn field was added in commit ea642c3216cb2a60d1c0e760ae47ee85c9c16447
and is called unconditionally. However, not all drivers were updated to set it.

Use the ttm_bo_default_io_mem_pfn function if a driver did not set its own.

Signed-off-by: Michal Srb <msrb@suse.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index c8ebb75..e25a99b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -234,7 +234,10 @@  static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		if (bo->mem.bus.is_iomem) {
 			/* Iomem should not be marked encrypted */
 			cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
-			pfn = bdev->driver->io_mem_pfn(bo, page_offset);
+			if (bdev->driver->io_mem_pfn)
+				pfn = bdev->driver->io_mem_pfn(bo, page_offset);
+			else
+				pfn = ttm_bo_default_io_mem_pfn(bo, page_offset);
 		} else {
 			page = ttm->pages[page_offset];
 			if (unlikely(!page && i == 0)) {

Comments

Am 24.12.2017 um 07:14 schrieb Tan Xiaojun:
> From: Michal Srb <msrb@suse.com>
>
> The io_mem_pfn field was added in commit ea642c3216cb2a60d1c0e760ae47ee85c9c16447
> and is called unconditionally. However, not all drivers were updated to set it.
>
> Use the ttm_bo_default_io_mem_pfn function if a driver did not set its own.
>
> Signed-off-by: Michal Srb <msrb@suse.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index c8ebb75..e25a99b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -234,7 +234,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
>   		if (bo->mem.bus.is_iomem) {
>   			/* Iomem should not be marked encrypted */
>   			cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
> -			pfn = bdev->driver->io_mem_pfn(bo, page_offset);
> +			if (bdev->driver->io_mem_pfn)
> +				pfn = bdev->driver->io_mem_pfn(bo, page_offset);
> +			else
> +				pfn = ttm_bo_default_io_mem_pfn(bo, page_offset);

Please move this check into a new function ttm_bo_io_mem_pfn().

You can then move the calculation of ttm_bo_default_io_mem_pfn() into 
this new function in patch #12 as well.

Regards,
Christian.

>   		} else {
>   			page = ttm->pages[page_offset];
>   			if (unlikely(!page && i == 0)) {
On 2017/12/24 17:27, Christian König wrote:
> Am 24.12.2017 um 07:14 schrieb Tan Xiaojun:
>> From: Michal Srb <msrb@suse.com>
>>
>> The io_mem_pfn field was added in commit ea642c3216cb2a60d1c0e760ae47ee85c9c16447
>> and is called unconditionally. However, not all drivers were updated to set it.
>>
>> Use the ttm_bo_default_io_mem_pfn function if a driver did not set its own.
>>
>> Signed-off-by: Michal Srb <msrb@suse.com>
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> index c8ebb75..e25a99b 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> @@ -234,7 +234,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
>>           if (bo->mem.bus.is_iomem) {
>>               /* Iomem should not be marked encrypted */
>>               cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
>> -            pfn = bdev->driver->io_mem_pfn(bo, page_offset);
>> +            if (bdev->driver->io_mem_pfn)
>> +                pfn = bdev->driver->io_mem_pfn(bo, page_offset);
>> +            else
>> +                pfn = ttm_bo_default_io_mem_pfn(bo, page_offset);
> 
> Please move this check into a new function ttm_bo_io_mem_pfn().
> 
> You can then move the calculation of ttm_bo_default_io_mem_pfn() into this new function in patch #12 as well.
> 
> Regards,
> Christian.
> 

OK. Thank you for your reply. I will modify it and send v2.

Thanks.
Xiaojun.

>>           } else {
>>               page = ttm->pages[page_offset];
>>               if (unlikely(!page && i == 0)) {
> 
> 
> .
>