#
✕ nick:sven
#asahi-dev · 2022-10-23 11:17
svenso essentially stuffing the currently active domain into the group data on attach and then only syncing to the locked table in attach/flush/inval should work for locked darts
#asahi-dev · 2022-10-23 11:16
svenok
#asahi-dev · 2022-10-23 11:16
svenah
#asahi-dev · 2022-10-23 11:12
sventhat makes sense
#asahi-dev · 2022-10-23 11:11
svenhuh, I wonder if that's intentional or a bug inside the iommu core
#asahi-dev · 2022-10-23 11:09
svenyou could probably stash the currently active domain into the group data and only do the l0 sync in flush/invalidate if domain == get_group(dev)->domain
#asahi-dev · 2022-10-23 11:08
svenso for the default domain detach is never called?
#asahi-dev · 2022-10-23 11:08
svenoh.. true
#asahi-dev · 2022-10-23 11:08
svenand then only the flush/invalidate callback moves the required pointers to the real l0
#asahi-dev · 2022-10-23 11:07
svenand iopgtbl only writes to that
#asahi-dev · 2022-10-23 11:07
svenfor each domain you always have a valid allocated shadow-l0
#asahi-dev · 2022-10-23 11:07
svenwhy?
#asahi-dev · 2022-10-23 11:06
sven(maybe s/L0/L1/, i don't remember the terminology. in the above line L0 = "first level pagetable that sits in memory and is configured in the locked TTBR register")
#asahi-dev · 2022-10-23 11:05
sventhen device attach is just "memcpy(locked-l0, domain-l0)" and each domain has its own domain-l0
#asahi-dev · 2022-10-23 11:05
svenyou can even optimize that with the flush/invalidate callbacks to only memcpy the required entries
#asahi-dev · 2022-10-23 11:04
svenone way around this for locked darts is to have a shadow copy of the L0 pagetable that's used by iopgtbl the entire time and not memmap anything. then whenever there's a map/unmap you just memcpy(locked-l0, shadow-l0)
#asahi-dev · 2022-10-23 11:03
svenand creating mappings in unattached domains is totally fine
#asahi-dev · 2022-10-23 11:03
svendma_map_sgtable will just create a mapping in the default domain that's not attached anymore
#asahi-dev · 2022-10-23 11:03
svenah
#asahi-dev · 2022-10-23 10:59
svenbut that’s also related to the part where the dart driver has to hack around the iommu so it’s quite possible I messed that up
#asahi-dev · 2022-10-23 10:58
svenonly the currently attached domain should be able to write there
#asahi-dev · 2022-10-23 10:58
svennow that sounds broken
#asahi-dev · 2022-10-23 10:48
svenso they shouldn’t appear in the unmanaged domain
#asahi-dev · 2022-10-23 10:48
svenhuh, dma_map_sgtable should go through the dma-api code and create the mapping there
#asahi-dev · 2022-10-23 10:32
svenisn't attach_dev called from attach group eventually?
#asahi-dev · 2022-10-23 10:26
sven(the iommu api is a bit confusing because dart has to hack around it quite a bit. this will all get better once robin's cleanup series is done)
#asahi-dev · 2022-10-23 10:24
sven+which
#asahi-dev · 2022-10-23 10:23
svenand it's perfectly fine to have two domains with valid mappings to you keep switching
#asahi-dev · 2022-10-23 10:23
sventechnically a domain doesn't need to know about which devices it will be attached to
#asahi-dev · 2022-10-23 10:23
svendomain really just means "pagetables with some mappings"
#asahi-dev · 2022-10-23 10:23
sveni'm more concerned that sysfs still shows DMA after attaching the unmanaged domain
#asahi-dev · 2022-10-23 10:22
svenyeah, but that's by design
#asahi-dev · 2022-10-23 10:16
svenvfio more or less does the same thing: create a domain and then attach a device to it that probably still had the default dma domain
#asahi-dev · 2022-10-23 10:15
svenand also something that should already work tbh
#asahi-dev · 2022-10-23 10:15
svenand something that can be easily caught in the iommu core
#asahi-dev · 2022-10-23 10:15
svenit just sounds like an issue every driver would have
#asahi-dev · 2022-10-23 10:11
svenit knows which device belongs to which group and shouldn’t allow a group to be attached to two domains
#asahi-dev · 2022-10-23 10:11
sventhis sounds like something the iommu api should enforce tbh
#asahi-dev · 2022-10-23 10:10
svenhm, weird
#asahi-dev · 2022-10-23 10:07
svenAnd I assume dart_attach_dev succeeded?
#asahi-dev · 2022-10-23 10:03
sven*attach
#asahi-dev · 2022-10-23 10:02
svenDoesnt the iommu api look up the piodma group and then just switches the domain on attack for that group?
#asahi-dev · 2022-10-23 10:01
svenuhh… maybe. Not sure if that’s indirectly enforced by the iommu groups
#asahi-dev · 2022-10-22 18:34
svennice! then I should be able to just rebase my dptx hacks on top of that from now
#asahi-dev · 2022-10-22 16:17
svenprobably just something on the dptx side broken, I remember I had this state with my python code as well at some point
#asahi-dev · 2022-10-22 16:15
svenlet's see
#asahi-dev · 2022-10-22 16:15
svenshows dcpext as connected but without any modes afaict
#asahi-dev · 2022-10-22 15:39
sveni'm at "[ 9.970618] apple-dcp 271c00000.dcp: dcp_hotplug: connected: 1" now after your fixes
#asahi-dev · 2022-10-22 15:39
svenjannau: so.. this is gonna sound dumb, but uh, how do I get dcp to actually set a mode?
#asahi-dev · 2022-10-22 15:17
svenjannau: https://f.svpe.de/91daefa55a757c4a658603341f67a012ca79cc5b1660f58b532308b1d3539fe5_0001-fixup-gpu-drm-apple-Start-using-tracepoints.patch those are the additional tracepoints I had

plus ›