Message ID | 20240618154306.279637-3-quic_sibis@quicinc.com |
---|---|
State | New |
Headers | show |
Series | arm64: dts: qcom: x1e80100: Enable bwmon support | expand |
On Tue, Jun 18, 2024 at 09:13:05PM GMT, Sibi Sankar wrote: > The multiple BWMONv4 instances available on the X1E80100 SoC use the > same interrupt number. Mark them are shared to allow for re-use across > instances. Handle the ensuing race introduced by relying on bwmon_disable In an effort to educate the reader, could you please describe what the race condition is here. It would also make sense to break this ("Handle...") into a separate paragraph. Regards, Bjorn > to disable the interrupt and coupled with explicit request/free irqs. > > Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> > --- > > v2: > * Use explicit request/free irq and add comments regarding the race > introduced when adding the IRQF_SHARED flag. [Krzysztof/Dmitry] > > drivers/soc/qcom/icc-bwmon.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c > index fb323b3364db..4a4e28b41509 100644 > --- a/drivers/soc/qcom/icc-bwmon.c > +++ b/drivers/soc/qcom/icc-bwmon.c > @@ -781,9 +781,10 @@ static int bwmon_probe(struct platform_device *pdev) > bwmon->dev = dev; > > bwmon_disable(bwmon); > - ret = devm_request_threaded_irq(dev, bwmon->irq, bwmon_intr, > - bwmon_intr_thread, > - IRQF_ONESHOT, dev_name(dev), bwmon); > + > + /* SoCs with multiple cpu-bwmon instances can end up using a shared interrupt line */ > + ret = request_threaded_irq(bwmon->irq, bwmon_intr, bwmon_intr_thread, > + IRQF_ONESHOT | IRQF_SHARED, dev_name(dev), bwmon); > if (ret) > return dev_err_probe(dev, ret, "failed to request IRQ\n"); > > @@ -798,6 +799,13 @@ static void bwmon_remove(struct platform_device *pdev) > struct icc_bwmon *bwmon = platform_get_drvdata(pdev); > > bwmon_disable(bwmon); > + > + /* > + * Handle the race introduced, when dealing with multiple bwmon instances > + * using a shared interrupt line, by relying on bwmon_disable to disable > + * the interrupt and followed by an explicit free. > + */ > + free_irq(bwmon->irq, bwmon); > } > > static const struct icc_bwmon_data msm8998_bwmon_data = { > -- > 2.34.1 >
On 6/21/24 11:15, Bjorn Andersson wrote: > On Tue, Jun 18, 2024 at 09:13:05PM GMT, Sibi Sankar wrote: >> The multiple BWMONv4 instances available on the X1E80100 SoC use the >> same interrupt number. Mark them are shared to allow for re-use across >> instances. Handle the ensuing race introduced by relying on bwmon_disable > > In an effort to educate the reader, could you please describe what the > race condition is here. > > It would also make sense to break this ("Handle...") into a separate > paragraph. Ack, will make the changes in the next re-spin. -Sibi > > Regards, > Bjorn > >> to disable the interrupt and coupled with explicit request/free irqs. >> >> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> >> --- >> >> v2: >> * Use explicit request/free irq and add comments regarding the race >> introduced when adding the IRQF_SHARED flag. [Krzysztof/Dmitry] >> >> drivers/soc/qcom/icc-bwmon.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c >> index fb323b3364db..4a4e28b41509 100644 >> --- a/drivers/soc/qcom/icc-bwmon.c >> +++ b/drivers/soc/qcom/icc-bwmon.c >> @@ -781,9 +781,10 @@ static int bwmon_probe(struct platform_device *pdev) >> bwmon->dev = dev; >> >> bwmon_disable(bwmon); >> - ret = devm_request_threaded_irq(dev, bwmon->irq, bwmon_intr, >> - bwmon_intr_thread, >> - IRQF_ONESHOT, dev_name(dev), bwmon); >> + >> + /* SoCs with multiple cpu-bwmon instances can end up using a shared interrupt line */ >> + ret = request_threaded_irq(bwmon->irq, bwmon_intr, bwmon_intr_thread, >> + IRQF_ONESHOT | IRQF_SHARED, dev_name(dev), bwmon); >> if (ret) >> return dev_err_probe(dev, ret, "failed to request IRQ\n"); >> >> @@ -798,6 +799,13 @@ static void bwmon_remove(struct platform_device *pdev) >> struct icc_bwmon *bwmon = platform_get_drvdata(pdev); >> >> bwmon_disable(bwmon); >> + >> + /* >> + * Handle the race introduced, when dealing with multiple bwmon instances >> + * using a shared interrupt line, by relying on bwmon_disable to disable >> + * the interrupt and followed by an explicit free. >> + */ >> + free_irq(bwmon->irq, bwmon); >> } >> >> static const struct icc_bwmon_data msm8998_bwmon_data = { >> -- >> 2.34.1 >>
On 6/19/24 00:25, Dmitry Baryshkov wrote: > On Tue, Jun 18, 2024 at 09:13:05PM GMT, Sibi Sankar wrote: >> The multiple BWMONv4 instances available on the X1E80100 SoC use the >> same interrupt number. Mark them are shared to allow for re-use across >> instances. Handle the ensuing race introduced by relying on bwmon_disable >> to disable the interrupt and coupled with explicit request/free irqs. >> >> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> >> --- >> >> v2: >> * Use explicit request/free irq and add comments regarding the race >> introduced when adding the IRQF_SHARED flag. [Krzysztof/Dmitry] >> >> drivers/soc/qcom/icc-bwmon.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c >> index fb323b3364db..4a4e28b41509 100644 >> --- a/drivers/soc/qcom/icc-bwmon.c >> +++ b/drivers/soc/qcom/icc-bwmon.c >> @@ -781,9 +781,10 @@ static int bwmon_probe(struct platform_device *pdev) >> bwmon->dev = dev; >> >> bwmon_disable(bwmon); >> - ret = devm_request_threaded_irq(dev, bwmon->irq, bwmon_intr, >> - bwmon_intr_thread, >> - IRQF_ONESHOT, dev_name(dev), bwmon); >> + >> + /* SoCs with multiple cpu-bwmon instances can end up using a shared interrupt line */ > > ... using devm_ here might result in the IRQ handler being executed > after bwmon_disable in bwmon_remove() Ack > >> + ret = request_threaded_irq(bwmon->irq, bwmon_intr, bwmon_intr_thread, >> + IRQF_ONESHOT | IRQF_SHARED, dev_name(dev), bwmon); >> if (ret) >> return dev_err_probe(dev, ret, "failed to request IRQ\n"); >> >> @@ -798,6 +799,13 @@ static void bwmon_remove(struct platform_device *pdev) >> struct icc_bwmon *bwmon = platform_get_drvdata(pdev); >> >> bwmon_disable(bwmon); >> + >> + /* >> + * Handle the race introduced, when dealing with multiple bwmon instances >> + * using a shared interrupt line, by relying on bwmon_disable to disable >> + * the interrupt and followed by an explicit free. >> + */ > > This sounds more like a part of the commit message. The comment before > request_threaded_irq() should be enough. Ack -Sibi > >> + free_irq(bwmon->irq, bwmon); >> } >> >> static const struct icc_bwmon_data msm8998_bwmon_data = { >> -- >> 2.34.1 >> >
diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c index fb323b3364db..4a4e28b41509 100644 --- a/drivers/soc/qcom/icc-bwmon.c +++ b/drivers/soc/qcom/icc-bwmon.c @@ -781,9 +781,10 @@ static int bwmon_probe(struct platform_device *pdev) bwmon->dev = dev; bwmon_disable(bwmon); - ret = devm_request_threaded_irq(dev, bwmon->irq, bwmon_intr, - bwmon_intr_thread, - IRQF_ONESHOT, dev_name(dev), bwmon); + + /* SoCs with multiple cpu-bwmon instances can end up using a shared interrupt line */ + ret = request_threaded_irq(bwmon->irq, bwmon_intr, bwmon_intr_thread, + IRQF_ONESHOT | IRQF_SHARED, dev_name(dev), bwmon); if (ret) return dev_err_probe(dev, ret, "failed to request IRQ\n"); @@ -798,6 +799,13 @@ static void bwmon_remove(struct platform_device *pdev) struct icc_bwmon *bwmon = platform_get_drvdata(pdev); bwmon_disable(bwmon); + + /* + * Handle the race introduced, when dealing with multiple bwmon instances + * using a shared interrupt line, by relying on bwmon_disable to disable + * the interrupt and followed by an explicit free. + */ + free_irq(bwmon->irq, bwmon); } static const struct icc_bwmon_data msm8998_bwmon_data = {
The multiple BWMONv4 instances available on the X1E80100 SoC use the same interrupt number. Mark them are shared to allow for re-use across instances. Handle the ensuing race introduced by relying on bwmon_disable to disable the interrupt and coupled with explicit request/free irqs. Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> --- v2: * Use explicit request/free irq and add comments regarding the race introduced when adding the IRQF_SHARED flag. [Krzysztof/Dmitry] drivers/soc/qcom/icc-bwmon.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)