^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Management Module Support for MPT (Message Passing Technology) based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * controllers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2012-2014 LSI Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2013-2014 Avago Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * (mailto: MPT-FusionLinux.pdl@avagotech.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * modify it under the terms of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * as published by the Free Software Foundation; either version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * solely responsible for determining the appropriateness of using and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * distributing the Program and assumes all risks associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * exercise of rights under this Agreement, including but not limited to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * the risks and costs of program errors, damage to or loss of data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * programs or equipment, and unavailability or interruption of operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * DISCLAIMER OF LIABILITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include "mpt3sas_base.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include "mpt3sas_ctl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static struct fasync_struct *async_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * enum block_state - blocking state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @NON_BLOCKING: non blocking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @BLOCKING: blocking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * These states are for ioctls that need to wait for a response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * from firmware, so they probably require sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) enum block_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) NON_BLOCKING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) BLOCKING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * _ctl_display_some_debug - debug routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @calling_function_name: string pass from calling function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @mpi_reply: reply message frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * Context: none.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * Function for displaying debug info helpful when debugging issues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * in this module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) _ctl_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) char *calling_function_name, MPI2DefaultReply_t *mpi_reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) Mpi2ConfigRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) char *desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (!(ioc->logging_level & MPT_DEBUG_IOCTL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) switch (mpi_request->Function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) case MPI2_FUNCTION_SCSI_IO_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) Mpi2SCSIIORequest_t *scsi_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) (Mpi2SCSIIORequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) snprintf(ioc->tmp_string, MPT_STRING_LENGTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) "scsi_io, cmd(0x%02x), cdb_len(%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) scsi_request->CDB.CDB32[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) le16_to_cpu(scsi_request->IoFlags) & 0xF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) desc = ioc->tmp_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) case MPI2_FUNCTION_SCSI_TASK_MGMT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) desc = "task_mgmt";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) case MPI2_FUNCTION_IOC_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) desc = "ioc_init";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) case MPI2_FUNCTION_IOC_FACTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) desc = "ioc_facts";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) case MPI2_FUNCTION_CONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) Mpi2ConfigRequest_t *config_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) (Mpi2ConfigRequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) snprintf(ioc->tmp_string, MPT_STRING_LENGTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) "config, type(0x%02x), ext_type(0x%02x), number(%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) (config_request->Header.PageType &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) MPI2_CONFIG_PAGETYPE_MASK), config_request->ExtPageType,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) config_request->Header.PageNumber);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) desc = ioc->tmp_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) case MPI2_FUNCTION_PORT_FACTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) desc = "port_facts";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) case MPI2_FUNCTION_PORT_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) desc = "port_enable";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) case MPI2_FUNCTION_EVENT_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) desc = "event_notification";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) case MPI2_FUNCTION_FW_DOWNLOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) desc = "fw_download";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) case MPI2_FUNCTION_FW_UPLOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) desc = "fw_upload";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) case MPI2_FUNCTION_RAID_ACTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) desc = "raid_action";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) case MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) Mpi2SCSIIORequest_t *scsi_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) (Mpi2SCSIIORequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) snprintf(ioc->tmp_string, MPT_STRING_LENGTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) "raid_pass, cmd(0x%02x), cdb_len(%d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) scsi_request->CDB.CDB32[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) le16_to_cpu(scsi_request->IoFlags) & 0xF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) desc = ioc->tmp_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) case MPI2_FUNCTION_SAS_IO_UNIT_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) desc = "sas_iounit_cntl";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) case MPI2_FUNCTION_SATA_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) desc = "sata_pass";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) case MPI2_FUNCTION_DIAG_BUFFER_POST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) desc = "diag_buffer_post";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) case MPI2_FUNCTION_DIAG_RELEASE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) desc = "diag_release";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) case MPI2_FUNCTION_SMP_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) desc = "smp_passthrough";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) case MPI2_FUNCTION_TOOLBOX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) desc = "toolbox";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) case MPI2_FUNCTION_NVME_ENCAPSULATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) desc = "nvme_encapsulated";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (!desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ioc_info(ioc, "%s: %s, smid(%d)\n", calling_function_name, desc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!mpi_reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (mpi_reply->IOCStatus || mpi_reply->IOCLogInfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ioc_info(ioc, "\tiocstatus(0x%04x), loginfo(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) le16_to_cpu(mpi_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) Mpi2SCSIIOReply_t *scsi_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) (Mpi2SCSIIOReply_t *)mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct _sas_device *sas_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) sas_device = mpt3sas_get_sdev_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) le16_to_cpu(scsi_reply->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ioc_warn(ioc, "\tsas_address(0x%016llx), phy(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) (u64)sas_device->sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) sas_device->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ioc_warn(ioc, "\tenclosure_logical_id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) (u64)sas_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) sas_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) sas_device_put(sas_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (!sas_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) pcie_device = mpt3sas_get_pdev_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) le16_to_cpu(scsi_reply->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (pcie_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ioc_warn(ioc, "\tWWID(0x%016llx), port(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) (unsigned long long)pcie_device->wwid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) pcie_device->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (pcie_device->enclosure_handle != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ioc_warn(ioc, "\tenclosure_logical_id(0x%016llx), slot(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) (u64)pcie_device->enclosure_logical_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) pcie_device->slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (scsi_reply->SCSIState || scsi_reply->SCSIStatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ioc_info(ioc, "\tscsi_state(0x%02x), scsi_status(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) scsi_reply->SCSIState,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) scsi_reply->SCSIStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * mpt3sas_ctl_done - ctl module completion routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * @smid: system request message index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * Context: none.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * The callback handler when using ioc->ctl_cb_idx.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MPI2DefaultReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) Mpi2SCSIIOReply_t *scsiio_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) Mpi26NVMeEncapsulatedErrorReply_t *nvme_error_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) const void *sense_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) u32 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (ioc->ctl_cmds.status == MPT3_CMD_NOT_USED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (ioc->ctl_cmds.smid != smid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ioc->ctl_cmds.status |= MPT3_CMD_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (mpi_reply) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) memcpy(ioc->ctl_cmds.reply, mpi_reply, mpi_reply->MsgLength*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ioc->ctl_cmds.status |= MPT3_CMD_REPLY_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /* get sense data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (mpi_reply->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) mpi_reply->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) scsiio_reply = (Mpi2SCSIIOReply_t *)mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (scsiio_reply->SCSIState &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) MPI2_SCSI_STATE_AUTOSENSE_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) sz = min_t(u32, SCSI_SENSE_BUFFERSIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) le32_to_cpu(scsiio_reply->SenseCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) sense_data = mpt3sas_base_get_sense_buffer(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) memcpy(ioc->ctl_cmds.sense, sense_data, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * Get Error Response data for NVMe device. The ctl_cmds.sense
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * buffer is used to store the Error Response data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (mpi_reply->Function == MPI2_FUNCTION_NVME_ENCAPSULATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) nvme_error_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) (Mpi26NVMeEncapsulatedErrorReply_t *)mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) sz = min_t(u32, NVME_ERROR_RESPONSE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) le16_to_cpu(nvme_error_reply->ErrorResponseCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) sense_data = mpt3sas_base_get_sense_buffer(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) memcpy(ioc->ctl_cmds.sense, sense_data, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) _ctl_display_some_debug(ioc, smid, "ctl_done", mpi_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ioc->ctl_cmds.status &= ~MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) complete(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * _ctl_check_event_type - determines when an event needs logging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * @event: firmware event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * The bitmask in ioc->event_type[] indicates which events should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * be saved in the driver event_log. This bitmask is set by application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * Return: 1 when event should be captured, or zero means no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) _ctl_check_event_type(struct MPT3SAS_ADAPTER *ioc, u16 event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) u32 desired_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (event >= 128 || !event || !ioc->event_log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) desired_event = (1 << (event % 32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (!desired_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) desired_event = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) i = event / 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return desired_event & ioc->event_type[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * mpt3sas_ctl_add_to_event_log - add event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * @mpi_reply: reply message frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) Mpi2EventNotificationReply_t *mpi_reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) struct MPT3_IOCTL_EVENTS *event_log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) u16 event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) u32 sz, event_data_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) u8 send_aen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (!ioc->event_log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) event = le16_to_cpu(mpi_reply->Event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) if (_ctl_check_event_type(ioc, event)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /* insert entry into circular event_log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) i = ioc->event_context % MPT3SAS_CTL_EVENT_LOG_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) event_log = ioc->event_log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) event_log[i].event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) event_log[i].context = ioc->event_context++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) event_data_sz = le16_to_cpu(mpi_reply->EventDataLength)*4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) sz = min_t(u32, event_data_sz, MPT3_EVENT_DATA_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) memset(event_log[i].data, 0, MPT3_EVENT_DATA_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) memcpy(event_log[i].data, mpi_reply->EventData, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) send_aen = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /* This aen_event_read_flag flag is set until the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * application has read the event log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * For MPI2_EVENT_LOG_ENTRY_ADDED, we always notify.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if (event == MPI2_EVENT_LOG_ENTRY_ADDED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) (send_aen && !ioc->aen_event_read_flag)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) ioc->aen_event_read_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) wake_up_interruptible(&ctl_poll_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (async_queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) kill_fasync(&async_queue, SIGIO, POLL_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * mpt3sas_ctl_event_callback - firmware event handler (called at ISR time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * @msix_index: MSIX table index supplied by the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * @reply: reply message frame(lower 32bit addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * Context: interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * This function merely adds a new work task into ioc->firmware_event_thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * The tasks are worked from _firmware_event_work in user context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * Return: 1 meaning mf should be freed from _base_interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * 0 means the mf is freed from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u32 reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) Mpi2EventNotificationReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (mpi_reply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) mpt3sas_ctl_add_to_event_log(ioc, mpi_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * _ctl_verify_adapter - validates ioc_number passed from application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * @ioc_number: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * @iocpp: The ioc pointer is returned in this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * @mpi_version: will be MPI2_VERSION for mpt2ctl ioctl device &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * MPI25_VERSION | MPI26_VERSION for mpt3ctl ioctl device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * Return: (-1) means error, else ioc_number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) _ctl_verify_adapter(int ioc_number, struct MPT3SAS_ADAPTER **iocpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) int mpi_version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) int version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) /* global ioc lock to protect controller on list operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) list_for_each_entry(ioc, &mpt3sas_ioc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (ioc->id != ioc_number)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /* Check whether this ioctl command is from right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * ioctl device or not, if not continue the search.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) version = ioc->hba_mpi_version_belonged;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) /* MPI25_VERSION and MPI26_VERSION uses same ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (mpi_version == (MPI25_VERSION | MPI26_VERSION)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if ((version == MPI25_VERSION) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) (version == MPI26_VERSION))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) if (version != mpi_version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) *iocpp = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return ioc_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) *iocpp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * mpt3sas_ctl_reset_handler - reset callback handler (for ctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) u8 issue_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_PRE_RESET\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (!(ioc->diag_buffer_status[i] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) MPT3_DIAG_BUFFER_IS_REGISTERED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if ((ioc->diag_buffer_status[i] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) MPT3_DIAG_BUFFER_IS_RELEASED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * add a log message to indicate the release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) "%s: Releasing the trace buffer due to adapter reset.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) mpt3sas_send_diag_release(ioc, i, &issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * mpt3sas_ctl_reset_handler - clears outstanding ioctl cmd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) void mpt3sas_ctl_clear_outstanding_ioctls(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) ioc_info(ioc, "%s: clear outstanding ioctl cmd\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (ioc->ctl_cmds.status & MPT3_CMD_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) ioc->ctl_cmds.status |= MPT3_CMD_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) mpt3sas_base_free_smid(ioc, ioc->ctl_cmds.smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) complete(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * mpt3sas_ctl_reset_handler - reset callback handler (for ctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * The handler for doing any required cleanup or initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (!(ioc->diag_buffer_status[i] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) MPT3_DIAG_BUFFER_IS_REGISTERED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if ((ioc->diag_buffer_status[i] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) MPT3_DIAG_BUFFER_IS_RELEASED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) ioc->diag_buffer_status[i] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) MPT3_DIAG_BUFFER_IS_DIAG_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * _ctl_fasync -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * @fd: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * @filep: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * @mode: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * Called when application request fasyn callback handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) _ctl_fasync(int fd, struct file *filep, int mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return fasync_helper(fd, filep, mode, &async_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * _ctl_poll -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * @filep: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * @wait: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) static __poll_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) _ctl_poll(struct file *filep, poll_table *wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) poll_wait(filep, &ctl_poll_wait, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) /* global ioc lock to protect controller on list operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) spin_lock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) list_for_each_entry(ioc, &mpt3sas_ioc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) if (ioc->aen_event_read_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return EPOLLIN | EPOLLRDNORM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) spin_unlock(&gioc_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) * _ctl_set_task_mid - assign an active smid to tm request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) * @karg: (struct mpt3_ioctl_command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) * @tm_request: pointer to mf from user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) * Return: 0 when an smid if found, else fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * during failure, the reply frame is filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) Mpi2SCSITaskManagementRequest_t *tm_request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) u8 found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) u16 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct scsi_cmnd *scmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct MPT3SAS_DEVICE *priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) Mpi2SCSITaskManagementReply_t *tm_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) u32 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) u32 lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) char *desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (tm_request->TaskType == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) desc = "abort_task";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) else if (tm_request->TaskType == MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) desc = "query_task";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) lun = scsilun_to_int((struct scsi_lun *)tm_request->LUN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) handle = le16_to_cpu(tm_request->DevHandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) for (smid = ioc->scsiio_depth; smid && !found; smid--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) struct scsiio_tracker *st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) if (!scmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) if (lun != scmd->device->lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) priv_data = scmd->device->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) if (priv_data->sas_target == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) if (priv_data->sas_target->handle != handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) st = scsi_cmd_priv(scmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * If the given TaskMID from the user space is zero, then the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * first outstanding smid will be picked up. Otherwise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) * targeted smid will be the one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) tm_request->TaskMID = cpu_to_le16(st->smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) if (!found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) ioc_info(ioc, "%s: handle(0x%04x), lun(%d), no active mid!!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) desc, le16_to_cpu(tm_request->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) lun));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) tm_reply = ioc->ctl_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) tm_reply->DevHandle = tm_request->DevHandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) tm_reply->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) tm_reply->TaskType = tm_request->TaskType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) tm_reply->MsgLength = sizeof(Mpi2SCSITaskManagementReply_t)/4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) tm_reply->VP_ID = tm_request->VP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) tm_reply->VF_ID = tm_request->VF_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) sz = min_t(u32, karg->max_reply_bytes, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) if (copy_to_user(karg->reply_frame_buf_ptr, ioc->ctl_cmds.reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) sz))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) ioc_info(ioc, "%s: handle(0x%04x), lun(%d), task_mid(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) desc, le16_to_cpu(tm_request->DevHandle), lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) le16_to_cpu(tm_request->TaskMID)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) * _ctl_do_mpt_command - main handler for MPT3COMMAND opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) * @karg: (struct mpt3_ioctl_command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * @mf: pointer to mf in user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) void __user *mf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) MPI2RequestHeader_t *mpi_request = NULL, *request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) MPI2DefaultReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) struct _pcie_device *pcie_device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) unsigned long timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) u8 issue_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) u32 sz, sz_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) void *psge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) void *data_out = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) dma_addr_t data_out_dma = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) size_t data_out_sz = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) void *data_in = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) dma_addr_t data_in_dma = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) size_t data_in_sz = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) u16 device_handle = MPT3SAS_INVALID_DEVICE_HANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) ioc_err(ioc, "%s: ctl_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) ret = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) ret = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) mpi_request = kzalloc(ioc->request_sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) if (!mpi_request) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) ioc_err(ioc, "%s: failed obtaining a memory for mpi_request\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) /* Check for overflow and wraparound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) if (karg.data_sge_offset * 4 > ioc->request_sz ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) karg.data_sge_offset > (UINT_MAX / 4)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) /* copy in request message frame from user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) if (copy_from_user(mpi_request, mf, karg.data_sge_offset*4)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) pr_err("failure at %s:%d/%s()!\n", __FILE__, __LINE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) smid = mpt3sas_base_get_smid_hpr(ioc, ioc->ctl_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) ret = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) /* Use first reserved smid for passthrough ioctls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) smid = ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) ioc->ctl_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) memset(request, 0, ioc->request_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) memcpy(request, mpi_request, karg.data_sge_offset*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) ioc->ctl_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) data_out_sz = karg.data_out_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) data_in_sz = karg.data_in_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) mpi_request->Function == MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) mpi_request->Function == MPI2_FUNCTION_SATA_PASSTHROUGH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) mpi_request->Function == MPI2_FUNCTION_NVME_ENCAPSULATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) device_handle = le16_to_cpu(mpi_request->FunctionDependent1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if (!device_handle || (device_handle >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) ioc->facts.MaxDevHandle)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) /* obtain dma-able memory for data transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if (data_out_sz) /* WRITE */ {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) data_out = dma_alloc_coherent(&ioc->pdev->dev, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) &data_out_dma, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) if (!data_out) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) if (copy_from_user(data_out, karg.data_out_buf_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) data_out_sz)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) if (data_in_sz) /* READ */ {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) data_in = dma_alloc_coherent(&ioc->pdev->dev, data_in_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) &data_in_dma, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) if (!data_in) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) psge = (void *)request + (karg.data_sge_offset*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) /* send command to firmware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) _ctl_display_some_debug(ioc, smid, "ctl_request", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) init_completion(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) switch (mpi_request->Function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) case MPI2_FUNCTION_NVME_ENCAPSULATED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) nvme_encap_request = (Mpi26NVMeEncapsulatedRequest_t *)request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) if (!ioc->pcie_sg_lookup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) dtmprintk(ioc, ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) "HBA doesn't support NVMe. Rejecting NVMe Encapsulated request.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) ));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) if (ioc->logging_level & MPT_DEBUG_TM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) _debug_dump_mf(nvme_encap_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) ioc->request_sz/4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * Get the Physical Address of the sense buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) * Use Error Response buffer address field to hold the sense
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) * buffer address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) * Clear the internal sense buffer, which will potentially hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) * the Completion Queue Entry on return, or 0 if no Entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) * Build the PRPs and set direction bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) * Send the request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) nvme_encap_request->ErrorResponseBaseAddress =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) cpu_to_le64(ioc->sense_dma & 0xFFFFFFFF00000000UL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) nvme_encap_request->ErrorResponseBaseAddress |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) cpu_to_le64(le32_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) mpt3sas_base_get_sense_buffer_dma(ioc, smid)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) nvme_encap_request->ErrorResponseAllocationLength =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) cpu_to_le16(NVME_ERROR_RESPONSE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) memset(ioc->ctl_cmds.sense, 0, NVME_ERROR_RESPONSE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) ioc->build_nvme_prp(ioc, smid, nvme_encap_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) data_out_dma, data_out_sz, data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) if (test_bit(device_handle, ioc->device_remove_in_progress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) ioc_info(ioc, "handle(0x%04x): ioctl failed due to device removal in progress\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) device_handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) mpt3sas_base_put_smid_nvme_encap(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) case MPI2_FUNCTION_SCSI_IO_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) case MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) Mpi2SCSIIORequest_t *scsiio_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) (Mpi2SCSIIORequest_t *)request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) scsiio_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) scsiio_request->SenseBufferLowAddress =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) mpt3sas_base_get_sense_buffer_dma(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) memset(ioc->ctl_cmds.sense, 0, SCSI_SENSE_BUFFERSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) if (test_bit(device_handle, ioc->device_remove_in_progress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) device_handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) ioc->put_smid_scsi_io(ioc, smid, device_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) case MPI2_FUNCTION_SCSI_TASK_MGMT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) Mpi2SCSITaskManagementRequest_t *tm_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) (Mpi2SCSITaskManagementRequest_t *)request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) ioc_info(ioc, "TASK_MGMT: handle(0x%04x), task_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) le16_to_cpu(tm_request->DevHandle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) tm_request->TaskType));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) ioc->got_task_abort_from_ioctl = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) if (tm_request->TaskType ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) tm_request->TaskType ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) if (_ctl_set_task_mid(ioc, &karg, tm_request)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) ioc->got_task_abort_from_ioctl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) ioc->got_task_abort_from_ioctl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) if (test_bit(device_handle, ioc->device_remove_in_progress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) device_handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) mpt3sas_scsih_set_tm_flag(ioc, le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) tm_request->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) ioc->put_smid_hi_priority(ioc, smid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) case MPI2_FUNCTION_SMP_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) Mpi2SmpPassthroughRequest_t *smp_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) (Mpi2SmpPassthroughRequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) u8 *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) /* ioc determines which port to use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) smp_request->PhysicalPort = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) if (smp_request->PassthroughFlags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) MPI2_SMP_PT_REQ_PT_FLAGS_IMMEDIATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) data = (u8 *)&smp_request->SGL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) if (unlikely(data_out == NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) data = data_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) if (data[1] == 0x91 && (data[10] == 1 || data[10] == 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) ioc->ioc_link_reset_in_progress = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) ioc->ignore_loginfos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) case MPI2_FUNCTION_SATA_PASSTHROUGH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) if (test_bit(device_handle, ioc->device_remove_in_progress)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) dtmprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) device_handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) case MPI2_FUNCTION_FW_DOWNLOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) case MPI2_FUNCTION_FW_UPLOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) case MPI2_FUNCTION_TOOLBOX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) Mpi2ToolboxCleanRequest_t *toolbox_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) (Mpi2ToolboxCleanRequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) if ((toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) || (toolbox_request->Tool ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) MPI26_TOOLBOX_BACKEND_PCIE_LANE_MARGIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) else if (toolbox_request->Tool ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) MPI2_TOOLBOX_MEMORY_MOVE_TOOL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) Mpi2ToolboxMemMoveRequest_t *mem_move_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) (Mpi2ToolboxMemMoveRequest_t *)request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) Mpi2SGESimple64_t tmp, *src = NULL, *dst = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) ioc->build_sg_mpi(ioc, psge, data_out_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) data_out_sz, data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) if (data_out_sz && !data_in_sz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) dst =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) (Mpi2SGESimple64_t *)&mem_move_request->SGL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) src = (void *)dst + ioc->sge_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) memcpy(&tmp, src, ioc->sge_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) memcpy(src, dst, ioc->sge_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) memcpy(dst, &tmp, ioc->sge_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) if (ioc->logging_level & MPT_DEBUG_TM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) "Mpi2ToolboxMemMoveRequest_t request msg\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) _debug_dump_mf(mem_move_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) ioc->request_sz/4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) case MPI2_FUNCTION_SAS_IO_UNIT_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) Mpi2SasIoUnitControlRequest_t *sasiounit_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) (Mpi2SasIoUnitControlRequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) if (sasiounit_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) || sasiounit_request->Operation ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) MPI2_SAS_OP_PHY_LINK_RESET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) ioc->ioc_link_reset_in_progress = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) ioc->ignore_loginfos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) /* drop to default case for posting the request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) data_in_dma, data_in_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (karg.timeout < MPT3_IOCTL_DEFAULT_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) timeout = MPT3_IOCTL_DEFAULT_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) timeout = karg.timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) wait_for_completion_timeout(&ioc->ctl_cmds.done, timeout*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) Mpi2SCSITaskManagementRequest_t *tm_request =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) (Mpi2SCSITaskManagementRequest_t *)mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) mpt3sas_scsih_clear_tm_flag(ioc, le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) tm_request->DevHandle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) mpt3sas_trigger_master(ioc, MASTER_TRIGGER_TASK_MANAGMENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) } else if ((mpi_request->Function == MPI2_FUNCTION_SMP_PASSTHROUGH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) mpi_request->Function == MPI2_FUNCTION_SAS_IO_UNIT_CONTROL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) ioc->ioc_link_reset_in_progress) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) ioc->ioc_link_reset_in_progress = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) ioc->ignore_loginfos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) ioc->ctl_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) karg.data_sge_offset, issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) goto issue_host_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) mpi_reply = ioc->ctl_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) if (mpi_reply->Function == MPI2_FUNCTION_SCSI_TASK_MGMT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) (ioc->logging_level & MPT_DEBUG_TM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) Mpi2SCSITaskManagementReply_t *tm_reply =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) (Mpi2SCSITaskManagementReply_t *)mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) ioc_info(ioc, "TASK_MGMT: IOCStatus(0x%04x), IOCLogInfo(0x%08x), TerminationCount(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) le16_to_cpu(tm_reply->IOCStatus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) le32_to_cpu(tm_reply->IOCLogInfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) le32_to_cpu(tm_reply->TerminationCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) /* copy out xdata to user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) if (data_in_sz) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) if (copy_to_user(karg.data_in_buf_ptr, data_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) data_in_sz)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) ret = -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) /* copy out reply message frame to user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) if (karg.max_reply_bytes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) sz = min_t(u32, karg.max_reply_bytes, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) if (copy_to_user(karg.reply_frame_buf_ptr, ioc->ctl_cmds.reply,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) sz)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) ret = -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) /* copy out sense/NVMe Error Response to user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) if (karg.max_sense_bytes && (mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) MPI2_FUNCTION_SCSI_IO_REQUEST || mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH || mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) MPI2_FUNCTION_NVME_ENCAPSULATED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) if (karg.sense_data_ptr == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) ioc_info(ioc, "Response buffer provided by application is NULL; Response data will not be returned\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) sz_arg = (mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) MPI2_FUNCTION_NVME_ENCAPSULATED) ? NVME_ERROR_RESPONSE_SIZE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) SCSI_SENSE_BUFFERSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) sz = min_t(u32, karg.max_sense_bytes, sz_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) if (copy_to_user(karg.sense_data_ptr, ioc->ctl_cmds.sense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) sz)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) pr_err("failure at %s:%d/%s()!\n", __FILE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) ret = -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) issue_host_reset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) if (issue_reset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) ret = -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) if ((mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) mpi_request->Function ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) mpi_request->Function == MPI2_FUNCTION_SATA_PASSTHROUGH)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) ioc_info(ioc, "issue target reset: handle = (0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) le16_to_cpu(mpi_request->FunctionDependent1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) mpt3sas_halt_firmware(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) pcie_device = mpt3sas_get_pdev_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) le16_to_cpu(mpi_request->FunctionDependent1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) if (pcie_device && (!ioc->tm_custom_handling) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) (!(mpt3sas_scsih_is_pcie_scsi_device(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) pcie_device->device_info))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) mpt3sas_scsih_issue_locked_tm(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) le16_to_cpu(mpi_request->FunctionDependent1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 0, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 0, pcie_device->reset_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) mpt3sas_scsih_issue_locked_tm(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) le16_to_cpu(mpi_request->FunctionDependent1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 0, 0, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 0, 30, MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) if (pcie_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) pcie_device_put(pcie_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) /* free memory associated with sg buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) if (data_in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) dma_free_coherent(&ioc->pdev->dev, data_in_sz, data_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) data_in_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) if (data_out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) dma_free_coherent(&ioc->pdev->dev, data_out_sz, data_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) data_out_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) kfree(mpi_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) * _ctl_getiocinfo - main handler for MPT3IOCINFO opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) _ctl_getiocinfo(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) struct mpt3_ioctl_iocinfo karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) dctlprintk(ioc, ioc_info(ioc, "%s: enter\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) memset(&karg, 0 , sizeof(karg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) if (ioc->pfacts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) karg.port_number = ioc->pfacts[0].PortNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) karg.hw_rev = ioc->pdev->revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) karg.pci_id = ioc->pdev->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) karg.subsystem_device = ioc->pdev->subsystem_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) karg.subsystem_vendor = ioc->pdev->subsystem_vendor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) karg.pci_information.u.bits.bus = ioc->pdev->bus->number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) karg.pci_information.u.bits.device = PCI_SLOT(ioc->pdev->devfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) karg.pci_information.u.bits.function = PCI_FUNC(ioc->pdev->devfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) karg.pci_information.segment_id = pci_domain_nr(ioc->pdev->bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) karg.firmware_version = ioc->facts.FWVersion.Word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) strcpy(karg.driver_version, ioc->driver_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) strcat(karg.driver_version, "-");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) switch (ioc->hba_mpi_version_belonged) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) case MPI2_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) if (ioc->is_warpdrive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) karg.adapter_type = MPT2_IOCTL_INTERFACE_SAS2_SSS6200;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) karg.adapter_type = MPT2_IOCTL_INTERFACE_SAS2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) strcat(karg.driver_version, MPT2SAS_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) case MPI25_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) case MPI26_VERSION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) if (ioc->is_gen35_ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) karg.adapter_type = MPT3_IOCTL_INTERFACE_SAS35;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) karg.adapter_type = MPT3_IOCTL_INTERFACE_SAS3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) strcat(karg.driver_version, MPT3SAS_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) karg.bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) if (copy_to_user(arg, &karg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * _ctl_eventquery - main handler for MPT3EVENTQUERY opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) _ctl_eventquery(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) struct mpt3_ioctl_eventquery karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) dctlprintk(ioc, ioc_info(ioc, "%s: enter\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) karg.event_entries = MPT3SAS_CTL_EVENT_LOG_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) memcpy(karg.event_types, ioc->event_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) MPI2_EVENT_NOTIFY_EVENTMASK_WORDS * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) if (copy_to_user(arg, &karg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) * _ctl_eventenable - main handler for MPT3EVENTENABLE opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) _ctl_eventenable(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) struct mpt3_ioctl_eventenable karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) dctlprintk(ioc, ioc_info(ioc, "%s: enter\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) memcpy(ioc->event_type, karg.event_types,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) MPI2_EVENT_NOTIFY_EVENTMASK_WORDS * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) mpt3sas_base_validate_event_type(ioc, ioc->event_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) if (ioc->event_log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) /* initialize event_log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) ioc->event_context = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) ioc->aen_event_read_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) ioc->event_log = kcalloc(MPT3SAS_CTL_EVENT_LOG_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) sizeof(struct MPT3_IOCTL_EVENTS), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) if (!ioc->event_log) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) * _ctl_eventreport - main handler for MPT3EVENTREPORT opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) _ctl_eventreport(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) struct mpt3_ioctl_eventreport karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) u32 number_bytes, max_events, max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) struct mpt3_ioctl_eventreport __user *uarg = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) dctlprintk(ioc, ioc_info(ioc, "%s: enter\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) number_bytes = karg.hdr.max_data_size -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) sizeof(struct mpt3_ioctl_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) max_events = number_bytes/sizeof(struct MPT3_IOCTL_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) max = min_t(u32, MPT3SAS_CTL_EVENT_LOG_SIZE, max_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) /* If fewer than 1 event is requested, there must have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) * been some type of error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) if (!max || !ioc->event_log)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) return -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) number_bytes = max * sizeof(struct MPT3_IOCTL_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) if (copy_to_user(uarg->event_data, ioc->event_log, number_bytes)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) /* reset flag so SIGIO can restart */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) ioc->aen_event_read_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) * _ctl_do_reset - main handler for MPT3HARDRESET opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) _ctl_do_reset(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) struct mpt3_ioctl_diag_reset karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) if (ioc->shost_recovery || ioc->pci_error_recovery ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) ioc->is_driver_loading)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) dctlprintk(ioc, ioc_info(ioc, "%s: enter\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) "Ioctl: host reset: %s\n", ((!retval) ? "SUCCESS" : "FAILED"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) * _ctl_btdh_search_sas_device - searching for sas device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) * @btdh: btdh ioctl payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) _ctl_btdh_search_sas_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) struct mpt3_ioctl_btdh_mapping *btdh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) struct _sas_device *sas_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) if (list_empty(&ioc->sas_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) spin_lock_irqsave(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) list_for_each_entry(sas_device, &ioc->sas_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) if (btdh->bus == 0xFFFFFFFF && btdh->id == 0xFFFFFFFF &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) btdh->handle == sas_device->handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) btdh->bus = sas_device->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) btdh->id = sas_device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) } else if (btdh->bus == sas_device->channel && btdh->id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) sas_device->id && btdh->handle == 0xFFFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) btdh->handle = sas_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) * _ctl_btdh_search_pcie_device - searching for pcie device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) * @btdh: btdh ioctl payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) _ctl_btdh_search_pcie_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) struct mpt3_ioctl_btdh_mapping *btdh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) struct _pcie_device *pcie_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) if (list_empty(&ioc->pcie_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) spin_lock_irqsave(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) if (btdh->bus == 0xFFFFFFFF && btdh->id == 0xFFFFFFFF &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) btdh->handle == pcie_device->handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) btdh->bus = pcie_device->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) btdh->id = pcie_device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) } else if (btdh->bus == pcie_device->channel && btdh->id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) pcie_device->id && btdh->handle == 0xFFFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) btdh->handle = pcie_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) * _ctl_btdh_search_raid_device - searching for raid device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) * @btdh: btdh ioctl payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) _ctl_btdh_search_raid_device(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) struct mpt3_ioctl_btdh_mapping *btdh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) if (list_empty(&ioc->raid_device_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) spin_lock_irqsave(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) list_for_each_entry(raid_device, &ioc->raid_device_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) if (btdh->bus == 0xFFFFFFFF && btdh->id == 0xFFFFFFFF &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) btdh->handle == raid_device->handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) btdh->bus = raid_device->channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) btdh->id = raid_device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) } else if (btdh->bus == raid_device->channel && btdh->id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) raid_device->id && btdh->handle == 0xFFFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) btdh->handle = raid_device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) * _ctl_btdh_mapping - main handler for MPT3BTDHMAPPING opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) _ctl_btdh_mapping(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) struct mpt3_ioctl_btdh_mapping karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) rc = _ctl_btdh_search_sas_device(ioc, &karg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) rc = _ctl_btdh_search_pcie_device(ioc, &karg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) _ctl_btdh_search_raid_device(ioc, &karg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) if (copy_to_user(arg, &karg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) * _ctl_diag_capability - return diag buffer capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) * @buffer_type: specifies either TRACE, SNAPSHOT, or EXTENDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) * returns 1 when diag buffer support is enabled in firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) _ctl_diag_capability(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) u8 rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) switch (buffer_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) case MPI2_DIAG_BUF_TYPE_TRACE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) if (ioc->facts.IOCCapabilities &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) MPI2_IOCFACTS_CAPABILITY_DIAG_TRACE_BUFFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) case MPI2_DIAG_BUF_TYPE_SNAPSHOT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) if (ioc->facts.IOCCapabilities &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) MPI2_IOCFACTS_CAPABILITY_SNAPSHOT_BUFFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) case MPI2_DIAG_BUF_TYPE_EXTENDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) if (ioc->facts.IOCCapabilities &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) MPI2_IOCFACTS_CAPABILITY_EXTENDED_BUFFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) * _ctl_diag_get_bufftype - return diag buffer type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) * either TRACE, SNAPSHOT, or EXTENDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) * @unique_id: specifies the unique_id for the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) * returns MPT3_DIAG_UID_NOT_FOUND if the id not found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) _ctl_diag_get_bufftype(struct MPT3SAS_ADAPTER *ioc, u32 unique_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) u8 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) for (index = 0; index < MPI2_DIAG_BUF_TYPE_COUNT; index++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) if (ioc->unique_id[index] == unique_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) return index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) return MPT3_DIAG_UID_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) * _ctl_diag_register_2 - wrapper for registering diag buffer support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) * @diag_register: the diag_register struct passed in from user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) struct mpt3_diag_register *diag_register)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) int rc, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) void *request_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) dma_addr_t request_data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) u32 request_data_sz = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) Mpi2DiagBufferPostRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) Mpi2DiagBufferPostReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) u8 buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) ioc_err(ioc, "%s: failed due to ioc not operational\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) ioc_err(ioc, "%s: ctl_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) buffer_type = diag_register->buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) if (!_ctl_diag_capability(ioc, buffer_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) if (diag_register->unique_id == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) "%s: Invalid UID(0x%08x), buffer_type(0x%02x)\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) diag_register->unique_id, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) MPT3_DIAG_BUFFER_IS_APP_OWNED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) !(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) MPT3_DIAG_BUFFER_IS_RELEASED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) "%s: buffer_type(0x%02x) is already registered by application with UID(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) __func__, buffer_type, ioc->unique_id[buffer_type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) if (ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) MPT3_DIAG_BUFFER_IS_REGISTERED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) * If driver posts buffer initially, then an application wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) * to Register that buffer (own it) without Releasing first,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) * the application Register command MUST have the same buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) * type and size in the Register command (obtained from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) * Query command). Otherwise that Register command will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) * failed. If the application has released the buffer but wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) * to re-register it, it should be allowed as long as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) * Unique-Id/Size match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) if (ioc->unique_id[buffer_type] == MPT3DIAGBUFFUNIQUEID &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) ioc->diag_buffer_sz[buffer_type] ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) diag_register->requested_buffer_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) if (!(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) MPT3_DIAG_BUFFER_IS_RELEASED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) dctlprintk(ioc, ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) "%s: diag_buffer (%d) ownership changed. old-ID(0x%08x), new-ID(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) __func__, buffer_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) ioc->unique_id[buffer_type],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) diag_register->unique_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) * Application wants to own the buffer with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) * the same size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) ioc->unique_id[buffer_type] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) diag_register->unique_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) rc = 0; /* success */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) } else if (ioc->unique_id[buffer_type] !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) MPT3DIAGBUFFUNIQUEID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) if (ioc->unique_id[buffer_type] !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) diag_register->unique_id ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) ioc->diag_buffer_sz[buffer_type] !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) diag_register->requested_buffer_size ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) !(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) MPT3_DIAG_BUFFER_IS_RELEASED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) "%s: already has a registered buffer for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) ioc_err(ioc, "%s: already has a registered buffer for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) } else if (ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) if (ioc->unique_id[buffer_type] != MPT3DIAGBUFFUNIQUEID ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) ioc->diag_buffer_sz[buffer_type] !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) diag_register->requested_buffer_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) "%s: already a buffer is allocated for buffer_type(0x%02x) of size %d bytes, so please try registering again with same size\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) __func__, buffer_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) ioc->diag_buffer_sz[buffer_type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) if (diag_register->requested_buffer_size % 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) ioc_err(ioc, "%s: the requested_buffer_size is not 4 byte aligned\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) ioc->ctl_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) ioc->ctl_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) request_data = ioc->diag_buffer[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) request_data_sz = diag_register->requested_buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) ioc->unique_id[buffer_type] = diag_register->unique_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) memcpy(ioc->product_specific[buffer_type],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) diag_register->product_specific, MPT3_PRODUCT_SPECIFIC_DWORDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) ioc->diagnostic_flags[buffer_type] = diag_register->diagnostic_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) if (request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) request_data_dma = ioc->diag_buffer_dma[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) if (request_data_sz != ioc->diag_buffer_sz[buffer_type]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) dma_free_coherent(&ioc->pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) ioc->diag_buffer_sz[buffer_type],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) request_data, request_data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) request_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) if (request_data == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) ioc->diag_buffer_sz[buffer_type] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) ioc->diag_buffer_dma[buffer_type] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) request_data = dma_alloc_coherent(&ioc->pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) request_data_sz, &request_data_dma, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) if (request_data == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) ioc_err(ioc, "%s: failed allocating memory for diag buffers, requested size(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) __func__, request_data_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) mpt3sas_base_free_smid(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) ioc->diag_buffer[buffer_type] = request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) ioc->diag_buffer_sz[buffer_type] = request_data_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) ioc->diag_buffer_dma[buffer_type] = request_data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) mpi_request->Function = MPI2_FUNCTION_DIAG_BUFFER_POST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) mpi_request->BufferType = diag_register->buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) mpi_request->Flags = cpu_to_le32(diag_register->diagnostic_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) mpi_request->BufferAddress = cpu_to_le64(request_data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) mpi_request->BufferLength = cpu_to_le32(request_data_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) mpi_request->VF_ID = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) mpi_request->VP_ID = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) ioc_info(ioc, "%s: diag_buffer(0x%p), dma(0x%llx), sz(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) __func__, request_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) (unsigned long long)request_data_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) le32_to_cpu(mpi_request->BufferLength)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) mpi_request->ProductSpecific[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) cpu_to_le32(ioc->product_specific[buffer_type][i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) init_completion(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) wait_for_completion_timeout(&ioc->ctl_cmds.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) MPT3_IOCTL_DEFAULT_TIMEOUT*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) ioc->ctl_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) sizeof(Mpi2DiagBufferPostRequest_t)/4, issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) goto issue_host_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) /* process the completed Reply Message Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) ioc_err(ioc, "%s: no reply message\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) mpi_reply = ioc->ctl_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) ioc->diag_buffer_status[buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) MPT3_DIAG_BUFFER_IS_REGISTERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) issue_host_reset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) if (issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) if (rc && request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) dma_free_coherent(&ioc->pdev->dev, request_data_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) request_data, request_data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) ~MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) * mpt3sas_enable_diag_buffer - enabling diag_buffers support driver load time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) * @bits_to_register: bitwise field where trace is bit 0, and snapshot is bit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) * This is called when command line option diag_buffer_enable is enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) * at driver load time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) struct mpt3_diag_register diag_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) u32 ret_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) u32 trace_buff_size = ioc->manu_pg11.HostTraceBufferMaxSizeKB<<10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) u32 min_trace_buff_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) u32 decr_trace_buff_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) memset(&diag_register, 0, sizeof(struct mpt3_diag_register));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) if (bits_to_register & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) ioc_info(ioc, "registering trace buffer support\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) ioc->diag_trigger_master.MasterData =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) (MASTER_TRIGGER_FW_FAULT + MASTER_TRIGGER_ADAPTER_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) diag_register.unique_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) (ioc->hba_mpi_version_belonged == MPI2_VERSION) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) if (trace_buff_size != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) diag_register.requested_buffer_size = trace_buff_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) min_trace_buff_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) ioc->manu_pg11.HostTraceBufferMinSizeKB<<10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) decr_trace_buff_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) ioc->manu_pg11.HostTraceBufferDecrementSizeKB<<10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) if (min_trace_buff_size > trace_buff_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) /* The buff size is not set correctly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) "Min Trace Buff size (%d KB) greater than Max Trace Buff size (%d KB)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) min_trace_buff_size>>10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) trace_buff_size>>10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) "Using zero Min Trace Buff Size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) min_trace_buff_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) if (decr_trace_buff_size == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) * retry the min size if decrement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) * is not available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) decr_trace_buff_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) trace_buff_size - min_trace_buff_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) /* register for 2MB buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) diag_register.requested_buffer_size = 2 * (1024 * 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) ret_val = _ctl_diag_register_2(ioc, &diag_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) if (ret_val == -ENOMEM && min_trace_buff_size &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) (trace_buff_size - decr_trace_buff_size) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) min_trace_buff_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) /* adjust the buffer size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) trace_buff_size -= decr_trace_buff_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) diag_register.requested_buffer_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) trace_buff_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) } while (true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) if (ret_val == -ENOMEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) ioc_err(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) "Cannot allocate trace buffer memory. Last memory tried = %d KB\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) diag_register.requested_buffer_size>>10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) else if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) & MPT3_DIAG_BUFFER_IS_REGISTERED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) ioc_err(ioc, "Trace buffer memory %d KB allocated\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) diag_register.requested_buffer_size>>10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) if (ioc->hba_mpi_version_belonged != MPI2_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) ioc->diag_buffer_status[
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) MPI2_DIAG_BUF_TYPE_TRACE] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) if (bits_to_register & 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) ioc_info(ioc, "registering snapshot buffer support\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_SNAPSHOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) /* register for 2MB buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) diag_register.requested_buffer_size = 2 * (1024 * 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) diag_register.unique_id = 0x7075901;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) _ctl_diag_register_2(ioc, &diag_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) if (bits_to_register & 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) ioc_info(ioc, "registering extended buffer support\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_EXTENDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) /* register for 2MB buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) diag_register.requested_buffer_size = 2 * (1024 * 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) diag_register.unique_id = 0x7075901;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) _ctl_diag_register_2(ioc, &diag_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) * _ctl_diag_register - application register with driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) * This will allow the driver to setup any required buffers that will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) * needed by firmware to communicate with the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) _ctl_diag_register(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) struct mpt3_diag_register karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) long rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) rc = _ctl_diag_register_2(ioc, &karg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if (!rc && (ioc->diag_buffer_status[karg.buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) MPT3_DIAG_BUFFER_IS_REGISTERED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) ioc->diag_buffer_status[karg.buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) MPT3_DIAG_BUFFER_IS_APP_OWNED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) * _ctl_diag_unregister - application unregister with driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) * This will allow the driver to cleanup any memory allocated for diag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) * messages and to free up any resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) _ctl_diag_unregister(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) struct mpt3_diag_unregister karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) void *request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) dma_addr_t request_data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) u32 request_data_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) u8 buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) if (!_ctl_diag_capability(ioc, buffer_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) MPT3_DIAG_BUFFER_IS_RELEASED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) ioc_err(ioc, "%s: buffer_type(0x%02x) has not been released\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) if (karg.unique_id != ioc->unique_id[buffer_type]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) request_data = ioc->diag_buffer[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) if (!request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) ioc_err(ioc, "%s: doesn't have memory allocated for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) if (ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) ioc->unique_id[buffer_type] = MPT3DIAGBUFFUNIQUEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) ~MPT3_DIAG_BUFFER_IS_APP_OWNED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) ~MPT3_DIAG_BUFFER_IS_REGISTERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) request_data_sz = ioc->diag_buffer_sz[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) request_data_dma = ioc->diag_buffer_dma[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) dma_free_coherent(&ioc->pdev->dev, request_data_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) request_data, request_data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) ioc->diag_buffer[buffer_type] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) ioc->diag_buffer_status[buffer_type] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) * _ctl_diag_query - query relevant info associated with diag buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) * The application will send only buffer_type and unique_id. Driver will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) * inspect unique_id first, if valid, fill in all the info. If unique_id is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) * 0x00, the driver will return info specified by Buffer Type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) _ctl_diag_query(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) struct mpt3_diag_query karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) void *request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) u8 buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) karg.application_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) buffer_type = karg.buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) if (!_ctl_diag_capability(ioc, buffer_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) if (!(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) if (karg.unique_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) if (karg.unique_id != ioc->unique_id[buffer_type]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) request_data = ioc->diag_buffer[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) if (!request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) ioc_err(ioc, "%s: doesn't have buffer for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) MPT3_DIAG_BUFFER_IS_REGISTERED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) karg.application_flags |= MPT3_APP_FLAGS_BUFFER_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) if (!(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) MPT3_DIAG_BUFFER_IS_RELEASED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) karg.application_flags |= MPT3_APP_FLAGS_FW_BUFFER_ACCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) if (!(ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) karg.application_flags |= MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) MPT3_DIAG_BUFFER_IS_APP_OWNED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) karg.application_flags |= MPT3_APP_FLAGS_APP_OWNED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) karg.product_specific[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) ioc->product_specific[buffer_type][i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) karg.total_buffer_size = ioc->diag_buffer_sz[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) karg.driver_added_buffer_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) karg.unique_id = ioc->unique_id[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) karg.diagnostic_flags = ioc->diagnostic_flags[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) if (copy_to_user(arg, &karg, sizeof(struct mpt3_diag_query))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) ioc_err(ioc, "%s: unable to write mpt3_diag_query data @ %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) __func__, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) * mpt3sas_send_diag_release - Diag Release Message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) * @buffer_type: specifies either TRACE, SNAPSHOT, or EXTENDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) * @issue_reset: specifies whether host reset is required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) u8 *issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) Mpi2DiagReleaseRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) Mpi2DiagReleaseReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) u8 reset_needed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) *issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) if (ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) MPT3_DIAG_BUFFER_IS_REGISTERED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) ioc->diag_buffer_status[buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) MPT3_DIAG_BUFFER_IS_RELEASED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) ioc_info(ioc, "%s: skipping due to FAULT state\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) ioc_err(ioc, "%s: ctl_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) ioc->ctl_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) ioc->ctl_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) mpi_request->Function = MPI2_FUNCTION_DIAG_RELEASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) mpi_request->BufferType = buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) mpi_request->VF_ID = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) mpi_request->VP_ID = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) init_completion(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) wait_for_completion_timeout(&ioc->ctl_cmds.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) MPT3_IOCTL_DEFAULT_TIMEOUT*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) ioc->ctl_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) sizeof(Mpi2DiagReleaseRequest_t)/4, reset_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) *issue_reset = reset_needed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) /* process the completed Reply Message Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) ioc_err(ioc, "%s: no reply message\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) mpi_reply = ioc->ctl_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) ioc->diag_buffer_status[buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) MPT3_DIAG_BUFFER_IS_RELEASED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) * _ctl_diag_release - request to send Diag Release Message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) * @ioc: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) * This allows ownership of the specified buffer to returned to the driver,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) * allowing an application to read the buffer without fear that firmware is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) * overwriting information in the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) _ctl_diag_release(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) struct mpt3_diag_release karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) void *request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) u8 buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) if (!_ctl_diag_capability(ioc, buffer_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) if (karg.unique_id != ioc->unique_id[buffer_type]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) if (ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) MPT3_DIAG_BUFFER_IS_RELEASED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) ioc_err(ioc, "%s: buffer_type(0x%02x) is already released\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) request_data = ioc->diag_buffer[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) if (!request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) ioc_err(ioc, "%s: doesn't have memory allocated for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) /* buffers were released by due to host reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) MPT3_DIAG_BUFFER_IS_DIAG_RESET)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) ioc->diag_buffer_status[buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) MPT3_DIAG_BUFFER_IS_RELEASED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) ~MPT3_DIAG_BUFFER_IS_DIAG_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) ioc_err(ioc, "%s: buffer_type(0x%02x) was released due to host reset\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) rc = mpt3sas_send_diag_release(ioc, buffer_type, &issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) if (issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) * _ctl_diag_read_buffer - request for copy of the diag buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) * @arg: user space buffer containing ioctl content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) _ctl_diag_read_buffer(struct MPT3SAS_ADAPTER *ioc, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) struct mpt3_diag_read_buffer karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) struct mpt3_diag_read_buffer __user *uarg = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) void *request_data, *diag_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) Mpi2DiagBufferPostRequest_t *mpi_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) Mpi2DiagBufferPostReply_t *mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) int rc, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) u8 buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) unsigned long request_size, copy_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) u16 smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) dctlprintk(ioc, ioc_info(ioc, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) if (!_ctl_diag_capability(ioc, buffer_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) if (karg.unique_id != ioc->unique_id[buffer_type]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) __func__, karg.unique_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) request_data = ioc->diag_buffer[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) if (!request_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) ioc_err(ioc, "%s: doesn't have buffer for buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) __func__, buffer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) request_size = ioc->diag_buffer_sz[buffer_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) ioc_err(ioc, "%s: either the starting_offset or bytes_to_read are not 4 byte aligned\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) if (karg.starting_offset > request_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) diag_data = (void *)(request_data + karg.starting_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) ioc_info(ioc, "%s: diag_buffer(%p), offset(%d), sz(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) __func__, diag_data, karg.starting_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) karg.bytes_to_read));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) /* Truncate data on requests that are too large */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) if ((diag_data + karg.bytes_to_read < diag_data) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) (diag_data + karg.bytes_to_read > request_data + request_size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) copy_size = request_size - karg.starting_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) copy_size = karg.bytes_to_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) if (copy_to_user((void __user *)uarg->diagnostic_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) diag_data, copy_size)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) ioc_err(ioc, "%s: Unable to write mpt_diag_read_buffer_t data @ %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) __func__, diag_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) if ((karg.flags & MPT3_FLAGS_REREGISTER) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) ioc_info(ioc, "%s: Reregister buffer_type(0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) __func__, buffer_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) if ((ioc->diag_buffer_status[buffer_type] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) MPT3_DIAG_BUFFER_IS_RELEASED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) ioc_info(ioc, "%s: buffer_type(0x%02x) is still registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) __func__, buffer_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) /* Get a free request frame and save the message context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) ioc_err(ioc, "%s: ctl_cmd in use\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) if (!smid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) rc = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) ioc->ctl_cmds.status = MPT3_CMD_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) ioc->ctl_cmds.smid = smid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) mpi_request->Function = MPI2_FUNCTION_DIAG_BUFFER_POST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) mpi_request->BufferType = buffer_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) mpi_request->BufferLength =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) cpu_to_le32(ioc->diag_buffer_sz[buffer_type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) mpi_request->BufferAddress =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) cpu_to_le64(ioc->diag_buffer_dma[buffer_type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) mpi_request->ProductSpecific[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) cpu_to_le32(ioc->product_specific[buffer_type][i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) mpi_request->VF_ID = 0; /* TODO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) mpi_request->VP_ID = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) init_completion(&ioc->ctl_cmds.done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) ioc->put_smid_default(ioc, smid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) wait_for_completion_timeout(&ioc->ctl_cmds.done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) MPT3_IOCTL_DEFAULT_TIMEOUT*HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) mpt3sas_check_cmd_timeout(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) ioc->ctl_cmds.status, mpi_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) sizeof(Mpi2DiagBufferPostRequest_t)/4, issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) goto issue_host_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) /* process the completed Reply Message Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) ioc_err(ioc, "%s: no reply message\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) mpi_reply = ioc->ctl_cmds.reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) ioc->diag_buffer_status[buffer_type] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) MPT3_DIAG_BUFFER_IS_REGISTERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) ioc->diag_buffer_status[buffer_type] &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) ~MPT3_DIAG_BUFFER_IS_RELEASED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) __func__, ioc_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) le32_to_cpu(mpi_reply->IOCLogInfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) rc = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) issue_host_reset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) if (issue_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) * _ctl_compat_mpt_command - convert 32bit pointers to 64bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) * @ioc: per adapter object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) * @cmd: ioctl opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) * @arg: (struct mpt3_ioctl_command32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) * MPT3COMMAND32 - Handle 32bit applications running on 64bit os.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) _ctl_compat_mpt_command(struct MPT3SAS_ADAPTER *ioc, unsigned cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) struct mpt3_ioctl_command32 karg32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) struct mpt3_ioctl_command32 __user *uarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) struct mpt3_ioctl_command karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) if (_IOC_SIZE(cmd) != sizeof(struct mpt3_ioctl_command32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) uarg = (struct mpt3_ioctl_command32 __user *) arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) if (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) memset(&karg, 0, sizeof(struct mpt3_ioctl_command));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) karg.hdr.ioc_number = karg32.hdr.ioc_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) karg.hdr.port_number = karg32.hdr.port_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) karg.hdr.max_data_size = karg32.hdr.max_data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) karg.timeout = karg32.timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) karg.max_reply_bytes = karg32.max_reply_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) karg.data_in_size = karg32.data_in_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) karg.data_out_size = karg32.data_out_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) karg.max_sense_bytes = karg32.max_sense_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) karg.data_sge_offset = karg32.data_sge_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) karg.reply_frame_buf_ptr = compat_ptr(karg32.reply_frame_buf_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) karg.data_in_buf_ptr = compat_ptr(karg32.data_in_buf_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) karg.data_out_buf_ptr = compat_ptr(karg32.data_out_buf_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) karg.sense_data_ptr = compat_ptr(karg32.sense_data_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) return _ctl_do_mpt_command(ioc, karg, &uarg->mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) * _ctl_ioctl_main - main ioctl entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) * @file: (struct file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) * @cmd: ioctl opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) * @arg: user space data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) * @compat: handles 32 bit applications in 64bit os
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) * @mpi_version: will be MPI2_VERSION for mpt2ctl ioctl device &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) * MPI25_VERSION | MPI26_VERSION for mpt3ctl ioctl device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) u8 compat, u16 mpi_version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) struct mpt3_ioctl_header ioctl_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) enum block_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) long ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) /* get IOCTL header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) if (copy_from_user(&ioctl_header, (char __user *)arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) sizeof(struct mpt3_ioctl_header))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) if (_ctl_verify_adapter(ioctl_header.ioc_number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) &ioc, mpi_version) == -1 || !ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) /* pci_access_mutex lock acquired by ioctl path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) mutex_lock(&ioc->pci_access_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) if (ioc->shost_recovery || ioc->pci_error_recovery ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) ioc->is_driver_loading || ioc->remove_host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) ret = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) goto out_unlock_pciaccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) state = (file->f_flags & O_NONBLOCK) ? NON_BLOCKING : BLOCKING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) if (state == NON_BLOCKING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) if (!mutex_trylock(&ioc->ctl_cmds.mutex)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) ret = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) goto out_unlock_pciaccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) } else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) ret = -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) goto out_unlock_pciaccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) case MPT3IOCINFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_iocinfo))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) ret = _ctl_getiocinfo(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) case MPT3COMMAND32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) case MPT3COMMAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) struct mpt3_ioctl_command __user *uarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) struct mpt3_ioctl_command karg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) if (compat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) ret = _ctl_compat_mpt_command(ioc, cmd, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) if (copy_from_user(&karg, arg, sizeof(karg))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) pr_err("failure at %s:%d/%s()!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) __FILE__, __LINE__, __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) if (karg.hdr.ioc_number != ioctl_header.ioc_number) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_command)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) uarg = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) ret = _ctl_do_mpt_command(ioc, karg, &uarg->mf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) case MPT3EVENTQUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_eventquery))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) ret = _ctl_eventquery(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) case MPT3EVENTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_eventenable))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) ret = _ctl_eventenable(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) case MPT3EVENTREPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) ret = _ctl_eventreport(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) case MPT3HARDRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_diag_reset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) ret = _ctl_do_reset(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) case MPT3BTDHMAPPING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_btdh_mapping))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) ret = _ctl_btdh_mapping(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) case MPT3DIAGREGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_diag_register))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) ret = _ctl_diag_register(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) case MPT3DIAGUNREGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_diag_unregister))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) ret = _ctl_diag_unregister(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) case MPT3DIAGQUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_diag_query))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) ret = _ctl_diag_query(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) case MPT3DIAGRELEASE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_diag_release))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) ret = _ctl_diag_release(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) case MPT3DIAGREADBUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) if (_IOC_SIZE(cmd) == sizeof(struct mpt3_diag_read_buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) ret = _ctl_diag_read_buffer(ioc, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) dctlprintk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) ioc_info(ioc, "unsupported ioctl opcode(0x%08x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) mutex_unlock(&ioc->ctl_cmds.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) out_unlock_pciaccess:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) mutex_unlock(&ioc->pci_access_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) * _ctl_ioctl - mpt3ctl main ioctl entry point (unlocked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) * @file: (struct file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) * @cmd: ioctl opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) * @arg: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) _ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) /* pass MPI25_VERSION | MPI26_VERSION value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) * to indicate that this ioctl cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) * came from mpt3ctl ioctl device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) ret = _ctl_ioctl_main(file, cmd, (void __user *)arg, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) MPI25_VERSION | MPI26_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) * _ctl_mpt2_ioctl - mpt2ctl main ioctl entry point (unlocked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) * @file: (struct file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) * @cmd: ioctl opcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) * @arg: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) _ctl_mpt2_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) /* pass MPI2_VERSION value, to indicate that this ioctl cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) * came from mpt2ctl ioctl device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) ret = _ctl_ioctl_main(file, cmd, (void __user *)arg, 0, MPI2_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) *_ ctl_ioctl_compat - main ioctl entry point (compat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) * @file: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) * @cmd: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) * @arg: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) * This routine handles 32 bit applications in 64bit os.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) _ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) ret = _ctl_ioctl_main(file, cmd, (void __user *)arg, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) MPI25_VERSION | MPI26_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) *_ ctl_mpt2_ioctl_compat - main ioctl entry point (compat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) * @file: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) * @cmd: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) * @arg: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) * This routine handles 32 bit applications in 64bit os.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) _ctl_mpt2_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) ret = _ctl_ioctl_main(file, cmd, (void __user *)arg, 1, MPI2_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) /* scsi host attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) * version_fw_show - firmware version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) version_fw_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) ioc->facts.FWVersion.Word & 0x000000FF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) static DEVICE_ATTR_RO(version_fw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) * version_bios_show - bios version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) version_bios_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) u32 version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) (version & 0xFF000000) >> 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) (version & 0x00FF0000) >> 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) (version & 0x0000FF00) >> 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) version & 0x000000FF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) static DEVICE_ATTR_RO(version_bios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) * version_mpi_show - MPI (message passing interface) version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) version_mpi_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) return snprintf(buf, PAGE_SIZE, "%03x.%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) static DEVICE_ATTR_RO(version_mpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) * version_product_show - product name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) version_product_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) return snprintf(buf, 16, "%s\n", ioc->manu_pg0.ChipName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) static DEVICE_ATTR_RO(version_product);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) * version_nvdata_persistent_show - ndvata persistent version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) version_nvdata_persistent_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) return snprintf(buf, PAGE_SIZE, "%08xh\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) le32_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) static DEVICE_ATTR_RO(version_nvdata_persistent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) * version_nvdata_default_show - nvdata default version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) version_nvdata_default_show(struct device *cdev, struct device_attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) return snprintf(buf, PAGE_SIZE, "%08xh\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) le32_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) static DEVICE_ATTR_RO(version_nvdata_default);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) * board_name_show - board name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) board_name_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) static DEVICE_ATTR_RO(board_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) * board_assembly_show - board assembly name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) board_assembly_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardAssembly);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) static DEVICE_ATTR_RO(board_assembly);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) * board_tracer_show - board tracer number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) board_tracer_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardTracerNumber);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) static DEVICE_ATTR_RO(board_tracer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) * io_delay_show - io missing delay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) * This is for firmware implemention for deboucing device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) * removal events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) io_delay_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) static DEVICE_ATTR_RO(io_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) * device_delay_show - device missing delay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) * This is for firmware implemention for deboucing device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) * removal events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) device_delay_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) static DEVICE_ATTR_RO(device_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) * fw_queue_depth_show - global credits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) * This is firmware queue depth limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) fw_queue_depth_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->facts.RequestCredit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) static DEVICE_ATTR_RO(fw_queue_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) * sas_address_show - sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) * This is the controller sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) host_sas_address_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) (unsigned long long)ioc->sas_hba.sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) static DEVICE_ATTR_RO(host_sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) * logging_level_show - logging level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) logging_level_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->logging_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) logging_level_store(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) int val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) if (sscanf(buf, "%x", &val) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) ioc->logging_level = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) ioc_info(ioc, "logging_level=%08xh\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) ioc->logging_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) static DEVICE_ATTR_RW(logging_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) * fwfault_debug_show - show/store fwfault_debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) * mpt3sas_fwfault_debug is command line option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) fwfault_debug_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) return snprintf(buf, PAGE_SIZE, "%d\n", ioc->fwfault_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) fwfault_debug_store(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) int val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) if (sscanf(buf, "%d", &val) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) ioc->fwfault_debug = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) ioc_info(ioc, "fwfault_debug=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) ioc->fwfault_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) static DEVICE_ATTR_RW(fwfault_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) * ioc_reset_count_show - ioc reset count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) * This is firmware queue depth limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) ioc_reset_count_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) return snprintf(buf, PAGE_SIZE, "%d\n", ioc->ioc_reset_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) static DEVICE_ATTR_RO(ioc_reset_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) * reply_queue_count_show - number of reply queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) * This is number of reply queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) reply_queue_count_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) u8 reply_queue_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) if ((ioc->facts.IOCCapabilities &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX) && ioc->msix_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) reply_queue_count = ioc->reply_queue_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) reply_queue_count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) return snprintf(buf, PAGE_SIZE, "%d\n", reply_queue_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) static DEVICE_ATTR_RO(reply_queue_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) * BRM_status_show - Backup Rail Monitor Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) * This is number of reply queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) BRM_status_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) Mpi2IOUnitPage3_t *io_unit_pg3 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) Mpi2ConfigReply_t mpi_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) u16 backup_rail_monitor_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) u16 ioc_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) int sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) ssize_t rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) if (!ioc->is_warpdrive) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) ioc_err(ioc, "%s: BRM attribute is only for warpdrive\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) /* pci_access_mutex lock acquired by sysfs show path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) mutex_lock(&ioc->pci_access_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) if (ioc->pci_error_recovery || ioc->remove_host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) /* allocate upto GPIOVal 36 entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) sz = offsetof(Mpi2IOUnitPage3_t, GPIOVal) + (sizeof(u16) * 36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) io_unit_pg3 = kzalloc(sz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) if (!io_unit_pg3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) ioc_err(ioc, "%s: failed allocating memory for iounit_pg3: (%d) bytes\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) __func__, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) if (mpt3sas_config_get_iounit_pg3(ioc, &mpi_reply, io_unit_pg3, sz) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) ioc_err(ioc, "%s: failed reading iounit_pg3\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) ioc_err(ioc, "%s: iounit_pg3 failed with ioc_status(0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) __func__, ioc_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) if (io_unit_pg3->GPIOCount < 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) ioc_err(ioc, "%s: iounit_pg3->GPIOCount less than 25 entries, detected (%d) entries\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) __func__, io_unit_pg3->GPIOCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) /* BRM status is in bit zero of GPIOVal[24] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) backup_rail_monitor_status = le16_to_cpu(io_unit_pg3->GPIOVal[24]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) rc = snprintf(buf, PAGE_SIZE, "%d\n", (backup_rail_monitor_status & 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) kfree(io_unit_pg3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) mutex_unlock(&ioc->pci_access_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) static DEVICE_ATTR_RO(BRM_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) struct DIAG_BUFFER_START {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) __le32 Size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) __le32 DiagVersion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) u8 BufferType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) u8 Reserved[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) __le32 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) __le32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) __le32 Reserved3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) * host_trace_buffer_size_show - host buffer size (trace only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) host_trace_buffer_size_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) u32 size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) struct DIAG_BUFFER_START *request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) ioc_err(ioc, "%s: host_trace_buffer is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) ioc_err(ioc, "%s: host_trace_buffer is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) request_data = (struct DIAG_BUFFER_START *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) if ((le32_to_cpu(request_data->DiagVersion) == 0x00000000 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) le32_to_cpu(request_data->DiagVersion) == 0x01000000 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) le32_to_cpu(request_data->DiagVersion) == 0x01010000) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) le32_to_cpu(request_data->Reserved3) == 0x4742444c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) size = le32_to_cpu(request_data->Size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) ioc->ring_buffer_sz = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) return snprintf(buf, PAGE_SIZE, "%d\n", size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) static DEVICE_ATTR_RO(host_trace_buffer_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) * host_trace_buffer_show - firmware ring buffer (trace only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) * You will only be able to read 4k bytes of ring buffer at a time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) * In order to read beyond 4k bytes, you will have to write out the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) * offset to the same attribute, it will move the pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) host_trace_buffer_show(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) void *request_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) ioc_err(ioc, "%s: host_trace_buffer is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) ioc_err(ioc, "%s: host_trace_buffer is not registered\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) if (ioc->ring_buffer_offset > ioc->ring_buffer_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) size = ioc->ring_buffer_sz - ioc->ring_buffer_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) size = (size >= PAGE_SIZE) ? (PAGE_SIZE - 1) : size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) request_data = ioc->diag_buffer[0] + ioc->ring_buffer_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) memcpy(buf, request_data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) host_trace_buffer_store(struct device *cdev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) int val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) if (sscanf(buf, "%d", &val) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) ioc->ring_buffer_offset = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) static DEVICE_ATTR_RW(host_trace_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) /*****************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) * host_trace_buffer_enable_show - firmware ring buffer (trace only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) * This is a mechnism to post/release host_trace_buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) host_trace_buffer_enable_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) if ((!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) return snprintf(buf, PAGE_SIZE, "off\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) else if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) MPT3_DIAG_BUFFER_IS_RELEASED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) return snprintf(buf, PAGE_SIZE, "release\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) return snprintf(buf, PAGE_SIZE, "post\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) host_trace_buffer_enable_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) char str[10] = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) struct mpt3_diag_register diag_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) u8 issue_reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) /* don't allow post/release occurr while recovery is active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) if (ioc->shost_recovery || ioc->remove_host ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) ioc->pci_error_recovery || ioc->is_driver_loading)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) if (sscanf(buf, "%9s", str) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) if (!strcmp(str, "post")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) /* exit out if host buffers are already posted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) if ((ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) MPT3_DIAG_BUFFER_IS_REGISTERED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) MPT3_DIAG_BUFFER_IS_RELEASED) == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) memset(&diag_register, 0, sizeof(struct mpt3_diag_register));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) ioc_info(ioc, "posting host trace buffers\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) /* post the same buffer allocated previously */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) diag_register.requested_buffer_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) * Free the diag buffer memory which was previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) * allocated by an application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) if ((ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) MPT3_DIAG_BUFFER_IS_APP_OWNED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) dma_free_coherent(&ioc->pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) ioc->diag_buffer_dma[MPI2_DIAG_BUF_TYPE_TRACE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) diag_register.requested_buffer_size = (1024 * 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) diag_register.unique_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) (ioc->hba_mpi_version_belonged == MPI2_VERSION) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) _ctl_diag_register_2(ioc, &diag_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) MPT3_DIAG_BUFFER_IS_REGISTERED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) ioc_info(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) "Trace buffer %d KB allocated through sysfs\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) diag_register.requested_buffer_size>>10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) if (ioc->hba_mpi_version_belonged != MPI2_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) ioc->diag_buffer_status[
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) MPI2_DIAG_BUF_TYPE_TRACE] |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) } else if (!strcmp(str, "release")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) /* exit out if host buffers are already released */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) MPT3_DIAG_BUFFER_IS_REGISTERED) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) MPT3_DIAG_BUFFER_IS_RELEASED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) ioc_info(ioc, "releasing host trace buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) mpt3sas_send_diag_release(ioc, MPI2_DIAG_BUF_TYPE_TRACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) &issue_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) static DEVICE_ATTR_RW(host_trace_buffer_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) /*********** diagnostic trigger suppport *********************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) * diag_trigger_master_show - show the diag_trigger_master attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) diag_trigger_master_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) rc = sizeof(struct SL_WH_MASTER_TRIGGER_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) memcpy(buf, &ioc->diag_trigger_master, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) * diag_trigger_master_store - store the diag_trigger_master attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) * @count: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) diag_trigger_master_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) rc = min(sizeof(struct SL_WH_MASTER_TRIGGER_T), count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) memset(&ioc->diag_trigger_master, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) sizeof(struct SL_WH_MASTER_TRIGGER_T));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) memcpy(&ioc->diag_trigger_master, buf, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) ioc->diag_trigger_master.MasterData |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) (MASTER_TRIGGER_FW_FAULT + MASTER_TRIGGER_ADAPTER_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) static DEVICE_ATTR_RW(diag_trigger_master);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) * diag_trigger_event_show - show the diag_trigger_event attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) diag_trigger_event_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) rc = sizeof(struct SL_WH_EVENT_TRIGGERS_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) memcpy(buf, &ioc->diag_trigger_event, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) * diag_trigger_event_store - store the diag_trigger_event attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) * @count: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) diag_trigger_event_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) ssize_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) sz = min(sizeof(struct SL_WH_EVENT_TRIGGERS_T), count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) memset(&ioc->diag_trigger_event, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) sizeof(struct SL_WH_EVENT_TRIGGERS_T));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) memcpy(&ioc->diag_trigger_event, buf, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) if (ioc->diag_trigger_event.ValidEntries > NUM_VALID_ENTRIES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) ioc->diag_trigger_event.ValidEntries = NUM_VALID_ENTRIES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) return sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) static DEVICE_ATTR_RW(diag_trigger_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) * diag_trigger_scsi_show - show the diag_trigger_scsi attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) diag_trigger_scsi_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) rc = sizeof(struct SL_WH_SCSI_TRIGGERS_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) memcpy(buf, &ioc->diag_trigger_scsi, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) * diag_trigger_scsi_store - store the diag_trigger_scsi attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) * @count: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) diag_trigger_scsi_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) ssize_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) sz = min(sizeof(ioc->diag_trigger_scsi), count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) memset(&ioc->diag_trigger_scsi, 0, sizeof(ioc->diag_trigger_scsi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) memcpy(&ioc->diag_trigger_scsi, buf, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) if (ioc->diag_trigger_scsi.ValidEntries > NUM_VALID_ENTRIES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) ioc->diag_trigger_scsi.ValidEntries = NUM_VALID_ENTRIES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) return sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) static DEVICE_ATTR_RW(diag_trigger_scsi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) * diag_trigger_scsi_show - show the diag_trigger_mpi attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) diag_trigger_mpi_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) ssize_t rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) rc = sizeof(struct SL_WH_MPI_TRIGGERS_T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) memcpy(buf, &ioc->diag_trigger_mpi, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) * diag_trigger_mpi_store - store the diag_trigger_mpi attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) * @count: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) * A sysfs 'read/write' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) diag_trigger_mpi_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) ssize_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) sz = min(sizeof(struct SL_WH_MPI_TRIGGERS_T), count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) memset(&ioc->diag_trigger_mpi, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) sizeof(ioc->diag_trigger_mpi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) memcpy(&ioc->diag_trigger_mpi, buf, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) return sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) static DEVICE_ATTR_RW(diag_trigger_mpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) /*********** diagnostic trigger suppport *** END ****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) /*****************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) * drv_support_bitmap_show - driver supported feature bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) * @attr: unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) drv_support_bitmap_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) static DEVICE_ATTR_RO(drv_support_bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) * enable_sdev_max_qd_show - display whether sdev max qd is enabled/disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) * @attr: unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) * A sysfs read/write shost attribute. This attribute is used to set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) * targets queue depth to HBA IO queue depth if this attribute is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) enable_sdev_max_qd_show(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) return snprintf(buf, PAGE_SIZE, "%d\n", ioc->enable_sdev_max_qd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) * enable_sdev_max_qd_store - Enable/disable sdev max qd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) * @cdev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) * @attr: unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) * @count: unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) * A sysfs read/write shost attribute. This attribute is used to set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) * targets queue depth to HBA IO queue depth if this attribute is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) * If this attribute is disabled then targets will have corresponding default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) * queue depth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) enable_sdev_max_qd_store(struct device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) struct device_attribute *attr, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) struct Scsi_Host *shost = class_to_shost(cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) struct MPT3SAS_DEVICE *sas_device_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) struct MPT3SAS_TARGET *sas_target_priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) int val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) struct scsi_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) struct _raid_device *raid_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) int qdepth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) if (kstrtoint(buf, 0, &val) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) ioc->enable_sdev_max_qd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) shost_for_each_device(sdev, ioc->shost) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) if (!sas_device_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) sas_target_priv_data = sas_device_priv_data->sas_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) if (!sas_target_priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) if (sas_target_priv_data->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) MPT_TARGET_FLAGS_VOLUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) raid_device =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) mpt3sas_raid_device_find_by_handle(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) sas_target_priv_data->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) switch (raid_device->volume_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) case MPI2_RAID_VOL_TYPE_RAID0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) if (raid_device->device_info &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) MPI2_SAS_DEVICE_INFO_SSP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) qdepth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) MPT3SAS_SAS_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) qdepth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) MPT3SAS_SATA_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) case MPI2_RAID_VOL_TYPE_RAID1E:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) case MPI2_RAID_VOL_TYPE_RAID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) case MPI2_RAID_VOL_TYPE_RAID10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) case MPI2_RAID_VOL_TYPE_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) } else if (sas_target_priv_data->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) MPT_TARGET_FLAGS_PCIE_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) qdepth = MPT3SAS_NVME_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) qdepth = MPT3SAS_SAS_QUEUE_DEPTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) mpt3sas_scsih_change_queue_depth(sdev, qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) ioc->enable_sdev_max_qd = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) shost_for_each_device(sdev, ioc->shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) mpt3sas_scsih_change_queue_depth(sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) shost->can_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) static DEVICE_ATTR_RW(enable_sdev_max_qd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) struct device_attribute *mpt3sas_host_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) &dev_attr_version_fw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) &dev_attr_version_bios,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) &dev_attr_version_mpi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) &dev_attr_version_product,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) &dev_attr_version_nvdata_persistent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) &dev_attr_version_nvdata_default,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) &dev_attr_board_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) &dev_attr_board_assembly,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) &dev_attr_board_tracer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) &dev_attr_io_delay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) &dev_attr_device_delay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) &dev_attr_logging_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) &dev_attr_fwfault_debug,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) &dev_attr_fw_queue_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) &dev_attr_host_sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) &dev_attr_ioc_reset_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) &dev_attr_host_trace_buffer_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) &dev_attr_host_trace_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) &dev_attr_host_trace_buffer_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) &dev_attr_reply_queue_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) &dev_attr_diag_trigger_master,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) &dev_attr_diag_trigger_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) &dev_attr_diag_trigger_scsi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) &dev_attr_diag_trigger_mpi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) &dev_attr_drv_support_bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) &dev_attr_BRM_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) &dev_attr_enable_sdev_max_qd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) /* device attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) * sas_address_show - sas address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) * @dev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) * This is the sas address for the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) sas_address_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) (unsigned long long)sas_device_priv_data->sas_target->sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) static DEVICE_ATTR_RO(sas_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) * sas_device_handle_show - device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) * @dev: pointer to embedded class device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) * This is the firmware assigned device handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) * A sysfs 'read-only' shost attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) sas_device_handle_show(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) return snprintf(buf, PAGE_SIZE, "0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) sas_device_priv_data->sas_target->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) static DEVICE_ATTR_RO(sas_device_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) * sas_ncq_io_prio_show - send prioritized io commands to device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) * @dev: pointer to embedded device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) * @attr: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) * @buf: the buffer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) * A sysfs 'read/write' sdev attribute, only works with SATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) sas_ncq_prio_enable_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) return snprintf(buf, PAGE_SIZE, "%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) sas_device_priv_data->ncq_prio_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) sas_ncq_prio_enable_store(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) struct scsi_device *sdev = to_scsi_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) bool ncq_prio_enable = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) if (kstrtobool(buf, &ncq_prio_enable))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) if (!scsih_ncq_prio_supp(sdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) sas_device_priv_data->ncq_prio_enable = ncq_prio_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) return strlen(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) static DEVICE_ATTR_RW(sas_ncq_prio_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) struct device_attribute *mpt3sas_dev_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) &dev_attr_sas_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) &dev_attr_sas_device_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) &dev_attr_sas_ncq_prio_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) /* file operations table for mpt3ctl device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) static const struct file_operations ctl_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) .unlocked_ioctl = _ctl_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) .poll = _ctl_poll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) .fasync = _ctl_fasync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) .compat_ioctl = _ctl_ioctl_compat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) /* file operations table for mpt2ctl device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) static const struct file_operations ctl_gen2_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) .unlocked_ioctl = _ctl_mpt2_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) .poll = _ctl_poll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) .fasync = _ctl_fasync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) .compat_ioctl = _ctl_mpt2_ioctl_compat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) static struct miscdevice ctl_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) .minor = MPT3SAS_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) .name = MPT3SAS_DEV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) .fops = &ctl_fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) static struct miscdevice gen2_ctl_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) .minor = MPT2SAS_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) .name = MPT2SAS_DEV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) .fops = &ctl_gen2_fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) * mpt3sas_ctl_init - main entry point for ctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) * @hbas_to_enumerate: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) mpt3sas_ctl_init(ushort hbas_to_enumerate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) async_queue = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) /* Don't register mpt3ctl ioctl device if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) * hbas_to_enumarate is one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) if (hbas_to_enumerate != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) if (misc_register(&ctl_dev) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) pr_err("%s can't register misc device [minor=%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) /* Don't register mpt3ctl ioctl device if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) * hbas_to_enumarate is two.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) if (hbas_to_enumerate != 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) if (misc_register(&gen2_ctl_dev) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) pr_err("%s can't register misc device [minor=%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) MPT2SAS_DRIVER_NAME, MPT2SAS_MINOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) init_waitqueue_head(&ctl_poll_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) * mpt3sas_ctl_exit - exit point for ctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) * @hbas_to_enumerate: ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) mpt3sas_ctl_exit(ushort hbas_to_enumerate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) struct MPT3SAS_ADAPTER *ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) list_for_each_entry(ioc, &mpt3sas_ioc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) /* free memory associated to diag buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) if (!ioc->diag_buffer[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) dma_free_coherent(&ioc->pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) ioc->diag_buffer_sz[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) ioc->diag_buffer[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) ioc->diag_buffer_dma[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) ioc->diag_buffer[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) ioc->diag_buffer_status[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) kfree(ioc->event_log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) if (hbas_to_enumerate != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) misc_deregister(&ctl_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) if (hbas_to_enumerate != 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) misc_deregister(&gen2_ctl_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) }