Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipu6-isys probe improvements #214

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drivers/media/pci/intel/ipu-isys-csi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,10 @@ int ipu_isys_csi2_init(struct ipu_isys_csi2 *csi2,
NR_OF_CSI2_SINK_PADS, 0,
CSI2_PAD_SOURCE,
CSI2_PAD_SINK);
if (rval)
if (rval) {
dev_err(&isys->adev->dev, "ipu_isys_subdev_init() err %d\n", rval);
goto fail;
}

csi2->asd.pad[CSI2_PAD_SINK].flags |= MEDIA_PAD_FL_MUST_CONNECT;

Expand Down
9 changes: 7 additions & 2 deletions drivers/media/pci/intel/ipu-isys-subdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,22 @@ int ipu_isys_subdev_init(struct ipu_isys_subdev *asd,
return -ENOMEM;

rval = media_entity_pads_init(&asd->sd.entity, num_pads, asd->pad);
if (rval)
if (rval) {
dev_err(&asd->isys->adev->dev, "%s: media_entity_pads_init(%d) err %d\n", __func__, num_pads, rval);
goto out_mutex_destroy;
}

if (asd->ctrl_init) {
rval = v4l2_ctrl_handler_init(&asd->ctrl_handler, nr_ctrls);
if (rval)
if (rval) {
dev_err(&asd->isys->adev->dev, "%s: v4l2_ctrl_handler_init() err %d\n", __func__, rval);
goto out_media_entity_cleanup;
}

asd->ctrl_init(&asd->sd);
if (asd->ctrl_handler.error) {
rval = asd->ctrl_handler.error;
dev_err(&asd->isys->adev->dev, "%s: ctrl_handler.error %d\n", __func__, rval);
goto out_v4l2_ctrl_handler_free;
}

Expand Down
53 changes: 38 additions & 15 deletions drivers/media/pci/intel/ipu-isys.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,21 @@ static int isys_register_subdevices(struct ipu_isys *isys)
const struct ipu_isys_internal_csi2_pdata *csi2 =
&isys->pdata->ipdata->csi2;
struct ipu_isys_csi2_be_soc *csi2_be_soc;
unsigned int i, k;
int rval;
int i = 0, k = 0, rval;

isys->csi2 = devm_kcalloc(&isys->adev->dev, csi2->nports,
sizeof(*isys->csi2), GFP_KERNEL);
if (!isys->csi2) {
rval = -ENOMEM;
goto fail;
}
if (!isys->csi2)
return -ENOMEM;

for (i = 0; i < csi2->nports; i++) {
rval = ipu_isys_csi2_init(&isys->csi2[i], isys,
isys->pdata->base +
csi2->offsets[i], i);
if (rval)
if (rval) {
dev_err(&isys->adev->dev, "ipu_isys_csi2_init() err %d\n", rval);
goto fail;
}

isys->isr_csi2_bits |= IPU_ISYS_UNISPART_IRQ_CSI2(i);
}
Expand All @@ -423,15 +422,25 @@ static int isys_register_subdevices(struct ipu_isys *isys)
if (rval) {
dev_info(&isys->adev->dev,
"can't create link csi2->be_soc\n");
goto fail;
isys_unregister_subdevices(isys);
return rval;
}
}
}

return 0;

fail:
isys_unregister_subdevices(isys);
while (--k >= 0) {
dev_info(&isys->adev->dev, "foo %d\n", k);
ipu_isys_csi2_be_soc_cleanup(&isys->csi2_be_soc[k]);
}

while (--i >= 0) {
dev_info(&isys->adev->dev, "bar %d\n", k);
ipu_isys_csi2_cleanup(&isys->csi2[i]);
}

return rval;
}

Expand Down Expand Up @@ -1009,12 +1018,16 @@ static int isys_register_devices(struct ipu_isys *isys)
goto out_v4l2_device_unregister;

rval = isys_notifier_init(isys);
if (rval)
if (rval) {
dev_err(&isys->adev->dev, "isys_notifier_init() err %d\n", rval);
goto out_isys_unregister_subdevices;
}

rval = v4l2_device_register_subdev_nodes(&isys->v4l2_dev);
if (rval)
if (rval) {
dev_err(&isys->adev->dev, "error registering subdev nodes %d\n", rval);
goto out_isys_notifier_cleanup;
}

return 0;

Expand Down Expand Up @@ -1157,8 +1170,7 @@ static void isys_remove(struct ipu_bus_device *adev)

dev_info(&adev->dev, "removed\n");
#ifdef CONFIG_DEBUG_FS
if (isp->ipu_dir)
debugfs_remove_recursive(isys->debugfsdir);
debugfs_remove_recursive(isys->debugfsdir);
#endif

list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) {
Expand Down Expand Up @@ -1204,6 +1216,7 @@ static void isys_remove(struct ipu_bus_device *adev)

mutex_destroy(&isys->stream_mutex);
mutex_destroy(&isys->mutex);
mutex_destroy(&isys->lib_mutex);

if (isys->short_packet_source == IPU_ISYS_SHORT_PACKET_FROM_TUNIT) {
u32 trace_size = IPU_ISYS_SHORT_PACKET_TRACE_BUFFER_SIZE;
Expand Down Expand Up @@ -1561,8 +1574,10 @@ static int isys_probe(struct ipu_bus_device *adev)
if (rval)
goto out_remove_pkg_dir_shared_buffer;
rval = isys_iwake_watermark_init(isys);
if (rval)
if (rval) {
dev_err(&adev->dev, "isys_iwake_watermark_init() err %d\n", rval);
goto out_unregister_devices;
}

ipu_mmu_hw_cleanup(adev->mmu);

Expand All @@ -1572,7 +1587,15 @@ static int isys_probe(struct ipu_bus_device *adev)
isys_iwake_watermark_cleanup(isys);
isys_unregister_devices(isys);
out_remove_pkg_dir_shared_buffer:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
cpu_latency_qos_remove_request(&isys->pm_qos);
#else
pm_qos_remove_request(&isys->pm_qos);
#endif
ipu_trace_uninit(&adev->dev);
#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(isys->debugfsdir);
#endif
if (!isp->secure_mode)
ipu_cpd_free_pkg_dir(adev, isys->pkg_dir,
isys->pkg_dir_dma_addr,
Expand All @@ -1583,10 +1606,10 @@ static int isys_probe(struct ipu_bus_device *adev)
release_firmware:
if (!isp->secure_mode)
release_firmware(isys->fw);
ipu_trace_uninit(&adev->dev);

mutex_destroy(&isys->mutex);
mutex_destroy(&isys->stream_mutex);
mutex_destroy(&isys->lib_mutex);

if (isys->short_packet_source == IPU_ISYS_SHORT_PACKET_FROM_TUNIT)
mutex_destroy(&isys->short_packet_tracing_mutex);
Expand Down