All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 3/7] drm/amdgpu: add amdgpu_gmc_agp_location v2
Date: Thu, 30 Aug 2018 11:08:45 +0800	[thread overview]
Message-ID: <5B875FBD.8080304@amd.com> (raw)
In-Reply-To: <20180829140809.1812-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>

On 08/29/2018 10:08 PM, Christian König wrote:
> Helper to figure out the location of the AGP BAR.
>
> v2: fix a couple of bugs
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 43 +++++++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  5 +++
>   2 files changed, 48 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index c6bcc4715373..1d201fd3f4af 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -143,3 +143,46 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
>   	dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n",
>   			mc->gart_size >> 20, mc->gart_start, mc->gart_end);
>   }
> +
> +/**
> + * amdgpu_gmc_agp_location - try to find AGP location
> + * @adev: amdgpu device structure holding all necessary informations
> + * @mc: memory controller structure holding memory informations
> + *
> + * Function will place try to find a place for the AGP BAR in the MC address
> + * space.
> + *
> + * AGP BAR will be assigned the largest available hole in the address space.
> + * Should be called after VRAM and GART locations are setup.
> + */
> +void amdgpu_gmc_agp_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
> +{
> +	const uint64_t sixteen_gb = 1ULL << 34;
> +	const uint64_t sixteen_gb_mask = ~(sixteen_gb - 1);
> +	u64 size_af, size_bf;
> +
> +	if (mc->vram_start > mc->gart_start) {
> +		size_bf = (mc->vram_start & sixteen_gb_mask) -
> +			ALIGN(mc->gart_end + 1, sixteen_gb);
> +		size_af = mc->mc_mask + 1 - ALIGN(mc->vram_end, sixteen_gb);
> +	} else {
> +		size_bf = mc->vram_start & sixteen_gb_mask;
> +		size_af = (mc->gart_start & sixteen_gb_mask) -
> +			ALIGN(mc->vram_end, sixteen_gb);

we may need ALIGN(mc->vram_end + 1, sixteen_gb) for size_af.

> +	}
> +
> +	if (size_bf > size_af) {
> +		mc->agp_start = mc->vram_start > mc->gart_start ?
> +			mc->gart_end + 1 : 0;
> +		mc->agp_size = size_bf;
> +	} else {
> +		mc->agp_start = (mc->vram_start > mc->gart_start ?
> +			mc->vram_end : mc->gart_end) + 1,
> +		mc->agp_size = size_af;
> +	}
> +
> +	mc->agp_start = ALIGN(mc->agp_start, sixteen_gb);
> +	mc->agp_end = mc->agp_start + mc->agp_size - 1;
> +	dev_info(adev->dev, "AGP: %lluM 0x%016llX - 0x%016llX\n",
> +			mc->agp_size >> 20, mc->agp_start, mc->agp_end);
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index 48715dd5808a..c9985e7dc9e5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -94,6 +94,9 @@ struct amdgpu_gmc {
>   	 * about vram size near mc fb location */
>   	u64			mc_vram_size;
>   	u64			visible_vram_size;
> +	u64			agp_size;
> +	u64			agp_start;
> +	u64			agp_end;
>   	u64			gart_size;
>   	u64			gart_start;
>   	u64			gart_end;
> @@ -164,5 +167,7 @@ void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
>   			      u64 base);
>   void amdgpu_gmc_gart_location(struct amdgpu_device *adev,
>   			      struct amdgpu_gmc *mc);
> +void amdgpu_gmc_agp_location(struct amdgpu_device *adev,
> +			     struct amdgpu_gmc *mc);
>
>   #endif
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-08-30  3:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 14:08 [PATCH 1/7] drm/amdgpu: correctly sign extend 48bit addresses v3 Christian König
     [not found] ` <20180829140809.1812-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-29 14:08   ` [PATCH 2/7] drm/amdgpu: put GART away from VRAM v2 Christian König
     [not found]     ` <20180829140809.1812-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-30  2:51       ` Zhang, Jerry (Junwei)
2018-08-29 14:08   ` [PATCH 3/7] drm/amdgpu: add amdgpu_gmc_agp_location v2 Christian König
     [not found]     ` <20180829140809.1812-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-30  3:08       ` Zhang, Jerry (Junwei) [this message]
2018-08-29 14:08   ` [PATCH 4/7] drm/amdgpu: use the AGP aperture for system memory access v2 Christian König
     [not found]     ` <20180829140809.1812-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-30  3:20       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B87627D.9050601-5C7GfCeVMHo@public.gmane.org>
2018-08-30 12:15           ` Christian König
     [not found]             ` <b7100847-7afc-5665-6752-99173e03934a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-31  1:39               ` Zhang, Jerry (Junwei)
2018-08-29 14:08   ` [PATCH 5/7] drm/amdgpu: manually map the shadow BOs again Christian König
     [not found]     ` <20180829140809.1812-5-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-30  3:29       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B876486.2060401-5C7GfCeVMHo@public.gmane.org>
2018-08-30 12:16           ` Christian König
2018-08-29 14:08   ` [PATCH 6/7] drm/amdgpu: enable AGP aperture for GMC9 Christian König
     [not found]     ` <20180829140809.1812-6-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-30  4:13       ` Zhang, Jerry (Junwei)
2018-08-29 14:08   ` [PATCH 7/7] drm/amdgpu: try to make kernel allocations USWC Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B875FBD.8080304@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.