All of lore.kernel.org
 help / color / mirror / Atom feed
* Minimal GPU setup
@ 2022-02-05  9:47 Amol
  2022-02-06 16:57 ` Christian König
  2022-02-07 16:27 ` Deucher, Alexander
  0 siblings, 2 replies; 5+ messages in thread
From: Amol @ 2022-02-05  9:47 UTC (permalink / raw)
  To: amd-gfx

Hello,

I am learning to program Radeon HD 7350 by reading the radeon
driver source in Linux, and the guides/manuals from AMD.

I understand the general flow of initialization the driver performs. I
have also been able to understand and re-implement the ATOM
BIOS virtual machine.

I am trying to program the device up from scratch (i.e. bare-metal).
Do I need to perform all those steps that the driver does? Reading
the evergreen_gpu_init function is demotivating; it initializes many
fields and registers which I suspect may not be required for a minimal
setup.

Is posting the BIOS and loading the microcode enough to get me started
with running basic tasks (DMA transfers, simple packet processing, etc.)?

Thanks,
Amol

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minimal GPU setup
  2022-02-05  9:47 Minimal GPU setup Amol
@ 2022-02-06 16:57 ` Christian König
  2022-02-08  9:34   ` Amol
  2022-02-07 16:27 ` Deucher, Alexander
  1 sibling, 1 reply; 5+ messages in thread
From: Christian König @ 2022-02-06 16:57 UTC (permalink / raw)
  To: Amol, amd-gfx

Hi Amol,

Am 05.02.22 um 10:47 schrieb Amol:
> Hello,
>
> I am learning to program Radeon HD 7350 by reading the radeon
> driver source in Linux, and the guides/manuals from AMD.
>
> I understand the general flow of initialization the driver performs. I
> have also been able to understand and re-implement the ATOM
> BIOS virtual machine.

That sounds like you already came pretty far.

> I am trying to program the device up from scratch (i.e. bare-metal).
> Do I need to perform all those steps that the driver does? Reading
> the evergreen_gpu_init function is demotivating; it initializes many
> fields and registers which I suspect may not be required for a minimal
> setup.
>
> Is posting the BIOS and loading the microcode enough to get me started
> with running basic tasks (DMA transfers, simple packet processing, etc.)?

Well yes and no. As bare minimum you need the following:
1. Firmware loading
2. Memory management
3. Ring buffer setup
4. Hardware initialization

When that is done you can write commands into the ring buffers of the CP 
or SDMA and see if they are executed (see the *_ring_test() functions in 
the driver). SDMA is usually easier to get working.

When you got that working you can worry about IB (indirect buffers) 
which are basically subroutines calls written into the ring buffers.

Most commands (like copy from A to B, fill something, write value X to 
memory or write X into register Y) can be used from the ring buffers 
directly, but IIRC some context switching commands which are part of the 
rendering process require special handling.

But keep in mind that all of this will just be horrible slow because the 
ASIC runs with the bootup clocks which are something like 100Mhz or even 
only 17Mhz on very old models. To change that you need to implement 
power management, interrupt handling etc etc....

Good luck,
Christian.

>
> Thanks,
> Amol


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minimal GPU setup
  2022-02-05  9:47 Minimal GPU setup Amol
  2022-02-06 16:57 ` Christian König
@ 2022-02-07 16:27 ` Deucher, Alexander
  2022-02-08  9:34   ` Amol
  1 sibling, 1 reply; 5+ messages in thread
From: Deucher, Alexander @ 2022-02-07 16:27 UTC (permalink / raw)
  To: Amol, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 2105 bytes --]

[AMD Official Use Only]

Most of the register programming in evergreen_gpu_init is required.  That code handles things like harvesting (e.g., disabling bad hardware resources) and setting sane asic specific settings in some registers.  If you don't do it, work may get scheduled to bad or incorrectly configured hardware blocks which will lead to hangs or corrupted results.  You can probably skip some of them, but I don't remember what is minimally required off hand.  It's generally a good idea to re-initialize those registers anyway in case someone has previously messed with them (e.g., manual register munging or GPU passed through to a VM etc.).

Posting the bios is enough to get you a working memory controller and enough asic setup to light up displays (basically what you need for pre-OS console).  As Christian mentioned, loading the ucodes will get the associated engines working so that you can start feeding commands to the GPU, but without proper configuration of the various hardware blocks on the GPU, you may not have success in feeding data to the GPU.

Alex


________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Amol <suratiamol@gmail.com>
Sent: Saturday, February 5, 2022 4:47 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Subject: Minimal GPU setup

Hello,

I am learning to program Radeon HD 7350 by reading the radeon
driver source in Linux, and the guides/manuals from AMD.

I understand the general flow of initialization the driver performs. I
have also been able to understand and re-implement the ATOM
BIOS virtual machine.

I am trying to program the device up from scratch (i.e. bare-metal).
Do I need to perform all those steps that the driver does? Reading
the evergreen_gpu_init function is demotivating; it initializes many
fields and registers which I suspect may not be required for a minimal
setup.

Is posting the BIOS and loading the microcode enough to get me started
with running basic tasks (DMA transfers, simple packet processing, etc.)?

