From d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 02:45:28 +0000 Subject: [PATCH] add boot partition size --- kernel/drivers/scsi/qla1280.c | 184 ++++++++++++++-------------------------------- 1 files changed, 56 insertions(+), 128 deletions(-) diff --git a/kernel/drivers/scsi/qla1280.c b/kernel/drivers/scsi/qla1280.c index 390775d..545936c 100644 --- a/kernel/drivers/scsi/qla1280.c +++ b/kernel/drivers/scsi/qla1280.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /****************************************************************************** * QLOGIC LINUX SOFTWARE * @@ -5,16 +6,6 @@ * Copyright (C) 2000 Qlogic Corporation (www.qlogic.com) * Copyright (C) 2001-2004 Jes Sorensen, Wild Open Source Inc. * Copyright (C) 2003-2004 Christoph Hellwig -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2, or (at your option) any -* later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. * ******************************************************************************/ #define QLA1280_VERSION "3.27.1" @@ -366,10 +357,6 @@ #include <scsi/scsi_host.h> #include <scsi/scsi_tcq.h> -#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) -#include <asm/sn/io.h> -#endif - /* * Compile time Options: @@ -383,26 +370,11 @@ #include "qla1280.h" -#ifndef BITS_PER_LONG -#error "BITS_PER_LONG not defined!" -#endif -#if (BITS_PER_LONG == 64) || defined CONFIG_HIGHMEM +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT #define QLA_64BIT_PTR 1 #endif -#ifdef QLA_64BIT_PTR -#define pci_dma_hi32(a) ((a >> 16) >> 16) -#else -#define pci_dma_hi32(a) 0 -#endif -#define pci_dma_lo32(a) (a & 0xffffffff) - #define NVRAM_DELAY() udelay(500) /* 2 microseconds */ - -#if defined(__ia64__) && !defined(ia64_platform_is) -#define ia64_platform_is(foo) (!strcmp(x, platform_name)) -#endif - #define IS_ISP1040(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020) #define IS_ISP1x40(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020 || \ @@ -554,7 +526,7 @@ }; MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl); -DEFINE_MUTEX(qla1280_firmware_mutex); +static DEFINE_MUTEX(qla1280_firmware_mutex); struct qla_fw { char *fwname; @@ -563,7 +535,7 @@ #define QL_NUM_FW_IMAGES 3 -struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = { +static struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = { {"qlogic/1040.bin", NULL}, /* image 0 */ {"qlogic/1280.bin", NULL}, /* image 1 */ {"qlogic/12160.bin", NULL}, /* image 2 */ @@ -1269,7 +1241,7 @@ { struct srb *sp; struct list_head *done_q; - int bus, target, lun; + int bus, target; struct scsi_cmnd *cmd; ENTER("qla1280_done"); @@ -1284,7 +1256,6 @@ cmd = sp->cmd; bus = SCSI_BUS_32(cmd); target = SCSI_TCN_32(cmd); - lun = SCSI_LUN_32(cmd); switch ((CMD_RESULT(cmd) >> 16)) { case DID_RESET: @@ -1445,15 +1416,6 @@ ha->flags.disable_host_adapter = 0; ha->flags.reset_active = 0; ha->flags.abort_isp_active = 0; - -#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) - if (ia64_platform_is("sn2")) { - printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA " - "dual channel lockup workaround\n", ha->host_no); - ha->flags.use_pci_vchannel = 1; - driver_setup.no_nvram = 1; - } -#endif /* TODO: implement support for the 1040 nvram format */ if (IS_ISP1040(ha)) @@ -1736,6 +1698,16 @@ return err; } +#ifdef QLA_64BIT_PTR +#define LOAD_CMD MBC_LOAD_RAM_A64_ROM +#define DUMP_CMD MBC_DUMP_RAM_A64_ROM +#define CMD_ARGS (BIT_7 | BIT_6 | BIT_4 | BIT_3 | BIT_2 | BIT_1 | BIT_0) +#else +#define LOAD_CMD MBC_LOAD_RAM +#define DUMP_CMD MBC_DUMP_RAM +#define CMD_ARGS (BIT_4 | BIT_3 | BIT_2 | BIT_1 | BIT_0) +#endif + #define DUMP_IT_BACK 0 /* for debug of RISC loading */ static int qla1280_load_firmware_dma(struct scsi_qla_host *ha) @@ -1750,7 +1722,7 @@ uint8_t *sp, *tbuf; dma_addr_t p_tbuf; - tbuf = pci_alloc_consistent(ha->pdev, 8000, &p_tbuf); + tbuf = dma_alloc_coherent(&ha->pdev->dev, 8000, &p_tbuf, GFP_KERNEL); if (!tbuf) return -ENOMEM; #endif @@ -1785,19 +1757,18 @@ for(i = 0; i < cnt; i++) ((__le16 *)ha->request_ring)[i] = fw_data[i]; - mb[0] = MBC_LOAD_RAM; + mb[0] = LOAD_CMD; mb[1] = risc_address; mb[4] = cnt; mb[3] = ha->request_dma & 0xffff; mb[2] = (ha->request_dma >> 16) & 0xffff; - mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff; - mb[6] = pci_dma_hi32(ha->request_dma) >> 16; + mb[7] = upper_32_bits(ha->request_dma) & 0xffff; + mb[6] = upper_32_bits(ha->request_dma) >> 16; dprintk(2, "%s: op=%d 0x%p = 0x%4x,0x%4x,0x%4x,0x%4x\n", __func__, mb[0], (void *)(long)ha->request_dma, mb[6], mb[7], mb[2], mb[3]); - err = qla1280_mailbox_command(ha, BIT_4 | BIT_3 | BIT_2 | - BIT_1 | BIT_0, mb); + err = qla1280_mailbox_command(ha, CMD_ARGS, mb); if (err) { printk(KERN_ERR "scsi(%li): Failed to load partial " "segment of f\n", ha->host_no); @@ -1805,16 +1776,15 @@ } #if DUMP_IT_BACK - mb[0] = MBC_DUMP_RAM; + mb[0] = DUMP_CMD; mb[1] = risc_address; mb[4] = cnt; mb[3] = p_tbuf & 0xffff; mb[2] = (p_tbuf >> 16) & 0xffff; - mb[7] = pci_dma_hi32(p_tbuf) & 0xffff; - mb[6] = pci_dma_hi32(p_tbuf) >> 16; + mb[7] = upper_32_bits(p_tbuf) & 0xffff; + mb[6] = upper_32_bits(p_tbuf) >> 16; - err = qla1280_mailbox_command(ha, BIT_4 | BIT_3 | BIT_2 | - BIT_1 | BIT_0, mb); + err = qla1280_mailbox_command(ha, CMD_ARGS, mb); if (err) { printk(KERN_ERR "Failed to dump partial segment of f/w\n"); @@ -1841,7 +1811,7 @@ out: #if DUMP_IT_BACK - pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf); + dma_free_coherent(&ha->pdev->dev, 8000, tbuf, p_tbuf); #endif return err; } @@ -1933,8 +1903,8 @@ mb[3] = ha->request_dma & 0xffff; mb[2] = (ha->request_dma >> 16) & 0xffff; mb[4] = 0; - mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff; - mb[6] = pci_dma_hi32(ha->request_dma) >> 16; + mb[7] = upper_32_bits(ha->request_dma) & 0xffff; + mb[6] = upper_32_bits(ha->request_dma) >> 16; if (!(status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_4 | BIT_3 | BIT_2 | BIT_1 | BIT_0, &mb[0]))) { @@ -1947,8 +1917,8 @@ mb[3] = ha->response_dma & 0xffff; mb[2] = (ha->response_dma >> 16) & 0xffff; mb[5] = 0; - mb[7] = pci_dma_hi32(ha->response_dma) & 0xffff; - mb[6] = pci_dma_hi32(ha->response_dma) >> 16; + mb[7] = upper_32_bits(ha->response_dma) & 0xffff; + mb[6] = upper_32_bits(ha->response_dma) >> 16; status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_5 | BIT_3 | BIT_2 | BIT_1 | BIT_0, &mb[0]); @@ -2214,13 +2184,12 @@ nv->cntr_flags_1.disable_loading_risc_code; if (IS_ISP1040(ha)) { - uint16_t hwrev, cfg1, cdma_conf, ddma_conf; + uint16_t hwrev, cfg1, cdma_conf; hwrev = RD_REG_WORD(®->cfg_0) & ISP_CFG0_HWMSK; cfg1 = RD_REG_WORD(®->cfg_1) & ~(BIT_4 | BIT_5 | BIT_6); cdma_conf = RD_REG_WORD(®->cdma_cfg); - ddma_conf = RD_REG_WORD(®->ddma_cfg); /* Busted fifo, says mjacob. */ if (hwrev != ISP_CFG0_1040A) @@ -2270,13 +2239,6 @@ mb[1] = nv->firmware_feature.f.enable_fast_posting; mb[1] |= nv->firmware_feature.f.report_lvd_bus_transition << 1; mb[1] |= nv->firmware_feature.f.disable_synchronous_backoff << 5; -#if defined(CONFIG_IA64_GENERIC) || defined (CONFIG_IA64_SGI_SN2) - if (ia64_platform_is("sn2")) { - printk(KERN_INFO "scsi(%li): Enabling SN2 PCI DMA " - "workaround\n", ha->host_no); - mb[1] |= nv->firmware_feature.f.unused_9 << 9; /* XXX */ - } -#endif status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); /* Retry count and delay. */ @@ -2463,7 +2425,6 @@ int cnt; uint16_t *optr, *iptr; uint16_t __iomem *mptr; - uint16_t data; DECLARE_COMPLETION_ONSTACK(wait); ENTER("qla1280_mailbox_command"); @@ -2498,7 +2459,7 @@ spin_unlock_irq(ha->host->host_lock); WRT_REG_WORD(®->host_cmd, HC_SET_HOST_INT); - data = qla1280_debounce_register(®->istatus); + qla1280_debounce_register(®->istatus); wait_for_completion(&wait); del_timer_sync(&ha->mailbox_timer); @@ -2907,20 +2868,14 @@ break; dma_handle = sg_dma_address(s); -#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) - if (ha->flags.use_pci_vchannel) - sn_pci_set_vchan(ha->pdev, - (unsigned long *)&dma_handle, - SCSI_BUS_32(cmd)); -#endif *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(dma_handle)); + cpu_to_le32(lower_32_bits(dma_handle)); *dword_ptr++ = - cpu_to_le32(pci_dma_hi32(dma_handle)); + cpu_to_le32(upper_32_bits(dma_handle)); *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n", - cpu_to_le32(pci_dma_hi32(dma_handle)), - cpu_to_le32(pci_dma_lo32(dma_handle)), + cpu_to_le32(upper_32_bits(dma_handle)), + cpu_to_le32(lower_32_bits(dma_handle)), cpu_to_le32(sg_dma_len(sg_next(s)))); remseg--; } @@ -2969,21 +2924,15 @@ if (cnt == 5) break; dma_handle = sg_dma_address(s); -#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) - if (ha->flags.use_pci_vchannel) - sn_pci_set_vchan(ha->pdev, - (unsigned long *)&dma_handle, - SCSI_BUS_32(cmd)); -#endif *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(dma_handle)); + cpu_to_le32(lower_32_bits(dma_handle)); *dword_ptr++ = - cpu_to_le32(pci_dma_hi32(dma_handle)); + cpu_to_le32(upper_32_bits(dma_handle)); *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n", - cpu_to_le32(pci_dma_hi32(dma_handle)), - cpu_to_le32(pci_dma_lo32(dma_handle)), + cpu_to_le32(upper_32_bits(dma_handle)), + cpu_to_le32(lower_32_bits(dma_handle)), cpu_to_le32(sg_dma_len(s))); } remseg -= cnt; @@ -3014,8 +2963,6 @@ sp->flags |= SRB_SENT; ha->actthreads++; WRT_REG_WORD(®->mailbox4, ha->req_ring_index); - /* Enforce mmio write ordering; see comment in qla1280_isp_cmd(). */ - mmiowb(); out: if (status) @@ -3178,10 +3125,10 @@ if (cnt == 4) break; *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); + cpu_to_le32(lower_32_bits(sg_dma_address(s))); *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n", - (pci_dma_lo32(sg_dma_address(s))), + (lower_32_bits(sg_dma_address(s))), (sg_dma_len(s))); remseg--; } @@ -3224,13 +3171,13 @@ if (cnt == 7) break; *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); + cpu_to_le32(lower_32_bits(sg_dma_address(s))); *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); dprintk(1, "S/G Segment Cont. phys_addr=0x%x, " "len=0x%x\n", - cpu_to_le32(pci_dma_lo32(sg_dma_address(s))), + cpu_to_le32(lower_32_bits(sg_dma_address(s))), cpu_to_le32(sg_dma_len(s))); } remseg -= cnt; @@ -3264,8 +3211,6 @@ sp->flags |= SRB_SENT; ha->actthreads++; WRT_REG_WORD(®->mailbox4, ha->req_ring_index); - /* Enforce mmio write ordering; see comment in qla1280_isp_cmd(). */ - mmiowb(); out: if (status) @@ -3377,19 +3322,8 @@ /* * Update request index to mailbox4 (Request Queue In). - * The mmiowb() ensures that this write is ordered with writes by other - * CPUs. Without the mmiowb(), it is possible for the following: - * CPUA posts write of index 5 to mailbox4 - * CPUA releases host lock - * CPUB acquires host lock - * CPUB posts write of index 6 to mailbox4 - * On PCI bus, order reverses and write of 6 posts, then index 5, - * causing chip to issue full queue of stale commands - * The mmiowb() prevents future writes from crossing the barrier. - * See Documentation/driver-api/device-io.rst for more information. */ WRT_REG_WORD(®->mailbox4, ha->req_ring_index); - mmiowb(); LEAVE("qla1280_isp_cmd"); } @@ -3667,7 +3601,6 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt, struct list_head *done_q) { - unsigned int bus, target, lun; int sense_sz; struct srb *sp; struct scsi_cmnd *cmd; @@ -3692,11 +3625,6 @@ ha->outstanding_cmds[handle] = NULL; cmd = sp->cmd; - - /* Generate LU queue on cntrl, target, LUN */ - bus = SCSI_BUS_32(cmd); - target = SCSI_TCN_32(cmd); - lun = SCSI_LUN_32(cmd); if (comp_status || scsi_status) { dprintk(3, "scsi: comp_status = 0x%x, scsi_status = " @@ -3736,7 +3664,8 @@ dprintk(2, "qla1280_status_entry: Check " "condition Sense data, b %i, t %i, " - "l %i\n", bus, target, lun); + "l %i\n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), + SCSI_LUN_32(cmd)); if (sense_sz) qla1280_dump_buffer(2, (char *)cmd->sense_buffer, @@ -4213,7 +4142,6 @@ .can_queue = MAX_OUTSTANDING_COMMANDS, .this_id = -1, .sg_tablesize = SG_ALL, - .use_clustering = ENABLE_CLUSTERING, }; @@ -4259,8 +4187,8 @@ ha->devnum = devnum; /* specifies microcode load address */ #ifdef QLA_64BIT_PTR - if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { - if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32))) { + if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { + if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; @@ -4270,7 +4198,7 @@ dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n", ha->host_no); #else - if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32))) { + if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; @@ -4278,17 +4206,17 @@ } #endif - ha->request_ring = pci_alloc_consistent(ha->pdev, + ha->request_ring = dma_alloc_coherent(&ha->pdev->dev, ((REQUEST_ENTRY_CNT + 1) * sizeof(request_t)), - &ha->request_dma); + &ha->request_dma, GFP_KERNEL); if (!ha->request_ring) { printk(KERN_INFO "qla1280: Failed to get request memory\n"); goto error_put_host; } - ha->response_ring = pci_alloc_consistent(ha->pdev, + ha->response_ring = dma_alloc_coherent(&ha->pdev->dev, ((RESPONSE_ENTRY_CNT + 1) * sizeof(struct response)), - &ha->response_dma); + &ha->response_dma, GFP_KERNEL); if (!ha->response_ring) { printk(KERN_INFO "qla1280: Failed to get response memory\n"); goto error_free_request_ring; @@ -4370,11 +4298,11 @@ release_region(host->io_port, 0xff); #endif error_free_response_ring: - pci_free_consistent(ha->pdev, + dma_free_coherent(&ha->pdev->dev, ((RESPONSE_ENTRY_CNT + 1) * sizeof(struct response)), ha->response_ring, ha->response_dma); error_free_request_ring: - pci_free_consistent(ha->pdev, + dma_free_coherent(&ha->pdev->dev, ((REQUEST_ENTRY_CNT + 1) * sizeof(request_t)), ha->request_ring, ha->request_dma); error_put_host: @@ -4404,10 +4332,10 @@ release_region(host->io_port, 0xff); #endif - pci_free_consistent(ha->pdev, + dma_free_coherent(&ha->pdev->dev, ((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))), ha->request_ring, ha->request_dma); - pci_free_consistent(ha->pdev, + dma_free_coherent(&ha->pdev->dev, ((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))), ha->response_ring, ha->response_dma); -- Gitblit v1.6.2