Skip to content

Commit

Permalink
gpu/intel: provide supported devices as config
Browse files Browse the repository at this point in the history
Adjust drivers_interactive, drivers_managed and sculpt accordingly.

Issue #4260
  • Loading branch information
alex-ab committed Sep 27, 2021
1 parent f5805b6 commit 895647a
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 44 deletions.
5 changes: 4 additions & 1 deletion repos/gems/recipes/raw/drivers_managed-pc/content.mk
@@ -1,11 +1,14 @@
content: drivers.config fb_drv.config event_filter.config en_us.chargen \
special.chargen numlock_remap.config
special.chargen numlock_remap.config gpu_drv.config

drivers.config numlock_remap.config event_filter.config:
cp $(REP_DIR)/recipes/raw/drivers_managed-pc/$@ $@

fb_drv.config:
cp $(GENODE_DIR)/repos/os/recipes/raw/drivers_interactive-pc/$@ $@

gpu_drv.config:
cp $(GENODE_DIR)/repos/os/src/drivers/gpu/intel/$@ $@

en_us.chargen special.chargen:
cp $(GENODE_DIR)/repos/os/src/server/event_filter/$@ $@
6 changes: 6 additions & 0 deletions repos/gems/run/sculpt.run
Expand Up @@ -115,6 +115,7 @@ install_config {
<rom name="special" label="special.chargen"/>
</dir>
<rom name="fb_drv" label="fb_drv.config"/>
<rom name="gpu_drv" label="gpu_drv.config"/>
<rom name="nitpicker" label="nitpicker.config"/>
<rom name="numlock_remap" label="numlock_remap.config"/>
<rom name="leitzentrale" label="leitzentrale.config"/>
Expand Down Expand Up @@ -255,6 +256,8 @@ install_config {
<child name="config_fs_rom"/> </service>
<service name="ROM" label_last="fb_drv.config">
<child name="config_fs_rom" label="managed/fb_drv"/> </service>
<service name="ROM" label_last="gpu_drv.config">
<child name="config_fs_rom" label="gpu_drv"/> </service>
<service name="ROM" label_last="numlock_remap.config">
<child name="config_fs_rom" label="numlock_remap"/> </service>
<service name="ROM" label_last="usb_policy">
Expand Down Expand Up @@ -539,6 +542,9 @@ if {[have_board pc]} {
copy_file [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/event_filter.config \
[run_dir]/genode/event_filter.config

copy_file [genode_dir]/repos/os/src/drivers/gpu/intel/gpu_drv.config \
[run_dir]/genode/gpu_drv.config

copy_file [genode_dir]/repos/gems/run/sculpt/machine.vbox [run_dir]/genode/

copy_file [genode_dir]/repos/gems/recipes/raw/drivers_managed-pc/drivers.config \
Expand Down
1 change: 1 addition & 0 deletions repos/gems/src/app/driver_manager/main.cc
Expand Up @@ -145,6 +145,7 @@ struct Driver_manager::Intel_gpu_driver : Device_driver
xml.attribute("name", Platform::Session::service_name()); });
});
xml.node("route", [&] () {
_gen_config_route(xml, "gpu_drv.config");
_gen_default_parent_route(xml);
});
});
Expand Down
5 changes: 4 additions & 1 deletion repos/os/recipes/raw/drivers_interactive-pc/content.mk
@@ -1,7 +1,10 @@
content: drivers.config fb_drv.config event_filter.config en_us.chargen special.chargen
content: drivers.config fb_drv.config event_filter.config en_us.chargen special.chargen gpu_drv.config

drivers.config fb_drv.config event_filter.config:
cp $(REP_DIR)/recipes/raw/drivers_interactive-pc/$@ $@

gpu_drv.config:
cp $(REP_DIR)/src/drivers/gpu/intel/$@ $@

