Hi Am 05.03.20 um 15:07 schrieb Gerd Hoffmann: > On Thu, Mar 05, 2020 at 02:29:08PM +0100, Nirmoy Das wrote: >> Calculate GEM VRAM bo's offset within vram-helper without depending on >> bo->offset. >> >> Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxx> >> Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx> >> --- >> drivers/gpu/drm/drm_gem_vram_helper.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c >> index 92a11bb42365..2749c2d25ac4 100644 >> --- a/drivers/gpu/drm/drm_gem_vram_helper.c >> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c >> @@ -198,6 +198,13 @@ u64 drm_gem_vram_mmap_offset(struct drm_gem_vram_object *gbo) >> } >> EXPORT_SYMBOL(drm_gem_vram_mmap_offset); >> >> +static s64 drm_gem_vram_pg_offset(struct drm_gem_vram_object *gbo) >> +{ >> + if (WARN_ON_ONCE(!gbo->bo.mem.mm_node)) >> + return 0; > > returns 0 on error. > >> + return gbo->bo.mem.start; >> +} >> + >> /** >> * drm_gem_vram_offset() - \ >> Returns a GEM VRAM object's offset in video memory >> @@ -214,7 +221,7 @@ s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo) >> { >> if (WARN_ON_ONCE(!gbo->pin_count)) >> return (s64)-ENODEV; > > returns -errno on error. > >> - return gbo->bo.offset; >> + return drm_gem_vram_pg_offset(gbo) << PAGE_SHIFT; > > And given that one calls the other behavior on error should better be > consistent ... It is expected that the offset is valid if pin_count is positive. Anything else would be a massive ref-counting bug. And that's been the behavior of the old code as well. But I agree that the current patch is inconsistent. I suggest changing the return type of drm_gem_vram_pg_offset() to u64. Best regards Thomas > > cheers, > Gerd > > _______________________________________________ > dri-devel mailing list > dri-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/dri-devel > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel