#asahi-dev · 2023-08-07 09:03
eilncaught a race condition in the command submission iova space. whoops#asahi-dev · 2023-08-04 09:52
eilnjannau: thank you :) kernel dev is too hard#asahi-dev · 2023-08-04 09:34
eiln[ 27.563717] apple-isp: frame 63: meta_iova: 0x3a48000 luma_iova: 0x3a50000 chroma_iova: 0x3b34000#asahi-dev · 2023-08-04 09:34
eiln[ 27.304247] apple-isp: frame 62: meta_iova: 0x3a40000 luma_iova: 0x3d00000 chroma_iova: 0x3de4000#asahi-dev · 2023-08-04 09:34
eilnOk it streams (v4l2 compliant) now#asahi-dev · 2023-08-04 09:34
eilnfucking hell why did that nearly explode my brain#asahi-dev · 2023-08-04 09:34
eilnSo I can pass on the doorbell until the queue accumulates#asahi-dev · 2023-08-04 09:34
eilnThe index of the last dequeued buffer is re-queued#asahi-dev · 2023-08-04 09:34
eilnmarcan: Ohhh#asahi-dev · 2023-08-04 08:17
eilnmarcan: give me a few minutes I'll push the branch#asahi-dev · 2023-08-04 07:45
eilnthe buf being buf = list_first_entry_or_null(&video->buffers, struct aspeed_video_buffer, link);#asahi-dev · 2023-08-04 07:45
eilnin the irq I'd do vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); list_del(&buf->link); for both buffers#asahi-dev · 2023-08-04 07:44
eilnthat private list is the one I operate on#asahi-dev · 2023-08-04 07:43
eilnthe ioctl behind buf_queue is list_add_tail(&buf->link, &isp->buffers); #asahi-dev · 2023-08-04 07:42
eilntypo, ignore#asahi-dev · 2023-08-04 07:41
eilnwhich they can't if I'm blocking on the "one empty buffer in the queue" part#asahi-dev · 2023-08-04 07:41
eilnI only have one queue, p->queued list. I don't track done bufs. the user has to re-queue it into the queued list#asahi-dev · 2023-08-04 07:34
eilnempty buffers?#asahi-dev · 2023-08-04 07:34
eilnif i block#asahi-dev · 2023-08-04 07:33
eilnbatch count#asahi-dev · 2023-08-04 07:33
eilnsay the reqbufs count is 3. I'd mark two done, leaving me with 1 in the queue. but the user would typically only poll for one dequeue, and (logically) enqueue one more. there's now 2 in my queue, which I'd process both and send off. the user (again) dequeues one and enqueues another, leaving 1 in the queue. they'd hang on the next dequeue because we're not operating on the same#asahi-dev · 2023-08-04 07:32
eilnuser initally requests all buffers with VIDIOC_REQBUFS. that count I can modify/gurantee. after that, when stream starts, the driver marks the processed buffers and kicks them out of the queue. then those can be delivered to userspace polling with VIDIOC_DQBUF. most processes would use alternating enqueue/dequeue, which for the ISP is NOT 1 but the batch count.#asahi-dev · 2023-08-04 07:32
eilnmarcan: deadlock is the VIDIOC_DQBUF ioctl, which polls for one buf to be processed by the driver#asahi-dev · 2023-08-04 07:19
eilndelivery/dequeue are the same#asahi-dev · 2023-08-04 07:19
eilnones I process are marked done and out of the queue#asahi-dev · 2023-08-04 07:17
eiln** waits for me to process, which I'm blocking#asahi-dev · 2023-08-04 07:16
eilnthe buf_dq ioctl waits #asahi-dev · 2023-08-04 07:15
eilnif there's 6 in, I can process 2-6 at once. if i do 6, they'd pop one, and add one. the next dequeue would hang without a way to enqueue#asahi-dev · 2023-08-04 07:05
eilnyeah, mostly the interrupt/ack dance#asahi-dev · 2023-08-04 07:03
eilnshould I bother changing the batch count?#asahi-dev · 2023-08-04 07:03
eilnI'll definitely check with userspace#asahi-dev · 2023-08-04 07:01
eilnthat's only checked once before start_streaming is called#asahi-dev · 2023-08-04 06:58
eilnit's that I need 2 queued, which isn't a requirement anywhere#asahi-dev · 2023-08-04 06:56
eilnIt'd be stuck cause userspace polls till dequeue signal#asahi-dev · 2023-08-04 06:55
eilnthey can dequeue all four at once, then enqueue just one, which leaves me with 1 frame#asahi-dev · 2023-08-04 06:54
eilnunder read_frame in case IO_METHOD_MMAP, the user dequeues a (done) buffer, and enqueues another for processing#asahi-dev · 2023-08-04 06:53
eilnbut delivery is dequeue. http://www.infradead.org/~mchehab/kernel_docs/userspace-api/media/v4l/capture.c.html#asahi-dev · 2023-08-04 06:50
eilnafter starting the stream it's the user's job to re-queue to keep the stream going#asahi-dev · 2023-08-04 06:49
eilnreqbufs is called one-time before stream_start() afaik#asahi-dev · 2023-08-04 06:46
eilnbatch count is n=2, user queued 1, so the 2nd frame is the fallback#asahi-dev · 2023-08-04 06:44
eilnI can't just hang until the user queues another one, so rn I have a "fallback" second frame under kernel ownership, which wastes half of the work (but it's better than nothing)#asahi-dev · 2023-08-04 06:44
eilnfrom my understanding (limited) the only way to enforce the "at least 2" is by making up a fake format of 2 chroma & 2 luma (...)#asahi-dev · 2023-08-04 06:43
eilnthe problem is that it's minimum 2 frames, but I have no guarantees on the number of (user) queued buffers (because they're from users). past the limit (v4l2 max buf count is 32) I can at least split them into sub-batches#asahi-dev · 2023-08-04 06:43
eilnisp processes frames in batches (2 <= n <= 10), so all n frames are bundled up in a single doorbell / interrupt cycle. batch count can differ per cycle, macos usually uses 2 or 3, prolly their timing/scheduling algo#asahi-dev · 2023-08-04 06:43
eilnmarcan: I have a sw-eng question related to v4l2#asahi-dev · 2023-08-04 06:14
eiln^same, im on 6.3.0#asahi-dev · 2023-08-02 13:18
eilnI can't keep them always-on either. they have to be reset before kicking the firmware, which is fine for the first boot. on the second boot asc dies (unbootable, interrupts stuck, not even "last resort" EDPRCR works) & dart gets stuck in translation fault when trying to recycle pages.#asahi-dev · 2023-08-02 13:17
eilncalling reset without the 0xf0017ff/0x7ff intermediate states (so just w32 0x0) makes the isp range inaccessible, so I get a MMIO fault on the deassert#asahi-dev · 2023-08-02 13:17
eilnisp pds aren't described in the device tree, just a fat range [0x23b700000, 0x8C000] (the entire pmgr range) in the isp node from which the h13cam kext works with. btw there's 12 power domains#asahi-dev · 2023-08-02 13:17
eilnmarcan: the first three isp power domains need bespoke handling. the three need 0xf0017ff, 0xf0017ff, and 0x7ff written before powering off (as normal) with 0x0.