2016-03-05 12:42:31

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH V4 4/6] slim: qcom: Add Qualcomm Slimbus controller driver

On Sat, Feb 06, 2016 at 11:44:23AM -0700, Sagar Dharia wrote:

>
> +if SLIMBUS
> +config SLIM_QCOM_CTRL
> + tristate "Qualcomm Slimbus Manager Component"
> + depends on SLIMBUS
> + default n
> + help

n is the default.

> +static irqreturn_t msm_slim_interrupt(int irq, void *d)
> +{
> + struct msm_slim_ctrl *dev = d;
> + u32 stat = readl_relaxed(dev->base + MGR_INT_STAT);
> + int err = 0;

> + if (stat & MGR_INT_TX_MSG_SENT || stat & MGR_INT_TX_NACKED_2) {

> + if (stat & MGR_INT_RX_MSG_RCVD) {

> + }

> + /**
> + * All interrupts are handled: complex RX messages requiring more work
> + * are queued to work-queue, others are handled above
> + */
> + return IRQ_HANDLED;

This unconditionally returns IRQ_HANDLED even if no interrupts were
flagged. This will break if the interrupt gets shared in some hardware
design or if something goes wrong with the hardware.

> + ret = devm_request_irq(&pdev->dev, dev->irq, msm_slim_interrupt,
> + IRQF_TRIGGER_HIGH, "msm_slim_irq", dev);
> + if (ret) {
> + dev_err(&pdev->dev, "request IRQ failed\n");
> + goto err_request_irq_failed;
> + }

Are you sure this is safe and we don't deallocate things the interrupt
handler uses before we disable the interrupt?

> + ret = clk_prepare_enable(hclk);
> + if (ret)
> + goto err_hclk_enable_failed;
> +
> + ret = clk_prepare_enable(rclk);
> + if (ret)
> + goto err_rclk_enable_failed;

The remove path doesn't disable these.

> + /* Register with framework before enabling frame, clock */
> + ret = slim_register_controller(&dev->ctrl);
> + if (ret) {
> + dev_err(dev->dev, "error adding controller\n");
> + goto err_ctrl_failed;
> + }

Should we have a devm_ version of slim_register_controller()? I'd also
expect this to be the last thing we do in probe, things may start using
the device before we've finished initializing it.


Attachments:
(No filename) (1.79 kB)
signature.asc (473.00 B)
Download all attachments

2016-04-15 16:17:44

by Sagar Dharia

[permalink] [raw]
Subject: Re: [PATCH V4 4/6] slim: qcom: Add Qualcomm Slimbus controller driver

Hello Mark
Apologies for a late reply. I will incorporate most of your comments.
Please see inline response for 2 comments:
>> + ret = devm_request_irq(&pdev->dev, dev->irq, msm_slim_interrupt,
>> + IRQF_TRIGGER_HIGH, "msm_slim_irq", dev);
>> + if (ret) {
>> + dev_err(&pdev->dev, "request IRQ failed\n");
>> + goto err_request_irq_failed;
>> + }
> Are you sure this is safe and we don't deallocate things the interrupt
> handler uses before we disable the interrupt?

Since clock is not enabled before this step, we won't be getting any
interrupts from HW at this stage.

>> + /* Register with framework before enabling frame, clock */
>> + ret = slim_register_controller(&dev->ctrl);
>> + if (ret) {
>> + dev_err(dev->dev, "error adding controller\n");
>> + goto err_ctrl_failed;
>> + }
> Should we have a devm_ version of slim_register_controller()? I'd also
> expect this to be the last thing we do in probe, things may start using
> the device before we've finished initializing it.
register_controller also allocates controller's TX/RX ring buffers.
These rings are needed when devices start
reporting present on the bus once they are enabled.
So register_controller needs to be done before enabling any devices.
All steps after register_controller in this function are related to
enabling various internal component devices
(e.g. framer, interface, manager devices) of this slimbus controller.

Thank you for your comments
Sagar


--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

2016-04-18 09:20:35

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH V4 4/6] slim: qcom: Add Qualcomm Slimbus controller driver

On Fri, Apr 15, 2016 at 10:17:36AM -0600, Sagar Dharia wrote:

Please leave blank lines between paragraphs, it makes things much easier
to read than a wall of uninterrupted text.

> >>+ ret = devm_request_irq(&pdev->dev, dev->irq, msm_slim_interrupt,
> >>+ IRQF_TRIGGER_HIGH, "msm_slim_irq", dev);
> >>+ if (ret) {
> >>+ dev_err(&pdev->dev, "request IRQ failed\n");
> >>+ goto err_request_irq_failed;
> >>+ }

> >Are you sure this is safe and we don't deallocate things the interrupt
> >handler uses before we disable the interrupt?

> Since clock is not enabled before this step, we won't be getting any
> interrupts from HW at this stage.

No, that's not what I'm saying - I'm asking about the *disable* path on
remove.


Attachments:
(No filename) (727.00 B)
signature.asc (473.00 B)
Download all attachments

2016-04-18 22:42:22

by Sagar Dharia

[permalink] [raw]
Subject: Re: [PATCH V4 4/6] slim: qcom: Add Qualcomm Slimbus controller driver

On 4/18/2016 3:19 AM, Mark Brown wrote:
> On Fri, Apr 15, 2016 at 10:17:36AM -0600, Sagar Dharia wrote:
>
> Please leave blank lines between paragraphs, it makes things much easier
> to read than a wall of uninterrupted text.
>
>>>> + ret = devm_request_irq(&pdev->dev, dev->irq, msm_slim_interrupt,
>>>> + IRQF_TRIGGER_HIGH, "msm_slim_irq", dev);
>>>> + if (ret) {
>>>> + dev_err(&pdev->dev, "request IRQ failed\n");
>>>> + goto err_request_irq_failed;
>>>> + }
>>> Are you sure this is safe and we don't deallocate things the interrupt
>>> handler uses before we disable the interrupt?
>> Since clock is not enabled before this step, we won't be getting any
>> interrupts from HW at this stage.
> No, that's not what I'm saying - I'm asking about the *disable* path on
> remove.
Good point, I will change the del_controller as well to enter clock-pause,
and the controller's remove function to disable interrupt.

Thanks
Sagar

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation