| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Adaptec AAC series RAID controller driver |
|---|
| 3 | 4 | * (c) Copyright 2001 Red Hat Inc. |
|---|
| .. | .. |
|---|
| 9 | 10 | * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com) |
|---|
| 10 | 11 | * 2016-2017 Microsemi Corp. (aacraid@microsemi.com) |
|---|
| 11 | 12 | * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 15 | | - * any later version. |
|---|
| 16 | | - * |
|---|
| 17 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | | - * GNU General Public License for more details. |
|---|
| 21 | | - * |
|---|
| 22 | | - * You should have received a copy of the GNU General Public License |
|---|
| 23 | | - * along with this program; see the file COPYING. If not, write to |
|---|
| 24 | | - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 25 | | - * |
|---|
| 26 | 13 | * Module Name: |
|---|
| 27 | 14 | * comminit.c |
|---|
| 28 | 15 | * |
|---|
| 29 | 16 | * Abstract: This supports the initialization of the host adapter commuication interface. |
|---|
| 30 | 17 | * This is a platform dependent module for the pci cyclone board. |
|---|
| 31 | | - * |
|---|
| 32 | 18 | */ |
|---|
| 33 | 19 | |
|---|
| 34 | 20 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 286 | 272 | q->entries = qsize; |
|---|
| 287 | 273 | } |
|---|
| 288 | 274 | |
|---|
| 275 | +static bool wait_for_io_iter(struct scsi_cmnd *cmd, void *data, bool rsvd) |
|---|
| 276 | +{ |
|---|
| 277 | + int *active = data; |
|---|
| 278 | + |
|---|
| 279 | + if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) |
|---|
| 280 | + *active = *active + 1; |
|---|
| 281 | + return true; |
|---|
| 282 | +} |
|---|
| 289 | 283 | static void aac_wait_for_io_completion(struct aac_dev *aac) |
|---|
| 290 | 284 | { |
|---|
| 291 | | - unsigned long flagv = 0; |
|---|
| 292 | | - int i = 0; |
|---|
| 285 | + int i = 0, active; |
|---|
| 293 | 286 | |
|---|
| 294 | 287 | for (i = 60; i; --i) { |
|---|
| 295 | | - struct scsi_device *dev; |
|---|
| 296 | | - struct scsi_cmnd *command; |
|---|
| 297 | | - int active = 0; |
|---|
| 298 | 288 | |
|---|
| 299 | | - __shost_for_each_device(dev, aac->scsi_host_ptr) { |
|---|
| 300 | | - spin_lock_irqsave(&dev->list_lock, flagv); |
|---|
| 301 | | - list_for_each_entry(command, &dev->cmd_list, list) { |
|---|
| 302 | | - if (command->SCp.phase == AAC_OWNER_FIRMWARE) { |
|---|
| 303 | | - active++; |
|---|
| 304 | | - break; |
|---|
| 305 | | - } |
|---|
| 306 | | - } |
|---|
| 307 | | - spin_unlock_irqrestore(&dev->list_lock, flagv); |
|---|
| 308 | | - if (active) |
|---|
| 309 | | - break; |
|---|
| 310 | | - |
|---|
| 311 | | - } |
|---|
| 289 | + active = 0; |
|---|
| 290 | + scsi_host_busy_iter(aac->scsi_host_ptr, |
|---|
| 291 | + wait_for_io_iter, &active); |
|---|
| 312 | 292 | /* |
|---|
| 313 | 293 | * We can exit If all the commands are complete |
|---|
| 314 | 294 | */ |
|---|
| 315 | 295 | if (active == 0) |
|---|
| 316 | 296 | break; |
|---|
| 297 | + dev_info(&aac->pdev->dev, |
|---|
| 298 | + "Wait for %d commands to complete\n", active); |
|---|
| 317 | 299 | ssleep(1); |
|---|
| 318 | 300 | } |
|---|
| 301 | + if (active) |
|---|
| 302 | + dev_err(&aac->pdev->dev, |
|---|
| 303 | + "%d outstanding commands during shutdown\n", active); |
|---|
| 319 | 304 | } |
|---|
| 320 | 305 | |
|---|
| 321 | 306 | /** |
|---|
| .. | .. |
|---|
| 585 | 570 | else |
|---|
| 586 | 571 | dev->sa_firmware = 0; |
|---|
| 587 | 572 | |
|---|
| 573 | + if (status[4] & le32_to_cpu(AAC_EXTOPT_SOFT_RESET)) |
|---|
| 574 | + dev->soft_reset_support = 1; |
|---|
| 575 | + else |
|---|
| 576 | + dev->soft_reset_support = 0; |
|---|
| 577 | + |
|---|
| 588 | 578 | if ((dev->comm_interface == AAC_COMM_MESSAGE) && |
|---|
| 589 | 579 | (status[2] > dev->base_size)) { |
|---|
| 590 | 580 | aac_adapter_ioremap(dev, 0); |
|---|