From patchwork Tue Feb 18 18:04:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nirmoy Das X-Patchwork-Id: 11390673 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 98D1B92A for ; Wed, 19 Feb 2020 08:20:59 +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 76DF724656 for ; Wed, 19 Feb 2020 08:20:59 +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="htkEcdHu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76DF724656 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 024F56EB22; Wed, 19 Feb 2020 08:20:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 631136E3A2; Tue, 18 Feb 2020 18:02:21 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id w15so25088869wru.4; Tue, 18 Feb 2020 10:02:21 -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=htkEcdHuKMZGFs0Lw6H78jlx7osGT2ycZJP1mT9tLp7Bp6X3yKZMam/pBpvm/GR6dF Ne6tbBEGyItgpybH7YY0Tks6Y9EPF1iWR6A6rDDEjcCNU1tGDeYwIRYn9WttDcLiFC5c BgYZ8hRHYKx+r3vh0f4rCeJaixjABuVZOj1SfucMfmoHpUrkWp9yyTcedfq4AvAceueH y/jGmBfxlZOtdD0ldKG+ElViBn68CgzBLGK8a3WZvi49p1Gc4hd4Y8dh7VjFI5k4xSo9 gharhkLbbKa6Dh/+cOUitOtzz55Uyzw45ogFLopuny6wCi6Qn0KlYx0ES9QsoysbAR2V BLqg== 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=ggVtMwE4+STd8qp1bTiyzp5TRg+QYJLPK5sI2Bxfzq68oRoaMKDsrMome4rWYApBaz snC3ANM7AY3GaUrTYBJ6GLe/fJYZcxRIJVnaTR3K9W+Zu2CgKyBTpxZp1rhr8IRfE7jk nhPMuzMBXBdmMSlj9Zx3ylTbthklZ9/s3PudJoxtVE8zUy943qZG7+ltVjP62p0jSDIj 59vn0vSsh4ayC7HfMXhWtDwzD/tw8yVT/hOjohI35zKGkpuqwHTMsvG9PnUnond+haYf czCnGHCZNSwCyebJGTsEETAbdsL1LQYdFeJQrewe2EswjiNbkNbZ2Rs7lSa7PXpe6ytT ozjg== X-Gm-Message-State: APjAAAW3f0NKCv4eAX/Pqo+WSsEWaQO4sQPl3p9vZQl1Z1oXCHJqM/CX 9OzZH8iqKEjh//VFJl4xv2KL3MlK+SORgw== X-Google-Smtp-Source: APXvYqxf1/efrwh1kulTuPplfjNrmvX+H7ljo6oiLxY24GIwDEhoRLwcT7x8BVl6tlBaFivroTLZuA== X-Received: by 2002:a05:6000:114f:: with SMTP id d15mr4641576wrx.130.1582048939624; Tue, 18 Feb 2020 10:02:19 -0800 (PST) Received: from brihaspati.fritz.box (p200300C58F2CE900751228326401B174.dip0.t-ipconnect.de. [2003:c5:8f2c:e900:7512:2832:6401:b174]) by smtp.gmail.com with ESMTPSA id d16sm7872733wrg.27.2020.02.18.10.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 10:02:18 -0800 (PST) From: Nirmoy Das X-Google-Original-From: Nirmoy Das To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/8] drm/radeon: don't use ttm bo->offset Date: Tue, 18 Feb 2020 19:04:48 +0100 Message-Id: <20200218180454.81866-3-nirmoy.das@amd.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200218180454.81866-1-nirmoy.das@amd.com> References: <20200218180454.81866-1-nirmoy.das@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 19 Feb 2020 08:19:59 +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;