Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: martin.petersen@oracle.com, sathya.prakash@broadcom.com,
	chandrakanth.patil@broadcom.com, ranjan.kumar@broadcom.com,
	prayas.patel@broadcom.com, linux-scsi@vger.kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 1/3] mpi3mr: Support PCIe Error Recovery callback handlers
Date: Thu, 13 Jun 2024 17:57:27 -0500	[thread overview]
Message-ID: <20240613225727.GA1089062@bhelgaas> (raw)
In-Reply-To: <20240613190022.4128-2-sumit.saxena@broadcom.com>

On Fri, Jun 14, 2024 at 12:30:20AM +0530, Sumit Saxena wrote:
> This patch adds support for the PCIe error recovery callback handlers which is
> crucial for the recovery of the controllers. This feature is necessary for
> addressing the errors reported by the PCI Error Recovery mechanism.

> +++ b/drivers/scsi/mpi3mr/mpi3mr.h

> +mpi3mr_pcierr_detected(struct pci_dev *pdev, pci_channel_state_t state)
> +{
> +	struct Scsi_Host *shost;
> +	struct mpi3mr_ioc *mrioc;
> +	unsigned int timeout = MPI3MR_RESET_TIMEOUT;
> +
> +	dev_info(&pdev->dev, "%s: callback invoked state(%d)\n", __func__,
> +	    state);
> +
> +	shost = pci_get_drvdata(pdev);
> +	mrioc = shost_priv(shost);

This will be a NULL pointer dereference if shost is NULL.  But I think
that's OK, and you don't need the check below, because we should never
get here if either shost or mrioc is NULL unless the code is broken,
and in that case we *want* the NULL pointer oops so we can fix it.

> +	if (!shost || !mrioc) {
> +		dev_err(&pdev->dev, "device not available\n");
> +		return PCI_ERS_RESULT_DISCONNECT;
> +	}

> +static pci_ers_result_t mpi3mr_pcierr_slot_reset(struct pci_dev *pdev)
> +{
> +	struct Scsi_Host *shost;
> +	struct mpi3mr_ioc *mrioc;
> +	unsigned int timeout = MPI3MR_RESET_TIMEOUT;
> +
> +	dev_info(&pdev->dev, "%s: callback invoked\n", __func__);
> +
> +	shost = pci_get_drvdata(pdev);
> +	mrioc = shost_priv(shost);
> +
> +	if (!shost || !mrioc) {
> +		dev_err(&pdev->dev, "device not available\n");
> +		return PCI_ERS_RESULT_DISCONNECT;
> +	}

Same here.

> +static void mpi3mr_pcierr_resume(struct pci_dev *pdev)
> +{
> +	struct Scsi_Host *shost;
> +	struct mpi3mr_ioc *mrioc;
> +
> +	dev_info(&pdev->dev, "%s: callback invoked\n", __func__);
> +
> +	shost = pci_get_drvdata(pdev);
> +	mrioc = shost_priv(shost);
> +
> +	if (!shost || !mrioc) {
> +		dev_err(&pdev->dev, "device not available\n");
> +		return;
> +	}

Same here.

> +	pci_aer_clear_nonfatal_status(pdev);

Why is there here?  No other driver does this.

> +static pci_ers_result_t mpi3mr_pcierr_mmio_enabled(struct pci_dev *pdev)
> +{
> +	struct Scsi_Host *shost;
> +	struct mpi3mr_ioc *mrioc;
> +
> +	dev_info(&pdev->dev, "%s: callback invoked\n", __func__);
> +
> +	shost = pci_get_drvdata(pdev);
> +	mrioc = shost_priv(shost);
> +
> +	if (!shost || !mrioc) {
> +		dev_err(&pdev->dev, "device not available\n");
> +		return PCI_ERS_RESULT_DISCONNECT;
> +	}

Same here.

> +static struct pci_error_handlers mpi3mr_err_handler = {
> +	.error_detected = mpi3mr_pcierr_detected,

I think it's nice if the function name includes the function pointer
name, i.e., ".error_detected = mpi3mr_error_detected" (or
"mpi3mr_pci_error_detected" if you prefer).

That way 'git grep -A5 ".*pci_ers_result_t.*error_detected"' finds
most of them for comparison.

> +	.mmio_enabled = mpi3mr_pcierr_mmio_enabled,
> +	.slot_reset = mpi3mr_pcierr_slot_reset,
> +	.resume = mpi3mr_pcierr_resume,
> +};

  reply	other threads:[~2024-06-13 22:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 19:00 [PATCH v3 0/3] mpi3mr: Support PCIe Error Recovery Sumit Saxena
2024-06-13 19:00 ` [PATCH v3 1/3] mpi3mr: Support PCIe Error Recovery callback handlers Sumit Saxena
2024-06-13 22:57   ` Bjorn Helgaas [this message]
2024-06-13 19:00 ` [PATCH v3 2/3] mpi3mr: Prevent PCI writes from driver during PCI error recovery Sumit Saxena
2024-06-13 19:00 ` [PATCH v3 3/3] mpi3mr: driver version update Sumit Saxena

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=20240613225727.GA1089062@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=chandrakanth.patil@broadcom.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=prayas.patel@broadcom.com \
    --cc=ranjan.kumar@broadcom.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=sumit.saxena@broadcom.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