en_us.chargen special.chargen:
cp $(REP_DIR)/src/server/event_filter/$@ $@
9 changes: 5 additions & 4 deletions repos/os/recipes/raw/drivers_interactive-pc/drivers.config
Expand Up @@ -166,11 +166,12 @@
<start name="intel_gpu_drv" caps="2500">
<binary name="intel_gpu_drv"/>
<resource name="RAM" quantum="64M"/>
<provides>
<service name="Gpu"/>
<service name="Platform"/>
</provides>
<provides>
<service name="Gpu"/>
<service name="Platform"/>
</provides>
<route>
<service name="ROM" label="config"> <parent label="gpu_drv.config"/> </service>
<service name="Platform"> <child name="platform_drv"/> </service>
<service name="IO_PORT"> <parent/> </service>
<service name="IO_MEM"> <parent/> </service>
Expand Down
11 changes: 11 additions & 0 deletions repos/os/src/drivers/gpu/intel/gpu_drv.config
@@ -0,0 +1,11 @@
<config>
<device vendor="0x8086" device="0x1606" generation="8" platform="broadwell" description="HD Graphics (BDW GT1 ULT)"/>
<device vendor="0x8086" device="0x1616" generation="8" platform="broadwell" description="HD Graphics 5500 (BDW GT2 ULT)"/>
<device vendor="0x8086" device="0x1622" generation="8" platform="broadwell" description="Iris Pro Graphics 6200 (BDW GT3e)"/>
<device vendor="0x8086" device="0x1916" generation="9" platform="skylake" description="HD Graphics 520 (Skylake, Gen9)"/>
<device vendor="0x8086" device="0x191b" generation="9" platform="skylake" description="HD Graphics 530 (Skylake, Gen9)"/>
<device vendor="0x8086" device="0x5916" generation="9" platform="kabylake" description="HD Graphics 620 (Kaby Lake, Gen9p5)"/>
<device vendor="0x8086" device="0x5917" generation="9" platform="kabylake" description="UHD Graphics 620 (Kaby Lake, Gen9p5)"/>
<device vendor="0x8086" device="0x591b" generation="9" platform="kabylake" description="HD Graphics 630 (Kaby Lake, Gen9p5)"/>
<device vendor="0x8086" device="0x3ea0" generation="9" platform="whiskeylake" description="UHD Graphics 620 (Whiskey Lake, Gen9p5)"/>
</config>
116 changes: 78 additions & 38 deletions repos/os/src/drivers/gpu/intel/main.cc
Expand Up @@ -64,29 +64,10 @@ struct Igd::Device_info
uint16_t id;
uint8_t generation;
Platform platform;
char const *descr;
uint64_t features;
};


/*
* IHD-OS-BDW-Vol 4-11.15 p. 9
*/
static Igd::Device_info _supported_devices[] = {
{ 0x1606, 8, Igd::Device_info::Platform::BROADWELL, "HD Graphics (BDW GT1 ULT)", 0ull },
{ 0x1616, 8, Igd::Device_info::Platform::BROADWELL, "HD Graphics 5500 (BDW GT2 ULT)", 0ull },
/* TODO proper eDRAM probing + caching */
{ 0x1622, 8, Igd::Device_info::Platform::BROADWELL, "Iris Pro Graphics 6200 (BDW GT3e)", 0ull },
{ 0x1916, 9, Igd::Device_info::Platform::SKYLAKE, "HD Graphics 520 (Skylake, Gen9)", 0ull },
{ 0x191b, 9, Igd::Device_info::Platform::SKYLAKE, "HD Graphics 530 (Skylake, Gen9)", 0ull },
{ 0x5916, 9, Igd::Device_info::Platform::KABYLAKE, "HD Graphics 620 (Kaby Lake, Gen9p5)", 0ull },
{ 0x5917, 9, Igd::Device_info::Platform::KABYLAKE, "UHD Graphics 620 (Kaby Lake, Gen9p5)", 0ull },
{ 0x591b, 9, Igd::Device_info::Platform::KABYLAKE, "HD Graphics 630 (Kaby Lake, Gen9p5)", 0ull },
{ 0x3ea0, 9, Igd::Device_info::Platform::WHISKEYLAKE, "UHD Graphics 620 (Whiskey Lake, Gen9p5)", 0ull },
};

#define ELEM_NUMBER(x) (sizeof((x)) / sizeof((x)[0]))


struct Igd::Device
{
Expand Down Expand Up @@ -138,7 +119,7 @@ struct Igd::Device
Gpu::Info::Eu_total _eus { };
Gpu::Info::Subslices _subslices { };

void _pci_info(char const *descr)
void _pci_info(String<64> const &descr) const
{
using namespace Genode;

Expand Down Expand Up @@ -172,19 +153,57 @@ struct Igd::Device
}
}

