Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] media: ipu3-cio2: shared DMA channel collision when dma_per_port is false
- [High] media: ipu3-cio2: chan_queue teardown race with cio2_irq_handle_once()
- [Low] media: ipu3-cio2: missing kernel-parameters.txt entry for dma_per_port
--
commit 34ff9744226d47c42d694c1913c34a92643aae69
Author: Joe Dzado <joe.dzado(a)icloud.com>
media: ipu3-cio2: give each CSI-2 port its own DMA channel
This commit maps each CSI-2 port queue to an even-numbered DMA channel
(2 * port) so multiple sensors can stream concurrently without sharing
interrupt bits, and adds a dma_per_port module parameter (default true) to
allow restoring the single-channel behavior.
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 071c5ea4af042..f92ac401047be 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -350,10 +350,18 @@ static int cio2_csi2_calc_timing(struct cio2_device *cio2, struct cio2_queue *q,
> return 0;
> };
>
> -/* Each queue (CSI-2 port) owns one DMA channel. */
> +/*
> + * Each queue (CSI-2 port) gets its own DMA channel so several sensors can stream at once.
> + * Channels 0, 2, 4, 6: IOS interrupt bits are shared by channel pairs (0/1, 2/3, ...) and
> + * IOC bits by pairs above 3, so even channels keep every queue's interrupts distinct.
> + */
> +static bool dma_per_port = true;
> +module_param(dma_per_port, bool, 0444);
> +MODULE_PARM_DESC(dma_per_port, "Use a DMA channel per CSI-2 port (allows concurrent streams)");
[Severity: Low]
Since dma_per_port can be set on the kernel command line at boot as
ipu3-cio2.dma_per_port, should this parameter also be documented in
Documentation/admin-guide/kernel-parameters.txt?
> +
> static unsigned int cio2_queue_dma_chan(unsigned int port)
> {
> - return CIO2_DMA_CHAN;
> + return dma_per_port ? 2 * port : CIO2_DMA_CHAN;
> }
[Severity: High]
When dma_per_port is set to false, cio2_queue_dma_chan() assigns
CIO2_DMA_CHAN (channel 0) to every queue in cio2_queue_init(). Because each
struct cio2_queue has its own vb2_queue lock and media_pipeline, user space
can still call VIDIOC_STREAMON on a second queue while a first queue is
already streaming on channel 0.
In drivers/media/pci/intel/ipu3/ipu3-cio2.c:cio2_vb2_start_streaming():
mutex_lock(&cio2->hw_lock);
cio2->chan_queue[q->dma_chan] = q;
r = cio2_hw_init(cio2, q);
if (r) {
cio2->chan_queue[q->dma_chan] = NULL;
mutex_unlock(&cio2->hw_lock);
goto fail_hw;
}
And in cio2_hw_init() when another stream is already active (!first):
} else {
writel(0, base + CIO2_REG_CDMABA(chan));
writel(0, base + CIO2_REG_CDMAC0(chan));
writel(0, base + CIO2_REG_CDMAC1(chan));
}
/* Enable DMA */
writel(PFN_DOWN(q->fbpt_bus_addr), base + CIO2_REG_CDMABA(chan));
Doesn't starting a second stream with dma_per_port=false overwrite
cio2->chan_queue[0], reset and reprogram channel 0's DMA registers while the
first stream is actively transferring, and clear cio2->chan_queue[0] to NULL
(or halt channel 0 in cio2_hw_exit()) if the second stream fails or stops?
Should cio2_vb2_start_streaming() reject starting a stream with -EBUSY when
cio2->chan_queue[q->dma_chan] is already non-NULL?
[Severity: High]
With concurrent streaming enabled across multiple CSI-2 ports, can tearing
down one stream in cio2_vb2_stop_streaming() (or the fail_csi2_subdev path of
cio2_vb2_start_streaming()) race with cio2_irq() -> cio2_irq_handle_once()
running for another active stream or a already-latched status bit?
In drivers/media/pci/intel/ipu3/ipu3-cio2.c:cio2_vb2_stop_streaming():
mutex_lock(&cio2->hw_lock);
cio2_hw_exit(cio2, q);
synchronize_irq(cio2->pci_dev->irq);
cio2->chan_queue[q->dma_chan] = NULL;
cio2->streaming--;
q->streaming = false;
mutex_unlock(&cio2->hw_lock);
cio2_vb2_return_all_buffers(q, VB2_BUF_STATE_ERROR);
cio2_hw_exit() clears CIO2_INT_IOC(chan) and CIO2_REG_INT_EN_IOS(chan) in
CIO2_REG_INT_EN, but does not clear pending status bits for chan in
CIO2_REG_INT_STS. In addition, synchronize_irq() is called before
cio2->chan_queue[q->dma_chan] is set to NULL.
When another port is actively streaming (or on the shared PCI IRQ line), a new
cio2_irq() invocation can start right after synchronize_irq() returns, read
CIO2_REG_INT_STS without masking against CIO2_REG_INT_EN, and run
cio2_irq_handle_once() while cio2->chan_queue[d] is being cleared:
if (int_status & CIO2_INT_IOC_MASK) {
...
for (d = 0; d < CIO2_NUM_DMA_CHAN; d++)
if (int_status & CIO2_INT_IOC(d)) {
clr |= CIO2_INT_IOC(d);
if (cio2->chan_queue[d])
cio2_buffer_done(cio2, d);
}
int_status &= ~clr;
}
if (int_status & CIO2_INT_IOS_IOLN_MASK) {
...
for (d = 0; d < CIO2_NUM_DMA_CHAN; d++)
if (int_status & CIO2_INT_IOS_IOLN(d)) {
clr |= CIO2_INT_IOS_IOLN(d);
if (cio2->chan_queue[d])
cio2_queue_event_sof(cio2,
cio2->chan_queue[d]);
}
int_status &= ~clr;
}
If cio2->chan_queue[d] becomes NULL between the if check and the argument load
for cio2_queue_event_sof(), won't cio2_queue_event_sof() dereference a NULL q
pointer in hardirq context? And if cio2_irq_handle_once() enters
cio2_buffer_done() after synchronize_irq() has already returned, can it race
with cio2_vb2_return_all_buffers() on q->bufs[] and complete the same vb2
buffer twice?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261031002332.33609-1-joe.dzado@icloud.com?…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] media: iris: open() still consumes session slots and breaks excess fds
- [High] media: iris: unvalidated over-limit session in iris_vb2_queue_setup()
--
commit 6a8f319e4b9cd5a700661289888d2d1a56ebd898
Author: Vishnu Reddy <busanna.reddy(a)oss.qualcomm.com>
Revert "media: iris: reject open() when the session limit is reached"
This commit reverts commit 397ebadcbc21 so that iris_open() no longer returns
-EBUSY when the number of open instances reaches max_session_count, relying
instead on iris_check_session_supported() to reject excess instances later.
Link: https://github.com/gjasny/v4l-utils/blob/master/utils/v4l2-compliance/v4l2-…
> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
> index 05aab6e3005d5..a27db6cd969a6 100644
> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
> @@ -56,23 +56,21 @@ void iris_inst_put(struct iris_inst *inst)
> kref_put(&inst->kref, iris_inst_release);
> }
>
> -static int iris_add_session(struct iris_inst *inst)
> +static void iris_add_session(struct iris_inst *inst)
> {
> struct iris_core *core = inst->core;
> struct iris_inst *iter;
> u32 count = 0;
>
> - guard(mutex)(&core->lock);
> + mutex_lock(&core->lock);
>
> list_for_each_entry(iter, &core->instances, list)
> count++;
>
> - if (count >= core->iris_platform_data->max_session_count)
> - return -EBUSY;
> -
> - list_add_tail(&inst->list, &core->instances);
> + if (count < core->iris_platform_data->max_session_count)
> + list_add_tail(&inst->list, &core->instances);
>
> - return 0;
> + mutex_unlock(&core->lock);
> }
[Severity: High]
When count >= core->iris_platform_data->max_session_count, iris_add_session()
silently leaves inst off core->instances while inst->state remains
IRIS_INST_DEINIT.
The commit message notes that iris_check_session_supported() rejects such an
instance in iris_vb2_queue_setup() and iris_vb2_start_streaming(). However,
if userspace allocates buffers via VIDIOC_CREATE_BUFS instead of
VIDIOC_REQBUFS, v4l2_m2m_ioctl_create_bufs() -> vb2_create_bufs() ->
vb2_core_create_bufs() calls iris_vb2_queue_setup() with *num_planes != 0:
drivers/media/platform/qcom/iris/iris_vb2.c:iris_vb2_queue_setup() {
...
if (*num_planes) {
if (*num_planes != f->fmt.pix_mp.num_planes ||
sizes[0] < f->fmt.pix_mp.plane_fmt[0].sizeimage)
ret = -EINVAL;
goto unlock;
}
ret = iris_check_session_supported(inst);
if (ret)
goto unlock;
if (!inst->once_per_session_set) {
inst->once_per_session_set = true;
ret = inst->hfi_session_ops->session_open(inst);
...
}
Because the if (*num_planes) branch jumps to unlock with ret = 0 before
calling iris_check_session_supported(inst) or session_open(inst), buffer
allocation succeeds for the untracked instance without opening a firmware
session.
If userspace then calls VIDIOC_STREAMON, iris_vb2_start_streaming() fails
iris_check_session_supported(inst) and jumps to error, which transitions
inst->state from IRIS_INST_DEINIT to IRIS_INST_ERROR:
drivers/media/platform/qcom/iris/iris_vb2.c:iris_vb2_start_streaming() {
...
ret = iris_check_session_supported(inst);
if (ret)
goto error;
...
error:
iris_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED);
iris_inst_change_state(inst, IRIS_INST_ERROR);
mutex_unlock(&inst->lock);
}
When the file descriptor is subsequently closed, iris_close() ->
iris_session_close() checks only for IRIS_INST_DEINIT:
drivers/media/platform/qcom/iris/iris_vidc.c:iris_session_close() {
...
if (inst->state == IRIS_INST_DEINIT)
return;
reinit_completion(&inst->completion);
ret = hfi_ops->session_close(inst);
if (ret)
wait_for_response = false;
if (wait_for_response)
iris_wait_for_session_response(inst, false);
}
Since inst->state is now IRIS_INST_ERROR, won't iris_session_close() send a
firmware session_close command for a session that was never opened and block
in iris_wait_for_session_response() until the hardware response timeout?
>
> static void iris_remove_session(struct iris_inst *inst)
> @@ -223,17 +221,12 @@ int iris_open(struct file *filp)
> if (ret)
> goto fail_m2m_ctx_release;
>
> - ret = iris_add_session(inst);
> - if (ret)
> - goto fail_inst_deinit;
> + iris_add_session(inst);
[Severity: High]
Because iris_add_session(inst) is still called only during iris_open(), every
open file descriptor (even an idle one opened only to query capabilities or
formats) is added to core->instances until max_session_count is reached, and
its default format and frame rate are counted against the core workload
limits in iris_check_core_mbpf() and iris_check_core_mbps().
At the same time, any file descriptor opened while max_session_count file
descriptors are already open is skipped by iris_add_session() and never added
to core->instances later, even if all earlier file descriptors are closed
before streaming starts. That causes iris_check_session_supported() to
permanently fail with -EINVAL for that file descriptor:
drivers/media/platform/qcom/iris/iris_vb2.c:iris_check_session_supported() {
...
mutex_lock(&core->lock);
list_for_each_entry(instance, &core->instances, list) {
if (instance == inst) {
found = true;
break;
}
}
mutex_unlock(&core->lock);
if (!found) {
ret = -EINVAL;
goto exit;
}
...
}
Should adding the instance to core->instances (and enforcing
max_session_count) happen when a firmware session is actually created in
iris_vb2_queue_setup() rather than in iris_open(), so that idle file
descriptors do not consume session slots or permanently break file
descriptors opened while the limit was reached?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261031-fix_v4l2_compliance_unlimited_opens…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] media: iris: omitted TIER .set removal in Milos and AR50LT Gen2 caps
- [Low] media: iris: inaccurate commit message on TIER loop order
--
commit 793d5ec374491466f1f3da42782dea0e0ac28038
Author: Vishnu Reddy <busanna.reddy(a)oss.qualcomm.com>
media: iris: Skip redundant HFI_PROP_TIER updates
This commit removes the .set callbacks from the TIER and TIER_AV1
capabilities in inst_fw_cap_sm8550_dec[] so that iris_set_properties()
does not redundantly reprogram HFI_PROP_TIER after
iris_hfi_gen2_set_tier() has already configured it for the active codec.
> media: iris: Skip redundant HFI_PROP_TIER updates
>
> HFI_PROP_TIER is already programmed by iris_hfi_gen2_set_tier(), which
> selects TIER or TIER_AV1 based on the active codec. The TIER and TIER_AV1
> caps also define a .set callback. As a result, iris_set_properties()
> programs HFI_PROP_TIER again through the generic cap path.
>
> The generic property loop sets TIER first and TIER_AV1 last. For non AV1
> codecs, the TIER_AV1 property is programmed after the correct tier value
> and overrides it. Remove the .set callbacks from both caps. This ensures
> HFI_PROP_TIER is programmed only once with the value for the active codec.
>
> Fixes: 2af481a459a4 ("media: iris: Define AV1-specific platform capabilities and properties")
> Cc: stable(a)vger.kernel.org
> Signed-off-by: Vishnu Reddy <busanna.reddy(a)oss.qualcomm.com>
[Severity: Low]
Is the commit message description of the generic property loop order
accurate?
Although TIER appears before TIER_AV1 in inst_fw_cap_sm8550_dec[],
iris_session_init_caps() stores capabilities in core->inst_fw_caps_dec[]
indexed by cap_id from enum platform_inst_fw_cap_type in
drivers/media/platform/qcom/iris/iris_platform_common.h:
PROFILE_AV1,
LEVEL_AV1,
TIER_AV1,
...
TIER,
When iris_set_properties() in drivers/media/platform/qcom/iris/iris_ctrls.c
iterates from 1 to INST_FW_CAP_MAX - 1, it visits TIER_AV1 before TIER.
It appears TIER_AV1 overrode the HEVC tier because
iris_hfi_gen2_set_tier() programmed HFI_PROP_TIER on HFI_PORT_BITSTREAM
earlier during session_set_config_params, and TIER_AV1 (which has
CAP_FLAG_INPUT_PORT, mapping to HFI_PORT_BITSTREAM on decoders) overwrote
HFI_PROP_TIER on HFI_PORT_BITSTREAM with 0, whereas TIER (which has
CAP_FLAG_OUTPUT_PORT, mapping to HFI_PORT_RAW on decoders) sent its update
to HFI_PORT_RAW.
Could the commit message be updated to reflect the actual order and port
behavior?
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> index 79bbd06ef8d2b..6888aecec902a 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2.c
> @@ -997,7 +997,6 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
> .value = V4L2_MPEG_VIDEO_HEVC_TIER_HIGH,
> .hfi_id = HFI_PROP_TIER,
> .flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
> - .set = iris_set_u32_enum,
> },
[Severity: Medium]
Should .set = iris_set_u32_enum also be removed from the TIER capability in
inst_fw_cap_milos_dec[] and inst_fw_cap_gen2_ar50lt_dec[] in
drivers/media/platform/qcom/iris/iris_hfi_gen2.c?
Both iris_hfi_milos_data and iris_hfi_gen2_ar50lt_data use
iris_hfi_gen2_sys_ops_init and sm8550_vdec_input_config_param_hevc, which
already programs HFI_PROP_TIER via
iris_hfi_gen2_session_set_config_params() -> iris_hfi_gen2_set_tier().
However, inst_fw_cap_milos_dec[] and inst_fw_cap_gen2_ar50lt_dec[] still
retain .set = iris_set_u32_enum on TIER:
{
.cap_id = TIER,
.min = V4L2_MPEG_VIDEO_HEVC_TIER_MAIN,
.max = V4L2_MPEG_VIDEO_HEVC_TIER_HIGH,
.step_or_mask = BIT(V4L2_MPEG_VIDEO_HEVC_TIER_MAIN) |
BIT(V4L2_MPEG_VIDEO_HEVC_TIER_HIGH),
.value = V4L2_MPEG_VIDEO_HEVC_TIER_HIGH,
.hfi_id = HFI_PROP_TIER,
.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
.set = iris_set_u32_enum,
},
When decoder streaming starts on Milos or Gen2 AR50LT,
iris_set_properties() will still invoke iris_set_u32_enum() through the
generic capability loop, programming HFI_PROP_TIER a second time on
HFI_PORT_RAW for HEVC and sending HFI_PROP_TIER unconditionally for
non-HEVC codecs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261031-fix_dec_seek-v1-0-cfedf0c267ee@oss.…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] media: siano: media_device leak and dangling device on smsdvb_hotplug() error
- [High] media: siano: use-after-free due to early unregister in smsdvb_hotplug()
--
commit b01f385798ad9458ef99b84831296b12265ba08b
Author: Guangshuo Li <liguangshuo(a)mail.sdu.edu.cn>
media: siano: Fix potential use-after-free on graph failure
This commit unregisters the smscore client on the dvb_create_media_graph()
error path in smsdvb_hotplug() and removes smsdvb_media_device_unregister()
from the error cleanup path.
> diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
> index 415c24fbbb652..664868627bf59 100644
> --- a/drivers/media/common/siano/smsdvb-main.c
> +++ b/drivers/media/common/siano/smsdvb-main.c
> @@ -1217,6 +1217,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
> mutex_unlock(&g_smsdvb_clientslock);
>
> smsdvb_debugfs_release(client);
> + smscore_unregister_client(client->smsclient);
[Severity: High]
Can calling smscore_unregister_client(client->smsclient) before
dvb_unregister_frontend() and dvb_dmxdev_release() cause a use-after-free
of client->smsclient?
In smsdvb_hotplug(), dvb_dmxdev_init() and dvb_register_frontend() register
the device nodes and expose them to userspace before dvb_create_media_graph()
is called. Once exposed, userspace processes can open frontend0 or demux0,
starting the frontend thread, issuing frontend ioctls (such as
smsdvb_read_status() or smsdvb_set_frontend()), or starting demux feeds via
smsdvb_start_feed().
When dvb_create_media_graph() fails, smscore_unregister_client() immediately
frees client->smsclient via kfree() while leaving client->smsclient as a
non-NULL dangling pointer:
drivers/media/common/siano/smscoreapi.c:smscore_unregister_client() {
...
list_del(&client->entry);
kfree(client);
...
}
Because dvb_unregister_frontend() and dvb_dmxdev_release() run after
smscore_unregister_client(), any active frontend thread or ioctl, or any open
demux file descriptor whose close is awaited by dvb_dmxdev_release() and
calls dvb_demux_release() -> dvb_dmxdev_filter_free() ->
dvb_dmxdev_filter_stop() -> smsdvb_stop_feed(), will invoke
smsclient_sendrequest(client->smsclient, ...) on the already-freed
client->smsclient.
In addition, in smscore_onresponse(), smscore_find_client() drops
coredev->clientslock before returning the client pointer and invoking
client->onresponse_handler(client->context, cb). Since transport streaming is
already active before smsdvb_hotplug() runs, unregistering and freeing client
here can also race with an in-flight smsdvb_onresponse(client, cb) call.
>
> client_error:
> dvb_unregister_frontend(&client->frontend);
> @@ -1228,7 +1229,6 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
> dvb_dmx_release(&client->demux);
>
> dvbdmx_error:
> - smsdvb_media_device_unregister(client);
[Severity: High]
Does removing smsdvb_media_device_unregister(client) here leak
coredev->media_dev and leave a dangling media_device registered when
smsdvb_hotplug() is invoked from module load?
The commit message notes that the USB probe error path releases the media
device, which happens when smsdvb_hotplug() is called synchronously via
smsusb_init_device() -> smscore_start_device(). However, in smsusb_probe(),
smsusb_init_device() completes before sms_board_load_modules() requests the
smsdvb module:
drivers/media/usb/siano/smsusb.c:smsusb_probe() {
...
} else {
rc = smsusb_init_device(intf, id->driver_info);
}
pr_info("Device initialized with return code %d\n", rc);
sms_board_load_modules(id->driver_info);
return rc;
}
When smsdvb is loaded then (or later via modprobe), smsdvb_module_init()
calls smscore_register_hotplug(smsdvb_hotplug), which invokes
smsdvb_hotplug() for each existing coredev after smsusb_init_device() has
already succeeded:
drivers/media/common/siano/smscoreapi.c:smscore_register_hotplug() {
...
for (next = first->next;
next != first && !rc;
next = next->next) {
struct smscore_device_t *coredev =
(struct smscore_device_t *) next;
rc = hotplug(coredev, coredev->device, 1);
}
...
}
If smsdvb_hotplug() fails on that path, smsusb_init_device()'s
err_unregister_device label does not run. Because client->smsclient has been
unregistered, coredev->clients is empty, and neither smsusb_term_device() nor
smscore_unregister_device() cleans up coredev->media_dev (which is normally
cleaned up only via smscore_notify_clients() -> smsdvb_onremove() ->
smsdvb_unregister_client() -> smsdvb_media_device_unregister()). When the USB
device is later disconnected, coredev and the underlying usb_device are freed
while coredev->media_dev remains registered in the kernel.
Even on the synchronous USB probe failure path where smsusb_init_device()
jumps to err_unregister_device, that path calls media_device_unregister(mdev)
and kfree(mdev) without calling media_device_cleanup(mdev), whereas
smsdvb_media_device_unregister() called media_device_cleanup() to free the
internal media_device resources initialized during entity registration.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1793377439.media.git.liguangshuo@mail.…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: media: hawi-camss missing required data-lanes in endpoint
- [Low] dt-bindings: media: hawi-camss example unit-address mismatches first reg
--
commit 97b880fd3cf2adf2e5bdc34dc34d8524f1dd635b
Author: Hangxiang Ma <hangxiang.ma(a)oss.qualcomm.com>
dt-bindings: media: Add CAMSS device for Hawi and Maili
This commit adds the Device Tree binding schema for the Camera Subsystem
(CAMSS) on the Qualcomm Hawi and Maili platforms.
> diff --git a/Documentation/devicetree/bindings/media/qcom,hawi-camss.yaml b/Documentation/devicetree/bindings/media/qcom,hawi-camss.yaml
> new file mode 100644
> index 0000000000000..32c1cc59e8767
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/qcom,hawi-camss.yaml
> @@ -0,0 +1,314 @@
[ ... ]
> + patternProperties:
> + "^port@[0-5]$":
> + $ref: /schemas/graph.yaml#/$defs/port-base
> + unevaluatedProperties: false
> + description:
> + Input ports for receiving CSI data on CSIPHY 0-5.
> +
> + properties:
> + endpoint:
> + $ref: video-interfaces.yaml#
> + unevaluatedProperties: false
> +
> + properties:
> + data-lanes:
> + minItems: 1
> + maxItems: 4
> +
> + bus-type:
> + enum:
> + - 1 # MEDIA_BUS_TYPE_CSI2_CPHY
> + - 4 # MEDIA_BUS_TYPE_CSI2_DPHY
[Severity: Medium]
As reported by Sashiko on v2 [1], should the endpoint schema under
patternProperties ^port@[0-5]$ include a required list specifying data-lanes,
matching sibling bindings such as qcom,kaanapali-camss.yaml and
qcom,x1e80100-camss.yaml?
During driver probe, camss_parse_endpoint_node() in
drivers/media/platform/qcom/camss/camss.c calls v4l2_fwnode_endpoint_parse()
on each port@[0-5] endpoint. When bus-type is omitted and data-lanes is
absent, v4l2_fwnode_endpoint_parse() does not detect a CSI-2 D-PHY bus and
camss_parse_endpoint_node() fails with -EINVAL. Even when bus-type is
explicitly set to D-PHY (4), omitting data-lanes leaves lncfg->num_data as 0,
causing csiphy_stream_on() in drivers/media/platform/qcom/camss/camss-csiphy.c
to fail phy_mipi_dphy_get_default_config_for_hsclk() with -EINVAL.
[ ... ]
> + soc {
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + isp@9253000 {
> + compatible = "qcom,hawi-camss";
> +
> + reg = <0x0 0x0900b000 0x0 0x1000>,
> + <0x0 0x09253000 0x0 0x5e80>,
[Severity: Low]
Should the node unit-address in the example be isp@900b000 instead of
isp@9253000?
The first reg entry (top) is at 0x0900b000, while 0x09253000 is the second
reg entry (csid0). Running make dt_binding_check triggers a dtc
simple_bus_reg warning when the node unit-address does not match the first
reg address.
[1] https://lore.kernel.org/r/20261013-hawi-maili-camss-v2-3-fc93222da89c@oss.q…
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030-hawi-maili-camss-v3-0-9742bca8cef2@…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dt-bindings: i2c: qcom,hawi-cci falls back to qcom,msm8996-cci
--
commit d9dc73bf069c6c548fe2a696e7ecbd69ab96e3f3
Author: Hangxiang Ma <hangxiang.ma(a)oss.qualcomm.com>
dt-bindings: i2c: qcom,i2c-cci: Add Hawi compatible
This commit documents the Camera Control Interface (CCI) compatible string
qcom,hawi-cci for the Qualcomm Hawi platform and adds it to the two-clock
constraint list in Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml.
> diff --git a/Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml b/Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml
> index 1e8def25ec0ec..b2b4d4bcf7807 100644
> --- a/Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml
> +++ b/Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml
> @@ -27,6 +27,7 @@ properties:
> - items:
> - enum:
> - qcom,glymur-cci
> + - qcom,hawi-cci
> - qcom,kaanapali-cci
> - qcom,milos-cci
> - qcom,qcm2290-cci
[Severity: Medium]
As reported by Loic Poulain on v1 [1], adding qcom,hawi-cci to this enum list
under properties:compatible in
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml requires device tree
nodes to specify qcom,msm8996-cci as a fallback compatible:
- items:
- enum:
- qcom,glymur-cci
- qcom,hawi-cci
...
- const: qcom,msm8996-cci # CCI v2
When a Hawi CCI controller node is probed via cci_probe() in
drivers/i2c/busses/i2c-qcom-cci.c, device_get_match_data() matches the
fallback entry in cci_dt_match[] and binds the controller to the legacy
cci_v2_data configuration:
static const struct cci_data cci_v2_data = {
.num_masters = 2,
.queue_size = { 64, 16 },
.quirks = {
.max_write_len = 11,
.max_read_len = 12,
},
.max_mode = I2C_MODE_FAST_PLUS,
};
static const struct of_device_id cci_dt_match[] = {
...
{ .compatible = "qcom,msm8996-cci", .data = &cci_v2_data},
Since newer CCI IP revisions have different hardware resources such as FIFO
and queue sizes, should qcom,hawi-cci stop falling back to qcom,msm8996-cci
and instead use a dedicated variant entry rather than reusing the msm8996
definition?
[1] https://lore.kernel.org/r/CAFEp6-1Zvt0hhBd7LNx2hsyi9J+bxCT8EWN3jZ4B30SO58SC…
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030-hawi-maili-camss-v3-0-9742bca8cef2@…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] media: i2c: os05b10: unnormalized mbus code and dev_err() in get_mode_table()
- [Medium] media: i2c: os05b10: fmt->code not updated on flip in os05b10_set_ctrl()
--
commit aad88eee35c09bdb383f88435aa6b1dc60529ac0
Author: Tarang Raval <tarang.raval(a)siliconsignals.io>
media: i2c: os05b10: add 12-bit RAW mode support
This commit adds 12-bit Bayer RAW mode support to the OS05B10 sensor driver by
introducing a 12-bit mode table, extending the enumerated media bus codes, and
selecting the mode table based on the media bus format.
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 48c9051659548..ba6a22ced3dba 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
[ ... ]
> @@ -565,6 +599,34 @@ static int os05b10_update_test_pattern(struct os05b10 *os05b10, u32 pattern)
> os05b10_tp_val[pattern], NULL);
> }
>
> +static int get_mode_table(struct os05b10 *os05b10, unsigned int code,
> + const struct os05b10_mode **mode_list,
> + unsigned int *num_modes)
> +{
> + switch (code) {
> + case MEDIA_BUS_FMT_SBGGR12_1X12:
> + case MEDIA_BUS_FMT_SGBRG12_1X12:
> + case MEDIA_BUS_FMT_SGRBG12_1X12:
> + case MEDIA_BUS_FMT_SRGGB12_1X12:
> + *mode_list = supported_modes_12bit;
> + *num_modes = ARRAY_SIZE(supported_modes_12bit);
> + return 0;
> +
> + case MEDIA_BUS_FMT_SBGGR10_1X10:
> + case MEDIA_BUS_FMT_SGBRG10_1X10:
> + case MEDIA_BUS_FMT_SGRBG10_1X10:
> + case MEDIA_BUS_FMT_SRGGB10_1X10:
> + *mode_list = supported_modes_10bit;
> + *num_modes = ARRAY_SIZE(supported_modes_10bit);
> + return 0;
> +
> + default:
> + dev_err(os05b10->dev,
> + "Unsupported media bus format: %#x\n", code);
> + return -EINVAL;
> + }
> +}
> +
> static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
> {
> struct os05b10 *os05b10 = container_of_const(ctrl->handler,
> @@ -625,7 +687,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
> if (ret)
> break;
>
> - fmt->code = os05b10_get_format_code(os05b10);
> + fmt->code = os05b10_get_format_code(os05b10, fmt->code);
> break;
> case V4L2_CID_TEST_PATTERN:
> ret = os05b10_update_test_pattern(os05b10, ctrl->val);
[Severity: Medium]
When userspace updates V4L2_CID_HFLIP or V4L2_CID_VFLIP while the sensor is
idle, will fmt->code in the active pad state remain stale?
In drivers/media/i2c/os05b10.c, os05b10_enable_streams() grabs both flip
controls while streaming is active:
__v4l2_ctrl_grab(os05b10->vflip, true);
__v4l2_ctrl_grab(os05b10->hflip, true);
Because of this, userspace can only change V4L2_CID_HFLIP or V4L2_CID_VFLIP
when the sensor is not streaming and is runtime-suspended. However,
os05b10_set_ctrl() checks pm_runtime_get_if_in_use() and returns early before
reaching the switch statement that updates fmt->code:
if (pm_runtime_get_if_in_use(os05b10->dev) == 0)
return 0;
Should fmt->code = os05b10_get_format_code(os05b10, fmt->code) be updated
before the pm_runtime_get_if_in_use() check (similar to how V4L2_CID_VBLANK
updates the exposure range above it) so that VIDIOC_SUBDEV_G_FMT and media
pipeline validation see the updated Bayer order while the device is suspended?
[ ... ]
> @@ -684,11 +747,20 @@ static int os05b10_set_pad_format(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *sd_state,
> struct v4l2_subdev_format *fmt)
> {
> - const struct os05b10_mode *mode = &supported_modes_10bit[0];
> struct os05b10 *os05b10 = to_os05b10(sd);
> + const struct os05b10_mode *mode_list;
> struct v4l2_mbus_framefmt *format;
> + const struct os05b10_mode *mode;
> + unsigned int num_modes;
> int ret;
>
> + ret = get_mode_table(os05b10, fmt->format.code, &mode_list, &num_modes);
> + if (ret)
> + return ret;
> +
> + mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
> + fmt->format.width, fmt->format.height);
> +
> fmt->format.width = mode->width;
> fmt->format.height = mode->height;
> fmt->format.field = V4L2_FIELD_NONE;
> @@ -732,12 +804,21 @@ static int os05b10_enum_frame_size(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *sd_state,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> - if (fse->index >= ARRAY_SIZE(supported_modes_10bit))
> + struct os05b10 *os05b10 = to_os05b10(sd);
> + const struct os05b10_mode *mode_list;
> + unsigned int num_modes;
> + int ret;
> +
> + ret = get_mode_table(os05b10, fse->code, &mode_list, &num_modes);
> + if (ret)
> + return ret;
> +
> + if (fse->index >= num_modes)
> return -EINVAL;
>
> - fse->min_width = supported_modes_10bit[fse->index].width;
> + fse->min_width = mode_list[fse->index].width;
> fse->max_width = fse->min_width;
> - fse->min_height = supported_modes_10bit[fse->index].height;
> + fse->min_height = mode_list[fse->index].height;
> fse->max_height = fse->min_height;
>
> return 0;
[Severity: Medium]
As reported by Sashiko on v3 [1], how should os05b10_set_pad_format() and
os05b10_enum_frame_size() handle unsupported or unflipped media bus format
codes when calling get_mode_table()?
In drivers/media/i2c/os05b10.c, calling VIDIOC_SUBDEV_S_FMT or
VIDIOC_SUBDEV_ENUM_FRAME_SIZE with an unrecognized format code hits the
default branch in get_mode_table(), which prints an unratelimited dev_err() on
user-controlled input and returns -EINVAL. For os05b10_set_pad_format(), V4L2
sub-device format negotiation expects unsupported format codes to be adjusted
to a valid default format rather than returning -EINVAL.
In addition, get_mode_table() accepts all four Bayer component orders for both
10-bit and 12-bit modes regardless of the current hflip and vflip state, and
os05b10_set_pad_format() no longer normalizes fmt->format.code via
os05b10_get_format_code() before storing:
format = v4l2_subdev_state_get_format(sd_state, 0);
*format = fmt->format;
If userspace requests MEDIA_BUS_FMT_SRGGB12_1X12 while hflip and vflip are
disabled, os05b10_set_pad_format() will store MEDIA_BUS_FMT_SRGGB12_1X12 even
though the sensor outputs MEDIA_BUS_FMT_SBGGR12_1X12 and
os05b10_enum_mbus_code() only enumerates MEDIA_BUS_FMT_SBGGR12_1X12. Likewise,
os05b10_enum_frame_size() will succeed for Bayer orders that do not match
os05b10_get_format_code(os05b10, fse->code).
Should os05b10_set_pad_format() normalize fmt->format.code with
os05b10_get_format_code(os05b10, fmt->format.code) first, and should
os05b10_enum_frame_size() check that fse->code matches
os05b10_get_format_code(os05b10, fse->code) without logging via dev_err()?
[1] https://lore.kernel.org/r/20260718200912.16001-9-tarang.raval@siliconsignal…
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030104806.1223991-1-tarang.raval@silico…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] media: i2c: os05b10: return per-mode crop in os05b10_get_selection()
--
commit 5bba98310d957cf0d3931b3300b2866b4e37fe36
Author: Tarang Raval <tarang.raval(a)siliconsignals.io>
media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes
This commit adds register sequences and mode definitions for 1920x1080 and
2x2 binned 1280x720 resolutions in both 10-bit and 12-bit pixel formats to
the os05b10 camera sensor driver.
[Severity: Medium]
In drivers/media/i2c/os05b10.c, the new register tables mode_1920_1080_regs
(line 459) and mode_1280_720_regs (line 495) program cropped analog windows
on the pixel array rather than reading out the full 2592x1944 active area.
Specifically, mode_1920_1080_regs sets OS05B10_REG_X_ADDR_START to 0x0280,
OS05B10_REG_Y_ADDR_START to 0x01b4, OS05B10_REG_X_ADDR_END to 0x0a0f,
OS05B10_REG_Y_ADDR_END to 0x05f3, and ISP X/Y window offsets of 8, which
crops a centered 1920x1080 region from the sensor array. Similarly,
mode_1280_720_regs sets OS05B10_REG_X_ADDR_START to 0x0140,
OS05B10_REG_Y_ADDR_START to 0x00fc, OS05B10_REG_X_ADDR_END to 0x0b4f,
OS05B10_REG_Y_ADDR_END to 0x06ab, and ISP X/Y window offsets of 4, cropping
a centered 2560x1440 region prior to 2x2 binning down to 1280x720.
However, struct os05b10_mode does not define a per-mode crop rectangle,
os05b10_set_pad_format() does not update the subdev state crop rectangle when
switching modes, and os05b10_get_selection() (line 914) continues to
unconditionally return os05b10_active_area (2592x1944) for V4L2_SEL_TGT_CROP.
When userspace configures the 1920x1080 or 1280x720 mode via
VIDIOC_SUBDEV_S_FMT and queries VIDIOC_SUBDEV_G_SELECTION for
V4L2_SEL_TGT_CROP, won't os05b10_get_selection() report the wrong analog crop
rectangle to camera pipelines calculating field of view and scaling or
binning ratios?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030104806.1223991-1-tarang.raval@silico…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] media: i2c: os05b10: conditional pm_runtime_dont_use_autosuspend() in remove
- [Medium] media: i2c: os05b10: misordered autosuspend setup and cleanup in probe
--
commit c992a9e0895632d5e5127f45ad7b76858008083c
Author: Tarang Raval <tarang.raval(a)siliconsignals.io>
media: i2c: os05b10: Enable runtime PM autosuspend
This commit enables runtime PM autosuspend with a 1000ms delay for the
os05b10 camera sensor driver and switches stream error and stop paths to
pm_runtime_put_autosuspend().
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 70ad9124ad414..7f6cb4c7edc87 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
[ ... ]
> @@ -1029,6 +1029,8 @@ static int os05b10_probe(struct i2c_client *client)
> goto error_subdev_cleanup;
> }
>
> + pm_runtime_set_autosuspend_delay(os05b10->dev, 1000);
> + pm_runtime_use_autosuspend(os05b10->dev);
> pm_runtime_idle(os05b10->dev);
>
> return 0;
> @@ -1037,6 +1039,7 @@ static int os05b10_probe(struct i2c_client *client)
> v4l2_subdev_cleanup(&os05b10->sd);
> pm_runtime_disable(os05b10->dev);
> pm_runtime_set_suspended(os05b10->dev);
> + pm_runtime_dont_use_autosuspend(os05b10->dev);
[Severity: Medium]
Should pm_runtime_set_autosuspend_delay() and pm_runtime_use_autosuspend()
be called before pm_runtime_enable() and v4l2_async_register_subdev_sensor()
in os05b10_probe()?
Currently in os05b10_probe():
pm_runtime_set_active(os05b10->dev);
pm_runtime_enable(os05b10->dev);
ret = v4l2_async_register_subdev_sensor(&os05b10->sd);
if (ret < 0) {
dev_err_probe(os05b10->dev, ret,
"failed to register os05b10 sub-device\n");
goto error_subdev_cleanup;
}
pm_runtime_set_autosuspend_delay(os05b10->dev, 1000);
pm_runtime_use_autosuspend(os05b10->dev);
pm_runtime_idle(os05b10->dev);
If v4l2_async_register_subdev_sensor() fails, control jumps to
error_subdev_cleanup and calls pm_runtime_dont_use_autosuspend() even though
pm_runtime_use_autosuspend() has not been called yet.
In addition, v4l2_async_register_subdev_sensor() exposes the subdevice to
async notifiers before autosuspend is configured, so
os05b10_enable_streams() and os05b10_disable_streams() can run and call
pm_runtime_put_autosuspend() while autosuspend is still disabled.
Finally, because pm_runtime_enable() is already active with usage_count == 0
and dev->power.use_autosuspend is still false when
pm_runtime_set_autosuspend_delay() runs, the call chain:
pm_runtime_set_autosuspend_delay()
-> update_autosuspend()
-> rpm_idle(dev, RPM_AUTO)
-> rpm_suspend(dev, RPM_AUTO)
sees use_autosuspend == false and synchronously suspends the sensor inside
pm_runtime_set_autosuspend_delay() before pm_runtime_use_autosuspend() and
pm_runtime_idle() are reached.
> error_media_entity:
> media_entity_cleanup(&os05b10->sd.entity);
> @@ -1064,6 +1067,7 @@ static void os05b10_remove(struct i2c_client *client)
> if (!pm_runtime_status_suspended(&client->dev)) {
> os05b10_power_off(&client->dev);
> pm_runtime_set_suspended(&client->dev);
> + pm_runtime_dont_use_autosuspend(&client->dev);
> }
> }
[Severity: Medium]
As reported by Sashiko on v3 [1], what happens in os05b10_remove() if the
device is already runtime-suspended when the driver is removed?
Because pm_runtime_dont_use_autosuspend(&client->dev) is placed inside the
!pm_runtime_status_suspended(&client->dev) block, it will be skipped whenever
os05b10_remove() is entered with the device already in RPM_SUSPENDED state
(for example, if autosuspend_delay_ms was set to 0 via sysfs so
__device_release_driver() suspends the device prior to removal, or during
post-probe teardown paths when the sensor is already suspended), leaving
autosuspend enabled on the device structure.
Should pm_runtime_dont_use_autosuspend(&client->dev) be called
unconditionally outside the !pm_runtime_status_suspended(&client->dev) check
(and before pm_runtime_disable(&client->dev))?
[1] https://lore.kernel.org/r/20260718200912.16001-17-tarang.raval@siliconsigna…
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261030104806.1223991-1-tarang.raval@silico…