From: Bjorn Helgaas <helgaas@kernel.org>
To: Ranjan Kumar <ranjan.kumar@broadcom.com>
Cc: linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com,
sumit.saxena@broadcom.com, chandrakanth.patil@broadcom.com,
prayas.patel@broadcom.com
Subject: Re: [PATCH v1 2/4] mpi3mr: Support PCIe Error Recovery callback handlers
Date: Wed, 6 Dec 2023 10:56:37 -0600 [thread overview]
Message-ID: <20231206165637.GA717462@bhelgaas> (raw)
In-Reply-To: <20231206152513.71253-3-ranjan.kumar@broadcom.com>
On Wed, Dec 06, 2023 at 08:55:11PM +0530, Ranjan Kumar wrote:
> The driver has been upgraded to include support for the
> PCIe error recovery callback handler which is crucial for
> the recovery of the controllers. This feature is
> necessary for addressing the errors reported by
> the PCIe AER (Advanced Error Reporting) mechanism.
>
> Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
> Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
> ...
> +static int
> +mpi3mr_get_shost_and_mrioc(struct pci_dev *pdev,
> + struct Scsi_Host **shost, struct mpi3mr_ioc **mrioc)
> +{
> + *shost = pci_get_drvdata(pdev);
> + if (*shost == NULL) {
> + dev_err(&pdev->dev, "pdev's driver data is null\n");
> + return -1;
> + }
> +
> + *mrioc = shost_priv(*shost);
> + if (*mrioc == NULL) {
> + dev_err(&pdev->dev, "shost's private data is null\n");
> + *shost = NULL;
> + return -1;
I'm a little bit skeptical about these checks for NULL, although I do
see that the existing code has similar "if (!shost)" checks.
Usually these checks will only find memory corruption or logic errors,
and silently bailing out, as the previous "if (!shost)" checks do,
just masks a serious problem. Logging errors, as you do here, is a
little better, but I think it's better to just take the exception when
we dereference the NULL pointer later because that's impossible to
ignore and usually gives more clues about what went wrong.
> +}
> + return 0;
> +}
The addition and use of mpi3mr_get_shost_and_mrioc() looks like it
could be a separate patch. If so, it might be nice to split this into
several smaller, simpler patches.
> static int __maybe_unused
> mpi3mr_suspend(struct device *dev)
> {
> struct pci_dev *pdev = to_pci_dev(dev);
> - struct Scsi_Host *shost = pci_get_drvdata(pdev);
> + struct Scsi_Host *shost;
> struct mpi3mr_ioc *mrioc;
>
> - if (!shost)
> - return 0;
> + if (mpi3mr_get_shost_and_mrioc(pdev, &shost, &mrioc))
> + return -1;
Is -1 really the best return value here? It seems like usually a
negative errno is returned.
Bjorn
next prev parent reply other threads:[~2023-12-06 16:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 15:25 [PATCH v1 0/4] mpi3mr: Few Enhancements and minor fix Ranjan Kumar
2023-12-06 15:25 ` [PATCH v1 1/4] mpi3mr: Improve Shutdown times when firmware has faulted Ranjan Kumar
2023-12-06 15:25 ` [PATCH v1 2/4] mpi3mr: Support PCIe Error Recovery callback handlers Ranjan Kumar
2023-12-06 16:56 ` Bjorn Helgaas [this message]
2023-12-07 16:55 ` Sathya Prakash Veerichetty
2023-12-07 20:24 ` Bjorn Helgaas
2023-12-07 15:07 ` kernel test robot
2023-12-06 15:25 ` [PATCH v1 3/4] mpi3mr: Reset stop_bsgs flag post controller reset failure Ranjan Kumar
2023-12-06 15:25 ` [PATCH v1 4/4] mpi3mr: Update driver version to 8.6.1.0.0 Ranjan Kumar
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=20231206165637.GA717462@bhelgaas \
--to=helgaas@kernel.org \
--cc=chandrakanth.patil@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=prayas.patel@broadcom.com \
--cc=rajsekhar.chundru@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