From patchwork Wed Apr 1 18:42:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nirmoy Das X-Patchwork-Id: 11470229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AE6B92A for ; Thu, 2 Apr 2020 07:18:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 291D420784 for ; Thu, 2 Apr 2020 07:18:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CRx7/A/8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 291D420784 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 944C56E9EE; Thu, 2 Apr 2020 07:18:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5E296E984 for ; Wed, 1 Apr 2020 18:38:36 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id t8so827574wmi.2 for ; Wed, 01 Apr 2020 11:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zR38ZJz9N+JMEkJu4kuO/NmD297bBtOd+wJpasb+334=; b=CRx7/A/8IESq1R1SqFL4udlX63sOgLDO0ZHdENXLB3SlndVsnUiNaKdv8OE9SA58zs /x4phhUwyTiFmZM93lpIPWwgvJdjrebzaE4yc7jGy2ckPykECzdBAoq9eeuKnMD9M8Fj RGjUpPoej1+s6rU3FaNmRZ8Cj0YXXNrms2gE/PxEf7YhajqelD2wlA9TJc6YlqJAcCWd qvtVecfmdpqOi6RQk9Pm5QLQyNY95bf0c/E2D8ylQVcZvceKFrV/8V/vKf5aI697IaUn LEhXlTs+J6r8LzbF3tA8hfsHGQfDSG/81FJ9phAV4JR3kbfnr7b086DMuZP2FuVMMQhq 2BSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zR38ZJz9N+JMEkJu4kuO/NmD297bBtOd+wJpasb+334=; b=YrHV25sLquYwI7gQQh3AG8y91LMJqwH0rNKQBWAjMHmiBkdwTavK5xS5RhznLpTFan odx7vlkzlaOnNBF0ScUQQ3nfVbnzfYZiIl3Qzb5n1gFb5Z/xSi9le4iyKerISu3RPA9p EBMwMDw1M7AY2x0pOxBkO9AfdcGVHaiWOBV2dQS8B/Wm5PzbWlL9hVBV4posbzAMd8Hg KOuQUo9mEFPUOq6DkcDyEyaf717pXhOwHl2gnsBQIhdlL+LvH4BZ42bit9TR62jCMdTK UmROwm6lM9GGxUfYgHEG2y8R2y8ky3EGs7vH3cpg2vH4NnIYvXlLfFRTI51VBMq08Gdj UOrA== X-Gm-Message-State: AGi0PuZmhtfwKZFZNrlw8Hl4pO0/Y1lCWzzoG24/2msXB9Dki1Fk42B5 HceGIUEA11p5zJEGzA4SJPeWHdW8BpI= X-Google-Smtp-Source: APiQypKviS+UExRe7ny0VL0hvce0f87QXebHq7qYYoiSngo+VvkuVH0hCqK/IHPDZFjpwK+FZUR4bQ== X-Received: by 2002:a1c:1fd0:: with SMTP id f199mr5624582wmf.92.1585766314960; Wed, 01 Apr 2020 11:38:34 -0700 (PDT) Received: from brihaspati.fritz.box (p5DE52E4E.dip0.t-ipconnect.de. [93.229.46.78]) by smtp.gmail.com with ESMTPSA id b11sm3976973wrq.26.2020.04.01.11.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 11:38:34 -0700 (PDT) From: Nirmoy Das X-Google-Original-From: Nirmoy Das To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/8] drm/radeon: don't use ttm bo->offset Date: Wed, 1 Apr 2020 20:42:41 +0200 Message-Id: <20200401184247.16643-3-nirmoy.das@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200401184247.16643-1-nirmoy.das@amd.com> References: <20200401184247.16643-1-nirmoy.das@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 02 Apr 2020 07:17:56 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thellstrom@vmware.com, airlied@linux.ie, kenny.ho@amd.com, brian.welty@intel.com, nirmoy.das@amd.com, linux-graphics-maintainer@vmware.com, bskeggs@redhat.com, alexander.deucher@amd.com, sean@poorly.run, christian.koenig@amd.com, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Calculate GPU offset in radeon_bo_gpu_offset without depending on bo->offset. Signed-off-by: Nirmoy Das Reviewed-and-tested-by: Christian König --- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++++++- drivers/gpu/drm/radeon/radeon_ttm.c | 4 +--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 30e32adc1fc6..b7c3fb2bfb54 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -2828,6 +2828,7 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size extern void radeon_program_register_sequence(struct radeon_device *rdev, const u32 *registers, const u32 array_size); +struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev); /* * vm diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index d23f2ed4126e..60275b822f79 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h @@ -90,7 +90,21 @@ static inline void radeon_bo_unreserve(struct radeon_bo *bo) */ static inline u64 radeon_bo_gpu_offset(struct radeon_bo *bo) { - return bo->tbo.offset; + struct radeon_device *rdev; + u64 start = 0; + + rdev = radeon_get_rdev(bo->tbo.bdev); + + switch (bo->tbo.mem.mem_type) { + case TTM_PL_TT: + start = rdev->mc.gtt_start; + break; + case TTM_PL_VRAM: + start = rdev->mc.vram_start; + break; + } + + return (bo->tbo.mem.start << PAGE_SHIFT) + start; } static inline unsigned long radeon_bo_size(struct radeon_bo *bo) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index badf1b6d1549..1c8303468e8f 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -56,7 +56,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev); static void radeon_ttm_debugfs_fini(struct radeon_device *rdev); -static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) +struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) { struct radeon_mman *mman; struct radeon_device *rdev; @@ -82,7 +82,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, break; case TTM_PL_TT: man->func = &ttm_bo_manager_func; - man->gpu_offset = rdev->mc.gtt_start; man->available_caching = TTM_PL_MASK_CACHING; man->default_caching = TTM_PL_FLAG_CACHED; man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA; @@ -104,7 +103,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, case TTM_PL_VRAM: /* "On-card" video ram */ man->func = &ttm_bo_manager_func; - man->gpu_offset = rdev->mc.vram_start; man->flags = TTM_MEMTYPE_FLAG_FIXED | TTM_MEMTYPE_FLAG_MAPPABLE; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;