diff options
Diffstat (limited to 'drivers/block')
38 files changed, 3007 insertions, 10739 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 245a879b036e..255591ab3716 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -1678,9 +1678,12 @@ static bool DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T Enquiry2->FirmwareID.FirmwareType = '0'; Enquiry2->FirmwareID.TurnID = 0; } - sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d", - Enquiry2->FirmwareID.MajorVersion, Enquiry2->FirmwareID.MinorVersion, - Enquiry2->FirmwareID.FirmwareType, Enquiry2->FirmwareID.TurnID); + snprintf(Controller->FirmwareVersion, sizeof(Controller->FirmwareVersion), + "%d.%02d-%c-%02d", + Enquiry2->FirmwareID.MajorVersion, + Enquiry2->FirmwareID.MinorVersion, + Enquiry2->FirmwareID.FirmwareType, + Enquiry2->FirmwareID.TurnID); if (!((Controller->FirmwareVersion[0] == '5' && strcmp(Controller->FirmwareVersion, "5.06") >= 0) || (Controller->FirmwareVersion[0] == '4' && @@ -6588,7 +6591,8 @@ static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller) &dac960_proc_fops); } - sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber); + snprintf(Controller->ControllerName, sizeof(Controller->ControllerName), + "c%d", Controller->ControllerNumber); ControllerProcEntry = proc_mkdir(Controller->ControllerName, DAC960_ProcDirectoryEntry); proc_create_data("initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller); diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 8ddc98279c8f..4a438b8abe27 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -17,6 +17,7 @@ if BLK_DEV config BLK_DEV_NULL_BLK tristate "Null test block driver" + depends on CONFIGFS_FS config BLK_DEV_FD tristate "Normal floppy disk support" @@ -111,33 +112,6 @@ source "drivers/block/mtip32xx/Kconfig" source "drivers/block/zram/Kconfig" -config BLK_CPQ_CISS_DA - tristate "Compaq Smart Array 5xxx support" - depends on PCI - select CHECK_SIGNATURE - select BLK_SCSI_REQUEST - help - This is the driver for Compaq Smart Array 5xxx controllers. - Everyone using these boards should say Y here. - See <file:Documentation/blockdev/cciss.txt> for the current list of - boards supported by this driver, and for further information - on the use of this driver. - -config CISS_SCSI_TAPE - bool "SCSI tape drive support for Smart Array 5xxx" - depends on BLK_CPQ_CISS_DA && PROC_FS - depends on SCSI=y || SCSI=BLK_CPQ_CISS_DA - help - When enabled (Y), this option allows SCSI tape drives and SCSI medium - changers (tape robots) to be accessed via a Compaq 5xxx array - controller. (See <file:Documentation/blockdev/cciss.txt> for more details.) - - "SCSI support" and "SCSI tape support" must also be enabled for this - option to work. - - When this option is disabled (N), the SCSI portion of the driver - is not compiled. - config BLK_DEV_DAC960 tristate "Mylex DAC960/DAC1100 PCI RAID Controller support" depends on PCI @@ -470,7 +444,7 @@ config VIRTIO_BLK depends on VIRTIO ---help--- This is the virtual block driver for virtio. It can be used with - lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. + QEMU based VMMs (like KVM or Xen). Say Y or M. config VIRTIO_BLK_SCSI bool "SCSI passthrough request for the Virtio block driver" diff --git a/drivers/block/Makefile b/drivers/block/Makefile index ec8c36897b75..1f456d86a190 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -15,7 +15,6 @@ obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o obj-$(CONFIG_BLK_DEV_RAM) += brd.o obj-$(CONFIG_BLK_DEV_LOOP) += loop.o -obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss.o obj-$(CONFIG_BLK_DEV_DAC960) += DAC960.o obj-$(CONFIG_XILINX_SYSACE) += xsysace.o obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 104b71c0490d..bbd0d186cfc0 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -294,14 +294,13 @@ out: static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio) { - struct block_device *bdev = bio->bi_bdev; - struct brd_device *brd = bdev->bd_disk->private_data; + struct brd_device *brd = bio->bi_disk->private_data; struct bio_vec bvec; sector_t sector; struct bvec_iter iter; sector = bio->bi_iter.bi_sector; - if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) + if (bio_end_sector(bio) > get_capacity(bio->bi_disk)) goto io_error; bio_for_each_segment(bvec, bio, iter) { @@ -326,7 +325,11 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector, struct page *page, bool is_write) { struct brd_device *brd = bdev->bd_disk->private_data; - int err = brd_do_bvec(brd, page, PAGE_SIZE, 0, is_write, sector); + int err; + + if (PageTransHuge(page)) + return -ENOTSUPP; + err = brd_do_bvec(brd, page, PAGE_SIZE, 0, is_write, sector); page_endio(page, is_write, err); return err; } diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c deleted file mode 100644 index 678af946be30..000000000000 --- a/drivers/block/cciss.c +++ /dev/null @@ -1,5415 +0,0 @@ -/* - * Disk Array driver for HP Smart Array controllers. - * (C) Copyright 2000, 2007 Hewlett-Packard Development Company, L.P. - * - * 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; version 2 of the License. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307, USA. - * - * Questions/Comments/Bugfixes to iss_storagedev@hp.com - * - */ - -#include <linux/module.h> -#include <linux/interrupt.h> -#include <linux/types.h> -#include <linux/pci.h> -#include <linux/pci-aspm.h> -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/major.h> -#include <linux/fs.h> -#include <linux/bio.h> -#include <linux/blkpg.h> -#include <linux/timer.h> -#include <linux/proc_fs.h> -#include <linux/seq_file.h> -#include <linux/init.h> -#include <linux/jiffies.h> -#include <linux/hdreg.h> -#include <linux/spinlock.h> -#include <linux/compat.h> -#include <linux/mutex.h> -#include <linux/bitmap.h> -#include <linux/io.h> -#include <linux/uaccess.h> - -#include <linux/dma-mapping.h> -#include <linux/blkdev.h> -#include <linux/genhd.h> -#include <linux/completion.h> -#include <scsi/scsi.h> -#include <scsi/sg.h> -#include <scsi/scsi_ioctl.h> -#include <scsi/scsi_request.h> -#include <linux/cdrom.h> -#include <linux/scatterlist.h> -#include <linux/kthread.h> - -#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) -#define DRIVER_NAME "HP CISS Driver (v 3.6.26)" -#define DRIVER_VERSION CCISS_DRIVER_VERSION(3, 6, 26) - -/* Embedded module documentation macros - see modules.h */ -MODULE_AUTHOR("Hewlett-Packard Company"); -MODULE_DESCRIPTION("Driver for HP Smart Array Controllers"); -MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers"); -MODULE_VERSION("3.6.26"); -MODULE_LICENSE("GPL"); -static int cciss_tape_cmds = 6; -module_param(cciss_tape_cmds, int, 0644); -MODULE_PARM_DESC(cciss_tape_cmds, - "number of commands to allocate for tape devices (default: 6)"); -static int cciss_simple_mode; -module_param(cciss_simple_mode, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(cciss_simple_mode, - "Use 'simple mode' rather than 'performant mode'"); - -static int cciss_allow_hpsa; -module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(cciss_allow_hpsa, - "Prevent cciss driver from accessing hardware known to be " - " supported by the hpsa driver"); - -static DEFINE_MUTEX(cciss_mutex); -static struct proc_dir_entry *proc_cciss; - -#include "cciss_cmd.h" -#include "cciss.h" -#include <linux/cciss_ioctl.h> - -/* define the PCI info for the cards we can control */ -static const struct pci_device_id cciss_pci_device_id[] = { - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, 0x0E11, 0x4070}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4080}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4082}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4083}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x4091}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409A}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409B}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409C}, - {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409D}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, 0x103C, 0x3225}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3223}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3234}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3235}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3211}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3212}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3237}, - {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x323D}, - {0,} -}; - -MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); - -/* board_id = Subsystem Device ID & Vendor ID - * product = Marketing Name for the board - * access = Address of the struct of function pointers - */ -static struct board_type products[] = { - {0x40700E11, "Smart Array 5300", &SA5_access}, - {0x40800E11, "Smart Array 5i", &SA5B_access}, - {0x40820E11, "Smart Array 532", &SA5B_access}, - {0x40830E11, "Smart Array 5312", &SA5B_access}, - {0x409A0E11, "Smart Array 641", &SA5_access}, - {0x409B0E11, "Smart Array 642", &SA5_access}, - {0x409C0E11, "Smart Array 6400", &SA5_access}, - {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, - {0x40910E11, "Smart Array 6i", &SA5_access}, - {0x3225103C, "Smart Array P600", &SA5_access}, - {0x3223103C, "Smart Array P800", &SA5_access}, - {0x3234103C, "Smart Array P400", &SA5_access}, - {0x3235103C, "Smart Array P400i", &SA5_access}, - {0x3211103C, "Smart Array E200i", &SA5_access}, - {0x3212103C, "Smart Array E200", &SA5_access}, - {0x3213103C, "Smart Array E200i", &SA5_access}, - {0x3214103C, "Smart Array E200i", &SA5_access}, - {0x3215103C, "Smart Array E200i", &SA5_access}, - {0x3237103C, "Smart Array E500", &SA5_access}, - {0x323D103C, "Smart Array P700m", &SA5_access}, -}; - -/* How long to wait (in milliseconds) for board to go into simple mode */ -#define MAX_CONFIG_WAIT 30000 -#define MAX_IOCTL_CONFIG_WAIT 1000 - -/*define how many times we will try a command because of bus resets */ -#define MAX_CMD_RETRIES 3 - -#define MAX_CTLR 32 - -/* Originally cciss driver only supports 8 major numbers */ -#define MAX_CTLR_ORIG 8 - -static ctlr_info_t *hba[MAX_CTLR]; - -static struct task_struct *cciss_scan_thread; -static DEFINE_MUTEX(scan_mutex); -static LIST_HEAD(scan_q); - -static void do_cciss_request(struct request_queue *q); -static irqreturn_t do_cciss_intx(int irq, void *dev_id); -static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id); -static int cciss_open(struct block_device *bdev, fmode_t mode); -static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode); -static void cciss_release(struct gendisk *disk, fmode_t mode); -static int cciss_ioctl(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg); -static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); - -static int cciss_revalidate(struct gendisk *disk); -static int rebuild_lun_table(ctlr_info_t *h, int first_time, int via_ioctl); -static int deregister_disk(ctlr_info_t *h, int drv_index, - int clear_all, int via_ioctl); - -static void cciss_read_capacity(ctlr_info_t *h, int logvol, - sector_t *total_size, unsigned int *block_size); -static void cciss_read_capacity_16(ctlr_info_t *h, int logvol, - sector_t *total_size, unsigned int *block_size); -static void cciss_geometry_inquiry(ctlr_info_t *h, int logvol, - sector_t total_size, - unsigned int block_size, InquiryData_struct *inq_buff, - drive_info_struct *drv); -static void cciss_interrupt_mode(ctlr_info_t *); -static int cciss_enter_simple_mode(struct ctlr_info *h); -static void start_io(ctlr_info_t *h); -static int sendcmd_withirq(ctlr_info_t *h, __u8 cmd, void *buff, size_t size, - __u8 page_code, unsigned char scsi3addr[], - int cmd_type); -static int sendcmd_withirq_core(ctlr_info_t *h, CommandList_struct *c, - int attempt_retry); -static int process_sendcmd_error(ctlr_info_t *h, CommandList_struct *c); - -static int add_to_scan_list(struct ctlr_info *h); -static int scan_thread(void *data); -static int check_for_unit_attention(ctlr_info_t *h, CommandList_struct *c); -static void cciss_hba_release(struct device *dev); -static void cciss_device_release(struct device *dev); -static void cciss_free_gendisk(ctlr_info_t *h, int drv_index); -static void cciss_free_drive_info(ctlr_info_t *h, int drv_index); -static inline u32 next_command(ctlr_info_t *h); -static int cciss_find_cfg_addrs(struct pci_dev *pdev, void __iomem *vaddr, - u32 *cfg_base_addr, u64 *cfg_base_addr_index, - u64 *cfg_offset); -static int cciss_pci_find_memory_BAR(struct pci_dev *pdev, - unsigned long *memory_bar); -static inline u32 cciss_tag_discard_error_bits(ctlr_info_t *h, u32 tag); -static int write_driver_ver_to_cfgtable(CfgTable_struct __iomem *cfgtable); - -/* performant mode helper functions */ -static void calc_bucket_map(int *bucket, int num_buckets, int nsgs, - int *bucket_map); -static void cciss_put_controller_into_performant_mode(ctlr_info_t *h); - -#ifdef CONFIG_PROC_FS -static void cciss_procinit(ctlr_info_t *h); -#else -static void cciss_procinit(ctlr_info_t *h) -{ -} -#endif /* CONFIG_PROC_FS */ - -#ifdef CONFIG_COMPAT -static int cciss_compat_ioctl(struct block_device *, fmode_t, - unsigned, unsigned long); -#endif - -static const struct block_device_operations cciss_fops = { - .owner = THIS_MODULE, - .open = cciss_unlocked_open, - .release = cciss_release, - .ioctl = cciss_ioctl, - .getgeo = cciss_getgeo, -#ifdef CONFIG_COMPAT - .compat_ioctl = cciss_compat_ioctl, -#endif - .revalidate_disk = cciss_revalidate, -}; - -/* set_performant_mode: Modify the tag for cciss performant - * set bit 0 for pull model, bits 3-1 for block fetch - * register number - */ -static void set_performant_mode(ctlr_info_t *h, CommandList_struct *c) -{ - if (likely(h->transMethod & CFGTBL_Trans_Performant)) - c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); -} - -/* - * Enqueuing and dequeuing functions for cmdlists. - */ -static inline void addQ(struct list_head *list, CommandList_struct *c) -{ - list_add_tail(&c->list, list); -} - -static inline void removeQ(CommandList_struct *c) -{ - /* - * After kexec/dump some commands might still - * be in flight, which the firmware will try - * to complete. Resetting the firmware doesn't work - * with old fw revisions, so we have to mark - * them off as 'stale' to prevent the driver from - * falling over. - */ - if (WARN_ON(list_empty(&c->list))) { - c->cmd_type = CMD_MSG_STALE; - return; - } - - list_del_init(&c->list); -} - -static void enqueue_cmd_and_start_io(ctlr_info_t *h, - CommandList_struct *c) -{ - unsigned long flags; - set_performant_mode(h, c); - spin_lock_irqsave(&h->lock, flags); - addQ(&h->reqQ, c); - h->Qdepth++; - if (h->Qdepth > h->maxQsinceinit) - h->maxQsinceinit = h->Qdepth; - start_io(h); - spin_unlock_irqrestore(&h->lock, flags); -} - -static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list, - int nr_cmds) -{ - int i; - - if (!cmd_sg_list) - return; - for (i = 0; i < nr_cmds; i++) { - kfree(cmd_sg_list[i]); - cmd_sg_list[i] = NULL; - } - kfree(cmd_sg_list); -} - -static SGDescriptor_struct **cciss_allocate_sg_chain_blocks( - ctlr_info_t *h, int chainsize, int nr_cmds) -{ - int j; - SGDescriptor_struct **cmd_sg_list; - - if (chainsize <= 0) - return NULL; - - cmd_sg_list = kmalloc(sizeof(*cmd_sg_list) * nr_cmds, GFP_KERNEL); - if (!cmd_sg_list) - return NULL; - - /* Build up chain blocks for each command */ - for (j = 0; j < nr_cmds; j++) { - /* Need a block of chainsized s/g elements. */ - cmd_sg_list[j] = kmalloc((chainsize * - sizeof(*cmd_sg_list[j])), GFP_KERNEL); - if (!cmd_sg_list[j]) { - dev_err(&h->pdev->dev, "Cannot get memory " - "for s/g chains.\n"); - goto clean; - } - } - return cmd_sg_list; -clean: - cciss_free_sg_chain_blocks(cmd_sg_list, nr_cmds); - return NULL; -} - -static void cciss_unmap_sg_chain_block(ctlr_info_t *h, CommandList_struct *c) -{ - SGDescriptor_struct *chain_sg; - u64bit temp64; - - if (c->Header.SGTotal <= h->max_cmd_sgentries) - return; - - chain_sg = &c->SG[h->max_cmd_sgentries - 1]; - temp64.val32.lower = chain_sg->Addr.lower; - temp64.val32.upper = chain_sg->Addr.upper; - pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE); -} - -static int cciss_map_sg_chain_block(ctlr_info_t *h, CommandList_struct *c, - SGDescriptor_struct *chain_block, int len) -{ - SGDescriptor_struct *chain_sg; - u64bit temp64; - - chain_sg = &c->SG[h->max_cmd_sgentries - 1]; - chain_sg->Ext = CCISS_SG_CHAIN; - chain_sg->Len = len; - temp64.val = pci_map_single(h->pdev, chain_block, len, - PCI_DMA_TODEVICE); - if (dma_mapping_error(&h->pdev->dev, temp64.val)) { - dev_warn(&h->pdev->dev, - "%s: error mapping chain block for DMA\n", - __func__); - return -1; - } - chain_sg->Addr.lower = temp64.val32.lower; - chain_sg->Addr.upper = temp64.val32.upper; - - return 0; -} - -#include "cciss_scsi.c" /* For SCSI tape support */ - -static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", - "UNKNOWN" -}; -#define RAID_UNKNOWN (ARRAY_SIZE(raid_label)-1) - -#ifdef CONFIG_PROC_FS - -/* - * Report information about this controller. - */ -#define ENG_GIG 1000000000 -#define ENG_GIG_FACTOR (ENG_GIG/512) -#define ENGAGE_SCSI "engage scsi" - -static void cciss_seq_show_header(struct seq_file *seq) -{ - ctlr_info_t *h = seq->private; - - seq_printf(seq, "%s: HP %s Controller\n" - "Board ID: 0x%08lx\n" - "Firmware Version: %c%c%c%c\n" - "IRQ: %d\n" - "Logical drives: %d\n" - "Current Q depth: %d\n" - "Current # commands on controller: %d\n" - "Max Q depth since init: %d\n" - "Max # commands on controller since init: %d\n" - "Max SG entries since init: %d\n", - h->devname, - h->product_name, - (unsigned long)h->board_id, - h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], - h->firm_ver[3], (unsigned int)h->intr[h->intr_mode], - h->num_luns, - h->Qdepth, h->commands_outstanding, - h->maxQsinceinit, h->max_outstanding, h->maxSG); - -#ifdef CONFIG_CISS_SCSI_TAPE - cciss_seq_tape_report(seq, h); -#endif /* CONFIG_CISS_SCSI_TAPE */ -} - -static void *cciss_seq_start(struct seq_file *seq, loff_t *pos) -{ - ctlr_info_t *h = seq->private; - unsigned long flags; - - /* prevent displaying bogus info during configuration - * or deconfiguration of a logical volume - */ - spin_lock_irqsave(&h->lock, flags); - if (h->busy_configuring) { - spin_unlock_irqrestore(&h->lock, flags); - return ERR_PTR(-EBUSY); - } - h->busy_configuring = 1; - spin_unlock_irqrestore(&h->lock, flags); - - if (*pos == 0) - cciss_seq_show_header(seq); - - return pos; -} - -static int cciss_seq_show(struct seq_file *seq, void *v) -{ - sector_t vol_sz, vol_sz_frac; - ctlr_info_t *h = seq->private; - unsigned ctlr = h->ctlr; - loff_t *pos = v; - drive_info_struct *drv = h->drv[*pos]; - - if (*pos > h->highest_lun) - return 0; - - if (drv == NULL) /* it's possible for h->drv[] to have holes. */ - return 0; - - if (drv->heads == 0) - return 0; - - vol_sz = drv->nr_blocks; - vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); - vol_sz_frac *= 100; - sector_div(vol_sz_frac, ENG_GIG_FACTOR); - - if (drv->raid_level < 0 || drv->raid_level > RAID_UNKNOWN) - drv->raid_level = RAID_UNKNOWN; - seq_printf(seq, "cciss/c%dd%d:" - "\t%4u.%02uGB\tRAID %s\n", - ctlr, (int) *pos, (int)vol_sz, (int)vol_sz_frac, - raid_label[drv->raid_level]); - return 0; -} - -static void *cciss_seq_next(struct seq_file *seq, void *v, loff_t *pos) -{ - ctlr_info_t *h = seq->private; - - if (*pos > h->highest_lun) - return NULL; - *pos += 1; - - return pos; -} - -static void cciss_seq_stop(struct seq_file *seq, void *v) -{ - ctlr_info_t *h = seq->private; - - /* Only reset h->busy_configuring if we succeeded in setting - * it during cciss_seq_start. */ - if (v == ERR_PTR(-EBUSY)) - return; - - h->busy_configuring = 0; -} - -static const struct seq_operations cciss_seq_ops = { - .start = cciss_seq_start, - .show = cciss_seq_show, - .next = cciss_seq_next, - .stop = cciss_seq_stop, -}; - -static int cciss_seq_open(struct inode *inode, struct file *file) -{ - int ret = seq_open(file, &cciss_seq_ops); - struct seq_file *seq = file->private_data; - - if (!ret) - seq->private = PDE_DATA(inode); - - return ret; -} - -static ssize_t -cciss_proc_write(struct file *file, const char __user *buf, - size_t length, loff_t *ppos) -{ - int err; - char *buffer; - -#ifndef CONFIG_CISS_SCSI_TAPE - return -EINVAL; -#endif - - if (!buf || length > PAGE_SIZE - 1) - return -EINVAL; - - buffer = memdup_user_nul(buf, length); - if (IS_ERR(buffer)) - return PTR_ERR(buffer); - -#ifdef CONFIG_CISS_SCSI_TAPE - if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) { - struct seq_file *seq = file->private_data; - ctlr_info_t *h = seq->private; - - err = cciss_engage_scsi(h); - if (err == 0) - err = length; - } else -#endif /* CONFIG_CISS_SCSI_TAPE */ - err = -EINVAL; - /* might be nice to have "disengage" too, but it's not - safely possible. (only 1 module use count, lock issues.) */ - - kfree(buffer); - return err; -} - -static const struct file_operations cciss_proc_fops = { - .owner = THIS_MODULE, - .open = cciss_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, - .write = cciss_proc_write, -}; - -static void cciss_procinit(ctlr_info_t *h) -{ - struct proc_dir_entry *pde; - - if (proc_cciss == NULL) - proc_cciss = proc_mkdir("driver/cciss", NULL); - if (!proc_cciss) - return; - pde = proc_create_data(h->devname, S_IWUSR | S_IRUSR | S_IRGRP | - S_IROTH, proc_cciss, - &cciss_proc_fops, h); -} -#endif /* CONFIG_PROC_FS */ - -#define MAX_PRODUCT_NAME_LEN 19 - -#define to_hba(n) container_of(n, struct ctlr_info, dev) -#define to_drv(n) container_of(n, drive_info_struct, dev) - -/* List of controllers which cannot be hard reset on kexec with reset_devices */ -static u32 unresettable_controller[] = { - 0x3223103C, /* Smart Array P800 */ - 0x3234103C, /* Smart Array P400 */ - 0x3235103C, /* Smart Array P400i */ - 0x3211103C, /* Smart Array E200i */ - 0x3212103C, /* Smart Array E200 */ - 0x3213103C, /* Smart Array E200i */ - 0x3214103C, /* Smart Array E200i */ - 0x3215103C, /* Smart Array E200i */ - 0x3237103C, /* Smart Array E500 */ - 0x323D103C, /* Smart Array P700m */ - 0x40800E11, /* Smart Array 5i */ - 0x409C0E11, /* Smart Array 6400 */ - 0x409D0E11, /* Smart Array 6400 EM */ - 0x40700E11, /* Smart Array 5300 */ - 0x40820E11, /* Smart Array 532 */ - 0x40830E11, /* Smart Array 5312 */ - 0x409A0E11, /* Smart Array 641 */ - 0x409B0E11, /* Smart Array 642 */ - 0x40910E11, /* Smart Array 6i */ -}; - -/* List of controllers which cannot even be soft reset */ -static u32 soft_unresettable_controller[] = { - 0x40800E11, /* Smart Array 5i */ - 0x40700E11, /* Smart Array 5300 */ - 0x40820E11, /* Smart Array 532 */ - 0x40830E11, /* Smart Array 5312 */ - 0x409A0E11, /* Smart Array 641 */ - 0x409B0E11, /* Smart Array 642 */ - 0x40910E11, /* Smart Array 6i */ - /* Exclude 640x boards. These are two pci devices in one slot - * which share a battery backed cache module. One controls the - * cache, the other accesses the cache through the one that controls - * it. If we reset the one controlling the cache, the other will - * likely not be happy. Just forbid resetting this conjoined mess. - */ - 0x409C0E11, /* Smart Array 6400 */ - 0x409D0E11, /* Smart Array 6400 EM */ -}; - -static int ctlr_is_hard_resettable(u32 board_id) -{ - int i; - - for (i = 0; i < ARR |