From patchwork Mon Feb 17 15:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nirmoy Das X-Patchwork-Id: 11387921 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 E4FA0138D for ; Tue, 18 Feb 2020 07:55:47 +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 C3E3921D56 for ; Tue, 18 Feb 2020 07:55:47 +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="UMJScIu9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3E3921D56 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 7BA236E158; Tue, 18 Feb 2020 07:55:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AEB76E978; Mon, 17 Feb 2020 15:02:05 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id a5so17447005wmb.0; Mon, 17 Feb 2020 07:02:05 -0800 (PST) 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=bWJVvbyji5lv93ku6dxciulHZbwF+rGmjiubbT57gkM=; b=UMJScIu9Z7aNensdn8Wxr2f4THU/W2zkxKndpS2FtJOlhVzWY9KlL0yAQA7ItGnNC3 gQK4DqhBYVSq4aISfRxg/QS46AlPoDeBBSv4BpbcZAg2hpIT23PGCndNH/lJO5yN/9Ng 2sVxhEk9EtCfJle86pfK4GTyOMrB8suInAzjDkVpEjoPsq9IVDiowMTmIDG8gQnRvRu9 k2mAFN8FTqR6FsyojjE0snKWS7fCzJzGiO+RvjY4CiTY9erhaxpLvnj+iCdruoeX2HvO L5pXipvryKAEDv6iSTHd4bP2uLEOJRnKlgbayt4ANlDLendyl4nWZuHCmHWU6X3mRyvF IqgA== 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=bWJVvbyji5lv93ku6dxciulHZbwF+rGmjiubbT57gkM=; b=mAwdpSHzzZ6c19Qk8w81SNvj3TLEz0RWSWHDDZPnPPqPhRFsc1xE2l4hFmeJ+01fA7 s5P5f4wFLXY9gFn1Q3JwvnpA2TBs29o2YotEhPNIFCJAaochpEPHhnmB9D6HRjdgn/fN 91QbdNfb7obFOY8sYCQfpKLOXkDksTnnKnH+CPc5ItXuEtd32c7iIk4iC/UnVTOEcbBg qBvsd1/lV3nC3zdwml0t9S+sUeubbC5e3M9aZwa385nxoYlGaFdUsHN/v8uhdrH/V2Ph YWefWcrPnXtBCoW0diyGDGsbTiNGvlIHJmlQ4J+HMHWP8QXb49SpklbrlhqCBlLjJEH+ +y9w== X-Gm-Message-State: APjAAAX0zdcbSd/FLAp5Vgsm3UKeb/IXKb7hPlk/SKKAydsZ8Jx9bwtL DaA/uK4X3dxTi+XVgcF4A6RhIxgFXO+Lbw== X-Google-Smtp-Source: APXvYqxBNbveVe405k5YBZp6i7W88P8dQDLO/GbCImzL7lj3wNHNZHo9rCmupBf4L+Zzd0hPx444VQ== X-Received: by 2002:a7b:c389:: with SMTP id s9mr21652083wmj.7.1581951723580; Mon, 17 Feb 2020 07:02:03 -0800 (PST) Received: from brihaspati.fritz.box (pD9566D64.dip0.t-ipconnect.de. [217.86.109.100]) by smtp.gmail.com with ESMTPSA id j15sm1441099wrp.9.2020.02.17.07.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 07:02:02 -0800 (PST) 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: Mon, 17 Feb 2020 16:04:21 +0100 Message-Id: <20200217150427.49994-3-nirmoy.das@amd.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217150427.49994-1-nirmoy.das@amd.com> References: <20200217150427.49994-1-nirmoy.das@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 18 Feb 2020 07:55:25 +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, amd-gfx@lists.freedesktop.org, 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..4d37571c7ff5 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;