From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, bbhatt@codeaurora.org,
hemantk@codeaurora.org
Subject: Re: [PATCH v7 06/10] mhi: pci_generic: Add PCI error handlers
Date: Mon, 4 Jan 2021 20:56:43 +0530 [thread overview]
Message-ID: <20210104152643.GC2256@work> (raw)
In-Reply-To: <1609768179-10132-7-git-send-email-loic.poulain@linaro.org>
On Mon, Jan 04, 2021 at 02:49:35PM +0100, Loic Poulain wrote:
> In AER capable root complex, errors are reported to the host which
> can then act accordingly and perform PCI recovering procedure.
>
> This patch enables error reporting and implements error_detected,
> slot_reset and resume callbacks.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by Hemant Kumar <hemantk@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thanks,
Mani
> ---
> drivers/bus/mhi/pci_generic.c | 50 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c
> index 3d459f3..0c12027 100644
> --- a/drivers/bus/mhi/pci_generic.c
> +++ b/drivers/bus/mhi/pci_generic.c
> @@ -8,6 +8,7 @@
> * Copyright (C) 2020 Linaro Ltd <loic.poulain@linaro.org>
> */
>
> +#include <linux/aer.h>
> #include <linux/delay.h>
> #include <linux/device.h>
> #include <linux/mhi.h>
> @@ -405,6 +406,8 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> pci_save_state(pdev);
> mhi_pdev->pci_state = pci_store_saved_state(pdev);
>
> + pci_enable_pcie_error_reporting(pdev);
> +
> err = mhi_register_controller(mhi_cntrl, mhi_cntrl_config);
> if (err)
> return err;
> @@ -501,7 +504,54 @@ static void mhi_pci_reset_done(struct pci_dev *pdev)
> set_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status);
> }
>
> +static pci_ers_result_t mhi_pci_error_detected(struct pci_dev *pdev,
> + pci_channel_state_t state)
> +{
> + struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
> + struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
> +
> + dev_err(&pdev->dev, "PCI error detected, state = %u\n", state);
> +
> + if (state == pci_channel_io_perm_failure)
> + return PCI_ERS_RESULT_DISCONNECT;
> +
> + /* Clean up MHI state */
> + if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
> + mhi_power_down(mhi_cntrl, false);
> + mhi_unprepare_after_power_down(mhi_cntrl);
> + } else {
> + /* Nothing to do */
> + return PCI_ERS_RESULT_RECOVERED;
> + }
> +
> + pci_disable_device(pdev);
> +
> + return PCI_ERS_RESULT_NEED_RESET;
> +}
> +
> +static pci_ers_result_t mhi_pci_slot_reset(struct pci_dev *pdev)
> +{
> + if (pci_enable_device(pdev)) {
> + dev_err(&pdev->dev, "Cannot re-enable PCI device after reset.\n");
> + return PCI_ERS_RESULT_DISCONNECT;
> + }
> +
> + return PCI_ERS_RESULT_RECOVERED;
> +}
> +
> +static void mhi_pci_io_resume(struct pci_dev *pdev)
> +{
> + struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
> +
> + dev_err(&pdev->dev, "PCI slot reset done\n");
> +
> + queue_work(system_long_wq, &mhi_pdev->recovery_work);
> +}
> +
> static const struct pci_error_handlers mhi_pci_err_handler = {
> + .error_detected = mhi_pci_error_detected,
> + .slot_reset = mhi_pci_slot_reset,
> + .resume = mhi_pci_io_resume,
> .reset_prepare = mhi_pci_reset_prepare,
> .reset_done = mhi_pci_reset_done,
> };
> --
> 2.7.4
>
next prev parent reply other threads:[~2021-01-04 15:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 13:49 [PATCH v7 00/10] mhi: pci_generic: Misc improvements Loic Poulain
2021-01-04 13:49 ` [PATCH v7 01/10] bus: mhi: core: Add device hardware reset support Loic Poulain
2021-01-04 15:16 ` Manivannan Sadhasivam
2021-01-04 13:49 ` [PATCH v7 02/10] mhi: pci-generic: Increase number of hardware events Loic Poulain
2021-01-04 13:49 ` [PATCH v7 03/10] mhi: pci_generic: Enable burst mode for hardware channels Loic Poulain
2021-01-04 13:49 ` [PATCH v7 04/10] mhi: pci_generic: Add support for reset Loic Poulain
2021-01-04 15:21 ` Manivannan Sadhasivam
2021-01-04 13:49 ` [PATCH v7 05/10] mhi: pci_generic: Add suspend/resume/recovery procedure Loic Poulain
2021-01-04 13:49 ` [PATCH v7 06/10] mhi: pci_generic: Add PCI error handlers Loic Poulain
2021-01-04 15:26 ` Manivannan Sadhasivam [this message]
2021-01-04 13:49 ` [PATCH v7 07/10] mhi: pci_generic: Add health-check Loic Poulain
2021-01-04 13:49 ` [PATCH v7 08/10] mhi: pci_generic: Increase controller timeout value Loic Poulain
2021-01-04 13:49 ` [PATCH v7 09/10] mhi: pci_generic: Add diag channels Loic Poulain
2021-01-04 13:49 ` [PATCH v7 10/10] mhi: pci_generic: Set irq moderation value to 1ms for hw channels Loic Poulain
2021-01-04 15:27 ` Manivannan Sadhasivam
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=20210104152643.GC2256@work \
--to=manivannan.sadhasivam@linaro.org \
--cc=bbhatt@codeaurora.org \
--cc=hemantk@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=loic.poulain@linaro.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.