diff mbox series

drm: Allow range of 0 for drm_mm_insert_node_in_range()

Message ID 20190626094330.3556-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm: Allow range of 0 for drm_mm_insert_node_in_range() | expand

Commit Message

Chris Wilson June 26, 2019, 9:43 a.m. UTC
We gracefully handle the caller specifying a zero range, so don't force
them to special case that condition if it naturally falls out of their
setup. What we don't check is if the end < start, so keep that as an
assert for an illegal call.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniele Ceraolo Spurio June 26, 2019, 5:32 p.m. UTC | #1
On 6/26/19 2:43 AM, Chris Wilson wrote:
> We gracefully handle the caller specifying a zero range, so don't force
> them to special case that condition if it naturally falls out of their
> setup. What we don't check is if the end < start, so keep that as an
> assert for an illegal call.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---

Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

Daniele

>   drivers/gpu/drm/drm_mm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 9a59865ce574..4581c5387372 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -472,7 +472,7 @@ int drm_mm_insert_node_in_range(struct drm_mm * const mm,
>   	u64 remainder_mask;
>   	bool once;
>   
> -	DRM_MM_BUG_ON(range_start >= range_end);
> +	DRM_MM_BUG_ON(range_start > range_end);
>   
>   	if (unlikely(size == 0 || range_end - range_start < size))
>   		return -ENOSPC;
>
Daniel Vetter June 26, 2019, 9:28 p.m. UTC | #2
On Wed, Jun 26, 2019 at 10:43:30AM +0100, Chris Wilson wrote:
> We gracefully handle the caller specifying a zero range, so don't force
> them to special case that condition if it naturally falls out of their
> setup. What we don't check is if the end < start, so keep that as an
> assert for an illegal call.

Maybe spend a few words on why a drm_mm user might want to do that. Sounds
very funky ...
-Daniel

> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_mm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 9a59865ce574..4581c5387372 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -472,7 +472,7 @@ int drm_mm_insert_node_in_range(struct drm_mm * const mm,
>  	u64 remainder_mask;
>  	bool once;
>  
> -	DRM_MM_BUG_ON(range_start >= range_end);
> +	DRM_MM_BUG_ON(range_start > range_end);
>  
>  	if (unlikely(size == 0 || range_end - range_start < size))
>  		return -ENOSPC;
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 9a59865ce574..4581c5387372 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -472,7 +472,7 @@  int drm_mm_insert_node_in_range(struct drm_mm * const mm,
 	u64 remainder_mask;
 	bool once;
 
-	DRM_MM_BUG_ON(range_start >= range_end);
+	DRM_MM_BUG_ON(range_start > range_end);
 
 	if (unlikely(size == 0 || range_end - range_start < size))
 		return -ENOSPC;