From d85a448c52a9586a1ac5790a9025b1ad20f92cb4 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 24 Sep 2021 15:53:49 +0200 Subject: [PATCH] gpu/intel: provide supported devices as config Adjust drivers_managed and sculpt accordingly. Issue #4260 --- .../recipes/raw/drivers_managed-pc/content.mk | 5 +- repos/gems/run/sculpt.run | 6 + repos/gems/src/app/driver_manager/main.cc | 1 + repos/os/src/drivers/gpu/intel/gpu_drv.config | 11 ++ repos/os/src/drivers/gpu/intel/main.cc | 116 ++++++++++++------ 5 files changed, 100 insertions(+), 39 deletions(-) create mode 100644 repos/os/src/drivers/gpu/intel/gpu_drv.config diff --git a/repos/gems/recipes/raw/drivers_managed-pc/content.mk b/repos/gems/recipes/raw/drivers_managed-pc/content.mk index 30200aeb2d..864b024deb 100644 --- a/repos/gems/recipes/raw/drivers_managed-pc/content.mk +++ b/repos/gems/recipes/raw/drivers_managed-pc/content.mk @@ -1,5 +1,5 @@ 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/$@ $@ @@ -7,5 +7,8 @@ drivers.config numlock_remap.config event_filter.config: 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/$@ $@ diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run index 651c58b233..a21b4f481d 100644 --- a/repos/gems/run/sculpt.run +++ b/repos/gems/run/sculpt.run @@ -115,6 +115,7 @@ install_config { + @@ -255,6 +256,8 @@ install_config { + + @@ -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 \ diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc index 743775c242..72c7ae63b2 100644 --- a/repos/gems/src/app/driver_manager/main.cc +++ b/repos/gems/src/app/driver_manager/main.cc @@ -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); }); }); diff --git a/repos/os/src/drivers/gpu/intel/gpu_drv.config b/repos/os/src/drivers/gpu/intel/gpu_drv.config new file mode 100644 index 0000000000..cf4a9a53e3 --- /dev/null +++ b/repos/os/src/drivers/gpu/intel/gpu_drv.config @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/repos/os/src/drivers/gpu/intel/main.cc b/repos/os/src/drivers/gpu/intel/main.cc index 5e25c1c5ae..5f6b1ac98a 100644 --- a/repos/os/src/drivers/gpu/intel/main.cc +++ b/repos/os/src/drivers/gpu/intel/main.cc @@ -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 { @@ -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; @@ -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(8); - _pci_info(_supported_devices[i].descr); - return true; + _pci_info(desc.string()); + + found = true; + return; } - } - _pci_info(""); - 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; } /********** @@ -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 @@ -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 _device { }; @@ -1873,17 +1894,39 @@ struct Main Constructible _platform_root { }; + Genode::Signal_handler
_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) { @@ -1891,9 +1934,6 @@ struct Main } catch (...) { Genode::error("Unknown error occurred - no GPU service"); } - - /* platform service */ - _platform_root.construct(_env, _device_md_alloc, _gpu_resources); } void handle_irq()