bool _supported()
bool _supported(Xml_node &supported)
{
uint16_t const id = _device.device_id();
for (size_t i = 0; i < ELEM_NUMBER(_supported_devices); i++) {
if (_supported_devices[i].id == id) {
_info = _supported_devices[i];
bool found = false;

supported.for_each_sub_node("device", [&] (Xml_node node) {
if (found)
return;

uint16_t const vendor = node.attribute_value("vendor", 0U);
uint16_t const device = node.attribute_value("device", 0U);
uint8_t const generation = node.attribute_value("generation", 0U);
String<16> const platform = node.attribute_value("platform", String<16>("unknown"));
String<64> const desc = node.attribute_value("description", String<64>("unknown"));

if (vendor != 0x8086 /* Intel */ || generation < 8)
return;

struct Igd::Device_info const info {
.id = device,
.generation = generation,
.platform = platform_type(platform),
.features = 0
};

if (info.platform == Igd::Device_info::Platform::UNKNOWN)
return;

if (info.id == _device.device_id()) {
_info = info;
_revision.value = _resources.config_read<uint8_t>(8);
_pci_info(_supported_devices[i].descr);
return true;
_pci_info(desc.string());

found = true;
return;
}
}
_pci_info("<Unsupported device>");
return false;
});

return found;
}

Igd::Device_info::Platform platform_type(String<16> const &platform) const
{
if (platform == "broadwell")
return Igd::Device_info::Platform::BROADWELL;
if (platform == "skylake")
return Igd::Device_info::Platform::SKYLAKE;
if (platform == "kabylake")
return Igd::Device_info::Platform::KABYLAKE;
if (platform == "whiskeylake")
return Igd::Device_info::Platform::WHISKEYLAKE;
return Igd::Device_info::UNKNOWN;
}

/**********
Expand Down Expand Up @@ -994,13 +1013,14 @@ struct Igd::Device
*/
Device(Genode::Env &env,
Genode::Allocator &alloc,
Resources &resources)
Resources &resources,
Genode::Xml_node &supported)
:
_env(env), _md_alloc(alloc), _resources(resources)
{
using namespace Genode;

if (!_supported()) { throw Unsupported_device(); }
if (!_supported(supported)) { throw Unsupported_device(); }

/*
* IHD-OS-BDW-Vol 2c-11.15 p. 1068
Expand Down Expand Up @@ -1859,8 +1879,9 @@ struct Main
** Gpu **
*********/

Genode::Sliced_heap _root_heap { _env.ram(), _env.rm() };
Gpu::Root _gpu_root { _env, _root_heap };
Genode::Sliced_heap _root_heap { _env.ram(), _env.rm() };
Gpu::Root _gpu_root { _env, _root_heap };
Genode::Attached_rom_dataspace _config_rom { _env, "config" };

Genode::Heap _device_md_alloc { _env.ram(), _env.rm() };
Genode::Constructible<Igd::Device> _device { };
Expand All @@ -1873,27 +1894,46 @@ struct Main

Constructible<Platform::Root> _platform_root { };

Genode::Signal_handler<Main> _config_sigh {
_env.ep(), *this, &Main::_handle_config_update };

Main(Genode::Env &env)
:
_env(env)
{
_config_rom.sigh(_config_sigh);

/* IRQ */
_irq.sigh(_irq_dispatcher);
_irq.ack_irq();

/* GPU */
_handle_config_update();

/* platform service */
_platform_root.construct(_env, _device_md_alloc, _gpu_resources);
}

void _handle_config_update()
{
_config_rom.update();

if (!_config_rom.valid()) { return; }

if (_device.constructed()) {
Genode::log("gpu device already initialized - ignore");
return;
}

try {
_device.construct(_env, _device_md_alloc, _gpu_resources);
_device.construct(_env, _device_md_alloc, _gpu_resources, _config_rom.xml());
_gpu_root.manage(*_device);
_env.parent().announce(_env.ep().manage(_gpu_root));
} catch (Igd::Device::Unsupported_device) {
Genode::warning("No supported Intel GPU detected - no GPU service");
} catch (...) {
Genode::error("Unknown error occurred - no GPU service");
}

/* platform service */
_platform_root.construct(_env, _device_md_alloc, _gpu_resources);
}

void handle_irq()
Expand Down

0 comments on commit 895647a

Please sign in to comment.