mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Anthony McGivern <anthony.mcgivern@arm.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 Nayden Kanchev <nayden.kanchev@arm.com>,
	 Konstantin Babin <konstantin.babin@arm.com>,
	 Linus Walleij <linusw@kernel.org>,
	jacopo.mondi@ideasonboard.com,  kieran.bingham@ideasonboard.com,
	laurent.pinchart@ideasonboard.com,  dan.scally@ideasonboard.com,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	 Rob Herring <robh@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Hans Verkuil <hverkuil@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>
Subject: Re: [PATCH 13/24] media: mali-c720: Add Mali-C720 ISP driver
Date: Wed, 25 Nov 2026 09:55:47 +0100	[thread overview]
Message-ID: <179559694752.14607.4218343265884065337.b4-reply@b4> (raw)
In-Reply-To: <20261124-b4-initial-upstream-candidate-v1-13-0cb9bde1bd30@arm.com>

On 2026-11-24 17:07 +0000, Anthony McGivern wrote:
> +
> +static int mali_c720_probe(struct platform_device *pdev)
> +{
> +	const struct mali_c720_discovery_target top = {
> +		.module_id = MALI_C720_DISC_MODULE_ID_PIPELINE_GLOBAL_CONTROL,
> +		.pipeline_id = MALI_C720_DISC_PIPE_GLOBAL,
> +	};
> +	struct device *dev = &pdev->dev;
> +	struct mali_c720 *mali_c720;
> +	struct resource *res;
> +	unsigned int irq;
> +	int ret;
> +
> +	mali_c720 = kvzalloc_obj(*mali_c720, GFP_KERNEL);

Why absolutely nothing here is resource managed?

> +	if (!mali_c720)
> +		return -ENOMEM;
> +
> +	mali_c720->dev = get_device(dev);
> +	platform_set_drvdata(pdev, mali_c720);
> +
> +	mutex_init(&mali_c720->device_lock);
> +
> +	mali_c720->base = devm_platform_get_and_ioremap_resource(pdev, 0,
> +								 &res);
> +	ret = PTR_ERR_OR_ZERO(mali_c720->base);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to map IO memory\n");
> +		goto err_free;
> +	}
> +
> +	mali_c720->mmio_size = resource_size(res);
> +
> +	if (resource_size(res) < MALI_C720_ID_SIZE) {
> +		ret = dev_err_probe(dev, -EINVAL,
> +				    "IO memory resource %pR is too small (minimum %#x bytes)\n",
> +				    res, MALI_C720_ID_SIZE);
> +		goto err_free;
> +	}
> +
> +	mali_c720->clk = devm_clk_get(dev, "vclk");
> +	ret = PTR_ERR_OR_ZERO(mali_c720->clk);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to acquire clock\n");
> +		goto err_free;
> +	}
> +
> +	mali_c720->reset = devm_reset_control_get_optional_shared(dev, "reset");
> +	ret = PTR_ERR_OR_ZERO(mali_c720->reset);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to acquire reset\n");
> +		goto err_free;
> +	}
> +
> +	ret = of_reserved_mem_device_init(dev);
> +	if (ret && ret != -ENODEV) {
> +		dev_err_probe(dev, ret, "failed to initialize reserved memory\n");
> +		goto err_free;
> +	}
> +
> +	ret = vb2_dma_contig_set_max_seg_size(dev, UINT_MAX);
> +	if (ret)
> +		goto err_release_mem;
> +
> +	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to set DMA mask\n");
> +		goto err_release_mem;
> +	}
> +
> +	ret = mali_c720_power_on(mali_c720);
> +	if (ret) {
> +		dev_err(dev, "failed to power on: %d\n", ret);
> +		goto err_release_mem;
> +	}
> +
> +	mali_c720->registers.id = mali_c720_get_id_regs();
> +	ret = mali_c720_identify_hw(mali_c720);
> +	if (ret)
> +		goto err_power_off;
> +
> +	ret = mali_c720_get_registers(mali_c720->hw_version->id, &mali_c720->registers);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "unsupported register layout\n");
> +		goto err_power_off;
> +	}
> +
> +	if (resource_size(res) < mali_c720->registers.context_size) {
> +		ret = dev_err_probe(dev, -EINVAL,
> +				    "IO memory resource %pR is too small (minimum %#x bytes)\n",
> +				    res, mali_c720->registers.context_size);
> +		goto err_power_off;
> +	}
> +
> +	ret = mali_c720_discovery_init(mali_c720, resource_size(res));
> +	if (ret) {
> +		dev_err(dev, "failed to parse capability discovery data\n");
> +		goto err_power_off;
> +	}
> +
> +	ret = mali_c720_discovery_get_module_base(mali_c720, &top, &mali_c720->top_base);
> +	if (ret) {
> +		dev_err(dev, "failed to get top base address from discovery data\n");
> +		goto err_power_off;
> +	}
> +
> +	ret = mali_c720_init_contexts(mali_c720);
> +	if (ret)
> +		goto err_power_off;
> +
> +	ret = mali_c720_init_ctx_mgr(mali_c720);
> +	if (ret)
> +		goto err_power_off;
> +
> +	pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_active(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
> +	ret = platform_get_irq_byname(pdev, "isp");
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to get interrupt\n");

Please use modern Linux drivers as an example for your code. All this
should be dev_err_probe or dropped, because core takes care of.


> +		goto err_pm_runtime_disable;
> +	}
> +	irq = (unsigned int)ret;
> +
> +	spin_lock_init(&mali_c720->irq_lock);
> +	INIT_KFIFO(mali_c720->irq_fifo);
> +	ret = devm_request_threaded_irq(&pdev->dev, irq,
> +					mali_c720_isr_top, mali_c720_isr,
> +					0,
> +					dev_driver_string(&pdev->dev),
> +					&pdev->dev);
> +	if (ret) {
> +		dev_err(dev, "Failed to request threaded IRQ\n");
> +		goto err_pm_runtime_disable;
> +	}
> +	mali_c720->irq = irq;
> +
> +	mali_c720->media_dev.dev = dev;
> +	mali_c720->media_dev.ops = &mali_c720_media_device_ops;
> +	ret = mali_c720_media_frameworks_init(mali_c720);
> +	if (ret)
> +		goto err_free_irq;
> +
> +	pm_runtime_idle(&pdev->dev);
> +
> +	dev_info(&pdev->dev, "Media frameworks and entities registered successfully\n");

