Skip to content

Commit

Permalink
ionic: no fw read when PCI reset failed
Browse files Browse the repository at this point in the history
If there was a failed attempt to reset the PCI connection,
don't later try to read from PCI as the space is unmapped
and will cause a paging request crash.  When clearing the PCI
setup we can clear the dev_info register pointer, and check
it before using it in the fw_running test.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Shannon Nelson authored and David S. Miller committed Dec 13, 2023
1 parent 13943d6 commit 219e183
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ static int ionic_sriov_configure(struct pci_dev *pdev, int num_vfs)

static void ionic_clear_pci(struct ionic *ionic)
{
ionic->idev.dev_info_regs = NULL;
ionic->idev.dev_cmd_regs = NULL;
ionic->idev.intr_status = NULL;
ionic->idev.intr_ctrl = NULL;

ionic_unmap_bars(ionic);
pci_release_regions(ionic->pdev);

Expand Down
23 changes: 18 additions & 5 deletions drivers/net/ethernet/pensando/ionic/ionic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,31 @@ void ionic_dev_teardown(struct ionic *ionic)
}

/* Devcmd Interface */
bool ionic_is_fw_running(struct ionic_dev *idev)
static bool __ionic_is_fw_running(struct ionic_dev *idev, u8 *status_ptr)
{
u8 fw_status = ioread8(&idev->dev_info_regs->fw_status);
u8 fw_status;

if (!idev->dev_info_regs) {
if (status_ptr)
*status_ptr = 0xff;
return false;
}

fw_status = ioread8(&idev->dev_info_regs->fw_status);
if (status_ptr)
*status_ptr = fw_status;

/* firmware is useful only if the running bit is set and
* fw_status != 0xff (bad PCI read)
*/
return (fw_status != 0xff) && (fw_status & IONIC_FW_STS_F_RUNNING);
}

bool ionic_is_fw_running(struct ionic_dev *idev)
{
return __ionic_is_fw_running(idev, NULL);
}

int ionic_heartbeat_check(struct ionic *ionic)
{
unsigned long check_time, last_check_time;
Expand All @@ -199,10 +214,8 @@ int ionic_heartbeat_check(struct ionic *ionic)
goto do_check_time;
}

fw_status = ioread8(&idev->dev_info_regs->fw_status);

/* If fw_status is not ready don't bother with the generation */
if (!ionic_is_fw_running(idev)) {
if (!__ionic_is_fw_running(idev, &fw_status)) {
fw_status_ready = false;
} else {
fw_generation = fw_status & IONIC_FW_STS_F_GENERATION;
Expand Down

0 comments on commit 219e183

Please sign in to comment.