hpsa.c (3d38f00c4107cc007056db9f4ab14ecb17ed193f) hpsa.c (b63c64ac5a5ccb6ee56e0d906f2f5d2b7e54cbd9)
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2016 Microsemi Corporation
4 * Copyright 2014-2015 PMC-Sierra, Inc.
5 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 4577 unchanged lines hidden (view full) ---

4586
4587sglist_finished:
4588
4589 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */
4590 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in cmd list */
4591 return 0;
4592}
4593
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2016 Microsemi Corporation
4 * Copyright 2014-2015 PMC-Sierra, Inc.
5 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 4577 unchanged lines hidden (view full) ---

4586
4587sglist_finished:
4588
4589 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */
4590 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in cmd list */
4591 return 0;
4592}
4593
4594#define IO_ACCEL_INELIGIBLE (1)
4594#define BUFLEN 128
4595static inline void warn_zero_length_transfer(struct ctlr_info *h,
4596 u8 *cdb, int cdb_len,
4597 const char *func)
4598{
4599 char buf[BUFLEN];
4600 int outlen;
4601 int i;
4602
4603 outlen = scnprintf(buf, BUFLEN,
4604 "%s: Blocking zero-length request: CDB:", func);
4605 for (i = 0; i < cdb_len; i++)
4606 outlen += scnprintf(buf+outlen, BUFLEN - outlen,
4607 "%02hhx", cdb[i]);
4608 dev_warn(&h->pdev->dev, "%s\n", buf);
4609}
4610
4611#define IO_ACCEL_INELIGIBLE 1
4612/* zero-length transfers trigger hardware errors. */
4613static bool is_zero_length_transfer(u8 *cdb)
4614{
4615 u32 block_cnt;
4616
4617 /* Block zero-length transfer sizes on certain commands. */
4618 switch (cdb[0]) {
4619 case READ_10:
4620 case WRITE_10:
4621 case VERIFY: /* 0x2F */
4622 case WRITE_VERIFY: /* 0x2E */
4623 block_cnt = get_unaligned_be16(&cdb[7]);
4624 break;
4625 case READ_12:
4626 case WRITE_12:
4627 case VERIFY_12: /* 0xAF */
4628 case WRITE_VERIFY_12: /* 0xAE */
4629 block_cnt = get_unaligned_be32(&cdb[6]);
4630 break;
4631 case READ_16:
4632 case WRITE_16:
4633 case VERIFY_16: /* 0x8F */
4634 block_cnt = get_unaligned_be32(&cdb[10]);
4635 break;
4636 default:
4637 return false;
4638 }
4639
4640 return block_cnt == 0;
4641}
4642
4595static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)
4596{
4597 int is_write = 0;
4598 u32 block;
4599 u32 block_cnt;
4600
4601 /* Perform some CDB fixups if needed using 10 byte reads/writes only */
4602 switch (cdb[0]) {

--- 50 unchanged lines hidden (view full) ---

4653 /* TODO: implement chaining support */
4654 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) {
4655 atomic_dec(&phys_disk->ioaccel_cmds_out);
4656 return IO_ACCEL_INELIGIBLE;
4657 }
4658
4659 BUG_ON(cmd->cmd_len > IOACCEL1_IOFLAGS_CDBLEN_MAX);
4660
4643static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)
4644{
4645 int is_write = 0;
4646 u32 block;
4647 u32 block_cnt;
4648
4649 /* Perform some CDB fixups if needed using 10 byte reads/writes only */
4650 switch (cdb[0]) {

--- 50 unchanged lines hidden (view full) ---

4701 /* TODO: implement chaining support */
4702 if (scsi_sg_count(cmd) > h->ioaccel_maxsg) {
4703 atomic_dec(&phys_disk->ioaccel_cmds_out);
4704 return IO_ACCEL_INELIGIBLE;
4705 }
4706
4707 BUG_ON(cmd->cmd_len > IOACCEL1_IOFLAGS_CDBLEN_MAX);
4708
4709 if (is_zero_length_transfer(cdb)) {
4710 warn_zero_length_transfer(h, cdb, cdb_len, __func__);
4711 atomic_dec(&phys_disk->ioaccel_cmds_out);
4712 return IO_ACCEL_INELIGIBLE;
4713 }
4714
4661 if (fixup_ioaccel_cdb(cdb, &cdb_len)) {
4662 atomic_dec(&phys_disk->ioaccel_cmds_out);
4663 return IO_ACCEL_INELIGIBLE;
4664 }
4665
4666 c->cmd_type = CMD_IOACCEL1;
4667
4668 /* Adjust the DMA address to point to the accelerated command buffer */

--- 148 unchanged lines hidden (view full) ---

4817 if (!cmd->device)
4818 return -1;
4819
4820 if (!cmd->device->hostdata)
4821 return -1;
4822
4823 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries);
4824
4715 if (fixup_ioaccel_cdb(cdb, &cdb_len)) {
4716 atomic_dec(&phys_disk->ioaccel_cmds_out);
4717 return IO_ACCEL_INELIGIBLE;
4718 }
4719
4720 c->cmd_type = CMD_IOACCEL1;
4721
4722 /* Adjust the DMA address to point to the accelerated command buffer */

--- 148 unchanged lines hidden (view full) ---

4871 if (!cmd->device)
4872 return -1;
4873
4874 if (!cmd->device->hostdata)
4875 return -1;
4876
4877 BUG_ON(scsi_sg_count(cmd) > h->maxsgentries);
4878
4879 if (is_zero_length_transfer(cdb)) {
4880 warn_zero_length_transfer(h, cdb, cdb_len, __func__);
4881 atomic_dec(&phys_disk->ioaccel_cmds_out);
4882 return IO_ACCEL_INELIGIBLE;
4883 }
4884
4825 if (fixup_ioaccel_cdb(cdb, &cdb_len)) {
4826 atomic_dec(&phys_disk->ioaccel_cmds_out);
4827 return IO_ACCEL_INELIGIBLE;
4828 }
4829
4830 c->cmd_type = CMD_IOACCEL2;
4831 /* Adjust the DMA address to point to the accelerated command buffer */
4832 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle +

--- 5285 unchanged lines hidden ---
4885 if (fixup_ioaccel_cdb(cdb, &cdb_len)) {
4886 atomic_dec(&phys_disk->ioaccel_cmds_out);
4887 return IO_ACCEL_INELIGIBLE;
4888 }
4889
4890 c->cmd_type = CMD_IOACCEL2;
4891 /* Adjust the DMA address to point to the accelerated command buffer */
4892 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle +

--- 5285 unchanged lines hidden ---