Drop, drivers should  be silent on success.

> +
> +	return 0;
> +
> +err_free_irq:
> +	devm_free_irq(dev, mali_c720->irq, dev);
> +err_pm_runtime_disable:
> +	pm_runtime_disable(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +err_power_off:
> +	mali_c720_power_off(mali_c720);
> +err_release_mem:
> +	of_reserved_mem_device_release(dev);
> +err_free:
> +	platform_set_drvdata(pdev, NULL);
> +	if (mali_c720->v4l2_dev.release)
> +		v4l2_device_put(&mali_c720->v4l2_dev);
> +	else
> +		mali_c720_free(mali_c720);
> +
> +	return ret;
> +}
> +

Best regards,
Krzysztof

-- 
Krzysztof Kozlowski <krzk@kernel.org>

  reply	other threads:[~2026-11-25  8:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 17:07 [PATCH 00/24] Add Arm Mali-C720 Image Signal Processor Driver Anthony McGivern
2026-11-24 17:07 ` [PATCH 01/24] media: uapi: Add 24-bit Bayer media bus formats Anthony McGivern
2026-11-24 17:07 ` [PATCH 02/24] dt-bindings: media: Add bindings for Arm Mali-C720 Anthony McGivern
2026-11-25  8:51   ` Krzysztof Kozlowski
2026-11-24 17:07 ` [PATCH 03/24] media: uapi: Add a control ID base for Mali-C720 ISP Anthony McGivern
2026-11-24 17:07 ` [PATCH 04/24] media: mali-c720: Add register access helpers Anthony McGivern
2026-11-24 17:07 ` [PATCH 05/24] media: mali-c720: Add hardware identification Anthony McGivern
2026-11-25  8:52   ` Krzysztof Kozlowski
2026-11-24 17:07 ` [PATCH 06/24] media: mali-c720: Add format handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 07/24] media: mali-c720: Add hardware discovery support Anthony McGivern
2026-11-24 17:07 ` [PATCH 08/24] media: mali-c720: Add context manager and interrupt handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 09/24] media: mali-c720: Add input frontend subdevice Anthony McGivern
2026-11-24 17:07 ` [PATCH 10/24] media: mali-c720: Add ISP and human vision subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 11/24] media: mali-c720: Add full-resolution output subdevice Anthony McGivern
2026-11-24 17:07 ` [PATCH 12/24] media: mali-c720: Add video capture nodes Anthony McGivern
2026-11-24 17:07 ` [PATCH 13/24] media: mali-c720: Add Mali-C720 ISP driver Anthony McGivern
2026-11-25  8:55   ` Krzysztof Kozlowski [this message]
2026-11-24 17:07 ` [PATCH 14/24] media: mali-c720: Add test pattern generator subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 15/24] media: Documentation: Add Mali-C720 ISP documentation Anthony McGivern
2026-11-24 17:07 ` [PATCH 16/24] media: uapi: Add Mali-C720 statistics meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 17/24] media: uapi: Add statistics structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:07 ` [PATCH 18/24] media: mali-c720: Add 3A statistics video node Anthony McGivern
2026-11-24 17:07 ` [PATCH 19/24] media: Documentation: Document Mali-C720 statistics capture Anthony McGivern
2026-11-24 17:07 ` [PATCH 20/24] media: uapi: Add Mali-C720 parameters meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 21/24] media: uapi: Add parameter structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:07 ` [PATCH 22/24] media: mali-c720: Add parameters video node Anthony McGivern
2026-11-24 17:07 ` [PATCH 23/24] media: Documentation: Document Mali-C720 parameter settings Anthony McGivern
2026-11-24 17:07 ` [PATCH 24/24] MAINTAINERS: Add entry for mali-c720 driver Anthony McGivern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179559694752.14607.4218343265884065337.b4-reply@b4 \
    --to=krzk@kernel.org \
    --cc=anthony.mcgivern@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=konstantin.babin@arm.com \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nayden.kanchev@arm.com \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=vincenzo.frascino@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®