From: rojay@codeaurora.org
To: Stephen Boyd <swboyd@chromium.org>
Cc: wsa@kernel.org, dianders@chromium.org,
saiprakash.ranjan@codeaurora.org, gregkh@linuxfoundation.org,
mka@chromium.org, akashast@codeaurora.org,
msavaliy@qti.qualcomm.com, skakit@codeaurora.org,
rnayak@codeaurora.org, agross@kernel.org,
bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
sumit.semwal@linaro.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH V2 2/2] i2c: i2c-qcom-geni: Add shutdown callback for i2c
Date: Fri, 28 Aug 2020 17:16:08 +0530 [thread overview]
Message-ID: <a5060091729429366465b205592aad2d@codeaurora.org> (raw)
In-Reply-To: <159796935923.334488.7479152222902825306@swboyd.mtv.corp.google.com>
On 2020-08-21 05:52, Stephen Boyd wrote:
> Quoting Roja Rani Yarubandi (2020-08-20 03:35:22)
>> If the hardware is still accessing memory after SMMU translation
>> is disabled (as part of smmu shutdown callback), then the
>> IOVAs (I/O virtual address) which it was using will go on the bus
>> as the physical addresses which will result in unknown crashes
>> like NoC/interconnect errors.
>>
>> So, implement shutdown callback to i2c driver to unmap DMA mappings
>> during system "reboot" or "shutdown".
>>
>> Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
>> ---
>
> I'd still put a Fixes tag because it's fixing the driver when someone
> runs shutdown.
>
Okay, will add fixes tag.
>> Changes in V2:
>> - As per Stephen's comments added seperate function for stop
>> transfer,
>> fixed minor nitpicks.
>>
>> drivers/i2c/busses/i2c-qcom-geni.c | 43
>> ++++++++++++++++++++++++++++++
>> include/linux/qcom-geni-se.h | 5 ++++
>> 2 files changed, 48 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c
>> b/drivers/i2c/busses/i2c-qcom-geni.c
>> index 1fda5c7c2cfc..d07f2f33bb75 100644
>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>> @@ -486,6 +486,28 @@ static int geni_i2c_xfer(struct i2c_adapter
>> *adap,
>> return ret;
>> }
>>
>> +static void geni_i2c_stop_xfer(struct geni_i2c_dev *gi2c)
>> +{
>> + u32 val;
>> + struct geni_se *se = &gi2c->se;
>> +
>> + val = readl_relaxed(gi2c->se.base + SE_DMA_DEBUG_REG0);
>> + if (val & DMA_TX_ACTIVE) {
>> + geni_i2c_abort_xfer(gi2c);
>> + gi2c->cur_wr = 0;
>> + if (gi2c->err)
>> + geni_i2c_tx_fsm_rst(gi2c);
>> + geni_se_tx_dma_unprep(se, gi2c->tx_dma,
>> gi2c->xfer_len);
>> + }
>> + if (val & DMA_RX_ACTIVE) {
>> + geni_i2c_abort_xfer(gi2c);
>> + gi2c->cur_rd = 0;
>> + if (gi2c->err)
>> + geni_i2c_rx_fsm_rst(gi2c);
>> + geni_se_rx_dma_unprep(se, gi2c->rx_dma,
>> gi2c->xfer_len);
>> + }
>> +}
>> +
>> static u32 geni_i2c_func(struct i2c_adapter *adap)
>> {
>> return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &
>> ~I2C_FUNC_SMBUS_QUICK);
>> @@ -617,6 +639,26 @@ static int geni_i2c_remove(struct platform_device
>> *pdev)
>> return 0;
>> }
>>
>> +static void geni_i2c_shutdown(struct platform_device *pdev)
>> +{
>> + int ret;
>> + u32 dma;
>> + struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
>> + struct geni_se *se = &gi2c->se;
>> +
>> + ret = pm_runtime_get_sync(gi2c->se.dev);
>> + if (ret < 0) {
>> + dev_err(gi2c->se.dev, "Failed to resume device: %d\n",
>> ret);
>> + return;
>> + }
>> +
>> + dma = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN);
>> + if (dma)
>> + geni_i2c_stop_xfer(gi2c);
>
> Any reason the if (dma) check isn't inside geni_i2c_stop_xfer()?
> Checking for dma and then bailing out early should work and keep the
> logic in one function. Then the pm_runtime_sync() call could go in
> there
> too and if (!dma) goto out. This assumes that we're going to call
> geni_i2c_stop_xfer() from somewhere else, like if a transfer times out
> or something?
>
Okay, will do the changes.
>> +
>> + pm_runtime_put_sync_suspend(gi2c->se.dev);
>> +}
>> +
>> static int __maybe_unused geni_i2c_runtime_suspend(struct device
>> *dev)
>> {
>> int ret;
WARNING: multiple messages have this Message-ID (diff)
From: rojay@codeaurora.org
To: Stephen Boyd <swboyd@chromium.org>
Cc: akashast@codeaurora.org, saiprakash.ranjan@codeaurora.org,
rnayak@codeaurora.org, gregkh@linuxfoundation.org,
linux-arm-msm@vger.kernel.org, dianders@chromium.org,
dri-devel@lists.freedesktop.org, bjorn.andersson@linaro.org,
wsa@kernel.org, linaro-mm-sig@lists.linaro.org, mka@chromium.org,
agross@kernel.org, msavaliy@qti.qualcomm.com,
linux-media@vger.kernel.org, skakit@codeaurora.org,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH V2 2/2] i2c: i2c-qcom-geni: Add shutdown callback for i2c
Date: Fri, 28 Aug 2020 17:16:08 +0530 [thread overview]
Message-ID: <a5060091729429366465b205592aad2d@codeaurora.org> (raw)
In-Reply-To: <159796935923.334488.7479152222902825306@swboyd.mtv.corp.google.com>
On 2020-08-21 05:52, Stephen Boyd wrote:
> Quoting Roja Rani Yarubandi (2020-08-20 03:35:22)
>> If the hardware is still accessing memory after SMMU translation
>> is disabled (as part of smmu shutdown callback), then the
>> IOVAs (I/O virtual address) which it was using will go on the bus
>> as the physical addresses which will result in unknown crashes
>> like NoC/interconnect errors.
>>
>> So, implement shutdown callback to i2c driver to unmap DMA mappings
>> during system "reboot" or "shutdown".
>>
>> Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
>> ---
>
> I'd still put a Fixes tag because it's fixing the driver when someone
> runs shutdown.
>
Okay, will add fixes tag.
>> Changes in V2:
>> - As per Stephen's comments added seperate function for stop
>> transfer,
>> fixed minor nitpicks.
>>
>> drivers/i2c/busses/i2c-qcom-geni.c | 43
>> ++++++++++++++++++++++++++++++
>> include/linux/qcom-geni-se.h | 5 ++++
>> 2 files changed, 48 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c
>> b/drivers/i2c/busses/i2c-qcom-geni.c
>> index 1fda5c7c2cfc..d07f2f33bb75 100644
>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>> @@ -486,6 +486,28 @@ static int geni_i2c_xfer(struct i2c_adapter
>> *adap,
>> return ret;
>> }
>>
>> +static void geni_i2c_stop_xfer(struct geni_i2c_dev *gi2c)
>> +{
>> + u32 val;
>> + struct geni_se *se = &gi2c->se;
>> +
>> + val = readl_relaxed(gi2c->se.base + SE_DMA_DEBUG_REG0);
>> + if (val & DMA_TX_ACTIVE) {
>> + geni_i2c_abort_xfer(gi2c);
>> + gi2c->cur_wr = 0;
>> + if (gi2c->err)
>> + geni_i2c_tx_fsm_rst(gi2c);
>> + geni_se_tx_dma_unprep(se, gi2c->tx_dma,
>> gi2c->xfer_len);
>> + }
>> + if (val & DMA_RX_ACTIVE) {
>> + geni_i2c_abort_xfer(gi2c);
>> + gi2c->cur_rd = 0;
>> + if (gi2c->err)
>> + geni_i2c_rx_fsm_rst(gi2c);
>> + geni_se_rx_dma_unprep(se, gi2c->rx_dma,
>> gi2c->xfer_len);
>> + }
>> +}
>> +
>> static u32 geni_i2c_func(struct i2c_adapter *adap)
>> {
>> return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &
>> ~I2C_FUNC_SMBUS_QUICK);
>> @@ -617,6 +639,26 @@ static int geni_i2c_remove(struct platform_device
>> *pdev)
>> return 0;
>> }
>>
>> +static void geni_i2c_shutdown(struct platform_device *pdev)
>> +{
>> + int ret;
>> + u32 dma;
>> + struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
>> + struct geni_se *se = &gi2c->se;
>> +
>> + ret = pm_runtime_get_sync(gi2c->se.dev);
>> + if (ret < 0) {
>> + dev_err(gi2c->se.dev, "Failed to resume device: %d\n",
>> ret);
>> + return;
>> + }
>> +
>> + dma = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN);
>> + if (dma)
>> + geni_i2c_stop_xfer(gi2c);
>
> Any reason the if (dma) check isn't inside geni_i2c_stop_xfer()?
> Checking for dma and then bailing out early should work and keep the
> logic in one function. Then the pm_runtime_sync() call could go in
> there
> too and if (!dma) goto out. This assumes that we're going to call
> geni_i2c_stop_xfer() from somewhere else, like if a transfer times out
> or something?
>
Okay, will do the changes.
>> +
>> + pm_runtime_put_sync_suspend(gi2c->se.dev);
>> +}
>> +
>> static int __maybe_unused geni_i2c_runtime_suspend(struct device
>> *dev)
>> {
>> int ret;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-08-28 11:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 10:35 [PATCH V2 0/2] Implement Shutdown callback for i2c Roja Rani Yarubandi
2020-08-20 10:35 ` Roja Rani Yarubandi
2020-08-20 10:35 ` [PATCH V2 1/2] i2c: i2c-qcom-geni: Store DMA mapping data in geni_i2c_dev struct Roja Rani Yarubandi
2020-08-20 10:35 ` Roja Rani Yarubandi
2020-08-21 0:18 ` Stephen Boyd
2020-08-21 0:18 ` Stephen Boyd
2020-08-28 11:45 ` rojay
2020-08-28 11:45 ` rojay
2020-08-26 11:55 ` Akash Asthana
2020-08-26 11:55 ` Akash Asthana
2020-09-07 12:51 ` rojay
2020-09-07 12:51 ` rojay
2020-08-20 10:35 ` [PATCH V2 2/2] i2c: i2c-qcom-geni: Add shutdown callback for i2c Roja Rani Yarubandi
2020-08-20 10:35 ` Roja Rani Yarubandi
2020-08-21 0:22 ` Stephen Boyd
2020-08-21 0:22 ` Stephen Boyd
2020-08-28 11:46 ` rojay [this message]
2020-08-28 11:46 ` rojay
2020-08-26 11:56 ` Akash Asthana
2020-08-26 11:56 ` Akash Asthana
2020-09-07 12:53 ` rojay
2020-09-07 12:53 ` rojay
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=a5060091729429366465b205592aad2d@codeaurora.org \
--to=rojay@codeaurora.org \
--cc=agross@kernel.org \
--cc=akashast@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mka@chromium.org \
--cc=msavaliy@qti.qualcomm.com \
--cc=rnayak@codeaurora.org \
--cc=saiprakash.ranjan@codeaurora.org \
--cc=skakit@codeaurora.org \
--cc=sumit.semwal@linaro.org \
--cc=swboyd@chromium.org \
--cc=wsa@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.