Thanks,
Amol

[-- Attachment #2: Type: text/html, Size: 3737 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minimal GPU setup
  2022-02-06 16:57 ` Christian König
@ 2022-02-08  9:34   ` Amol
  0 siblings, 0 replies; 5+ messages in thread
From: Amol @ 2022-02-08  9:34 UTC (permalink / raw)
  To: Christian König; +Cc: amd-gfx

Thank you Christian.

On 06/02/2022, Christian König <christian.koenig@amd.com> wrote:
> Hi Amol,
>
> Am 05.02.22 um 10:47 schrieb Amol:

. . .

>> Is posting the BIOS and loading the microcode enough to get me started
>> with running basic tasks (DMA transfers, simple packet processing, etc.)?
>
> Well yes and no. As bare minimum you need the following:
> 1. Firmware loading
> 2. Memory management
> 3. Ring buffer setup
> 4. Hardware initialization
>
> When that is done you can write commands into the ring buffers of the CP
> or SDMA and see if they are executed (see the *_ring_test() functions in
> the driver). SDMA is usually easier to get working.

The DMA-ring-test of making the SDMA write into a WB location in the
system RAM succeeded.

The sequence followed mimics what the Linux driver does for the most part,
until evergreen_gpu_init. That and the portions of power mgmt, interrupt mgmt,
indirect buffer mgmt, the entire _modeset_init were skipped for now.

The WB and the CP, DMA ring buffers are PAGE_SIZE buffers in the system
RAM. GTT is a 512-entries table, in the BAR0 aperture, appropriately filled in
to map the WB, CP and DMA buffers.

>
> When you got that working you can worry about IB (indirect buffers)
> which are basically subroutines calls written into the ring buffers.
>
> Most commands (like copy from A to B, fill something, write value X to
> memory or write X into register Y) can be used from the ring buffers
> directly, but IIRC some context switching commands which are part of the
> rendering process require special handling.
>
> But keep in mind that all of this will just be horrible slow because the
> ASIC runs with the bootup clocks which are something like 100Mhz or even
> only 17Mhz on very old models. To change that you need to implement
> power management, interrupt handling etc etc....

Understood. Yes, the DPM and the IH portions. I think by programming only
for the hardware I have I can manage to set them up with comparatively less
effort.

Thanks,
Amol

>
> Good luck,
> Christian.
>
>>
>> Thanks,
>> Amol
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minimal GPU setup
  2022-02-07 16:27 ` Deucher, Alexander
@ 2022-02-08  9:34   ` Amol
  0 siblings, 0 replies; 5+ messages in thread
From: Amol @ 2022-02-08  9:34 UTC (permalink / raw)
  To: Deucher, Alexander; +Cc: amd-gfx

Thank you Alex.

On 07/02/2022, Deucher, Alexander <Alexander.Deucher@amd.com> wrote:
> [AMD Official Use Only]
>
> Most of the register programming in evergreen_gpu_init is required.  That
> code handles things like harvesting (e.g., disabling bad hardware resources)
> and setting sane asic specific settings in some registers.  If you don't do
> it, work may get scheduled to bad or incorrectly configured hardware blocks
> which will lead to hangs or corrupted results.  You can probably skip some
> of them, but I don't remember what is minimally required off hand.  It's
> generally a good idea to re-initialize those registers anyway in case
> someone has previously messed with them (e.g., manual register munging or
> GPU passed through to a VM etc.).

Understood.

>
> Posting the bios is enough to get you a working memory controller and enough
> asic setup to light up displays (basically what you need for pre-OS
> console).  As Christian mentioned, loading the ucodes will get the
> associated engines working so that you can start feeding commands to the
> GPU, but without proper configuration of the various hardware blocks on the
> GPU, you may not have success in feeding data to the GPU.

Understood. I think I wanted a confirmation that the steps I took so far are not
completely incorrect and may be just enough to see some GPU activity,
before I spend more effort programming other blocks. The feedback and a small
but working test helps restore the motivation.

Thanks,
Amol

>
> Alex
>
>
> ________________________________
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Amol
> <suratiamol@gmail.com>
> Sent: Saturday, February 5, 2022 4:47 AM
> To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
> Subject: Minimal GPU setup
>
> Hello,
>
> I am learning to program Radeon HD 7350 by reading the radeon
> driver source in Linux, and the guides/manuals from AMD.
>
> I understand the general flow of initialization the driver performs. I
> have also been able to understand and re-implement the ATOM
> BIOS virtual machine.
>
> I am trying to program the device up from scratch (i.e. bare-metal).
> Do I need to perform all those steps that the driver does? Reading
> the evergreen_gpu_init function is demotivating; it initializes many
> fields and registers which I suspect may not be required for a minimal
> setup.
>
> Is posting the BIOS and loading the microcode enough to get me started
> with running basic tasks (DMA transfers, simple packet processing, etc.)?
>
> Thanks,
> Amol
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-08  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05  9:47 Minimal GPU setup Amol
2022-02-06 16:57 ` Christian König
2022-02-08  9:34   ` Amol
2022-02-07 16:27 ` Deucher, Alexander
2022-02-08  9:34   ` Amol

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.