Merge ../scsi-misc-2.6

Conflicts:

drivers/scsi/nsp32.c
drivers/scsi/pcmcia/nsp_cs.c

Removal of randomness flag conflicts with SA_ -> IRQF_ global
replacement.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

+4528 -2890
+16
Documentation/scsi/ChangeLog.megaraid_sas
··· 1 1 2 + 1 Release Date : Sun May 14 22:49:52 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com> 3 + 2 Current Version : 00.00.03.01 4 + 3 Older Version : 00.00.02.04 5 + 6 + i. Added support for ZCR controller. 7 + 8 + New device id 0x413 added. 9 + 10 + ii. Bug fix : Disable controller interrupt before firing INIT cmd to FW. 11 + 12 + Interrupt is enabled after required initialization is over. 13 + This is done to ensure that driver is ready to handle interrupts when 14 + it is generated by the controller. 15 + 16 + -Sumant Patro <Sumant.Patro@lsil.com> 17 + 2 18 1 Release Date : Wed Feb 03 14:31:44 PST 2006 - Sumant Patro <Sumant.Patro@lsil.com> 3 19 2 Current Version : 00.00.02.04 4 20 3 Older Version : 00.00.02.04
+17 -121
drivers/infiniband/ulp/iser/iscsi_iser.c
··· 437 437 } 438 438 439 439 static int 440 - iscsi_iser_conn_set_param(struct iscsi_cls_conn *cls_conn, 441 - enum iscsi_param param, uint32_t value) 440 + iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn, 441 + enum iscsi_param param, char *buf, int buflen) 442 442 { 443 - struct iscsi_conn *conn = cls_conn->dd_data; 444 - struct iscsi_session *session = conn->session; 445 - 446 - spin_lock_bh(&session->lock); 447 - if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE && 448 - conn->stop_stage != STOP_CONN_RECOVER) { 449 - printk(KERN_ERR "iscsi_iser: can not change parameter [%d]\n", 450 - param); 451 - spin_unlock_bh(&session->lock); 452 - return 0; 453 - } 454 - spin_unlock_bh(&session->lock); 443 + int value; 455 444 456 445 switch (param) { 457 446 case ISCSI_PARAM_MAX_RECV_DLENGTH: 458 447 /* TBD */ 459 448 break; 460 - case ISCSI_PARAM_MAX_XMIT_DLENGTH: 461 - conn->max_xmit_dlength = value; 462 - break; 463 449 case ISCSI_PARAM_HDRDGST_EN: 450 + sscanf(buf, "%d", &value); 464 451 if (value) { 465 452 printk(KERN_ERR "DataDigest wasn't negotiated to None"); 466 453 return -EPROTO; 467 454 } 468 455 break; 469 456 case ISCSI_PARAM_DATADGST_EN: 457 + sscanf(buf, "%d", &value); 470 458 if (value) { 471 459 printk(KERN_ERR "DataDigest wasn't negotiated to None"); 472 460 return -EPROTO; 473 461 } 474 462 break; 475 - case ISCSI_PARAM_INITIAL_R2T_EN: 476 - session->initial_r2t_en = value; 477 - break; 478 - case ISCSI_PARAM_IMM_DATA_EN: 479 - session->imm_data_en = value; 480 - break; 481 - case ISCSI_PARAM_FIRST_BURST: 482 - session->first_burst = value; 483 - break; 484 - case ISCSI_PARAM_MAX_BURST: 485 - session->max_burst = value; 486 - break; 487 - case ISCSI_PARAM_PDU_INORDER_EN: 488 - session->pdu_inorder_en = value; 489 - break; 490 - case ISCSI_PARAM_DATASEQ_INORDER_EN: 491 - session->dataseq_inorder_en = value; 492 - break; 493 - case ISCSI_PARAM_ERL: 494 - session->erl = value; 495 - break; 496 463 case ISCSI_PARAM_IFMARKER_EN: 464 + sscanf(buf, "%d", &value); 497 465 if (value) { 498 466 printk(KERN_ERR "IFMarker wasn't negotiated to No"); 499 467 return -EPROTO; 500 468 } 501 469 break; 502 470 case ISCSI_PARAM_OFMARKER_EN: 471 + sscanf(buf, "%d", &value); 503 472 if (value) { 504 473 printk(KERN_ERR "OFMarker wasn't negotiated to No"); 505 474 return -EPROTO; 506 475 } 507 476 break; 508 477 default: 509 - break; 478 + return iscsi_set_param(cls_conn, param, buf, buflen); 510 479 } 511 480 512 481 return 0; 513 482 } 514 - 515 - static int 516 - iscsi_iser_session_get_param(struct iscsi_cls_session *cls_session, 517 - enum iscsi_param param, uint32_t *value) 518 - { 519 - struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 520 - struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 521 - 522 - switch (param) { 523 - case ISCSI_PARAM_INITIAL_R2T_EN: 524 - *value = session->initial_r2t_en; 525 - break; 526 - case ISCSI_PARAM_MAX_R2T: 527 - *value = session->max_r2t; 528 - break; 529 - case ISCSI_PARAM_IMM_DATA_EN: 530 - *value = session->imm_data_en; 531 - break; 532 - case ISCSI_PARAM_FIRST_BURST: 533 - *value = session->first_burst; 534 - break; 535 - case ISCSI_PARAM_MAX_BURST: 536 - *value = session->max_burst; 537 - break; 538 - case ISCSI_PARAM_PDU_INORDER_EN: 539 - *value = session->pdu_inorder_en; 540 - break; 541 - case ISCSI_PARAM_DATASEQ_INORDER_EN: 542 - *value = session->dataseq_inorder_en; 543 - break; 544 - case ISCSI_PARAM_ERL: 545 - *value = session->erl; 546 - break; 547 - case ISCSI_PARAM_IFMARKER_EN: 548 - *value = 0; 549 - break; 550 - case ISCSI_PARAM_OFMARKER_EN: 551 - *value = 0; 552 - break; 553 - default: 554 - return ISCSI_ERR_PARAM_NOT_FOUND; 555 - } 556 - 557 - return 0; 558 - } 559 - 560 - static int 561 - iscsi_iser_conn_get_param(struct iscsi_cls_conn *cls_conn, 562 - enum iscsi_param param, uint32_t *value) 563 - { 564 - struct iscsi_conn *conn = cls_conn->dd_data; 565 - 566 - switch(param) { 567 - case ISCSI_PARAM_MAX_RECV_DLENGTH: 568 - *value = conn->max_recv_dlength; 569 - break; 570 - case ISCSI_PARAM_MAX_XMIT_DLENGTH: 571 - *value = conn->max_xmit_dlength; 572 - break; 573 - case ISCSI_PARAM_HDRDGST_EN: 574 - *value = 0; 575 - break; 576 - case ISCSI_PARAM_DATADGST_EN: 577 - *value = 0; 578 - break; 579 - /*case ISCSI_PARAM_TARGET_RECV_DLENGTH: 580 - *value = conn->target_recv_dlength; 581 - break; 582 - case ISCSI_PARAM_INITIATOR_RECV_DLENGTH: 583 - *value = conn->initiator_recv_dlength; 584 - break;*/ 585 - default: 586 - return ISCSI_ERR_PARAM_NOT_FOUND; 587 - } 588 - 589 - return 0; 590 - } 591 - 592 483 593 484 static void 594 485 iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats) ··· 592 701 ISCSI_FIRST_BURST | 593 702 ISCSI_MAX_BURST | 594 703 ISCSI_PDU_INORDER_EN | 595 - ISCSI_DATASEQ_INORDER_EN, 704 + ISCSI_DATASEQ_INORDER_EN | 705 + ISCSI_EXP_STATSN | 706 + ISCSI_PERSISTENT_PORT | 707 + ISCSI_PERSISTENT_ADDRESS | 708 + ISCSI_TARGET_NAME | 709 + ISCSI_TPGT, 596 710 .host_template = &iscsi_iser_sht, 597 711 .conndata_size = sizeof(struct iscsi_conn), 598 712 .max_lun = ISCSI_ISER_MAX_LUN, ··· 609 713 .create_conn = iscsi_iser_conn_create, 610 714 .bind_conn = iscsi_iser_conn_bind, 611 715 .destroy_conn = iscsi_iser_conn_destroy, 612 - .set_param = iscsi_iser_conn_set_param, 613 - .get_conn_param = iscsi_iser_conn_get_param, 614 - .get_session_param = iscsi_iser_session_get_param, 716 + .set_param = iscsi_iser_set_param, 717 + .get_conn_param = iscsi_conn_get_param, 718 + .get_session_param = iscsi_session_get_param, 615 719 .start_conn = iscsi_iser_conn_start, 616 720 .stop_conn = iscsi_conn_stop, 617 721 /* these are called as part of conn recovery */
+5
drivers/message/fusion/Makefile
··· 33 33 # For mptfc: 34 34 #CFLAGS_mptfc.o += -DMPT_DEBUG_FC 35 35 36 + # For mptsas: 37 + #CFLAGS_mptsas.o += -DMPT_DEBUG_SAS 38 + #CFLAGS_mptsas.o += -DMPT_DEBUG_SAS_WIDE 39 + 40 + 36 41 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC 37 42 38 43 obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o
-89
drivers/message/fusion/lsi/fc_log.h
··· 1 - /* 2 - * Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved. 3 - * 4 - * NAME: fc_log.h 5 - * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips 6 - * DESCRIPTION: Contains the enumerated list of values that may be returned 7 - * in the IOCLogInfo field of a MPI Default Reply Message. 8 - * 9 - * CREATION DATE: 6/02/2000 10 - * ID: $Id: fc_log.h,v 4.6 2001/07/26 14:41:33 sschremm Exp $ 11 - */ 12 - 13 - 14 - /* 15 - * MpiIocLogInfo_t enum 16 - * 17 - * These 32 bit values are used in the IOCLogInfo field of the MPI reply 18 - * messages. 19 - * The value is 0xabcccccc where 20 - * a = The type of log info as per the MPI spec. Since these codes are 21 - * all for Fibre Channel this value will always be 2. 22 - * b = Specifies a subclass of the firmware where 23 - * 0 = FCP Initiator 24 - * 1 = FCP Target 25 - * 2 = LAN 26 - * 3 = MPI Message Layer 27 - * 4 = FC Link 28 - * 5 = Context Manager 29 - * 6 = Invalid Field Offset 30 - * 7 = State Change Info 31 - * all others are reserved for future use 32 - * c = A specific value within the subclass. 33 - * 34 - * NOTE: Any new values should be added to the end of each subclass so that the 35 - * codes remain consistent across firmware releases. 36 - */ 37 - typedef enum _MpiIocLogInfoFc 38 - { 39 - MPI_IOCLOGINFO_FC_INIT_BASE = 0x20000000, 40 - MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 0x20000001, /* received an out of order frame - unsupported */ 41 - MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 0x20000002, /* Bad Rx Frame, bad start of frame primative */ 42 - MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME = 0x20000003, /* Bad Rx Frame, bad end of frame primative */ 43 - MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN = 0x20000004, /* Bad Rx Frame, overrun */ 44 - MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER = 0x20000005, /* Other errors caught by IOC which require retries */ 45 - MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD = 0x20000006, /* Main processor could not initialize sub-processor */ 46 - MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN = 0x20000007, /* Scatter Gather overrun */ 47 - MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS = 0x20000008, /* Receiver detected context mismatch via invalid header */ 48 - MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME= 0x20000009, /* CtxMgr detected unsupported frame type */ 49 - MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE = 0x2000000A, /* Link failure occurred */ 50 - MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT = 0x2000000B, /* Transmitter timeout error */ 51 - 52 - MPI_IOCLOGINFO_FC_TARGET_BASE = 0x21000000, 53 - MPI_IOCLOGINFO_FC_TARGET_NO_PDISC = 0x21000001, /* not sent because we are waiting for a PDISC from the initiator */ 54 - MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN = 0x21000002, /* not sent because we are not logged in to the remote node */ 55 - MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP = 0x21000003, /* Data Out, Auto Response, not sent due to a LIP */ 56 - MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP = 0x21000004, /* Data In, Auto Response, not sent due to a LIP */ 57 - MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA = 0x21000005, /* Data In, Auto Response, missing data frames */ 58 - MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP = 0x21000006, /* Data Out, No Response, not sent due to a LIP */ 59 - MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP = 0x21000007, /* Auto-response after a write not sent due to a LIP */ 60 - MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP = 0x21000008, /* Data In, No Response, not completed due to a LIP */ 61 - MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA = 0x21000009, /* Data In, No Response, missing data frames */ 62 - MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP = 0x2100000a, /* Manual Response not sent due to a LIP */ 63 - MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3 = 0x2100000b, /* not sent because remote node does not support Class 3 */ 64 - MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID = 0x2100000c, /* not sent because login to remote node not validated */ 65 - MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND = 0x2100000e, /* cleared from the outbound queue after a logout */ 66 - MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN = 0x2100000f, /* cleared waiting for data after a logout */ 67 - 68 - MPI_IOCLOGINFO_FC_LAN_BASE = 0x22000000, 69 - MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING = 0x22000001, /* Transaction Context Sgl Missing */ 70 - MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE = 0x22000002, /* Transaction Context found before an EOB */ 71 - MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET = 0x22000003, /* Transaction Context value has reserved bits set */ 72 - MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG = 0x22000004, /* Invalid SGL Flags */ 73 - 74 - MPI_IOCLOGINFO_FC_MSG_BASE = 0x23000000, 75 - 76 - MPI_IOCLOGINFO_FC_LINK_BASE = 0x24000000, 77 - MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT = 0x24000001, /* Loop initialization timed out */ 78 - MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED = 0x24000002, /* Another system controller already initialized the loop */ 79 - MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED = 0x24000003, /* Not synchronized to signal or still negotiating (possible cable problem) */ 80 - MPI_IOCLOGINFO_FC_LINK_CRC_ERROR = 0x24000004, /* CRC check detected error on received frame */ 81 - 82 - MPI_IOCLOGINFO_FC_CTX_BASE = 0x25000000, 83 - 84 - MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET = 0x26000000, /* The lower 24 bits give the byte offset of the field in the request message that is invalid */ 85 - MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET = 0x26ffffff, 86 - 87 - MPI_IOCLOGINFO_FC_STATE_CHANGE = 0x27000000 /* The lower 24 bits give additional information concerning state change */ 88 - 89 - } MpiIocLogInfoFc_t;
+3 -2
drivers/message/fusion/lsi/mpi.h
··· 6 6 * Title: MPI Message independent structures and definitions 7 7 * Creation Date: July 27, 2000 8 8 * 9 - * mpi.h Version: 01.05.10 9 + * mpi.h Version: 01.05.11 10 10 * 11 11 * Version History 12 12 * --------------- ··· 76 76 * Added EEDP IOCStatus codes. 77 77 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT. 78 78 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target. 79 + * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 79 80 * -------------------------------------------------------------------------- 80 81 */ 81 82 ··· 107 106 /* Note: The major versions of 0xe0 through 0xff are reserved */ 108 107 109 108 /* versioning for this MPI header set */ 110 - #define MPI_HEADER_VERSION_UNIT (0x0C) 109 + #define MPI_HEADER_VERSION_UNIT (0x0D) 111 110 #define MPI_HEADER_VERSION_DEV (0x00) 112 111 #define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) 113 112 #define MPI_HEADER_VERSION_UNIT_SHIFT (8)
+140 -18
drivers/message/fusion/lsi/mpi_cnfg.h
··· 6 6 * Title: MPI Config message, structures, and Pages 7 7 * Creation Date: July 27, 2000 8 8 * 9 - * mpi_cnfg.h Version: 01.05.11 9 + * mpi_cnfg.h Version: 01.05.12 10 10 * 11 11 * Version History 12 12 * --------------- ··· 266 266 * Added postpone SATA Init bit to SAS IO Unit Page 1 267 267 * ControlFlags. 268 268 * Changed LogEntry format for Log Page 0. 269 + * 03-27-06 01.05.12 Added two new Flags defines for Manufacturing Page 4. 270 + * Added Manufacturing Page 7. 271 + * Added MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING. 272 + * Added IOC Page 6. 273 + * Added PrevBootDeviceForm field to CONFIG_PAGE_BIOS_2. 274 + * Added MaxLBAHigh field to RAID Volume Page 0. 275 + * Added Nvdata version fields to SAS IO Unit Page 0. 276 + * Added AdditionalControlFlags, MaxTargetPortConnectTime, 277 + * ReportDeviceMissingDelay, and IODeviceMissingDelay 278 + * fields to SAS IO Unit Page 1. 269 279 * -------------------------------------------------------------------------- 270 280 */ 271 281 ··· 641 631 } CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4, 642 632 ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t; 643 633 644 - #define MPI_MANUFACTURING4_PAGEVERSION (0x03) 634 + #define MPI_MANUFACTURING4_PAGEVERSION (0x04) 645 635 646 636 /* defines for the Flags field */ 637 + #define MPI_MANPAGE4_FORCE_BAD_BLOCK_TABLE (0x80) 638 + #define MPI_MANPAGE4_FORCE_OFFLINE_FAILOVER (0x40) 647 639 #define MPI_MANPAGE4_IME_DISABLE (0x20) 648 640 #define MPI_MANPAGE4_IM_DISABLE (0x10) 649 641 #define MPI_MANPAGE4_IS_DISABLE (0x08) ··· 678 666 ManufacturingPage6_t, MPI_POINTER pManufacturingPage6_t; 679 667 680 668 #define MPI_MANUFACTURING6_PAGEVERSION (0x00) 669 + 670 + 671 + typedef struct _MPI_MANPAGE7_CONNECTOR_INFO 672 + { 673 + U32 Pinout; /* 00h */ 674 + U8 Connector[16]; /* 04h */ 675 + U8 Location; /* 14h */ 676 + U8 Reserved1; /* 15h */ 677 + U16 Slot; /* 16h */ 678 + U32 Reserved2; /* 18h */ 679 + } MPI_MANPAGE7_CONNECTOR_INFO, MPI_POINTER PTR_MPI_MANPAGE7_CONNECTOR_INFO, 680 + MpiManPage7ConnectorInfo_t, MPI_POINTER pMpiManPage7ConnectorInfo_t; 681 + 682 + /* defines for the Pinout field */ 683 + #define MPI_MANPAGE7_PINOUT_SFF_8484_L4 (0x00080000) 684 + #define MPI_MANPAGE7_PINOUT_SFF_8484_L3 (0x00040000) 685 + #define MPI_MANPAGE7_PINOUT_SFF_8484_L2 (0x00020000) 686 + #define MPI_MANPAGE7_PINOUT_SFF_8484_L1 (0x00010000) 687 + #define MPI_MANPAGE7_PINOUT_SFF_8470_L4 (0x00000800) 688 + #define MPI_MANPAGE7_PINOUT_SFF_8470_L3 (0x00000400) 689 + #define MPI_MANPAGE7_PINOUT_SFF_8470_L2 (0x00000200) 690 + #define MPI_MANPAGE7_PINOUT_SFF_8470_L1 (0x00000100) 691 + #define MPI_MANPAGE7_PINOUT_SFF_8482 (0x00000002) 692 + #define MPI_MANPAGE7_PINOUT_CONNECTION_UNKNOWN (0x00000001) 693 + 694 + /* defines for the Location field */ 695 + #define MPI_MANPAGE7_LOCATION_UNKNOWN (0x01) 696 + #define MPI_MANPAGE7_LOCATION_INTERNAL (0x02) 697 + #define MPI_MANPAGE7_LOCATION_EXTERNAL (0x04) 698 + #define MPI_MANPAGE7_LOCATION_SWITCHABLE (0x08) 699 + #define MPI_MANPAGE7_LOCATION_AUTO (0x10) 700 + #define MPI_MANPAGE7_LOCATION_NOT_PRESENT (0x20) 701 + #define MPI_MANPAGE7_LOCATION_NOT_CONNECTED (0x80) 702 + 703 + /* 704 + * Host code (drivers, BIOS, utilities, etc.) should leave this define set to 705 + * one and check NumPhys at runtime. 706 + */ 707 + #ifndef MPI_MANPAGE7_CONNECTOR_INFO_MAX 708 + #define MPI_MANPAGE7_CONNECTOR_INFO_MAX (1) 709 + #endif 710 + 711 + typedef struct _CONFIG_PAGE_MANUFACTURING_7 712 + { 713 + CONFIG_PAGE_HEADER Header; /* 00h */ 714 + U32 Reserved1; /* 04h */ 715 + U32 Reserved2; /* 08h */ 716 + U32 Flags; /* 0Ch */ 717 + U8 EnclosureName[16]; /* 10h */ 718 + U8 NumPhys; /* 20h */ 719 + U8 Reserved3; /* 21h */ 720 + U16 Reserved4; /* 22h */ 721 + MPI_MANPAGE7_CONNECTOR_INFO ConnectorInfo[MPI_MANPAGE7_CONNECTOR_INFO_MAX]; /* 24h */ 722 + } CONFIG_PAGE_MANUFACTURING_7, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_7, 723 + ManufacturingPage7_t, MPI_POINTER pManufacturingPage7_t; 724 + 725 + #define MPI_MANUFACTURING7_PAGEVERSION (0x00) 726 + 727 + /* defines for the Flags field */ 728 + #define MPI_MANPAGE7_FLAG_USE_SLOT_INFO (0x00000001) 681 729 682 730 683 731 /**************************************************************************** ··· 939 867 } CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, 940 868 IOCPage2_t, MPI_POINTER pIOCPage2_t; 941 869 942 - #define MPI_IOCPAGE2_PAGEVERSION (0x03) 870 + #define MPI_IOCPAGE2_PAGEVERSION (0x04) 943 871 944 872 /* IOC Page 2 Capabilities flags */ 945 873 ··· 950 878 #define MPI_IOCPAGE2_CAP_FLAGS_RAID_6_SUPPORT (0x00000010) 951 879 #define MPI_IOCPAGE2_CAP_FLAGS_RAID_10_SUPPORT (0x00000020) 952 880 #define MPI_IOCPAGE2_CAP_FLAGS_RAID_50_SUPPORT (0x00000040) 881 + #define MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING (0x10000000) 953 882 #define MPI_IOCPAGE2_CAP_FLAGS_SES_SUPPORT (0x20000000) 954 883 #define MPI_IOCPAGE2_CAP_FLAGS_SAFTE_SUPPORT (0x40000000) 955 884 #define MPI_IOCPAGE2_CAP_FLAGS_CROSS_CHANNEL_SUPPORT (0x80000000) ··· 1047 974 IOCPage5_t, MPI_POINTER pIOCPage5_t; 1048 975 1049 976 #define MPI_IOCPAGE5_PAGEVERSION (0x00) 977 + 978 + typedef struct _CONFIG_PAGE_IOC_6 979 + { 980 + CONFIG_PAGE_HEADER Header; /* 00h */ 981 + U32 CapabilitiesFlags; /* 04h */ 982 + U8 MaxDrivesIS; /* 08h */ 983 + U8 MaxDrivesIM; /* 09h */ 984 + U8 MaxDrivesIME; /* 0Ah */ 985 + U8 Reserved1; /* 0Bh */ 986 + U8 MinDrivesIS; /* 0Ch */ 987 + U8 MinDrivesIM; /* 0Dh */ 988 + U8 MinDrivesIME; /* 0Eh */ 989 + U8 Reserved2; /* 0Fh */ 990 + U8 MaxGlobalHotSpares; /* 10h */ 991 + U8 Reserved3; /* 11h */ 992 + U16 Reserved4; /* 12h */ 993 + U32 Reserved5; /* 14h */ 994 + U32 SupportedStripeSizeMapIS; /* 18h */ 995 + U32 SupportedStripeSizeMapIME; /* 1Ch */ 996 + U32 Reserved6; /* 20h */ 997 + U8 MetadataSize; /* 24h */ 998 + U8 Reserved7; /* 25h */ 999 + U16 Reserved8; /* 26h */ 1000 + U16 MaxBadBlockTableEntries; /* 28h */ 1001 + U16 Reserved9; /* 2Ah */ 1002 + U16 IRNvsramUsage; /* 2Ch */ 1003 + U16 Reserved10; /* 2Eh */ 1004 + U32 IRNvsramVersion; /* 30h */ 1005 + U32 Reserved11; /* 34h */ 1006 + U32 Reserved12; /* 38h */ 1007 + } CONFIG_PAGE_IOC_6, MPI_POINTER PTR_CONFIG_PAGE_IOC_6, 1008 + IOCPage6_t, MPI_POINTER pIOCPage6_t; 1009 + 1010 + #define MPI_IOCPAGE6_PAGEVERSION (0x00) 1011 + 1012 + /* IOC Page 6 Capabilities Flags */ 1013 + 1014 + #define MPI_IOCPAGE6_CAP_FLAGS_GLOBAL_HOT_SPARE (0x00000001) 1050 1015 1051 1016 1052 1017 /**************************************************************************** ··· 1329 1218 U32 Reserved5; /* 14h */ 1330 1219 U32 Reserved6; /* 18h */ 1331 1220 U8 BootDeviceForm; /* 1Ch */ 1332 - U8 Reserved7; /* 1Dh */ 1221 + U8 PrevBootDeviceForm; /* 1Ch */ 1333 1222 U16 Reserved8; /* 1Eh */ 1334 1223 MPI_BIOSPAGE2_BOOT_DEVICE BootDevice; /* 20h */ 1335 1224 } CONFIG_PAGE_BIOS_2, MPI_POINTER PTR_CONFIG_PAGE_BIOS_2, 1336 1225 BIOSPage2_t, MPI_POINTER pBIOSPage2_t; 1337 1226 1338 - #define MPI_BIOSPAGE2_PAGEVERSION (0x01) 1227 + #define MPI_BIOSPAGE2_PAGEVERSION (0x02) 1339 1228 1340 1229 #define MPI_BIOSPAGE2_FORM_MASK (0x0F) 1341 1230 #define MPI_BIOSPAGE2_FORM_ADAPTER_ORDER (0x00) ··· 2191 2080 RAID_VOL0_STATUS VolumeStatus; /* 08h */ 2192 2081 RAID_VOL0_SETTINGS VolumeSettings; /* 0Ch */ 2193 2082 U32 MaxLBA; /* 10h */ 2194 - U32 Reserved1; /* 14h */ 2083 + U32 MaxLBAHigh; /* 14h */ 2195 2084 U32 StripeSize; /* 18h */ 2196 2085 U32 Reserved2; /* 1Ch */ 2197 2086 U32 Reserved3; /* 20h */ ··· 2203 2092 } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, 2204 2093 RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t; 2205 2094 2206 - #define MPI_RAIDVOLPAGE0_PAGEVERSION (0x05) 2095 + #define MPI_RAIDVOLPAGE0_PAGEVERSION (0x06) 2207 2096 2208 2097 /* values for RAID Volume Page 0 InactiveStatus field */ 2209 2098 #define MPI_RAIDVOLPAGE0_UNKNOWN_INACTIVE (0x00) ··· 2435 2324 typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 2436 2325 { 2437 2326 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2438 - U32 Reserved1; /* 08h */ 2327 + U16 NvdataVersionDefault; /* 08h */ 2328 + U16 NvdataVersionPersistent; /* 0Ah */ 2439 2329 U8 NumPhys; /* 0Ch */ 2440 2330 U8 Reserved2; /* 0Dh */ 2441 2331 U16 Reserved3; /* 0Eh */ ··· 2444 2332 } CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, 2445 2333 SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t; 2446 2334 2447 - #define MPI_SASIOUNITPAGE0_PAGEVERSION (0x03) 2335 + #define MPI_SASIOUNITPAGE0_PAGEVERSION (0x04) 2448 2336 2449 2337 /* values for SAS IO Unit Page 0 PortFlags */ 2450 2338 #define MPI_SAS_IOUNIT0_PORT_FLAGS_DISCOVERY_IN_PROGRESS (0x08) ··· 2485 2373 2486 2374 typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA 2487 2375 { 2488 - U8 Port; /* 00h */ 2489 - U8 PortFlags; /* 01h */ 2490 - U8 PhyFlags; /* 02h */ 2491 - U8 MaxMinLinkRate; /* 03h */ 2492 - U32 ControllerPhyDeviceInfo;/* 04h */ 2493 - U32 Reserved1; /* 08h */ 2376 + U8 Port; /* 00h */ 2377 + U8 PortFlags; /* 01h */ 2378 + U8 PhyFlags; /* 02h */ 2379 + U8 MaxMinLinkRate; /* 03h */ 2380 + U32 ControllerPhyDeviceInfo; /* 04h */ 2381 + U16 MaxTargetPortConnectTime; /* 08h */ 2382 + U16 Reserved1; /* 0Ah */ 2494 2383 } MPI_SAS_IO_UNIT1_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT1_PHY_DATA, 2495 2384 SasIOUnit1PhyData, MPI_POINTER pSasIOUnit1PhyData; 2496 2385 ··· 2508 2395 CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ 2509 2396 U16 ControlFlags; /* 08h */ 2510 2397 U16 MaxNumSATATargets; /* 0Ah */ 2511 - U32 Reserved1; /* 0Ch */ 2398 + U16 AdditionalControlFlags; /* 0Ch */ 2399 + U16 Reserved1; /* 0Eh */ 2512 2400 U8 NumPhys; /* 10h */ 2513 2401 U8 SATAMaxQDepth; /* 11h */ 2514 - U16 Reserved2; /* 12h */ 2402 + U8 ReportDeviceMissingDelay; /* 12h */ 2403 + U8 IODeviceMissingDelay; /* 13h */ 2515 2404 MPI_SAS_IO_UNIT1_PHY_DATA PhyData[MPI_SAS_IOUNIT1_PHY_MAX]; /* 14h */ 2516 2405 } CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1, 2517 2406 SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t; 2518 2407 2519 - #define MPI_SASIOUNITPAGE1_PAGEVERSION (0x05) 2408 + #define MPI_SASIOUNITPAGE1_PAGEVERSION (0x06) 2520 2409 2521 2410 /* values for SAS IO Unit Page 1 ControlFlags */ 2522 2411 #define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST (0x8000) ··· 2542 2427 #define MPI_SAS_IOUNIT1_CONTROL_SUBTRACTIVE_ILLEGAL (0x0004) 2543 2428 #define MPI_SAS_IOUNIT1_CONTROL_FIRST_LVL_DISC_ONLY (0x0002) 2544 2429 #define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION (0x0001) 2430 + 2431 + /* values for SAS IO Unit Page 1 AdditionalControlFlags */ 2432 + #define MPI_SAS_IOUNIT1_ACONTROL_ALLOW_TABLE_TO_TABLE (0x0001) 2433 + 2434 + /* defines for SAS IO Unit Page 1 ReportDeviceMissingDelay */ 2435 + #define MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK (0x7F) 2436 + #define MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16 (0x80) 2545 2437 2546 2438 /* values for SAS IO Unit Page 1 PortFlags */ 2547 2439 #define MPI_SAS_IOUNIT1_PORT_FLAGS_0_TARGET_IOC_NUM (0x00)
+52 -24
drivers/message/fusion/lsi/mpi_history.txt
··· 6 6 Copyright (c) 2000-2005 LSI Logic Corporation. 7 7 8 8 --------------------------------------- 9 - Header Set Release Version: 01.05.12 10 - Header Set Release Date: 08-30-05 9 + Header Set Release Version: 01.05.13 10 + Header Set Release Date: 03-27-06 11 11 --------------------------------------- 12 12 13 13 Filename Current version Prior version 14 14 ---------- --------------- ------------- 15 - mpi.h 01.05.10 01.05.09 16 - mpi_ioc.h 01.05.10 01.05.09 17 - mpi_cnfg.h 01.05.11 01.05.10 18 - mpi_init.h 01.05.06 01.05.06 19 - mpi_targ.h 01.05.05 01.05.05 15 + mpi.h 01.05.11 01.05.10 16 + mpi_ioc.h 01.05.11 01.05.10 17 + mpi_cnfg.h 01.05.12 01.05.11 18 + mpi_init.h 01.05.07 01.05.06 19 + mpi_targ.h 01.05.06 01.05.05 20 20 mpi_fc.h 01.05.01 01.05.01 21 21 mpi_lan.h 01.05.01 01.05.01 22 22 mpi_raid.h 01.05.02 01.05.02 23 23 mpi_tool.h 01.05.03 01.05.03 24 24 mpi_inb.h 01.05.01 01.05.01 25 - mpi_sas.h 01.05.02 01.05.01 26 - mpi_type.h 01.05.02 01.05.01 27 - mpi_history.txt 01.05.12 01.05.11 25 + mpi_sas.h 01.05.03 01.05.02 26 + mpi_type.h 01.05.02 01.05.02 27 + mpi_history.txt 01.05.13 01.05.12 28 28 29 29 30 30 * Date Version Description ··· 93 93 * Added EEDP IOCStatus codes. 94 94 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT. 95 95 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target. 96 + * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 96 97 * -------------------------------------------------------------------------- 97 98 98 99 mpi_ioc.h ··· 171 170 * Added new ReasonCode value for SAS Device Status Change 172 171 * event. 173 172 * Added new family code for FC949E. 173 + * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR. 174 + * Added additional Reason Codes and more event data fields 175 + * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE. 176 + * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and 177 + * new event. 178 + * Added MPI_EVENT_SAS_SMP_ERROR and event data structure. 179 + * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event 180 + * data structure. 181 + * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event 182 + * data structure. 183 + * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION. 174 184 * -------------------------------------------------------------------------- 175 185 176 186 mpi_cnfg.h ··· 437 425 * Added postpone SATA Init bit to SAS IO Unit Page 1 438 426 * ControlFlags. 439 427 * Changed LogEntry format for Log Page 0. 428 + * 03-27-06 01.05.12 Added two new Flags defines for Manufacturing Page 4. 429 + * Added Manufacturing Page 7. 430 + * Added MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING. 431 + * Added IOC Page 6. 432 + * Added PrevBootDeviceForm field to CONFIG_PAGE_BIOS_2. 433 + * Added MaxLBAHigh field to RAID Volume Page 0. 434 + * Added Nvdata version fields to SAS IO Unit Page 0. 435 + * Added AdditionalControlFlags, MaxTargetPortConnectTime, 436 + * ReportDeviceMissingDelay, and IODeviceMissingDelay 437 + * fields to SAS IO Unit Page 1. 440 438 * -------------------------------------------------------------------------- 441 439 442 440 mpi_init.h ··· 489 467 * Added four new defines for SEP SlotStatus. 490 468 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them 491 469 * unique in the first 32 characters. 470 + * 03-27-06 01.05.07 Added Task Management type of Clear ACA. 492 471 * -------------------------------------------------------------------------- 493 472 494 473 mpi_targ.h ··· 534 511 * 02-22-05 01.05.03 Changed a comment. 535 512 * 03-11-05 01.05.04 Removed TargetAssistExtended Request. 536 513 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. 514 + * 03-27-06 01.05.06 Added a comment. 537 515 * -------------------------------------------------------------------------- 538 516 539 517 mpi_fc.h ··· 634 610 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP. 635 611 * Added PrimFlags and Primitive field to SAS IO Unit 636 612 * Control request, and added a new operation code. 613 + * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal, 614 + * and Remove Device operations to SAS IO Unit Control. 615 + * Added DevHandle field to SAS IO Unit Control request and 616 + * reply. 637 617 * -------------------------------------------------------------------------- 638 618 639 619 mpi_type.h ··· 653 625 654 626 mpi_history.txt Parts list history 655 627 656 - Filename 01.05.12 01.05.11 01.05.10 01.05.09 657 - ---------- -------- -------- -------- -------- 658 - mpi.h 01.05.10 01.05.09 01.05.08 01.05.07 659 - mpi_ioc.h 01.05.10 01.05.09 01.05.09 01.05.08 660 - mpi_cnfg.h 01.05.11 01.05.10 01.05.09 01.05.08 661 - mpi_init.h 01.05.06 01.05.06 01.05.05 01.05.04 662 - mpi_targ.h 01.05.05 01.05.05 01.05.05 01.05.04 663 - mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 664 - mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 665 - mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02 666 - mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 667 - mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 668 - mpi_sas.h 01.05.02 01.05.01 01.05.01 01.05.01 669 - mpi_type.h 01.05.02 01.05.01 01.05.01 01.05.01 628 + Filename 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09 629 + ---------- -------- -------- -------- -------- -------- 630 + mpi.h 01.05.11 01.05.10 01.05.09 01.05.08 01.05.07 631 + mpi_ioc.h 01.05.11 01.05.10 01.05.09 01.05.09 01.05.08 632 + mpi_cnfg.h 01.05.12 01.05.11 01.05.10 01.05.09 01.05.08 633 + mpi_init.h 01.05.07 01.05.06 01.05.06 01.05.05 01.05.04 634 + mpi_targ.h 01.05.06 01.05.05 01.05.05 01.05.05 01.05.04 635 + mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01 636 + mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01 637 + mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02 01.05.02 638 + mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 01.05.03 639 + mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01 640 + mpi_sas.h 01.05.03 01.05.02 01.05.01 01.05.01 01.05.01 641 + mpi_type.h 01.05.02 01.05.02 01.05.01 01.05.01 01.05.01 670 642 671 643 Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03 672 644 ---------- -------- -------- -------- -------- -------- --------
+3 -1
drivers/message/fusion/lsi/mpi_init.h
··· 6 6 * Title: MPI initiator mode messages and structures 7 7 * Creation Date: June 8, 2000 8 8 * 9 - * mpi_init.h Version: 01.05.06 9 + * mpi_init.h Version: 01.05.07 10 10 * 11 11 * Version History 12 12 * --------------- ··· 52 52 * Added four new defines for SEP SlotStatus. 53 53 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them 54 54 * unique in the first 32 characters. 55 + * 03-27-06 01.05.07 Added Task Management type of Clear ACA. 55 56 * -------------------------------------------------------------------------- 56 57 */ 57 58 ··· 428 427 #define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) 429 428 #define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) 430 429 #define MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) 430 + #define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) 431 431 432 432 /* MsgFlags bits */ 433 433 #define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION (0x00)
+123 -31
drivers/message/fusion/lsi/mpi_ioc.h
··· 6 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 7 7 * Creation Date: August 11, 2000 8 8 * 9 - * mpi_ioc.h Version: 01.05.10 9 + * mpi_ioc.h Version: 01.05.11 10 10 * 11 11 * Version History 12 12 * --------------- ··· 87 87 * Added new ReasonCode value for SAS Device Status Change 88 88 * event. 89 89 * Added new family code for FC949E. 90 + * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR. 91 + * Added additional Reason Codes and more event data fields 92 + * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE. 93 + * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and 94 + * new event. 95 + * Added MPI_EVENT_SAS_SMP_ERROR and event data structure. 96 + * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event 97 + * data structure. 98 + * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event 99 + * data structure. 100 + * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION. 90 101 * -------------------------------------------------------------------------- 91 102 */ 92 103 ··· 283 272 #define MPI_IOCFACTS_CAPABILITY_MULTICAST (0x00000100) 284 273 #define MPI_IOCFACTS_CAPABILITY_SCSIIO32 (0x00000200) 285 274 #define MPI_IOCFACTS_CAPABILITY_NO_SCSIIO16 (0x00000400) 275 + #define MPI_IOCFACTS_CAPABILITY_TLR (0x00000800) 286 276 287 277 288 278 /***************************************************************************** ··· 460 448 461 449 /* Event */ 462 450 463 - #define MPI_EVENT_NONE (0x00000000) 464 - #define MPI_EVENT_LOG_DATA (0x00000001) 465 - #define MPI_EVENT_STATE_CHANGE (0x00000002) 466 - #define MPI_EVENT_UNIT_ATTENTION (0x00000003) 467 - #define MPI_EVENT_IOC_BUS_RESET (0x00000004) 468 - #define MPI_EVENT_EXT_BUS_RESET (0x00000005) 469 - #define MPI_EVENT_RESCAN (0x00000006) 470 - #define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007) 471 - #define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008) 472 - #define MPI_EVENT_LOGOUT (0x00000009) 473 - #define MPI_EVENT_EVENT_CHANGE (0x0000000A) 474 - #define MPI_EVENT_INTEGRATED_RAID (0x0000000B) 475 - #define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C) 476 - #define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D) 477 - #define MPI_EVENT_QUEUE_FULL (0x0000000E) 478 - #define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F) 479 - #define MPI_EVENT_SAS_SES (0x00000010) 480 - #define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011) 481 - #define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012) 482 - #define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013) 483 - #define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014) 484 - #define MPI_EVENT_IR2 (0x00000015) 485 - #define MPI_EVENT_SAS_DISCOVERY (0x00000016) 486 - #define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021) 451 + #define MPI_EVENT_NONE (0x00000000) 452 + #define MPI_EVENT_LOG_DATA (0x00000001) 453 + #define MPI_EVENT_STATE_CHANGE (0x00000002) 454 + #define MPI_EVENT_UNIT_ATTENTION (0x00000003) 455 + #define MPI_EVENT_IOC_BUS_RESET (0x00000004) 456 + #define MPI_EVENT_EXT_BUS_RESET (0x00000005) 457 + #define MPI_EVENT_RESCAN (0x00000006) 458 + #define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007) 459 + #define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008) 460 + #define MPI_EVENT_LOGOUT (0x00000009) 461 + #define MPI_EVENT_EVENT_CHANGE (0x0000000A) 462 + #define MPI_EVENT_INTEGRATED_RAID (0x0000000B) 463 + #define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C) 464 + #define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D) 465 + #define MPI_EVENT_QUEUE_FULL (0x0000000E) 466 + #define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F) 467 + #define MPI_EVENT_SAS_SES (0x00000010) 468 + #define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011) 469 + #define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012) 470 + #define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013) 471 + #define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014) 472 + #define MPI_EVENT_IR2 (0x00000015) 473 + #define MPI_EVENT_SAS_DISCOVERY (0x00000016) 474 + #define MPI_EVENT_SAS_BROADCAST_PRIMITIVE (0x00000017) 475 + #define MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE (0x00000018) 476 + #define MPI_EVENT_SAS_INIT_TABLE_OVERFLOW (0x00000019) 477 + #define MPI_EVENT_SAS_SMP_ERROR (0x0000001A) 478 + #define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021) 487 479 488 480 /* AckRequired field values */ 489 481 ··· 574 558 U8 PhyNum; /* 0Eh */ 575 559 U8 Reserved1; /* 0Fh */ 576 560 U64 SASAddress; /* 10h */ 561 + U8 LUN[8]; /* 18h */ 562 + U16 TaskTag; /* 20h */ 563 + U16 Reserved2; /* 22h */ 577 564 } EVENT_DATA_SAS_DEVICE_STATUS_CHANGE, 578 565 MPI_POINTER PTR_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE, 579 566 MpiEventDataSasDeviceStatusChange_t, 580 567 MPI_POINTER pMpiEventDataSasDeviceStatusChange_t; 581 568 582 569 /* MPI SAS Device Status Change Event data ReasonCode values */ 583 - #define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03) 584 - #define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04) 585 - #define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05) 586 - #define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06) 587 - #define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07) 588 - #define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08) 570 + #define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03) 571 + #define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04) 572 + #define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05) 573 + #define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06) 574 + #define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07) 575 + #define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08) 576 + #define MPI_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL (0x09) 577 + #define MPI_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL (0x0A) 578 + #define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B) 579 + #define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C) 589 580 590 581 591 582 /* SCSI Event data for Queue Full event */ ··· 765 742 } EVENT_DATA_SAS_SES, MPI_POINTER PTR_EVENT_DATA_SAS_SES, 766 743 MpiEventDataSasSes_t, MPI_POINTER pMpiEventDataSasSes_t; 767 744 745 + /* SAS Broadcast Primitive Event data */ 746 + 747 + typedef struct _EVENT_DATA_SAS_BROADCAST_PRIMITIVE 748 + { 749 + U8 PhyNum; /* 00h */ 750 + U8 Port; /* 01h */ 751 + U8 PortWidth; /* 02h */ 752 + U8 Primitive; /* 04h */ 753 + } EVENT_DATA_SAS_BROADCAST_PRIMITIVE, 754 + MPI_POINTER PTR_EVENT_DATA_SAS_BROADCAST_PRIMITIVE, 755 + MpiEventDataSasBroadcastPrimitive_t, 756 + MPI_POINTER pMpiEventDataSasBroadcastPrimitive_t; 757 + 758 + #define MPI_EVENT_PRIMITIVE_CHANGE (0x01) 759 + #define MPI_EVENT_PRIMITIVE_EXPANDER (0x03) 760 + #define MPI_EVENT_PRIMITIVE_RESERVED2 (0x04) 761 + #define MPI_EVENT_PRIMITIVE_RESERVED3 (0x05) 762 + #define MPI_EVENT_PRIMITIVE_RESERVED4 (0x06) 763 + #define MPI_EVENT_PRIMITIVE_CHANGE0_RESERVED (0x07) 764 + #define MPI_EVENT_PRIMITIVE_CHANGE1_RESERVED (0x08) 765 + 768 766 /* SAS Phy Link Status Event data */ 769 767 770 768 typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS ··· 847 803 #define MPI_EVENT_DSCVRY_ERR_DS_TABLE_TO_TABLE (0x00000400) 848 804 #define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS (0x00000800) 849 805 #define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000) 806 + 807 + /* SAS SMP Error Event data */ 808 + 809 + typedef struct _EVENT_DATA_SAS_SMP_ERROR 810 + { 811 + U8 Status; /* 00h */ 812 + U8 Port; /* 01h */ 813 + U8 SMPFunctionResult; /* 02h */ 814 + U8 Reserved1; /* 03h */ 815 + U64 SASAddress; /* 04h */ 816 + } EVENT_DATA_SAS_SMP_ERROR, MPI_POINTER PTR_EVENT_DATA_SAS_SMP_ERROR, 817 + MpiEventDataSasSmpError_t, MPI_POINTER pMpiEventDataSasSmpError_t; 818 + 819 + /* defines for the Status field of the SAS SMP Error event */ 820 + #define MPI_EVENT_SAS_SMP_FUNCTION_RESULT_VALID (0x00) 821 + #define MPI_EVENT_SAS_SMP_CRC_ERROR (0x01) 822 + #define MPI_EVENT_SAS_SMP_TIMEOUT (0x02) 823 + #define MPI_EVENT_SAS_SMP_NO_DESTINATION (0x03) 824 + #define MPI_EVENT_SAS_SMP_BAD_DESTINATION (0x04) 825 + 826 + /* SAS Initiator Device Status Change Event data */ 827 + 828 + typedef struct _EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE 829 + { 830 + U8 ReasonCode; /* 00h */ 831 + U8 Port; /* 01h */ 832 + U16 DevHandle; /* 02h */ 833 + U64 SASAddress; /* 04h */ 834 + } EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE, 835 + MPI_POINTER PTR_EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE, 836 + MpiEventDataSasInitDevStatusChange_t, 837 + MPI_POINTER pMpiEventDataSasInitDevStatusChange_t; 838 + 839 + /* defines for the ReasonCode field of the SAS Initiator Device Status Change event */ 840 + #define MPI_EVENT_SAS_INIT_RC_ADDED (0x01) 841 + 842 + /* SAS Initiator Device Table Overflow Event data */ 843 + 844 + typedef struct _EVENT_DATA_SAS_INIT_TABLE_OVERFLOW 845 + { 846 + U8 MaxInit; /* 00h */ 847 + U8 CurrentInit; /* 01h */ 848 + U16 Reserved1; /* 02h */ 849 + } EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 850 + MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 851 + MpiEventDataSasInitTableOverflow_t, 852 + MPI_POINTER pMpiEventDataSasInitTableOverflow_t; 850 853 851 854 852 855 /***************************************************************************** ··· 1104 1013 #define MPI_EXT_IMAGE_TYPE_FW (0x01) 1105 1014 #define MPI_EXT_IMAGE_TYPE_NVDATA (0x03) 1106 1015 #define MPI_EXT_IMAGE_TYPE_BOOTLOADER (0x04) 1016 + #define MPI_EXT_IMAGE_TYPE_INITIALIZATION (0x05) 1107 1017 1108 1018 #endif
+79 -3
drivers/message/fusion/lsi/mpi_log_sas.h
··· 13 13 #ifndef IOPI_IOCLOGINFO_H_INCLUDED 14 14 #define IOPI_IOCLOGINFO_H_INCLUDED 15 15 16 + #define SAS_LOGINFO_NEXUS_LOSS 0x31170000 17 + #define SAS_LOGINFO_MASK 0xFFFF0000 16 18 17 19 /****************************************************************************/ 18 20 /* IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF */ ··· 53 51 #define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM (0x00030500) /* Device Not Mapped */ 54 52 #define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST (0x00030600) /* Persistent Page not found */ 55 53 #define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT (0x00030700) /* Default Page not found */ 54 + 55 + #define IOP_LOGINFO_CODE_DIAG_MSG_ERROR (0x00040000) /* Error handling diag msg - or'd with diag status */ 56 + 56 57 #define IOP_LOGINFO_CODE_TASK_TERMINATED (0x00050000) 57 58 58 59 #define IOP_LOGINFO_CODE_ENCL_MGMT_READ_ACTION_ERR0R (0x00060001) /* Read Action not supported for SEP msg */ ··· 108 103 #define PL_LOGINFO_CODE_IO_EXECUTED (0x00140000) 109 104 #define PL_LOGINFO_CODE_PERS_RESV_OUT_NOT_AFFIL_OWNER (0x00150000) 110 105 #define PL_LOGINFO_CODE_OPEN_TXDMA_ABORT (0x00160000) 106 + #define PL_LOGINFO_CODE_IO_DEVICE_MISSING_DELAY_RETRY (0x00170000) 111 107 #define PL_LOGINFO_SUB_CODE_OPEN_FAILURE (0x00000100) 112 108 #define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_NO_DEST_TIMEOUT (0x00000101) 113 109 #define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_ORR_TIMEOUT (0x0000011A) /* Open Reject (Retry) Timeout */ ··· 171 165 /****************************************************************************/ 172 166 /* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR */ 173 167 /****************************************************************************/ 174 - #define IR_LOGINFO_CODE_UNUSED1 (0x00010000) 175 - #define IR_LOGINFO_CODE_UNUSED2 (0x00020000) 168 + #define IR_LOGINFO_RAID_ACTION_ERROR (0x00010000) 169 + #define IR_LOGINFO_CODE_UNUSED2 (0x00020000) 170 + 171 + /* Amount of information passed down for Create Volume is too large */ 172 + #define IR_LOGINFO_VOLUME_CREATE_INVALID_LENGTH (0x00010001) 173 + /* Creation of duplicate volume attempted (Bus/Target ID checked) */ 174 + #define IR_LOGINFO_VOLUME_CREATE_DUPLICATE (0x00010002) 175 + /* Creation failed due to maximum number of supported volumes exceeded */ 176 + #define IR_LOGINFO_VOLUME_CREATE_NO_SLOTS (0x00010003) 177 + /* Creation failed due to DMA error in trying to read from host */ 178 + #define IR_LOGINFO_VOLUME_CREATE_DMA_ERROR (0x00010004) 179 + /* Creation failed due to invalid volume type passed down */ 180 + #define IR_LOGINFO_VOLUME_CREATE_INVALID_VOLUME_TYPE (0x00010005) 181 + /* Creation failed due to error reading MFG Page 4 */ 182 + #define IR_LOGINFO_VOLUME_MFG_PAGE4_ERROR (0x00010006) 183 + /* Creation failed when trying to create internal structures */ 184 + #define IR_LOGINFO_VOLUME_INTERNAL_CONFIG_STRUCTURE_ERROR (0x00010007) 185 + 186 + /* Activation failed due to trying to activate an already active volume */ 187 + #define IR_LOGINFO_VOLUME_ACTIVATING_AN_ACTIVE_VOLUME (0x00010010) 188 + /* Activation failed due to trying to active unsupported volume type */ 189 + #define IR_LOGINFO_VOLUME_ACTIVATING_INVALID_VOLUME_TYPE (0x00010011) 190 + /* Activation failed due to trying to active too many volumes */ 191 + #define IR_LOGINFO_VOLUME_ACTIVATING_TOO_MANY_VOLUMES (0x00010012) 192 + /* Activation failed due to Volume ID in use already */ 193 + #define IR_LOGINFO_VOLUME_ACTIVATING_VOLUME_ID_IN_USE (0x00010013) 194 + /* Activation failed call to activateVolume returned failure */ 195 + #define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014) 196 + /* Activation failed trying to import the volume */ 197 + #define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015) 198 + 199 + /* Phys Disk failed, too many phys disks */ 200 + #define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020) 201 + /* Amount of information passed down for Create Pnysdisk is too large */ 202 + #define IR_LOGINFO_PHYSDISK_CREATE_INVALID_LENGTH (0x00010021) 203 + /* Creation failed due to DMA error in trying to read from host */ 204 + #define IR_LOGINFO_PHYSDISK_CREATE_DMA_ERROR (0x00010022) 205 + /* Creation failed due to invalid Bus TargetID passed down */ 206 + #define IR_LOGINFO_PHYSDISK_CREATE_BUS_TID_INVALID (0x00010023) 207 + /* Creation failed due to error in creating RAID Phys Disk Config Page */ 208 + #define IR_LOGINFO_PHYSDISK_CREATE_CONFIG_PAGE_ERROR (0x00010024) 209 + 210 + 211 + /* Compatibility Error : IR Disabled */ 212 + #define IR_LOGINFO_COMPAT_ERROR_RAID_DISABLED (0x00010030) 213 + /* Compatibility Error : Inquiry Comand failed */ 214 + #define IR_LOGINFO_COMPAT_ERROR_INQUIRY_FAILED (0x00010031) 215 + /* Compatibility Error : Device not direct access device */ 216 + #define IR_LOGINFO_COMPAT_ERROR_NOT_DIRECT_ACCESS (0x00010032) 217 + /* Compatibility Error : Removable device found */ 218 + #define IR_LOGINFO_COMPAT_ERROR_REMOVABLE_FOUND (0x00010033) 219 + /* Compatibility Error : Device SCSI Version not 2 or higher */ 220 + #define IR_LOGINFO_COMPAT_ERROR_NEED_SCSI_2_OR_HIGHER (0x00010034) 221 + /* Compatibility Error : SATA device, 48 BIT LBA not supported */ 222 + #define IR_LOGINFO_COMPAT_ERROR_SATA_48BIT_LBA_NOT_SUPPORTED (0x00010035) 223 + /* Compatibility Error : Device does not have 512 byte block sizes */ 224 + #define IR_LOGINFO_COMPAT_ERROR_DEVICE_NOT_512_BYTE_BLOCK (0x00010036) 225 + /* Compatibility Error : Volume Type check failed */ 226 + #define IR_LOGINFO_COMPAT_ERROR_VOLUME_TYPE_CHECK_FAILED (0x00010037) 227 + /* Compatibility Error : Volume Type is unsupported by FW */ 228 + #define IR_LOGINFO_COMPAT_ERROR_UNSUPPORTED_VOLUME_TYPE (0x00010038) 229 + /* Compatibility Error : Disk drive too small for use in volume */ 230 + #define IR_LOGINFO_COMPAT_ERROR_DISK_TOO_SMALL (0x00010039) 231 + /* Compatibility Error : Phys disk for Create Volume not found */ 232 + #define IR_LOGINFO_COMPAT_ERROR_PHYS_DISK_NOT_FOUND (0x0001003A) 233 + /* Compatibility Error : membership count error, too many or too few disks for volume type */ 234 + #define IR_LOGINFO_COMPAT_ERROR_MEMBERSHIP_COUNT (0x0001003B) 235 + /* Compatibility Error : Disk stripe sizes must be 64KB */ 236 + #define IR_LOGINFO_COMPAT_ERROR_NON_64K_STRIPE_SIZE (0x0001003C) 237 + /* Compatibility Error : IME size limited to < 2TB */ 238 + #define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D) 239 + 176 240 177 241 /****************************************************************************/ 178 - /* Defines for convienence */ 242 + /* Defines for convenience */ 179 243 /****************************************************************************/ 180 244 #define IOC_LOGINFO_PREFIX_IOP ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP) 181 245 #define IOC_LOGINFO_PREFIX_PL ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL)
+10 -3
drivers/message/fusion/lsi/mpi_sas.h
··· 6 6 * Title: MPI Serial Attached SCSI structures and definitions 7 7 * Creation Date: August 19, 2004 8 8 * 9 - * mpi_sas.h Version: 01.05.02 9 + * mpi_sas.h Version: 01.05.03 10 10 * 11 11 * Version History 12 12 * --------------- ··· 17 17 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP. 18 18 * Added PrimFlags and Primitive field to SAS IO Unit 19 19 * Control request, and added a new operation code. 20 + * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal, 21 + * and Remove Device operations to SAS IO Unit Control. 22 + * Added DevHandle field to SAS IO Unit Control request and 23 + * reply. 20 24 * -------------------------------------------------------------------------- 21 25 */ 22 26 ··· 213 209 U8 Reserved1; /* 01h */ 214 210 U8 ChainOffset; /* 02h */ 215 211 U8 Function; /* 03h */ 216 - U16 Reserved2; /* 04h */ 212 + U16 DevHandle; /* 04h */ 217 213 U8 Reserved3; /* 06h */ 218 214 U8 MsgFlags; /* 07h */ 219 215 U32 MsgContext; /* 08h */ ··· 235 231 #define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08) 236 232 #define MPI_SAS_OP_MAP_CURRENT (0x09) 237 233 #define MPI_SAS_OP_SEND_PRIMITIVE (0x0A) 234 + #define MPI_SAS_OP_FORCE_FULL_DISCOVERY (0x0B) 235 + #define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C) 236 + #define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D) 238 237 239 238 /* values for the PrimFlags field */ 240 239 #define MPI_SAS_PRIMFLAGS_SINGLE (0x08) ··· 252 245 U8 Reserved1; /* 01h */ 253 246 U8 MsgLength; /* 02h */ 254 247 U8 Function; /* 03h */ 255 - U16 Reserved2; /* 04h */ 248 + U16 DevHandle; /* 04h */ 256 249 U8 Reserved3; /* 06h */ 257 250 U8 MsgFlags; /* 07h */ 258 251 U32 MsgContext; /* 08h */
+3 -2
drivers/message/fusion/lsi/mpi_targ.h
··· 6 6 * Title: MPI Target mode messages and structures 7 7 * Creation Date: June 22, 2000 8 8 * 9 - * mpi_targ.h Version: 01.05.05 9 + * mpi_targ.h Version: 01.05.06 10 10 * 11 11 * Version History 12 12 * --------------- ··· 54 54 * 02-22-05 01.05.03 Changed a comment. 55 55 * 03-11-05 01.05.04 Removed TargetAssistExtended Request. 56 56 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines. 57 + * 03-27-06 01.05.06 Added a comment. 57 58 * -------------------------------------------------------------------------- 58 59 */ 59 60 ··· 352 351 #define TARGET_ASSIST_FLAGS_CONFIRMED (0x08) 353 352 #define TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER (0x80) 354 353 355 - 354 + /* Standard Target Mode Reply message */ 356 355 typedef struct _MSG_TARGET_ERROR_REPLY 357 356 { 358 357 U16 Reserved; /* 00h */
+48 -27
drivers/message/fusion/mptbase.c
··· 368 368 mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) 369 369 { 370 370 MPT_ADAPTER *ioc = bus_id; 371 - u32 pa; 371 + u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); 372 + 373 + if (pa == 0xFFFFFFFF) 374 + return IRQ_NONE; 372 375 373 376 /* 374 377 * Drain the reply FIFO! 375 378 */ 376 - while (1) { 377 - pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); 378 - if (pa == 0xFFFFFFFF) 379 - return IRQ_HANDLED; 380 - else if (pa & MPI_ADDRESS_REPLY_A_BIT) 379 + do { 380 + if (pa & MPI_ADDRESS_REPLY_A_BIT) 381 381 mpt_reply(ioc, pa); 382 382 else 383 383 mpt_turbo_reply(ioc, pa); 384 - } 384 + pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); 385 + } while (pa != 0xFFFFFFFF); 385 386 386 387 return IRQ_HANDLED; 387 388 } ··· 1220 1219 port = psize = 0; 1221 1220 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) { 1222 1221 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) { 1222 + if (psize) 1223 + continue; 1223 1224 /* Get I/O space! */ 1224 1225 port = pci_resource_start(pdev, ii); 1225 1226 psize = pci_resource_len(pdev,ii); 1226 1227 } else { 1228 + if (msize) 1229 + continue; 1227 1230 /* Get memmap */ 1228 1231 mem_phys = pci_resource_start(pdev, ii); 1229 1232 msize = pci_resource_len(pdev,ii); 1230 - break; 1231 1233 } 1232 1234 } 1233 1235 ioc->mem_size = msize; 1234 1236 1235 - if (ii == DEVICE_COUNT_RESOURCE) { 1236 - printk(KERN_ERR MYNAM ": ERROR - MPT adapter has no memory regions defined!\n"); 1237 - kfree(ioc); 1238 - return -EINVAL; 1239 - } 1240 - 1241 - dinitprintk((KERN_INFO MYNAM ": MPT adapter @ %lx, msize=%dd bytes\n", mem_phys, msize)); 1242 - dinitprintk((KERN_INFO MYNAM ": (port i/o @ %lx, psize=%dd bytes)\n", port, psize)); 1243 - 1244 1237 mem = NULL; 1245 1238 /* Get logical ptr for PciMem0 space */ 1246 1239 /*mem = ioremap(mem_phys, msize);*/ 1247 - mem = ioremap(mem_phys, 0x100); 1240 + mem = ioremap(mem_phys, msize); 1248 1241 if (mem == NULL) { 1249 1242 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n"); 1250 1243 kfree(ioc); ··· 1338 1343 ioc->bus_type = SAS; 1339 1344 ioc->errata_flag_1064 = 1; 1340 1345 } 1341 - else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066) { 1342 - ioc->prod_name = "LSISAS1066"; 1343 - ioc->bus_type = SAS; 1344 - ioc->errata_flag_1064 = 1; 1345 - } 1346 1346 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) { 1347 1347 ioc->prod_name = "LSISAS1068"; 1348 1348 ioc->bus_type = SAS; ··· 1347 1357 ioc->prod_name = "LSISAS1064E"; 1348 1358 ioc->bus_type = SAS; 1349 1359 } 1350 - else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066E) { 1351 - ioc->prod_name = "LSISAS1066E"; 1352 - ioc->bus_type = SAS; 1353 - } 1354 1360 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) { 1355 1361 ioc->prod_name = "LSISAS1068E"; 1362 + ioc->bus_type = SAS; 1363 + } 1364 + else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { 1365 + ioc->prod_name = "LSISAS1078"; 1356 1366 ioc->bus_type = SAS; 1357 1367 } 1358 1368 ··· 3173 3183 #ifdef MPT_DEBUG 3174 3184 u32 diag1val = 0; 3175 3185 #endif 3186 + 3187 + if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { 3188 + drsprintk((MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset " 3189 + "address=%p\n", ioc->name, __FUNCTION__, 3190 + &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); 3191 + CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); 3192 + if (sleepFlag == CAN_SLEEP) 3193 + msleep(1); 3194 + else 3195 + mdelay(1); 3196 + 3197 + for (count = 0; count < 60; count ++) { 3198 + doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); 3199 + doorbell &= MPI_IOC_STATE_MASK; 3200 + 3201 + drsprintk((MYIOC_s_INFO_FMT 3202 + "looking for READY STATE: doorbell=%x" 3203 + " count=%d\n", 3204 + ioc->name, doorbell, count)); 3205 + if (doorbell == MPI_IOC_STATE_READY) { 3206 + return 0; 3207 + } 3208 + 3209 + /* wait 1 sec */ 3210 + if (sleepFlag == CAN_SLEEP) 3211 + msleep(1000); 3212 + else 3213 + mdelay(1000); 3214 + } 3215 + return -1; 3216 + } 3176 3217 3177 3218 /* Clear any existing interrupts */ 3178 3219 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
+15 -4
drivers/message/fusion/mptbase.h
··· 75 75 #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 76 76 #endif 77 77 78 - #define MPT_LINUX_VERSION_COMMON "3.03.10" 79 - #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.10" 78 + #define MPT_LINUX_VERSION_COMMON "3.04.00" 79 + #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.00" 80 80 #define WHAT_MAGIC_STRING "@" "(" "#" ")" 81 81 82 82 #define show_mptmod_ver(s,ver) \ ··· 307 307 u32 HostIndex; /* 50 Host Index register */ 308 308 u32 Reserved4[15]; /* 54-8F */ 309 309 u32 Fubar; /* 90 For Fubar usage */ 310 - u32 Reserved5[27]; /* 94-FF */ 310 + u32 Reserved5[1050];/* 94-10F8 */ 311 + u32 Reset_1078; /* 10FC Reset 1078 */ 311 312 } SYSIF_REGS; 312 313 313 314 /* ··· 342 341 u8 negoFlags; /* bit field, see above */ 343 342 u8 raidVolume; /* set, if RAID Volume */ 344 343 u8 type; /* byte 0 of Inquiry data */ 344 + u8 deleted; /* target in process of being removed */ 345 345 u32 num_luns; 346 346 u32 luns[8]; /* Max LUNs is 256 */ 347 347 } VirtTarget; ··· 631 629 struct mutex sas_discovery_mutex; 632 630 u8 sas_discovery_runtime; 633 631 u8 sas_discovery_ignore_events; 632 + u16 handle; 634 633 int sas_index; /* index refrencing */ 635 634 MPT_SAS_MGMT sas_mgmt; 636 635 int num_ports; 637 - struct work_struct mptscsih_persistTask; 636 + struct work_struct sas_persist_task; 638 637 639 638 struct work_struct fc_setup_reset_work; 640 639 struct list_head fc_rports; ··· 644 641 struct work_struct fc_rescan_work; 645 642 char fc_rescan_work_q_name[KOBJ_NAME_LEN]; 646 643 struct workqueue_struct *fc_rescan_work_q; 644 + u8 port_serial_number; 647 645 } MPT_ADAPTER; 648 646 649 647 /* ··· 894 890 #else 895 891 #define DBG_DUMP_REPLY_FRAME(mfp) 896 892 #define DBG_DUMP_REQUEST_FRAME_HDR(mfp) 893 + #endif 894 + 895 + // debug sas wide ports 896 + #ifdef MPT_DEBUG_SAS_WIDE 897 + #define dsaswideprintk(x) printk x 898 + #else 899 + #define dsaswideprintk(x) 897 900 #endif 898 901 899 902
+8 -8
drivers/message/fusion/mptfc.c
··· 132 132 */ 133 133 134 134 static struct pci_device_id mptfc_pci_table[] = { 135 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC909, 135 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC909, 136 136 PCI_ANY_ID, PCI_ANY_ID }, 137 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919, 137 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC919, 138 138 PCI_ANY_ID, PCI_ANY_ID }, 139 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929, 139 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC929, 140 140 PCI_ANY_ID, PCI_ANY_ID }, 141 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919X, 141 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC919X, 142 142 PCI_ANY_ID, PCI_ANY_ID }, 143 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929X, 143 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC929X, 144 144 PCI_ANY_ID, PCI_ANY_ID }, 145 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC939X, 145 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC939X, 146 146 PCI_ANY_ID, PCI_ANY_ID }, 147 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949X, 147 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949X, 148 148 PCI_ANY_ID, PCI_ANY_ID }, 149 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949ES, 149 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949E, 150 150 PCI_ANY_ID, PCI_ANY_ID }, 151 151 {0} /* Terminating entry */ 152 152 };
+727 -283
drivers/message/fusion/mptsas.c
··· 50 50 #include <linux/errno.h> 51 51 #include <linux/sched.h> 52 52 #include <linux/workqueue.h> 53 + #include <linux/delay.h> /* for mdelay */ 53 54 55 + #include <scsi/scsi.h> 54 56 #include <scsi/scsi_cmnd.h> 55 57 #include <scsi/scsi_device.h> 56 58 #include <scsi/scsi_host.h> 57 59 #include <scsi/scsi_transport_sas.h> 60 + #include <scsi/scsi_dbg.h> 58 61 59 62 #include "mptbase.h" 60 63 #include "mptscsih.h" ··· 140 137 u32 device_info; /* bitfield detailed info about this device */ 141 138 }; 142 139 140 + /* 141 + * Specific details on ports, wide/narrow 142 + */ 143 + struct mptsas_portinfo_details{ 144 + u8 port_id; /* port number provided to transport */ 145 + u16 num_phys; /* number of phys belong to this port */ 146 + u64 phy_bitmask; /* TODO, extend support for 255 phys */ 147 + struct sas_rphy *rphy; /* transport layer rphy object */ 148 + struct sas_port *port; /* transport layer port object */ 149 + struct scsi_target *starget; 150 + struct mptsas_portinfo *port_info; 151 + }; 152 + 143 153 struct mptsas_phyinfo { 144 154 u8 phy_id; /* phy index */ 145 - u8 port_id; /* port number this phy is part of */ 155 + u8 port_id; /* firmware port identifier */ 146 156 u8 negotiated_link_rate; /* nego'd link rate for this phy */ 147 157 u8 hw_link_rate; /* hardware max/min phys link rate */ 148 158 u8 programmed_link_rate; /* programmed max/min phy link rate */ 159 + u8 sas_port_add_phy; /* flag to request sas_port_add_phy*/ 149 160 struct mptsas_devinfo identify; /* point to phy device info */ 150 161 struct mptsas_devinfo attached; /* point to attached device info */ 151 - struct sas_phy *phy; 152 - struct sas_rphy *rphy; 153 - struct scsi_target *starget; 162 + struct sas_phy *phy; /* transport layer phy object */ 163 + struct mptsas_portinfo *portinfo; 164 + struct mptsas_portinfo_details * port_details; 154 165 }; 155 166 156 167 struct mptsas_portinfo { 157 168 struct list_head list; 158 169 u16 handle; /* unique id to address this */ 159 - u8 num_phys; /* number of phys */ 170 + u16 num_phys; /* number of phys */ 160 171 struct mptsas_phyinfo *phy_info; 161 172 }; 162 173 ··· 186 169 u8 sep_channel; /* SEP channel logical channel id */ 187 170 }; 188 171 189 - #ifdef SASDEBUG 172 + #ifdef MPT_DEBUG_SAS 190 173 static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) 191 174 { 192 175 printk("---- IO UNIT PAGE 0 ------------\n"); ··· 322 305 static inline int 323 306 mptsas_is_end_device(struct mptsas_devinfo * attached) 324 307 { 325 - if ((attached->handle) && 308 + if ((attached->sas_address) && 326 309 (attached->device_info & 327 310 MPI_SAS_DEVICE_INFO_END_DEVICE) && 328 311 ((attached->device_info & ··· 334 317 return 1; 335 318 else 336 319 return 0; 320 + } 321 + 322 + /* no mutex */ 323 + static void 324 + mptsas_port_delete(struct mptsas_portinfo_details * port_details) 325 + { 326 + struct mptsas_portinfo *port_info; 327 + struct mptsas_phyinfo *phy_info; 328 + u8 i; 329 + 330 + if (!port_details) 331 + return; 332 + 333 + port_info = port_details->port_info; 334 + phy_info = port_info->phy_info; 335 + 336 + dsaswideprintk((KERN_DEBUG "%s: [%p]: port=%02d num_phys=%02d " 337 + "bitmask=0x%016llX\n", 338 + __FUNCTION__, port_details, port_details->port_id, 339 + port_details->num_phys, port_details->phy_bitmask)); 340 + 341 + for (i = 0; i < port_info->num_phys; i++, phy_info++) { 342 + if(phy_info->port_details != port_details) 343 + continue; 344 + memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 345 + phy_info->port_details = NULL; 346 + } 347 + kfree(port_details); 348 + } 349 + 350 + static inline struct sas_rphy * 351 + mptsas_get_rphy(struct mptsas_phyinfo *phy_info) 352 + { 353 + if (phy_info->port_details) 354 + return phy_info->port_details->rphy; 355 + else 356 + return NULL; 357 + } 358 + 359 + static inline void 360 + mptsas_set_rphy(struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy) 361 + { 362 + if (phy_info->port_details) { 363 + phy_info->port_details->rphy = rphy; 364 + dsaswideprintk((KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy)); 365 + } 366 + 367 + #ifdef MPT_DEBUG_SAS_WIDE 368 + if (rphy) { 369 + dev_printk(KERN_DEBUG, &rphy->dev, "add:"); 370 + printk("rphy=%p release=%p\n", 371 + rphy, rphy->dev.release); 372 + } 373 + #endif 374 + } 375 + 376 + static inline struct sas_port * 377 + mptsas_get_port(struct mptsas_phyinfo *phy_info) 378 + { 379 + if (phy_info->port_details) 380 + return phy_info->port_details->port; 381 + else 382 + return NULL; 383 + } 384 + 385 + static inline void 386 + mptsas_set_port(struct mptsas_phyinfo *phy_info, struct sas_port *port) 387 + { 388 + if (phy_info->port_details) 389 + phy_info->port_details->port = port; 390 + 391 + #ifdef MPT_DEBUG_SAS_WIDE 392 + if (port) { 393 + dev_printk(KERN_DEBUG, &port->dev, "add: "); 394 + printk("port=%p release=%p\n", 395 + port, port->dev.release); 396 + } 397 + #endif 398 + } 399 + 400 + static inline struct scsi_target * 401 + mptsas_get_starget(struct mptsas_phyinfo *phy_info) 402 + { 403 + if (phy_info->port_details) 404 + return phy_info->port_details->starget; 405 + else 406 + return NULL; 407 + } 408 + 409 + static inline void 410 + mptsas_set_starget(struct mptsas_phyinfo *phy_info, struct scsi_target * 411 + starget) 412 + { 413 + if (phy_info->port_details) 414 + phy_info->port_details->starget = starget; 415 + } 416 + 417 + 418 + /* 419 + * mptsas_setup_wide_ports 420 + * 421 + * Updates for new and existing narrow/wide port configuration 422 + * in the sas_topology 423 + */ 424 + static void 425 + mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info) 426 + { 427 + struct mptsas_portinfo_details * port_details; 428 + struct mptsas_phyinfo *phy_info, *phy_info_cmp; 429 + u64 sas_address; 430 + int i, j; 431 + 432 + mutex_lock(&ioc->sas_topology_mutex); 433 + 434 + phy_info = port_info->phy_info; 435 + for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { 436 + if (phy_info->attached.handle) 437 + continue; 438 + port_details = phy_info->port_details; 439 + if (!port_details) 440 + continue; 441 + if (port_details->num_phys < 2) 442 + continue; 443 + /* 444 + * Removing a phy from a port, letting the last 445 + * phy be removed by firmware events. 446 + */ 447 + dsaswideprintk((KERN_DEBUG 448 + "%s: [%p]: port=%d deleting phy = %d\n", 449 + __FUNCTION__, port_details, 450 + port_details->port_id, i)); 451 + port_details->num_phys--; 452 + port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); 453 + memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 454 + sas_port_delete_phy(port_details->port, phy_info->phy); 455 + phy_info->port_details = NULL; 456 + } 457 + 458 + /* 459 + * Populate and refresh the tree 460 + */ 461 + phy_info = port_info->phy_info; 462 + for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { 463 + sas_address = phy_info->attached.sas_address; 464 + dsaswideprintk((KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n", 465 + i, sas_address)); 466 + if (!sas_address) 467 + continue; 468 + port_details = phy_info->port_details; 469 + /* 470 + * Forming a port 471 + */ 472 + if (!port_details) { 473 + port_details = kzalloc(sizeof(*port_details), 474 + GFP_KERNEL); 475 + if (!port_details) 476 + goto out; 477 + port_details->num_phys = 1; 478 + port_details->port_info = port_info; 479 + port_details->port_id = ioc->port_serial_number++; 480 + if (phy_info->phy_id < 64 ) 481 + port_details->phy_bitmask |= 482 + (1 << phy_info->phy_id); 483 + phy_info->sas_port_add_phy=1; 484 + dsaswideprintk((KERN_DEBUG "\t\tForming port\n\t\t" 485 + "phy_id=%d sas_address=0x%018llX\n", 486 + i, sas_address)); 487 + phy_info->port_details = port_details; 488 + } 489 + 490 + if (i == port_info->num_phys - 1) 491 + continue; 492 + phy_info_cmp = &port_info->phy_info[i + 1]; 493 + for (j = i + 1 ; j < port_info->num_phys ; j++, 494 + phy_info_cmp++) { 495 + if (!phy_info_cmp->attached.sas_address) 496 + continue; 497 + if (sas_address != phy_info_cmp->attached.sas_address) 498 + continue; 499 + if (phy_info_cmp->port_details == port_details ) 500 + continue; 501 + dsaswideprintk((KERN_DEBUG 502 + "\t\tphy_id=%d sas_address=0x%018llX\n", 503 + j, phy_info_cmp->attached.sas_address)); 504 + if (phy_info_cmp->port_details) { 505 + port_details->rphy = 506 + mptsas_get_rphy(phy_info_cmp); 507 + port_details->port = 508 + mptsas_get_port(phy_info_cmp); 509 + port_details->starget = 510 + mptsas_get_starget(phy_info_cmp); 511 + port_details->port_id = 512 + phy_info_cmp->port_details->port_id; 513 + port_details->num_phys = 514 + phy_info_cmp->port_details->num_phys; 515 + // port_info->port_serial_number--; 516 + ioc->port_serial_number--; 517 + if (!phy_info_cmp->port_details->num_phys) 518 + kfree(phy_info_cmp->port_details); 519 + } else 520 + phy_info_cmp->sas_port_add_phy=1; 521 + /* 522 + * Adding a phy to a port 523 + */ 524 + phy_info_cmp->port_details = port_details; 525 + if (phy_info_cmp->phy_id < 64 ) 526 + port_details->phy_bitmask |= 527 + (1 << phy_info_cmp->phy_id); 528 + port_details->num_phys++; 529 + } 530 + } 531 + 532 + out: 533 + 534 + #ifdef MPT_DEBUG_SAS_WIDE 535 + for (i = 0; i < port_info->num_phys; i++) { 536 + port_details = port_info->phy_info[i].port_details; 537 + if (!port_details) 538 + continue; 539 + dsaswideprintk((KERN_DEBUG 540 + "%s: [%p]: phy_id=%02d port_id=%02d num_phys=%02d " 541 + "bitmask=0x%016llX\n", 542 + __FUNCTION__, 543 + port_details, i, port_details->port_id, 544 + port_details->num_phys, port_details->phy_bitmask)); 545 + dsaswideprintk((KERN_DEBUG"\t\tport = %p rphy=%p\n", 546 + port_details->port, port_details->rphy)); 547 + } 548 + dsaswideprintk((KERN_DEBUG"\n")); 549 + #endif 550 + mutex_unlock(&ioc->sas_topology_mutex); 551 + } 552 + 553 + static void 554 + mptsas_target_reset(MPT_ADAPTER *ioc, VirtTarget * vtarget) 555 + { 556 + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 557 + 558 + if (mptscsih_TMHandler(hd, 559 + MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 560 + vtarget->bus_id, vtarget->target_id, 0, 0, 5) < 0) { 561 + hd->tmPending = 0; 562 + hd->tmState = TM_STATE_NONE; 563 + printk(MYIOC_s_WARN_FMT 564 + "Error processing TaskMgmt id=%d TARGET_RESET\n", 565 + ioc->name, vtarget->target_id); 566 + } 337 567 } 338 568 339 569 static int ··· 664 400 return mptscsih_slave_configure(sdev); 665 401 } 666 402 667 - /* 668 - * This is pretty ugly. We will be able to seriously clean it up 669 - * once the DV code in mptscsih goes away and we can properly 670 - * implement ->target_alloc. 671 - */ 403 + static int 404 + mptsas_target_alloc(struct scsi_target *starget) 405 + { 406 + struct Scsi_Host *host = dev_to_shost(&starget->dev); 407 + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 408 + VirtTarget *vtarget; 409 + u32 target_id; 410 + u32 channel; 411 + struct sas_rphy *rphy; 412 + struct mptsas_portinfo *p; 413 + int i; 414 + 415 + vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); 416 + if (!vtarget) 417 + return -ENOMEM; 418 + 419 + vtarget->starget = starget; 420 + vtarget->ioc_id = hd->ioc->id; 421 + vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; 422 + 423 + target_id = starget->id; 424 + channel = 0; 425 + 426 + hd->Targets[target_id] = vtarget; 427 + 428 + /* 429 + * RAID volumes placed beyond the last expected port. 430 + */ 431 + if (starget->channel == hd->ioc->num_ports) 432 + goto out; 433 + 434 + rphy = dev_to_rphy(starget->dev.parent); 435 + mutex_lock(&hd->ioc->sas_topology_mutex); 436 + list_for_each_entry(p, &hd->ioc->sas_topology, list) { 437 + for (i = 0; i < p->num_phys; i++) { 438 + if (p->phy_info[i].attached.sas_address != 439 + rphy->identify.sas_address) 440 + continue; 441 + target_id = p->phy_info[i].attached.id; 442 + channel = p->phy_info[i].attached.channel; 443 + mptsas_set_starget(&p->phy_info[i], starget); 444 + 445 + /* 446 + * Exposing hidden raid components 447 + */ 448 + if (mptscsih_is_phys_disk(hd->ioc, target_id)) { 449 + target_id = mptscsih_raid_id_to_num(hd, 450 + target_id); 451 + vtarget->tflags |= 452 + MPT_TARGET_FLAGS_RAID_COMPONENT; 453 + } 454 + mutex_unlock(&hd->ioc->sas_topology_mutex); 455 + goto out; 456 + } 457 + } 458 + mutex_unlock(&hd->ioc->sas_topology_mutex); 459 + 460 + kfree(vtarget); 461 + return -ENXIO; 462 + 463 + out: 464 + vtarget->target_id = target_id; 465 + vtarget->bus_id = channel; 466 + starget->hostdata = vtarget; 467 + return 0; 468 + } 469 + 470 + static void 471 + mptsas_target_destroy(struct scsi_target *starget) 472 + { 473 + struct Scsi_Host *host = dev_to_shost(&starget->dev); 474 + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 475 + struct sas_rphy *rphy; 476 + struct mptsas_portinfo *p; 477 + int i; 478 + 479 + if (!starget->hostdata) 480 + return; 481 + 482 + if (starget->channel == hd->ioc->num_ports) 483 + goto out; 484 + 485 + rphy = dev_to_rphy(starget->dev.parent); 486 + list_for_each_entry(p, &hd->ioc->sas_topology, list) { 487 + for (i = 0; i < p->num_phys; i++) { 488 + if (p->phy_info[i].attached.sas_address != 489 + rphy->identify.sas_address) 490 + continue; 491 + mptsas_set_starget(&p->phy_info[i], NULL); 492 + goto out; 493 + } 494 + } 495 + 496 + out: 497 + kfree(starget->hostdata); 498 + starget->hostdata = NULL; 499 + } 500 + 501 + 672 502 static int 673 503 mptsas_slave_alloc(struct scsi_device *sdev) 674 504 { ··· 770 412 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 771 413 struct sas_rphy *rphy; 772 414 struct mptsas_portinfo *p; 773 - VirtTarget *vtarget; 774 415 VirtDevice *vdev; 775 416 struct scsi_target *starget; 776 - u32 target_id; 777 - int i; 417 + int i; 778 418 779 419 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 780 420 if (!vdev) { 781 - printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 421 + printk(MYIOC_s_ERR_FMT "slave_alloc kzalloc(%zd) FAILED!\n", 782 422 hd->ioc->name, sizeof(VirtDevice)); 783 423 return -ENOMEM; 784 424 } 785 - sdev->hostdata = vdev; 786 425 starget = scsi_target(sdev); 787 - vtarget = starget->hostdata; 788 - vtarget->ioc_id = hd->ioc->id; 789 - vdev->vtarget = vtarget; 790 - if (vtarget->num_luns == 0) { 791 - vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; 792 - hd->Targets[sdev->id] = vtarget; 793 - } 426 + vdev->vtarget = starget->hostdata; 794 427 795 428 /* 796 - RAID volumes placed beyond the last expected port. 797 - */ 798 - if (sdev->channel == hd->ioc->num_ports) { 799 - target_id = sdev->id; 800 - vtarget->bus_id = 0; 801 - vdev->lun = 0; 429 + * RAID volumes placed beyond the last expected port. 430 + */ 431 + if (sdev->channel == hd->ioc->num_ports) 802 432 goto out; 803 - } 804 433 805 434 rphy = dev_to_rphy(sdev->sdev_target->dev.parent); 806 435 mutex_lock(&hd->ioc->sas_topology_mutex); 807 436 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 808 437 for (i = 0; i < p->num_phys; i++) { 809 - if (p->phy_info[i].attached.sas_address == 810 - rphy->identify.sas_address) { 811 - target_id = p->phy_info[i].attached.id; 812 - vtarget->bus_id = p->phy_info[i].attached.channel; 813 - vdev->lun = sdev->lun; 814 - p->phy_info[i].starget = sdev->sdev_target; 815 - /* 816 - * Exposing hidden disk (RAID) 817 - */ 818 - if (mptscsih_is_phys_disk(hd->ioc, target_id)) { 819 - target_id = mptscsih_raid_id_to_num(hd, 820 - target_id); 821 - vdev->vtarget->tflags |= 822 - MPT_TARGET_FLAGS_RAID_COMPONENT; 823 - sdev->no_uld_attach = 1; 824 - } 825 - mutex_unlock(&hd->ioc->sas_topology_mutex); 826 - goto out; 827 - } 438 + if (p->phy_info[i].attached.sas_address != 439 + rphy->identify.sas_address) 440 + continue; 441 + vdev->lun = sdev->lun; 442 + /* 443 + * Exposing hidden raid components 444 + */ 445 + if (mptscsih_is_phys_disk(hd->ioc, 446 + p->phy_info[i].attached.id)) 447 + sdev->no_uld_attach = 1; 448 + mutex_unlock(&hd->ioc->sas_topology_mutex); 449 + goto out; 828 450 } 829 451 } 830 452 mutex_unlock(&hd->ioc->sas_topology_mutex); ··· 813 475 return -ENXIO; 814 476 815 477 out: 816 - vtarget->target_id = target_id; 817 - vtarget->num_luns++; 478 + vdev->vtarget->num_luns++; 479 + sdev->hostdata = vdev; 818 480 return 0; 819 481 } 820 482 821 - static void 822 - mptsas_slave_destroy(struct scsi_device *sdev) 483 + static int 484 + mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 823 485 { 824 - struct Scsi_Host *host = sdev->host; 825 - MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 826 - VirtDevice *vdev; 486 + VirtDevice *vdev = SCpnt->device->hostdata; 827 487 828 - /* 829 - * Issue target reset to flush firmware outstanding commands. 830 - */ 831 - vdev = sdev->hostdata; 832 - if (vdev->configured_lun){ 833 - if (mptscsih_TMHandler(hd, 834 - MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 835 - vdev->vtarget->bus_id, 836 - vdev->vtarget->target_id, 837 - 0, 0, 5 /* 5 second timeout */) 838 - < 0){ 839 - 840 - /* The TM request failed! 841 - * Fatal error case. 842 - */ 843 - printk(MYIOC_s_WARN_FMT 844 - "Error processing TaskMgmt id=%d TARGET_RESET\n", 845 - hd->ioc->name, 846 - vdev->vtarget->target_id); 847 - 848 - hd->tmPending = 0; 849 - hd->tmState = TM_STATE_NONE; 850 - } 488 + // scsi_print_command(SCpnt); 489 + if (vdev->vtarget->deleted) { 490 + SCpnt->result = DID_NO_CONNECT << 16; 491 + done(SCpnt); 492 + return 0; 851 493 } 852 - mptscsih_slave_destroy(sdev); 494 + 495 + return mptscsih_qcmd(SCpnt,done); 853 496 } 497 + 854 498 855 499 static struct scsi_host_template mptsas_driver_template = { 856 500 .module = THIS_MODULE, ··· 840 520 .proc_info = mptscsih_proc_info, 841 521 .name = "MPT SPI Host", 842 522 .info = mptscsih_info, 843 - .queuecommand = mptscsih_qcmd, 844 - .target_alloc = mptscsih_target_alloc, 523 + .queuecommand = mptsas_qcmd, 524 + .target_alloc = mptsas_target_alloc, 845 525 .slave_alloc = mptsas_slave_alloc, 846 526 .slave_configure = mptsas_slave_configure, 847 - .target_destroy = mptscsih_target_destroy, 848 - .slave_destroy = mptsas_slave_destroy, 527 + .target_destroy = mptsas_target_destroy, 528 + .slave_destroy = mptscsih_slave_destroy, 849 529 .change_queue_depth = mptscsih_change_queue_depth, 850 530 .eh_abort_handler = mptscsih_abort, 851 531 .eh_device_reset_handler = mptscsih_dev_reset, ··· 1115 795 1116 796 port_info->num_phys = buffer->NumPhys; 1117 797 port_info->phy_info = kcalloc(port_info->num_phys, 1118 - sizeof(struct mptsas_phyinfo),GFP_KERNEL); 798 + sizeof(*port_info->phy_info),GFP_KERNEL); 1119 799 if (!port_info->phy_info) { 1120 800 error = -ENOMEM; 1121 801 goto out_free_consistent; ··· 1131 811 buffer->PhyData[i].Port; 1132 812 port_info->phy_info[i].negotiated_link_rate = 1133 813 buffer->PhyData[i].NegotiatedLinkRate; 814 + port_info->phy_info[i].portinfo = port_info; 1134 815 } 1135 816 1136 817 out_free_consistent: ··· 1289 968 CONFIGPARMS cfg; 1290 969 SasExpanderPage0_t *buffer; 1291 970 dma_addr_t dma_handle; 1292 - int error; 971 + int i, error; 1293 972 1294 973 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; 1295 974 hdr.ExtPageLength = 0; ··· 1334 1013 port_info->num_phys = buffer->NumPhys; 1335 1014 port_info->handle = le16_to_cpu(buffer->DevHandle); 1336 1015 port_info->phy_info = kcalloc(port_info->num_phys, 1337 - sizeof(struct mptsas_phyinfo),GFP_KERNEL); 1016 + sizeof(*port_info->phy_info),GFP_KERNEL); 1338 1017 if (!port_info->phy_info) { 1339 1018 error = -ENOMEM; 1340 1019 goto out_free_consistent; 1341 1020 } 1021 + 1022 + for (i = 0; i < port_info->num_phys; i++) 1023 + port_info->phy_info[i].portinfo = port_info; 1342 1024 1343 1025 out_free_consistent: 1344 1026 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, ··· 1485 1161 { 1486 1162 MPT_ADAPTER *ioc; 1487 1163 struct sas_phy *phy; 1488 - int error; 1164 + struct sas_port *port; 1165 + int error = 0; 1489 1166 1490 - if (!dev) 1491 - return -ENODEV; 1167 + if (!dev) { 1168 + error = -ENODEV; 1169 + goto out; 1170 + } 1492 1171 1493 1172 if (!phy_info->phy) { 1494 1173 phy = sas_phy_alloc(dev, index); 1495 - if (!phy) 1496 - return -ENOMEM; 1174 + if (!phy) { 1175 + error = -ENOMEM; 1176 + goto out; 1177 + } 1497 1178 } else 1498 1179 phy = phy_info->phy; 1499 1180 1500 - phy->port_identifier = phy_info->port_id; 1501 1181 mptsas_parse_device_info(&phy->identify, &phy_info->identify); 1502 1182 1503 1183 /* ··· 1593 1265 error = sas_phy_add(phy); 1594 1266 if (error) { 1595 1267 sas_phy_free(phy); 1596 - return error; 1268 + goto out; 1597 1269 } 1598 1270 phy_info->phy = phy; 1599 1271 } 1600 1272 1601 - if ((phy_info->attached.handle) && 1602 - (!phy_info->rphy)) { 1273 + if (!phy_info->attached.handle || 1274 + !phy_info->port_details) 1275 + goto out; 1276 + 1277 + port = mptsas_get_port(phy_info); 1278 + ioc = phy_to_ioc(phy_info->phy); 1279 + 1280 + if (phy_info->sas_port_add_phy) { 1281 + 1282 + if (!port) { 1283 + port = sas_port_alloc(dev, 1284 + phy_info->port_details->port_id); 1285 + dsaswideprintk((KERN_DEBUG 1286 + "sas_port_alloc: port=%p dev=%p port_id=%d\n", 1287 + port, dev, phy_info->port_details->port_id)); 1288 + if (!port) { 1289 + error = -ENOMEM; 1290 + goto out; 1291 + } 1292 + error = sas_port_add(port); 1293 + if (error) { 1294 + dfailprintk((MYIOC_s_ERR_FMT 1295 + "%s: exit at line=%d\n", ioc->name, 1296 + __FUNCTION__, __LINE__)); 1297 + goto out; 1298 + } 1299 + mptsas_set_port(phy_info, port); 1300 + } 1301 + dsaswideprintk((KERN_DEBUG "sas_port_add_phy: phy_id=%d\n", 1302 + phy_info->phy_id)); 1303 + sas_port_add_phy(port, phy_info->phy); 1304 + phy_info->sas_port_add_phy = 0; 1305 + } 1306 + 1307 + if (!mptsas_get_rphy(phy_info) && port && !port->rphy) { 1603 1308 1604 1309 struct sas_rphy *rphy; 1310 + struct device *parent; 1605 1311 struct sas_identify identify; 1606 1312 1607 - ioc = phy_to_ioc(phy_info->phy); 1608 - 1313 + parent = dev->parent->parent; 1609 1314 /* 1610 1315 * Let the hotplug_work thread handle processing 1611 1316 * the adding/removing of devices that occur ··· 1646 1285 */ 1647 1286 if (ioc->sas_discovery_runtime && 1648 1287 mptsas_is_end_device(&phy_info->attached)) 1649 - return 0; 1288 + goto out; 1650 1289 1651 1290 mptsas_parse_device_info(&identify, &phy_info->attached); 1291 + if (scsi_is_host_device(parent)) { 1292 + struct mptsas_portinfo *port_info; 1293 + int i; 1294 + 1295 + mutex_lock(&ioc->sas_topology_mutex); 1296 + port_info = mptsas_find_portinfo_by_handle(ioc, 1297 + ioc->handle); 1298 + mutex_unlock(&ioc->sas_topology_mutex); 1299 + 1300 + for (i = 0; i < port_info->num_phys; i++) 1301 + if (port_info->phy_info[i].identify.sas_address == 1302 + identify.sas_address) 1303 + goto out; 1304 + 1305 + } else if (scsi_is_sas_rphy(parent)) { 1306 + struct sas_rphy *parent_rphy = dev_to_rphy(parent); 1307 + if (identify.sas_address == 1308 + parent_rphy->identify.sas_address) 1309 + goto out; 1310 + } 1311 + 1652 1312 switch (identify.device_type) { 1653 1313 case SAS_END_DEVICE: 1654 - rphy = sas_end_device_alloc(phy); 1314 + rphy = sas_end_device_alloc(port); 1655 1315 break; 1656 1316 case SAS_EDGE_EXPANDER_DEVICE: 1657 1317 case SAS_FANOUT_EXPANDER_DEVICE: 1658 - rphy = sas_expander_alloc(phy, identify.device_type); 1318 + rphy = sas_expander_alloc(port, identify.device_type); 1659 1319 break; 1660 1320 default: 1661 1321 rphy = NULL; 1662 1322 break; 1663 1323 } 1664 - if (!rphy) 1665 - return 0; /* non-fatal: an rphy can be added later */ 1666 - 1667 - rphy->identify = identify; 1668 - 1669 - error = sas_rphy_add(rphy); 1670 - if (error) { 1671 - sas_rphy_free(rphy); 1672 - return error; 1324 + if (!rphy) { 1325 + dfailprintk((MYIOC_s_ERR_FMT 1326 + "%s: exit at line=%d\n", ioc->name, 1327 + __FUNCTION__, __LINE__)); 1328 + goto out; 1673 1329 } 1674 1330 1675 - phy_info->rphy = rphy; 1331 + rphy->identify = identify; 1332 + error = sas_rphy_add(rphy); 1333 + if (error) { 1334 + dfailprintk((MYIOC_s_ERR_FMT 1335 + "%s: exit at line=%d\n", ioc->name, 1336 + __FUNCTION__, __LINE__)); 1337 + sas_rphy_free(rphy); 1338 + goto out; 1339 + } 1340 + mptsas_set_rphy(phy_info, rphy); 1676 1341 } 1677 1342 1678 - return 0; 1343 + out: 1344 + return error; 1679 1345 } 1680 1346 1681 1347 static int ··· 1721 1333 goto out_free_port_info; 1722 1334 1723 1335 mutex_lock(&ioc->sas_topology_mutex); 1336 + ioc->handle = hba->handle; 1724 1337 port_info = mptsas_find_portinfo_by_handle(ioc, hba->handle); 1725 1338 if (!port_info) { 1726 1339 port_info = hba; ··· 1731 1342 for (i = 0; i < hba->num_phys; i++) 1732 1343 port_info->phy_info[i].negotiated_link_rate = 1733 1344 hba->phy_info[i].negotiated_link_rate; 1734 - if (hba->phy_info) 1735 - kfree(hba->phy_info); 1345 + kfree(hba->phy_info); 1736 1346 kfree(hba); 1737 1347 hba = NULL; 1738 1348 } ··· 1750 1362 port_info->phy_info[i].phy_id; 1751 1363 handle = port_info->phy_info[i].identify.handle; 1752 1364 1753 - if (port_info->phy_info[i].attached.handle) { 1365 + if (port_info->phy_info[i].attached.handle) 1754 1366 mptsas_sas_device_pg0(ioc, 1755 1367 &port_info->phy_info[i].attached, 1756 1368 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << 1757 1369 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 1758 1370 port_info->phy_info[i].attached.handle); 1759 - } 1371 + } 1760 1372 1373 + mptsas_setup_wide_ports(ioc, port_info); 1374 + 1375 + for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++) 1761 1376 mptsas_probe_one_phy(&ioc->sh->shost_gendev, 1762 1377 &port_info->phy_info[i], ioc->sas_index, 1); 1763 - ioc->sas_index++; 1764 - } 1765 1378 1766 1379 return 0; 1767 1380 ··· 1776 1387 mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle) 1777 1388 { 1778 1389 struct mptsas_portinfo *port_info, *p, *ex; 1390 + struct device *parent; 1391 + struct sas_rphy *rphy; 1779 1392 int error = -ENOMEM, i, j; 1780 1393 1781 1394 ex = kzalloc(sizeof(*port_info), GFP_KERNEL); ··· 1799 1408 list_add_tail(&port_info->list, &ioc->sas_topology); 1800 1409 } else { 1801 1410 port_info->handle = ex->handle; 1802 - if (ex->phy_info) 1803 - kfree(ex->phy_info); 1411 + kfree(ex->phy_info); 1804 1412 kfree(ex); 1805 1413 ex = NULL; 1806 1414 } 1807 1415 mutex_unlock(&ioc->sas_topology_mutex); 1808 1416 1809 1417 for (i = 0; i < port_info->num_phys; i++) { 1810 - struct device *parent; 1811 - 1812 1418 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i], 1813 1419 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM << 1814 1420 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle); ··· 1829 1441 port_info->phy_info[i].attached.phy_id = 1830 1442 port_info->phy_info[i].phy_id; 1831 1443 } 1444 + } 1832 1445 1833 - /* 1834 - * If we find a parent port handle this expander is 1835 - * attached to another expander, else it hangs of the 1836 - * HBA phys. 1837 - */ 1838 - parent = &ioc->sh->shost_gendev; 1446 + parent = &ioc->sh->shost_gendev; 1447 + for (i = 0; i < port_info->num_phys; i++) { 1839 1448 mutex_lock(&ioc->sas_topology_mutex); 1840 1449 list_for_each_entry(p, &ioc->sas_topology, list) { 1841 1450 for (j = 0; j < p->num_phys; j++) { 1842 - if (port_info->phy_info[i].identify.handle == 1451 + if (port_info->phy_info[i].identify.handle != 1843 1452 p->phy_info[j].attached.handle) 1844 - parent = &p->phy_info[j].rphy->dev; 1453 + continue; 1454 + rphy = mptsas_get_rphy(&p->phy_info[j]); 1455 + parent = &rphy->dev; 1845 1456 } 1846 1457 } 1847 1458 mutex_unlock(&ioc->sas_topology_mutex); 1459 + } 1848 1460 1461 + mptsas_setup_wide_ports(ioc, port_info); 1462 + 1463 + for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++) 1849 1464 mptsas_probe_one_phy(parent, &port_info->phy_info[i], 1850 1465 ioc->sas_index, 0); 1851 - ioc->sas_index++; 1852 - } 1853 1466 1854 1467 return 0; 1855 1468 1856 1469 out_free_port_info: 1857 1470 if (ex) { 1858 - if (ex->phy_info) 1859 - kfree(ex->phy_info); 1471 + kfree(ex->phy_info); 1860 1472 kfree(ex); 1861 1473 } 1862 1474 out: ··· 1875 1487 { 1876 1488 struct mptsas_portinfo buffer; 1877 1489 struct mptsas_portinfo *port_info, *n, *parent; 1490 + struct mptsas_phyinfo *phy_info; 1491 + struct scsi_target * starget; 1492 + VirtTarget * vtarget; 1493 + struct sas_port * port; 1878 1494 int i; 1495 + u64 expander_sas_address; 1879 1496 1880 1497 mutex_lock(&ioc->sas_topology_mutex); 1881 1498 list_for_each_entry_safe(port_info, n, &ioc->sas_topology, list) { ··· 1895 1502 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), port_info->handle)) { 1896 1503 1897 1504 /* 1505 + * Issue target reset to all child end devices 1506 + * then mark them deleted to prevent further 1507 + * IO going to them. 1508 + */ 1509 + phy_info = port_info->phy_info; 1510 + for (i = 0; i < port_info->num_phys; i++, phy_info++) { 1511 + starget = mptsas_get_starget(phy_info); 1512 + if (!starget) 1513 + continue; 1514 + vtarget = starget->hostdata; 1515 + if(vtarget->deleted) 1516 + continue; 1517 + vtarget->deleted = 1; 1518 + mptsas_target_reset(ioc, vtarget); 1519 + sas_port_delete(mptsas_get_port(phy_info)); 1520 + mptsas_port_delete(phy_info->port_details); 1521 + } 1522 + 1523 + /* 1898 1524 * Obtain the port_info instance to the parent port 1899 1525 */ 1900 1526 parent = mptsas_find_portinfo_by_handle(ioc, ··· 1922 1510 if (!parent) 1923 1511 goto next_port; 1924 1512 1513 + expander_sas_address = 1514 + port_info->phy_info[0].identify.sas_address; 1515 + 1925 1516 /* 1926 1517 * Delete rphys in the parent that point 1927 1518 * to this expander. The transport layer will 1928 1519 * cleanup all the children. 1929 1520 */ 1930 - for (i = 0; i < parent->num_phys; i++) { 1931 - if ((!parent->phy_info[i].rphy) || 1932 - (parent->phy_info[i].attached.sas_address != 1933 - port_info->phy_info[i].identify.sas_address)) 1521 + phy_info = parent->phy_info; 1522 + for (i = 0; i < parent->num_phys; i++, phy_info++) { 1523 + port = mptsas_get_port(phy_info); 1524 + if (!port) 1934 1525 continue; 1935 - sas_rphy_delete(parent->phy_info[i].rphy); 1936 - memset(&parent->phy_info[i].attached, 0, 1937 - sizeof(struct mptsas_devinfo)); 1938 - parent->phy_info[i].rphy = NULL; 1939 - parent->phy_info[i].starget = NULL; 1526 + if (phy_info->attached.sas_address != 1527 + expander_sas_address) 1528 + continue; 1529 + #ifdef MPT_DEBUG_SAS_WIDE 1530 + dev_printk(KERN_DEBUG, &port->dev, "delete\n"); 1531 + #endif 1532 + sas_port_delete(port); 1533 + mptsas_port_delete(phy_info->port_details); 1940 1534 } 1941 1535 next_port: 1536 + 1537 + phy_info = port_info->phy_info; 1538 + for (i = 0; i < port_info->num_phys; i++, phy_info++) 1539 + mptsas_port_delete(phy_info->port_details); 1540 + 1942 1541 list_del(&port_info->list); 1943 - if (port_info->phy_info) 1944 - kfree(port_info->phy_info); 1542 + kfree(port_info->phy_info); 1945 1543 kfree(port_info); 1946 1544 } 1947 1545 /* 1948 1546 * Free this memory allocated from inside 1949 1547 * mptsas_sas_expander_pg0 1950 1548 */ 1951 - if (buffer.phy_info) 1952 - kfree(buffer.phy_info); 1549 + kfree(buffer.phy_info); 1953 1550 } 1954 1551 mutex_unlock(&ioc->sas_topology_mutex); 1955 1552 } ··· 1994 1573 /* 1995 1574 * Work queue thread to handle Runtime discovery 1996 1575 * Mere purpose is the hot add/delete of expanders 1576 + *(Mutex UNLOCKED) 1997 1577 */ 1998 1578 static void 1999 - mptscsih_discovery_work(void * arg) 1579 + __mptsas_discovery_work(MPT_ADAPTER *ioc) 2000 1580 { 2001 - struct mptsas_discovery_event *ev = arg; 2002 - MPT_ADAPTER *ioc = ev->ioc; 2003 1581 u32 handle = 0xFFFF; 2004 1582 2005 - mutex_lock(&ioc->sas_discovery_mutex); 2006 1583 ioc->sas_discovery_runtime=1; 2007 1584 mptsas_delete_expander_phys(ioc); 2008 1585 mptsas_probe_hba_phys(ioc); 2009 1586 while (!mptsas_probe_expander_phys(ioc, &handle)) 2010 1587 ; 2011 - kfree(ev); 2012 1588 ioc->sas_discovery_runtime=0; 1589 + } 1590 + 1591 + /* 1592 + * Work queue thread to handle Runtime discovery 1593 + * Mere purpose is the hot add/delete of expanders 1594 + *(Mutex LOCKED) 1595 + */ 1596 + static void 1597 + mptsas_discovery_work(void * arg) 1598 + { 1599 + struct mptsas_discovery_event *ev = arg; 1600 + MPT_ADAPTER *ioc = ev->ioc; 1601 + 1602 + mutex_lock(&ioc->sas_discovery_mutex); 1603 + __mptsas_discovery_work(ioc); 2013 1604 mutex_unlock(&ioc->sas_discovery_mutex); 1605 + kfree(ev); 2014 1606 } 2015 1607 2016 1608 static struct mptsas_phyinfo * 2017 - mptsas_find_phyinfo_by_parent(MPT_ADAPTER *ioc, u16 parent_handle, u8 phy_id) 1609 + mptsas_find_phyinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address) 2018 1610 { 2019 1611 struct mptsas_portinfo *port_info; 2020 - struct mptsas_devinfo device_info; 2021 1612 struct mptsas_phyinfo *phy_info = NULL; 2022 - int i, error; 1613 + int i; 2023 1614 2024 - /* 2025 - * Retrieve the parent sas_address 2026 - */ 2027 - error = mptsas_sas_device_pg0(ioc, &device_info, 2028 - (MPI_SAS_DEVICE_PGAD_FORM_HANDLE << 2029 - MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 2030 - parent_handle); 2031 - if (error) 2032 - return NULL; 2033 - 2034 - /* 2035 - * The phy_info structures are never deallocated during lifetime of 2036 - * a host, so the code below is safe without additional refcounting. 2037 - */ 2038 1615 mutex_lock(&ioc->sas_topology_mutex); 2039 1616 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2040 1617 for (i = 0; i < port_info->num_phys; i++) { 2041 - if (port_info->phy_info[i].identify.sas_address == 2042 - device_info.sas_address && 2043 - port_info->phy_info[i].phy_id == phy_id) { 2044 - phy_info = &port_info->phy_info[i]; 2045 - break; 2046 - } 1618 + if (port_info->phy_info[i].attached.sas_address 1619 + != sas_address) 1620 + continue; 1621 + if (!mptsas_is_end_device( 1622 + &port_info->phy_info[i].attached)) 1623 + continue; 1624 + phy_info = &port_info->phy_info[i]; 1625 + break; 2047 1626 } 2048 1627 } 2049 1628 mutex_unlock(&ioc->sas_topology_mutex); 2050 - 2051 1629 return phy_info; 2052 1630 } 2053 1631 ··· 2057 1637 struct mptsas_phyinfo *phy_info = NULL; 2058 1638 int i; 2059 1639 2060 - /* 2061 - * The phy_info structures are never deallocated during lifetime of 2062 - * a host, so the code below is safe without additional refcounting. 2063 - */ 2064 1640 mutex_lock(&ioc->sas_topology_mutex); 2065 1641 list_for_each_entry(port_info, &ioc->sas_topology, list) { 2066 - for (i = 0; i < port_info->num_phys; i++) 2067 - if (mptsas_is_end_device(&port_info->phy_info[i].attached)) 2068 - if (port_info->phy_info[i].attached.id == id) { 2069 - phy_info = &port_info->phy_info[i]; 2070 - break; 2071 - } 1642 + for (i = 0; i < port_info->num_phys; i++) { 1643 + if (port_info->phy_info[i].attached.id != id) 1644 + continue; 1645 + if (!mptsas_is_end_device( 1646 + &port_info->phy_info[i].attached)) 1647 + continue; 1648 + phy_info = &port_info->phy_info[i]; 1649 + break; 1650 + } 2072 1651 } 2073 1652 mutex_unlock(&ioc->sas_topology_mutex); 2074 - 2075 1653 return phy_info; 2076 1654 } 2077 1655 ··· 2077 1659 * Work queue thread to clear the persitency table 2078 1660 */ 2079 1661 static void 2080 - mptscsih_sas_persist_clear_table(void * arg) 1662 + mptsas_persist_clear_table(void * arg) 2081 1663 { 2082 1664 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2083 1665 ··· 2098 1680 mptsas_reprobe_lun); 2099 1681 } 2100 1682 2101 - 2102 1683 /* 2103 1684 * Work queue thread to handle SAS hotplug events 2104 1685 */ ··· 2108 1691 MPT_ADAPTER *ioc = ev->ioc; 2109 1692 struct mptsas_phyinfo *phy_info; 2110 1693 struct sas_rphy *rphy; 1694 + struct sas_port *port; 2111 1695 struct scsi_device *sdev; 1696 + struct scsi_target * starget; 2112 1697 struct sas_identify identify; 2113 1698 char *ds = NULL; 2114 1699 struct mptsas_devinfo sas_device; 2115 1700 VirtTarget *vtarget; 1701 + VirtDevice *vdevice; 1702 + 2116 1703 2117 1704 mutex_lock(&ioc->sas_discovery_mutex); 2118 - 2119 1705 switch (ev->event_type) { 2120 1706 case MPTSAS_DEL_DEVICE: 2121 1707 ··· 2127 1707 /* 2128 1708 * Sanity checks, for non-existing phys and remote rphys. 2129 1709 */ 2130 - if (!phy_info) 1710 + if (!phy_info || !phy_info->port_details) { 1711 + dfailprintk((MYIOC_s_ERR_FMT 1712 + "%s: exit at line=%d\n", ioc->name, 1713 + __FUNCTION__, __LINE__)); 2131 1714 break; 2132 - if (!phy_info->rphy) 1715 + } 1716 + rphy = mptsas_get_rphy(phy_info); 1717 + if (!rphy) { 1718 + dfailprintk((MYIOC_s_ERR_FMT 1719 + "%s: exit at line=%d\n", ioc->name, 1720 + __FUNCTION__, __LINE__)); 2133 1721 break; 2134 - if (phy_info->starget) { 2135 - vtarget = phy_info->starget->hostdata; 1722 + } 1723 + port = mptsas_get_port(phy_info); 1724 + if (!port) { 1725 + dfailprintk((MYIOC_s_ERR_FMT 1726 + "%s: exit at line=%d\n", ioc->name, 1727 + __FUNCTION__, __LINE__)); 1728 + break; 1729 + } 2136 1730 2137 - if (!vtarget) 1731 + starget = mptsas_get_starget(phy_info); 1732 + if (starget) { 1733 + vtarget = starget->hostdata; 1734 + 1735 + if (!vtarget) { 1736 + dfailprintk((MYIOC_s_ERR_FMT 1737 + "%s: exit at line=%d\n", ioc->name, 1738 + __FUNCTION__, __LINE__)); 2138 1739 break; 1740 + } 1741 + 2139 1742 /* 2140 1743 * Handling RAID components 2141 1744 */ 2142 1745 if (ev->phys_disk_num_valid) { 2143 1746 vtarget->target_id = ev->phys_disk_num; 2144 1747 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; 2145 - mptsas_reprobe_target(vtarget->starget, 1); 1748 + mptsas_reprobe_target(starget, 1); 2146 1749 break; 2147 1750 } 1751 + 1752 + vtarget->deleted = 1; 1753 + mptsas_target_reset(ioc, vtarget); 2148 1754 } 2149 1755 2150 1756 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET) ··· 2184 1738 "removing %s device, channel %d, id %d, phy %d\n", 2185 1739 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); 2186 1740 2187 - sas_rphy_delete(phy_info->rphy); 2188 - memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 2189 - phy_info->rphy = NULL; 2190 - phy_info->starget = NULL; 1741 + #ifdef MPT_DEBUG_SAS_WIDE 1742 + dev_printk(KERN_DEBUG, &port->dev, "delete\n"); 1743 + #endif 1744 + sas_port_delete(port); 1745 + mptsas_port_delete(phy_info->port_details); 2191 1746 break; 2192 1747 case MPTSAS_ADD_DEVICE: 2193 1748 ··· 2200 1753 */ 2201 1754 if (mptsas_sas_device_pg0(ioc, &sas_device, 2202 1755 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID << 2203 - MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) 1756 + MPI_SAS_DEVICE_PGAD_FORM_SHIFT), ev->id)) { 1757 + dfailprintk((MYIOC_s_ERR_FMT 1758 + "%s: exit at line=%d\n", ioc->name, 1759 + __FUNCTION__, __LINE__)); 2204 1760 break; 2205 - 2206 - phy_info = mptsas_find_phyinfo_by_parent(ioc, 2207 - sas_device.handle_parent, sas_device.phy_id); 2208 - 2209 - if (!phy_info) { 2210 - u32 handle = 0xFFFF; 2211 - 2212 - /* 2213 - * Its possible when an expander has been hot added 2214 - * containing attached devices, the sas firmware 2215 - * may send a RC_ADDED event prior to the 2216 - * DISCOVERY STOP event. If that occurs, our 2217 - * view of the topology in the driver in respect to this 2218 - * expander might of not been setup, and we hit this 2219 - * condition. 2220 - * Therefore, this code kicks off discovery to 2221 - * refresh the data. 2222 - * Then again, we check whether the parent phy has 2223 - * been created. 2224 - */ 2225 - ioc->sas_discovery_runtime=1; 2226 - mptsas_delete_expander_phys(ioc); 2227 - mptsas_probe_hba_phys(ioc); 2228 - while (!mptsas_probe_expander_phys(ioc, &handle)) 2229 - ; 2230 - ioc->sas_discovery_runtime=0; 2231 - 2232 - phy_info = mptsas_find_phyinfo_by_parent(ioc, 2233 - sas_device.handle_parent, sas_device.phy_id); 2234 - if (!phy_info) 2235 - break; 2236 1761 } 2237 1762 2238 - if (phy_info->starget) { 2239 - vtarget = phy_info->starget->hostdata; 1763 + ssleep(2); 1764 + __mptsas_discovery_work(ioc); 2240 1765 2241 - if (!vtarget) 1766 + phy_info = mptsas_find_phyinfo_by_sas_address(ioc, 1767 + sas_device.sas_address); 1768 + 1769 + if (!phy_info || !phy_info->port_details) { 1770 + dfailprintk((MYIOC_s_ERR_FMT 1771 + "%s: exit at line=%d\n", ioc->name, 1772 + __FUNCTION__, __LINE__)); 1773 + break; 1774 + } 1775 + 1776 + starget = mptsas_get_starget(phy_info); 1777 + if (starget) { 1778 + vtarget = starget->hostdata; 1779 + 1780 + if (!vtarget) { 1781 + dfailprintk((MYIOC_s_ERR_FMT 1782 + "%s: exit at line=%d\n", ioc->name, 1783 + __FUNCTION__, __LINE__)); 2242 1784 break; 1785 + } 2243 1786 /* 2244 1787 * Handling RAID components 2245 1788 */ 2246 1789 if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 2247 1790 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; 2248 1791 vtarget->target_id = ev->id; 2249 - mptsas_reprobe_target(phy_info->starget, 0); 1792 + mptsas_reprobe_target(starget, 0); 2250 1793 } 2251 1794 break; 2252 1795 } 2253 1796 2254 - if (phy_info->rphy) 1797 + if (mptsas_get_rphy(phy_info)) { 1798 + dfailprintk((MYIOC_s_ERR_FMT 1799 + "%s: exit at line=%d\n", ioc->name, 1800 + __FUNCTION__, __LINE__)); 2255 1801 break; 1802 + } 1803 + port = mptsas_get_port(phy_info); 1804 + if (!port) { 1805 + dfailprintk((MYIOC_s_ERR_FMT 1806 + "%s: exit at line=%d\n", ioc->name, 1807 + __FUNCTION__, __LINE__)); 1808 + break; 1809 + } 2256 1810 2257 1811 memcpy(&phy_info->attached, &sas_device, 2258 1812 sizeof(struct mptsas_devinfo)); ··· 2270 1822 ioc->name, ds, ev->channel, ev->id, ev->phy_id); 2271 1823 2272 1824 mptsas_parse_device_info(&identify, &phy_info->attached); 2273 - switch (identify.device_type) { 2274 - case SAS_END_DEVICE: 2275 - rphy = sas_end_device_alloc(phy_info->phy); 2276 - break; 2277 - case SAS_EDGE_EXPANDER_DEVICE: 2278 - case SAS_FANOUT_EXPANDER_DEVICE: 2279 - rphy = sas_expander_alloc(phy_info->phy, identify.device_type); 2280 - break; 2281 - default: 2282 - rphy = NULL; 2283 - break; 2284 - } 2285 - if (!rphy) 1825 + rphy = sas_end_device_alloc(port); 1826 + if (!rphy) { 1827 + dfailprintk((MYIOC_s_ERR_FMT 1828 + "%s: exit at line=%d\n", ioc->name, 1829 + __FUNCTION__, __LINE__)); 2286 1830 break; /* non-fatal: an rphy can be added later */ 1831 + } 2287 1832 2288 1833 rphy->identify = identify; 2289 1834 if (sas_rphy_add(rphy)) { 1835 + dfailprintk((MYIOC_s_ERR_FMT 1836 + "%s: exit at line=%d\n", ioc->name, 1837 + __FUNCTION__, __LINE__)); 2290 1838 sas_rphy_free(rphy); 2291 1839 break; 2292 1840 } 2293 - 2294 - phy_info->rphy = rphy; 1841 + mptsas_set_rphy(phy_info, rphy); 2295 1842 break; 2296 1843 case MPTSAS_ADD_RAID: 2297 1844 sdev = scsi_device_lookup( ··· 2318 1875 printk(MYIOC_s_INFO_FMT 2319 1876 "removing raid volume, channel %d, id %d\n", 2320 1877 ioc->name, ioc->num_ports, ev->id); 1878 + vdevice = sdev->hostdata; 1879 + vdevice->vtarget->deleted = 1; 1880 + mptsas_target_reset(ioc, vdevice->vtarget); 2321 1881 scsi_remove_device(sdev); 2322 1882 scsi_device_put(sdev); 2323 1883 mpt_findImVolumes(ioc); ··· 2330 1884 break; 2331 1885 } 2332 1886 2333 - kfree(ev); 2334 1887 mutex_unlock(&ioc->sas_discovery_mutex); 1888 + kfree(ev); 1889 + 2335 1890 } 2336 1891 2337 1892 static void 2338 - mptscsih_send_sas_event(MPT_ADAPTER *ioc, 1893 + mptsas_send_sas_event(MPT_ADAPTER *ioc, 2339 1894 EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data) 2340 1895 { 2341 1896 struct mptsas_hotplug_event *ev; ··· 2352 1905 switch (sas_event_data->ReasonCode) { 2353 1906 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: 2354 1907 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: 2355 - ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 1908 + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2356 1909 if (!ev) { 2357 1910 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2358 1911 break; ··· 2382 1935 /* 2383 1936 * Persistent table is full. 2384 1937 */ 2385 - INIT_WORK(&ioc->mptscsih_persistTask, 2386 - mptscsih_sas_persist_clear_table, 2387 - (void *)ioc); 2388 - schedule_work(&ioc->mptscsih_persistTask); 1938 + INIT_WORK(&ioc->sas_persist_task, 1939 + mptsas_persist_clear_table, (void *)ioc); 1940 + schedule_work(&ioc->sas_persist_task); 2389 1941 break; 2390 1942 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2391 1943 /* TODO */ ··· 2396 1950 } 2397 1951 2398 1952 static void 2399 - mptscsih_send_raid_event(MPT_ADAPTER *ioc, 1953 + mptsas_send_raid_event(MPT_ADAPTER *ioc, 2400 1954 EVENT_DATA_RAID *raid_event_data) 2401 1955 { 2402 1956 struct mptsas_hotplug_event *ev; ··· 2406 1960 if (ioc->bus_type != SAS) 2407 1961 return; 2408 1962 2409 - ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 1963 + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2410 1964 if (!ev) { 2411 1965 printk(KERN_WARNING "mptsas: lost hotplug event\n"); 2412 1966 return; 2413 1967 } 2414 1968 2415 - memset(ev,0,sizeof(struct mptsas_hotplug_event)); 2416 1969 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2417 1970 ev->ioc = ioc; 2418 1971 ev->id = raid_event_data->VolumeID; ··· 2473 2028 } 2474 2029 2475 2030 static void 2476 - mptscsih_send_discovery(MPT_ADAPTER *ioc, 2031 + mptsas_send_discovery_event(MPT_ADAPTER *ioc, 2477 2032 EVENT_DATA_SAS_DISCOVERY *discovery_data) 2478 2033 { 2479 2034 struct mptsas_discovery_event *ev; ··· 2488 2043 if (discovery_data->DiscoveryStatus) 2489 2044 return; 2490 2045 2491 - ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 2046 + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2492 2047 if (!ev) 2493 2048 return; 2494 - memset(ev,0,sizeof(struct mptsas_discovery_event)); 2495 - INIT_WORK(&ev->work, mptscsih_discovery_work, ev); 2049 + INIT_WORK(&ev->work, mptsas_discovery_work, ev); 2496 2050 ev->ioc = ioc; 2497 2051 schedule_work(&ev->work); 2498 2052 }; ··· 2519 2075 2520 2076 switch (event) { 2521 2077 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: 2522 - mptscsih_send_sas_event(ioc, 2078 + mptsas_send_sas_event(ioc, 2523 2079 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data); 2524 2080 break; 2525 2081 case MPI_EVENT_INTEGRATED_RAID: 2526 - mptscsih_send_raid_event(ioc, 2082 + mptsas_send_raid_event(ioc, 2527 2083 (EVENT_DATA_RAID *)reply->Data); 2528 2084 break; 2529 2085 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2530 - INIT_WORK(&ioc->mptscsih_persistTask, 2531 - mptscsih_sas_persist_clear_table, 2086 + INIT_WORK(&ioc->sas_persist_task, 2087 + mptsas_persist_clear_table, 2532 2088 (void *)ioc); 2533 - schedule_work(&ioc->mptscsih_persistTask); 2089 + schedule_work(&ioc->sas_persist_task); 2534 2090 break; 2535 2091 case MPI_EVENT_SAS_DISCOVERY: 2536 - mptscsih_send_discovery(ioc, 2092 + mptsas_send_discovery_event(ioc, 2537 2093 (EVENT_DATA_SAS_DISCOVERY *)reply->Data); 2538 2094 break; 2539 2095 default: ··· 2752 2308 2753 2309 return 0; 2754 2310 2755 - out_mptsas_probe: 2311 + out_mptsas_probe: 2756 2312 2757 2313 mptscsih_remove(pdev); 2758 2314 return error; ··· 2762 2318 { 2763 2319 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 2764 2320 struct mptsas_portinfo *p, *n; 2321 + int i; 2765 2322 2766 2323 ioc->sas_discovery_ignore_events=1; 2767 2324 sas_remove_host(ioc->sh); ··· 2770 2325 mutex_lock(&ioc->sas_topology_mutex); 2771 2326 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { 2772 2327 list_del(&p->list); 2773 - if (p->phy_info) 2774 - kfree(p->phy_info); 2328 + for (i = 0 ; i < p->num_phys ; i++) 2329 + mptsas_port_delete(p->phy_info[i].port_details); 2330 + kfree(p->phy_info); 2775 2331 kfree(p); 2776 2332 } 2777 2333 mutex_unlock(&ioc->sas_topology_mutex); ··· 2781 2335 } 2782 2336 2783 2337 static struct pci_device_id mptsas_pci_table[] = { 2784 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064, 2338 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064, 2785 2339 PCI_ANY_ID, PCI_ANY_ID }, 2786 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066, 2340 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068, 2787 2341 PCI_ANY_ID, PCI_ANY_ID }, 2788 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068, 2342 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1064E, 2789 2343 PCI_ANY_ID, PCI_ANY_ID }, 2790 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064E, 2344 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1068E, 2791 2345 PCI_ANY_ID, PCI_ANY_ID }, 2792 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066E, 2793 - PCI_ANY_ID, PCI_ANY_ID }, 2794 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068E, 2346 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_SAS1078, 2795 2347 PCI_ANY_ID, PCI_ANY_ID }, 2796 2348 {0} /* Terminating entry */ 2797 2349 };
+2 -2
drivers/message/fusion/mptspi.c
··· 775 775 */ 776 776 777 777 static struct pci_device_id mptspi_pci_table[] = { 778 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C1030, 778 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030, 779 779 PCI_ANY_ID, PCI_ANY_ID }, 780 - { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_1030_53C1035, 780 + { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035, 781 781 PCI_ANY_ID, PCI_ANY_ID }, 782 782 {0} /* Terminating entry */ 783 783 };
+30 -26
drivers/scsi/53c700.c
··· 173 173 STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt); 174 174 STATIC void NCR_700_chip_setup(struct Scsi_Host *host); 175 175 STATIC void NCR_700_chip_reset(struct Scsi_Host *host); 176 + STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt); 176 177 STATIC int NCR_700_slave_configure(struct scsi_device *SDpnt); 177 178 STATIC void NCR_700_slave_destroy(struct scsi_device *SDpnt); 178 179 static int NCR_700_change_queue_depth(struct scsi_device *SDpnt, int depth); ··· 182 181 STATIC struct device_attribute *NCR_700_dev_attrs[]; 183 182 184 183 STATIC struct scsi_transport_template *NCR_700_transport_template = NULL; 185 - 186 - struct NCR_700_sense { 187 - unsigned char cmnd[MAX_COMMAND_SIZE]; 188 - }; 189 184 190 185 static char *NCR_700_phase[] = { 191 186 "", ··· 330 333 tpnt->use_clustering = ENABLE_CLUSTERING; 331 334 tpnt->slave_configure = NCR_700_slave_configure; 332 335 tpnt->slave_destroy = NCR_700_slave_destroy; 336 + tpnt->slave_alloc = NCR_700_slave_alloc; 333 337 tpnt->change_queue_depth = NCR_700_change_queue_depth; 334 338 tpnt->change_queue_type = NCR_700_change_queue_type; 335 339 ··· 609 611 struct NCR_700_command_slot *slot = 610 612 (struct NCR_700_command_slot *)SCp->host_scribble; 611 613 612 - NCR_700_unmap(hostdata, SCp, slot); 614 + dma_unmap_single(hostdata->dev, slot->pCmd, 615 + sizeof(SCp->cmnd), DMA_TO_DEVICE); 613 616 if (slot->flags == NCR_700_FLAG_AUTOSENSE) { 614 - struct NCR_700_sense *sense = SCp->device->hostdata; 617 + char *cmnd = NCR_700_get_sense_cmnd(SCp->device); 615 618 #ifdef NCR_700_DEBUG 616 619 printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n", 617 620 SCp, SCp->cmnd[7], result); ··· 623 624 /* restore the old result if the request sense was 624 625 * successful */ 625 626 if(result == 0) 626 - result = sense->cmnd[7]; 627 + result = cmnd[7]; 627 628 } else 628 - dma_unmap_single(hostdata->dev, slot->pCmd, 629 - sizeof(SCp->cmnd), DMA_TO_DEVICE); 629 + NCR_700_unmap(hostdata, SCp, slot); 630 630 631 631 free_slot(slot, hostdata); 632 632 #ifdef NCR_700_DEBUG ··· 967 969 status_byte(hostdata->status[0]) == COMMAND_TERMINATED) { 968 970 struct NCR_700_command_slot *slot = 969 971 (struct NCR_700_command_slot *)SCp->host_scribble; 970 - if(SCp->cmnd[0] == REQUEST_SENSE) { 972 + if(slot->flags == NCR_700_FLAG_AUTOSENSE) { 971 973 /* OOPS: bad device, returning another 972 974 * contingent allegiance condition */ 973 975 scmd_printk(KERN_ERR, SCp, 974 976 "broken device is looping in contingent allegiance: ignoring\n"); 975 977 NCR_700_scsi_done(hostdata, SCp, hostdata->status[0]); 976 978 } else { 977 - struct NCR_700_sense *sense = SCp->device->hostdata; 979 + char *cmnd = 980 + NCR_700_get_sense_cmnd(SCp->device); 978 981 #ifdef NCR_DEBUG 979 982 scsi_print_command(SCp); 980 983 printk(" cmd %p has status %d, requesting sense\n", ··· 993 994 sizeof(SCp->cmnd), 994 995 DMA_TO_DEVICE); 995 996 996 - sense->cmnd[0] = REQUEST_SENSE; 997 - sense->cmnd[1] = (SCp->device->lun & 0x7) << 5; 998 - sense->cmnd[2] = 0; 999 - sense->cmnd[3] = 0; 1000 - sense->cmnd[4] = sizeof(SCp->sense_buffer); 1001 - sense->cmnd[5] = 0; 997 + cmnd[0] = REQUEST_SENSE; 998 + cmnd[1] = (SCp->device->lun & 0x7) << 5; 999 + cmnd[2] = 0; 1000 + cmnd[3] = 0; 1001 + cmnd[4] = sizeof(SCp->sense_buffer); 1002 + cmnd[5] = 0; 1002 1003 /* Here's a quiet hack: the 1003 1004 * REQUEST_SENSE command is six bytes, 1004 1005 * so store a flag indicating that 1005 1006 * this was an internal sense request 1006 1007 * and the original status at the end 1007 1008 * of the command */ 1008 - sense->cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; 1009 - sense->cmnd[7] = hostdata->status[0]; 1010 - slot->pCmd = dma_map_single(hostdata->dev, sense->cmnd, sizeof(sense->cmnd), DMA_TO_DEVICE); 1009 + cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; 1010 + cmnd[7] = hostdata->status[0]; 1011 + slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1011 1012 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1012 1013 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); 1013 1014 slot->SG[0].pAddr = bS_to_host(slot->dma_handle); ··· 1529 1530 1530 1531 /* clear all the negotiated parameters */ 1531 1532 __shost_for_each_device(SDp, host) 1532 - SDp->hostdata = NULL; 1533 + NCR_700_clear_flag(SDp, ~0); 1533 1534 1534 1535 /* clear all the slots and their pending commands */ 1535 1536 for(i = 0; i < NCR_700_COMMAND_SLOTS_PER_HOST; i++) { ··· 2034 2035 spi_flags(STp) |= NCR_700_DEV_PRINT_SYNC_NEGOTIATION; 2035 2036 } 2036 2037 2038 + STATIC int 2039 + NCR_700_slave_alloc(struct scsi_device *SDp) 2040 + { 2041 + SDp->hostdata = kzalloc(sizeof(struct NCR_700_Device_Parameters), 2042 + GFP_KERNEL); 2037 2043 2044 + if (!SDp->hostdata) 2045 + return -ENOMEM; 2046 + 2047 + return 0; 2048 + } 2038 2049 2039 2050 STATIC int 2040 2051 NCR_700_slave_configure(struct scsi_device *SDp) 2041 2052 { 2042 2053 struct NCR_700_Host_Parameters *hostdata = 2043 2054 (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; 2044 - 2045 - SDp->hostdata = kmalloc(GFP_KERNEL, sizeof(struct NCR_700_sense)); 2046 - 2047 - if (!SDp->hostdata) 2048 - return -ENOMEM; 2049 2055 2050 2056 /* to do here: allocate memory; build a queue_full list */ 2051 2057 if(SDp->tagged_supported) {
+23 -11
drivers/scsi/53c700.h
··· 12 12 #include <asm/io.h> 13 13 14 14 #include <scsi/scsi_device.h> 15 - 15 + #include <scsi/scsi_cmnd.h> 16 16 17 17 /* Turn on for general debugging---too verbose for normal use */ 18 18 #undef NCR_700_DEBUG ··· 76 76 #define SCRIPT_RETURN 0x90080000 77 77 }; 78 78 79 - /* We use device->hostdata to store negotiated parameters. This is 80 - * supposed to be a pointer to a device private area, but we cannot 81 - * really use it as such since it will never be freed, so just use the 82 - * 32 bits to cram the information. The SYNC negotiation sequence looks 83 - * like: 79 + struct NCR_700_Device_Parameters { 80 + /* space for creating a request sense command. Really, except 81 + * for the annoying SCSI-2 requirement for LUN information in 82 + * cmnd[1], this could be in static storage */ 83 + unsigned char cmnd[MAX_COMMAND_SIZE]; 84 + __u8 depth; 85 + }; 86 + 87 + 88 + /* The SYNC negotiation sequence looks like: 84 89 * 85 90 * If DEV_NEGOTIATED_SYNC not set, tack and SDTR message on to the 86 91 * initial identify for the device and set DEV_BEGIN_SYNC_NEGOTATION ··· 103 98 #define NCR_700_DEV_BEGIN_SYNC_NEGOTIATION (1<<17) 104 99 #define NCR_700_DEV_PRINT_SYNC_NEGOTIATION (1<<19) 105 100 101 + static inline char *NCR_700_get_sense_cmnd(struct scsi_device *SDp) 102 + { 103 + struct NCR_700_Device_Parameters *hostdata = SDp->hostdata; 104 + 105 + return hostdata->cmnd; 106 + } 107 + 106 108 static inline void 107 109 NCR_700_set_depth(struct scsi_device *SDp, __u8 depth) 108 110 { 109 - long l = (long)SDp->hostdata; 111 + struct NCR_700_Device_Parameters *hostdata = SDp->hostdata; 110 112 111 - l &= 0xffff00ff; 112 - l |= 0xff00 & (depth << 8); 113 - SDp->hostdata = (void *)l; 113 + hostdata->depth = depth; 114 114 } 115 115 static inline __u8 116 116 NCR_700_get_depth(struct scsi_device *SDp) 117 117 { 118 - return ((((unsigned long)SDp->hostdata) & 0xff00)>>8); 118 + struct NCR_700_Device_Parameters *hostdata = SDp->hostdata; 119 + 120 + return hostdata->depth; 119 121 } 120 122 static inline int 121 123 NCR_700_is_flag_set(struct scsi_device *SDp, __u32 flag)
+1 -25
drivers/scsi/aacraid/comminit.c
··· 92 92 init->AdapterFibsPhysicalAddress = cpu_to_le32((u32)phys); 93 93 init->AdapterFibsSize = cpu_to_le32(fibsize); 94 94 init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib)); 95 - /* 96 - * number of 4k pages of host physical memory. The aacraid fw needs 97 - * this number to be less than 4gb worth of pages. num_physpages is in 98 - * system page units. New firmware doesn't have any issues with the 99 - * mapping system, but older Firmware did, and had *troubles* dealing 100 - * with the math overloading past 32 bits, thus we must limit this 101 - * field. 102 - * 103 - * This assumes the memory is mapped zero->n, which isnt 104 - * always true on real computers. It also has some slight problems 105 - * with the GART on x86-64. I've btw never tried DMA from PCI space 106 - * on this platform but don't be surprised if its problematic. 107 - * [AK: something is very very wrong when a driver tests this symbol. 108 - * Someone should figure out what the comment writer really meant here and fix 109 - * the code. Or just remove that bad code. ] 110 - */ 111 - #ifndef CONFIG_IOMMU 112 - if ((num_physpages << (PAGE_SHIFT - 12)) <= AAC_MAX_HOSTPHYSMEMPAGES) { 113 - init->HostPhysMemPages = 114 - cpu_to_le32(num_physpages << (PAGE_SHIFT-12)); 115 - } else 116 - #endif 117 - { 118 - init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES); 119 - } 95 + init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES); 120 96 121 97 init->InitFlags = 0; 122 98 if (dev->new_comm_interface) {
+1
drivers/scsi/aic7xxx/aic79xx.h
··· 1487 1487 } ahd_queue_alg; 1488 1488 1489 1489 void ahd_set_tags(struct ahd_softc *ahd, 1490 + struct scsi_cmnd *cmd, 1490 1491 struct ahd_devinfo *devinfo, 1491 1492 ahd_queue_alg alg); 1492 1493
+13 -11
drivers/scsi/aic7xxx/aic79xx_core.c
··· 1090 1090 1091 1091 /* Notify XPT */ 1092 1092 ahd_send_async(ahd, devinfo.channel, devinfo.target, 1093 - CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); 1093 + CAM_LUN_WILDCARD, AC_SENT_BDR); 1094 1094 1095 1095 /* 1096 1096 * Allow the sequencer to continue with ··· 3062 3062 tinfo->curr.ppr_options = ppr_options; 3063 3063 3064 3064 ahd_send_async(ahd, devinfo->channel, devinfo->target, 3065 - CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 3065 + CAM_LUN_WILDCARD, AC_TRANSFER_NEG); 3066 3066 if (bootverbose) { 3067 3067 if (offset != 0) { 3068 3068 int options; ··· 3184 3184 3185 3185 tinfo->curr.width = width; 3186 3186 ahd_send_async(ahd, devinfo->channel, devinfo->target, 3187 - CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 3187 + CAM_LUN_WILDCARD, AC_TRANSFER_NEG); 3188 3188 if (bootverbose) { 3189 3189 printf("%s: target %d using %dbit transfers\n", 3190 3190 ahd_name(ahd), devinfo->target, ··· 3211 3211 * Update the current state of tagged queuing for a given target. 3212 3212 */ 3213 3213 void 3214 - ahd_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, 3215 - ahd_queue_alg alg) 3214 + ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, 3215 + struct ahd_devinfo *devinfo, ahd_queue_alg alg) 3216 3216 { 3217 - ahd_platform_set_tags(ahd, devinfo, alg); 3217 + struct scsi_device *sdev = cmd->device; 3218 + 3219 + ahd_platform_set_tags(ahd, sdev, devinfo, alg); 3218 3220 ahd_send_async(ahd, devinfo->channel, devinfo->target, 3219 - devinfo->lun, AC_TRANSFER_NEG, &alg); 3221 + devinfo->lun, AC_TRANSFER_NEG); 3220 3222 } 3221 3223 3222 3224 static void ··· 4748 4746 printf("(%s:%c:%d:%d): refuses tagged commands. " 4749 4747 "Performing non-tagged I/O\n", ahd_name(ahd), 4750 4748 devinfo->channel, devinfo->target, devinfo->lun); 4751 - ahd_set_tags(ahd, devinfo, AHD_QUEUE_NONE); 4749 + ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE); 4752 4750 mask = ~0x23; 4753 4751 } else { 4754 4752 printf("(%s:%c:%d:%d): refuses %s tagged commands. " ··· 4756 4754 ahd_name(ahd), devinfo->channel, devinfo->target, 4757 4755 devinfo->lun, tag_type == MSG_ORDERED_TASK 4758 4756 ? "ordered" : "head of queue"); 4759 - ahd_set_tags(ahd, devinfo, AHD_QUEUE_BASIC); 4757 + ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC); 4760 4758 mask = ~0x03; 4761 4759 } 4762 4760 ··· 5100 5098 5101 5099 if (status != CAM_SEL_TIMEOUT) 5102 5100 ahd_send_async(ahd, devinfo->channel, devinfo->target, 5103 - CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); 5101 + CAM_LUN_WILDCARD, AC_SENT_BDR); 5104 5102 5105 5103 if (message != NULL && bootverbose) 5106 5104 printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd), ··· 7954 7952 #endif 7955 7953 /* Notify the XPT that a bus reset occurred */ 7956 7954 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD, 7957 - CAM_LUN_WILDCARD, AC_BUS_RESET, NULL); 7955 + CAM_LUN_WILDCARD, AC_BUS_RESET); 7958 7956 7959 7957 /* 7960 7958 * Revert to async/narrow transfers until we renegotiate.
+12 -50
drivers/scsi/aic7xxx/aic79xx_osm.c
··· 484 484 struct seeprom_config *sc = ahd->seep_config; 485 485 unsigned long flags; 486 486 struct scsi_target **ahd_targp = ahd_linux_target_in_softc(starget); 487 - struct ahd_linux_target *targ = scsi_transport_target_data(starget); 488 487 struct ahd_devinfo devinfo; 489 488 struct ahd_initiator_tinfo *tinfo; 490 489 struct ahd_tmode_tstate *tstate; ··· 494 495 BUG_ON(*ahd_targp != NULL); 495 496 496 497 *ahd_targp = starget; 497 - memset(targ, 0, sizeof(*targ)); 498 498 499 499 if (sc) { 500 500 int flags = sc->device_flags[starget->id]; ··· 549 551 { 550 552 struct ahd_softc *ahd = 551 553 *((struct ahd_softc **)sdev->host->hostdata); 552 - struct scsi_target *starget = sdev->sdev_target; 553 - struct ahd_linux_target *targ = scsi_transport_target_data(starget); 554 554 struct ahd_linux_device *dev; 555 555 556 556 if (bootverbose) 557 557 printf("%s: Slave Alloc %d\n", ahd_name(ahd), sdev->id); 558 - 559 - BUG_ON(targ->sdev[sdev->lun] != NULL); 560 558 561 559 dev = scsi_transport_device_data(sdev); 562 560 memset(dev, 0, sizeof(*dev)); ··· 570 576 */ 571 577 dev->maxtags = 0; 572 578 573 - targ->sdev[sdev->lun] = sdev; 574 - 575 579 return (0); 576 580 } 577 581 ··· 589 597 spi_dv_device(sdev); 590 598 591 599 return 0; 592 - } 593 - 594 - static void 595 - ahd_linux_slave_destroy(struct scsi_device *sdev) 596 - { 597 - struct ahd_softc *ahd; 598 - struct ahd_linux_device *dev = scsi_transport_device_data(sdev); 599 - struct ahd_linux_target *targ = scsi_transport_target_data(sdev->sdev_target); 600 - 601 - ahd = *((struct ahd_softc **)sdev->host->hostdata); 602 - if (bootverbose) 603 - printf("%s: Slave Destroy %d\n", ahd_name(ahd), sdev->id); 604 - 605 - BUG_ON(dev->active); 606 - 607 - targ->sdev[sdev->lun] = NULL; 608 - 609 600 } 610 601 611 602 #if defined(__i386__) ··· 797 822 .use_clustering = ENABLE_CLUSTERING, 798 823 .slave_alloc = ahd_linux_slave_alloc, 799 824 .slave_configure = ahd_linux_slave_configure, 800 - .slave_destroy = ahd_linux_slave_destroy, 801 825 .target_alloc = ahd_linux_target_alloc, 802 826 .target_destroy = ahd_linux_target_destroy, 803 827 }; ··· 1223 1249 ahd_platform_free(struct ahd_softc *ahd) 1224 1250 { 1225 1251 struct scsi_target *starget; 1226 - int i, j; 1252 + int i; 1227 1253 1228 1254 if (ahd->platform_data != NULL) { 1229 1255 /* destroy all of the device and target objects */ 1230 1256 for (i = 0; i < AHD_NUM_TARGETS; i++) { 1231 1257 starget = ahd->platform_data->starget[i]; 1232 1258 if (starget != NULL) { 1233 - for (j = 0; j < AHD_NUM_LUNS; j++) { 1234 - struct ahd_linux_target *targ = 1235 - scsi_transport_target_data(starget); 1236 - if (targ->sdev[j] == NULL) 1237 - continue; 1238 - targ->sdev[j] = NULL; 1239 - } 1240 1259 ahd->platform_data->starget[i] = NULL; 1241 1260 } 1242 1261 } ··· 1285 1318 } 1286 1319 1287 1320 void 1288 - ahd_platform_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, 1289 - ahd_queue_alg alg) 1321 + ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, 1322 + struct ahd_devinfo *devinfo, ahd_queue_alg alg) 1290 1323 { 1291 - struct scsi_target *starget; 1292 - struct ahd_linux_target *targ; 1293 1324 struct ahd_linux_device *dev; 1294 - struct scsi_device *sdev; 1295 1325 int was_queuing; 1296 1326 int now_queuing; 1297 1327 1298 - starget = ahd->platform_data->starget[devinfo->target]; 1299 - targ = scsi_transport_target_data(starget); 1300 - BUG_ON(targ == NULL); 1301 - sdev = targ->sdev[devinfo->lun]; 1302 1328 if (sdev == NULL) 1303 1329 return; 1304 1330 ··· 1427 1467 tags = ahd_linux_user_tagdepth(ahd, &devinfo); 1428 1468 if (tags != 0 && sdev->tagged_supported != 0) { 1429 1469 1430 - ahd_set_tags(ahd, &devinfo, AHD_QUEUE_TAGGED); 1470 + ahd_platform_set_tags(ahd, sdev, &devinfo, AHD_QUEUE_TAGGED); 1471 + ahd_send_async(ahd, devinfo.channel, devinfo.target, 1472 + devinfo.lun, AC_TRANSFER_NEG); 1431 1473 ahd_print_devinfo(ahd, &devinfo); 1432 1474 printf("Tagged Queuing enabled. Depth %d\n", tags); 1433 1475 } else { 1434 - ahd_set_tags(ahd, &devinfo, AHD_QUEUE_NONE); 1476 + ahd_platform_set_tags(ahd, sdev, &devinfo, AHD_QUEUE_NONE); 1477 + ahd_send_async(ahd, devinfo.channel, devinfo.target, 1478 + devinfo.lun, AC_TRANSFER_NEG); 1435 1479 } 1436 1480 } 1437 1481 ··· 1593 1629 1594 1630 void 1595 1631 ahd_send_async(struct ahd_softc *ahd, char channel, 1596 - u_int target, u_int lun, ac_code code, void *arg) 1632 + u_int target, u_int lun, ac_code code) 1597 1633 { 1598 1634 switch (code) { 1599 1635 case AC_TRANSFER_NEG: ··· 1920 1956 } 1921 1957 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); 1922 1958 ahd_set_scsi_status(scb, SCSI_STATUS_OK); 1923 - ahd_platform_set_tags(ahd, &devinfo, 1959 + ahd_platform_set_tags(ahd, sdev, &devinfo, 1924 1960 (dev->flags & AHD_DEV_Q_BASIC) 1925 1961 ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); 1926 1962 break; ··· 1930 1966 * as if the target returned BUSY SCSI status. 1931 1967 */ 1932 1968 dev->openings = 1; 1933 - ahd_platform_set_tags(ahd, &devinfo, 1969 + ahd_platform_set_tags(ahd, sdev, &devinfo, 1934 1970 (dev->flags & AHD_DEV_Q_BASIC) 1935 1971 ? AHD_QUEUE_BASIC : AHD_QUEUE_TAGGED); 1936 1972 ahd_set_scsi_status(scb, SCSI_STATUS_BUSY); ··· 2742 2778 if (!ahd_linux_transport_template) 2743 2779 return -ENODEV; 2744 2780 2745 - scsi_transport_reserve_target(ahd_linux_transport_template, 2746 - sizeof(struct ahd_linux_target)); 2747 2781 scsi_transport_reserve_device(ahd_linux_transport_template, 2748 2782 sizeof(struct ahd_linux_device)); 2749 2783
+2 -9
drivers/scsi/aic7xxx/aic79xx_osm.h
··· 262 262 AHD_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 263 263 } ahd_linux_dev_flags; 264 264 265 - struct ahd_linux_target; 266 265 struct ahd_linux_device { 267 266 TAILQ_ENTRY(ahd_linux_device) links; 268 267 ··· 339 340 */ 340 341 u_int commands_since_idle_or_otag; 341 342 #define AHD_OTAG_THRESH 500 342 - }; 343 - 344 - struct ahd_linux_target { 345 - struct scsi_device *sdev[AHD_NUM_LUNS]; 346 - struct ahd_transinfo last_tinfo; 347 - struct ahd_softc *ahd; 348 343 }; 349 344 350 345 /********************* Definitions Required by the Core ***********************/ ··· 857 864 } 858 865 } 859 866 860 - void ahd_platform_set_tags(struct ahd_softc *ahd, 867 + void ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev, 861 868 struct ahd_devinfo *devinfo, ahd_queue_alg); 862 869 int ahd_platform_abort_scbs(struct ahd_softc *ahd, int target, 863 870 char channel, int lun, u_int tag, ··· 866 873 ahd_linux_isr(int irq, void *dev_id, struct pt_regs * regs); 867 874 void ahd_done(struct ahd_softc*, struct scb*); 868 875 void ahd_send_async(struct ahd_softc *, char channel, 869 - u_int target, u_int lun, ac_code, void *); 876 + u_int target, u_int lun, ac_code); 870 877 void ahd_print_path(struct ahd_softc *, struct scb *); 871 878 872 879 #ifdef CONFIG_PCI
+8 -11
drivers/scsi/aic7xxx/aic79xx_proc.c
··· 47 47 static void ahd_dump_target_state(struct ahd_softc *ahd, 48 48 struct info_str *info, 49 49 u_int our_id, char channel, 50 - u_int target_id, u_int target_offset); 50 + u_int target_id); 51 51 static void ahd_dump_device_state(struct info_str *info, 52 52 struct scsi_device *sdev); 53 53 static int ahd_proc_write_seeprom(struct ahd_softc *ahd, ··· 204 204 205 205 static void 206 206 ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, 207 - u_int our_id, char channel, u_int target_id, 208 - u_int target_offset) 207 + u_int our_id, char channel, u_int target_id) 209 208 { 210 - struct ahd_linux_target *targ; 211 209 struct scsi_target *starget; 212 210 struct ahd_initiator_tinfo *tinfo; 213 211 struct ahd_tmode_tstate *tstate; ··· 216 218 copy_info(info, "Target %d Negotiation Settings\n", target_id); 217 219 copy_info(info, "\tUser: "); 218 220 ahd_format_transinfo(info, &tinfo->user); 219 - starget = ahd->platform_data->starget[target_offset]; 221 + starget = ahd->platform_data->starget[target_id]; 220 222 if (starget == NULL) 221 223 return; 222 - targ = scsi_transport_target_data(starget); 223 224 224 225 copy_info(info, "\tGoal: "); 225 226 ahd_format_transinfo(info, &tinfo->goal); ··· 228 231 for (lun = 0; lun < AHD_NUM_LUNS; lun++) { 229 232 struct scsi_device *dev; 230 233 231 - dev = targ->sdev[lun]; 234 + dev = scsi_device_lookup_by_target(starget, lun); 232 235 233 236 if (dev == NULL) 234 237 continue; ··· 352 355 copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", 353 356 ahd->scb_data.numscbs, AHD_NSEG); 354 357 355 - max_targ = 15; 358 + max_targ = 16; 356 359 357 360 if (ahd->seep_config == NULL) 358 361 copy_info(&info, "No Serial EEPROM\n"); ··· 370 373 copy_info(&info, "\n"); 371 374 372 375 if ((ahd->features & AHD_WIDE) == 0) 373 - max_targ = 7; 376 + max_targ = 8; 374 377 375 - for (i = 0; i <= max_targ; i++) { 378 + for (i = 0; i < max_targ; i++) { 376 379 377 380 ahd_dump_target_state(ahd, &info, ahd->our_id, 'A', 378 - /*target_id*/i, /*target_offset*/i); 381 + /*target_id*/i); 379 382 } 380 383 retval = info.pos > info.offset ? info.pos - info.offset : 0; 381 384 done:
+83 -74
drivers/scsi/atp870u.c
··· 2625 2625 unsigned int base_io, tmport, error,n; 2626 2626 unsigned char host_id; 2627 2627 struct Scsi_Host *shpnt = NULL; 2628 - struct atp_unit atp_dev, *p; 2628 + struct atp_unit *atpdev, *p; 2629 2629 unsigned char setupdata[2][16]; 2630 2630 int count = 0; 2631 - 2631 + 2632 + atpdev = kzalloc(sizeof(*atpdev), GFP_KERNEL); 2633 + if (!atpdev) 2634 + return -ENOMEM; 2635 + 2632 2636 if (pci_enable_device(pdev)) 2633 - return -EIO; 2637 + goto err_eio; 2634 2638 2635 2639 if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 2636 2640 printk(KERN_INFO "atp870u: use 32bit DMA mask.\n"); 2637 2641 } else { 2638 2642 printk(KERN_ERR "atp870u: DMA mask required but not available.\n"); 2639 - return -EIO; 2643 + goto err_eio; 2640 2644 } 2641 2645 2642 - memset(&atp_dev, 0, sizeof atp_dev); 2643 2646 /* 2644 2647 * It's probably easier to weed out some revisions like 2645 2648 * this than via the PCI device table 2646 2649 */ 2647 2650 if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610) { 2648 - error = pci_read_config_byte(pdev, PCI_CLASS_REVISION, &atp_dev.chip_ver); 2649 - if (atp_dev.chip_ver < 2) 2650 - return -EIO; 2651 + error = pci_read_config_byte(pdev, PCI_CLASS_REVISION, &atpdev->chip_ver); 2652 + if (atpdev->chip_ver < 2) 2653 + goto err_eio; 2651 2654 } 2652 2655 2653 2656 switch (ent->device) { ··· 2659 2656 case ATP880_DEVID1: 2660 2657 case ATP880_DEVID2: 2661 2658 case ATP885_DEVID: 2662 - atp_dev.chip_ver = 0x04; 2659 + atpdev->chip_ver = 0x04; 2663 2660 default: 2664 2661 break; 2665 2662 } 2666 2663 base_io = pci_resource_start(pdev, 0); 2667 2664 base_io &= 0xfffffff8; 2668 - 2665 + 2669 2666 if ((ent->device == ATP880_DEVID1)||(ent->device == ATP880_DEVID2)) { 2670 - error = pci_read_config_byte(pdev, PCI_CLASS_REVISION, &atp_dev.chip_ver); 2667 + error = pci_read_config_byte(pdev, PCI_CLASS_REVISION, &atpdev->chip_ver); 2671 2668 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);//JCC082803 2672 2669 2673 2670 host_id = inb(base_io + 0x39); ··· 2675 2672 2676 2673 printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d" 2677 2674 " IO:%x, IRQ:%d.\n", count, base_io, pdev->irq); 2678 - atp_dev.ioport[0] = base_io + 0x40; 2679 - atp_dev.pciport[0] = base_io + 0x28; 2680 - atp_dev.dev_id = ent->device; 2681 - atp_dev.host_id[0] = host_id; 2675 + atpdev->ioport[0] = base_io + 0x40; 2676 + atpdev->pciport[0] = base_io + 0x28; 2677 + atpdev->dev_id = ent->device; 2678 + atpdev->host_id[0] = host_id; 2682 2679 2683 2680 tmport = base_io + 0x22; 2684 - atp_dev.scam_on = inb(tmport); 2681 + atpdev->scam_on = inb(tmport); 2685 2682 tmport += 0x13; 2686 - atp_dev.global_map[0] = inb(tmport); 2683 + atpdev->global_map[0] = inb(tmport); 2687 2684 tmport += 0x07; 2688 - atp_dev.ultra_map[0] = inw(tmport); 2685 + atpdev->ultra_map[0] = inw(tmport); 2689 2686 2690 2687 n = 0x3f09; 2691 2688 next_fblk_880: ··· 2698 2695 if (inb(base_io + 0x30) == 0xff) 2699 2696 goto flash_ok_880; 2700 2697 2701 - atp_dev.sp[0][m++] = inb(base_io + 0x30); 2702 - atp_dev.sp[0][m++] = inb(base_io + 0x31); 2703 - atp_dev.sp[0][m++] = inb(base_io + 0x32); 2704 - atp_dev.sp[0][m++] = inb(base_io + 0x33); 2698 + atpdev->sp[0][m++] = inb(base_io + 0x30); 2699 + atpdev->sp[0][m++] = inb(base_io + 0x31); 2700 + atpdev->sp[0][m++] = inb(base_io + 0x32); 2701 + atpdev->sp[0][m++] = inb(base_io + 0x33); 2705 2702 outw(n, base_io + 0x34); 2706 2703 n += 0x0002; 2707 - atp_dev.sp[0][m++] = inb(base_io + 0x30); 2708 - atp_dev.sp[0][m++] = inb(base_io + 0x31); 2709 - atp_dev.sp[0][m++] = inb(base_io + 0x32); 2710 - atp_dev.sp[0][m++] = inb(base_io + 0x33); 2704 + atpdev->sp[0][m++] = inb(base_io + 0x30); 2705 + atpdev->sp[0][m++] = inb(base_io + 0x31); 2706 + atpdev->sp[0][m++] = inb(base_io + 0x32); 2707 + atpdev->sp[0][m++] = inb(base_io + 0x33); 2711 2708 outw(n, base_io + 0x34); 2712 2709 n += 0x0002; 2713 - atp_dev.sp[0][m++] = inb(base_io + 0x30); 2714 - atp_dev.sp[0][m++] = inb(base_io + 0x31); 2715 - atp_dev.sp[0][m++] = inb(base_io + 0x32); 2716 - atp_dev.sp[0][m++] = inb(base_io + 0x33); 2710 + atpdev->sp[0][m++] = inb(base_io + 0x30); 2711 + atpdev->sp[0][m++] = inb(base_io + 0x31); 2712 + atpdev->sp[0][m++] = inb(base_io + 0x32); 2713 + atpdev->sp[0][m++] = inb(base_io + 0x33); 2717 2714 outw(n, base_io + 0x34); 2718 2715 n += 0x0002; 2719 - atp_dev.sp[0][m++] = inb(base_io + 0x30); 2720 - atp_dev.sp[0][m++] = inb(base_io + 0x31); 2721 - atp_dev.sp[0][m++] = inb(base_io + 0x32); 2722 - atp_dev.sp[0][m++] = inb(base_io + 0x33); 2716 + atpdev->sp[0][m++] = inb(base_io + 0x30); 2717 + atpdev->sp[0][m++] = inb(base_io + 0x31); 2718 + atpdev->sp[0][m++] = inb(base_io + 0x32); 2719 + atpdev->sp[0][m++] = inb(base_io + 0x33); 2723 2720 n += 0x0018; 2724 2721 goto next_fblk_880; 2725 2722 flash_ok_880: 2726 2723 outw(0, base_io + 0x34); 2727 - atp_dev.ultra_map[0] = 0; 2728 - atp_dev.async[0] = 0; 2724 + atpdev->ultra_map[0] = 0; 2725 + atpdev->async[0] = 0; 2729 2726 for (k = 0; k < 16; k++) { 2730 2727 n = 1; 2731 2728 n = n << k; 2732 - if (atp_dev.sp[0][k] > 1) { 2733 - atp_dev.ultra_map[0] |= n; 2729 + if (atpdev->sp[0][k] > 1) { 2730 + atpdev->ultra_map[0] |= n; 2734 2731 } else { 2735 - if (atp_dev.sp[0][k] == 0) 2736 - atp_dev.async[0] |= n; 2732 + if (atpdev->sp[0][k] == 0) 2733 + atpdev->async[0] |= n; 2737 2734 } 2738 2735 } 2739 - atp_dev.async[0] = ~(atp_dev.async[0]); 2740 - outb(atp_dev.global_map[0], base_io + 0x35); 2736 + atpdev->async[0] = ~(atpdev->async[0]); 2737 + outb(atpdev->global_map[0], base_io + 0x35); 2741 2738 2742 2739 shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit)); 2743 2740 if (!shpnt) 2744 - return -ENOMEM; 2741 + goto err_nomem; 2745 2742 2746 2743 p = (struct atp_unit *)&shpnt->hostdata; 2747 2744 2748 - atp_dev.host = shpnt; 2749 - atp_dev.pdev = pdev; 2745 + atpdev->host = shpnt; 2746 + atpdev->pdev = pdev; 2750 2747 pci_set_drvdata(pdev, p); 2751 - memcpy(p, &atp_dev, sizeof atp_dev); 2748 + memcpy(p, atpdev, sizeof(*atpdev)); 2752 2749 if (atp870u_init_tables(shpnt) < 0) { 2753 2750 printk(KERN_ERR "Unable to allocate tables for Acard controller\n"); 2754 2751 goto unregister; ··· 2801 2798 printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%x, IRQ:%d.\n" 2802 2799 , base_io, pdev->irq); 2803 2800 2804 - atp_dev.pdev = pdev; 2805 - atp_dev.dev_id = ent->device; 2806 - atp_dev.baseport = base_io; 2807 - atp_dev.ioport[0] = base_io + 0x80; 2808 - atp_dev.ioport[1] = base_io + 0xc0; 2809 - atp_dev.pciport[0] = base_io + 0x40; 2810 - atp_dev.pciport[1] = base_io + 0x50; 2801 + atpdev->pdev = pdev; 2802 + atpdev->dev_id = ent->device; 2803 + atpdev->baseport = base_io; 2804 + atpdev->ioport[0] = base_io + 0x80; 2805 + atpdev->ioport[1] = base_io + 0xc0; 2806 + atpdev->pciport[0] = base_io + 0x40; 2807 + atpdev->pciport[1] = base_io + 0x50; 2811 2808 2812 2809 shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit)); 2813 2810 if (!shpnt) 2814 - return -ENOMEM; 2811 + goto err_nomem; 2815 2812 2816 2813 p = (struct atp_unit *)&shpnt->hostdata; 2817 2814 2818 - atp_dev.host = shpnt; 2819 - atp_dev.pdev = pdev; 2815 + atpdev->host = shpnt; 2816 + atpdev->pdev = pdev; 2820 2817 pci_set_drvdata(pdev, p); 2821 - memcpy(p, &atp_dev, sizeof(struct atp_unit)); 2818 + memcpy(p, atpdev, sizeof(struct atp_unit)); 2822 2819 if (atp870u_init_tables(shpnt) < 0) 2823 2820 goto unregister; 2824 2821 ··· 2977 2974 printk(KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: %d " 2978 2975 "IO:%x, IRQ:%d.\n", count, base_io, pdev->irq); 2979 2976 2980 - atp_dev.ioport[0] = base_io; 2981 - atp_dev.pciport[0] = base_io + 0x20; 2982 - atp_dev.dev_id = ent->device; 2977 + atpdev->ioport[0] = base_io; 2978 + atpdev->pciport[0] = base_io + 0x20; 2979 + atpdev->dev_id = ent->device; 2983 2980 host_id &= 0x07; 2984 - atp_dev.host_id[0] = host_id; 2981 + atpdev->host_id[0] = host_id; 2985 2982 tmport = base_io + 0x22; 2986 - atp_dev.scam_on = inb(tmport); 2983 + atpdev->scam_on = inb(tmport); 2987 2984 tmport += 0x0b; 2988 - atp_dev.global_map[0] = inb(tmport++); 2989 - atp_dev.ultra_map[0] = inw(tmport); 2985 + atpdev->global_map[0] = inb(tmport++); 2986 + atpdev->ultra_map[0] = inw(tmport); 2990 2987 2991 - if (atp_dev.ultra_map[0] == 0) { 2992 - atp_dev.scam_on = 0x00; 2993 - atp_dev.global_map[0] = 0x20; 2994 - atp_dev.ultra_map[0] = 0xffff; 2988 + if (atpdev->ultra_map[0] == 0) { 2989 + atpdev->scam_on = 0x00; 2990 + atpdev->global_map[0] = 0x20; 2991 + atpdev->ultra_map[0] = 0xffff; 2995 2992 } 2996 2993 2997 2994 shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit)); 2998 2995 if (!shpnt) 2999 - return -ENOMEM; 2996 + goto err_nomem; 3000 2997 3001 2998 p = (struct atp_unit *)&shpnt->hostdata; 3002 2999 3003 - atp_dev.host = shpnt; 3004 - atp_dev.pdev = pdev; 3000 + atpdev->host = shpnt; 3001 + atpdev->pdev = pdev; 3005 3002 pci_set_drvdata(pdev, p); 3006 - memcpy(p, &atp_dev, sizeof atp_dev); 3003 + memcpy(p, atpdev, sizeof(*atpdev)); 3007 3004 if (atp870u_init_tables(shpnt) < 0) 3008 3005 goto unregister; 3009 3006 ··· 3013 3010 } 3014 3011 3015 3012 spin_lock_irqsave(shpnt->host_lock, flags); 3016 - if (atp_dev.chip_ver > 0x07) { /* check if atp876 chip then enable terminator */ 3013 + if (atpdev->chip_ver > 0x07) { /* check if atp876 chip then enable terminator */ 3017 3014 tmport = base_io + 0x3e; 3018 3015 outb(0x00, tmport); 3019 3016 } ··· 3047 3044 outb((inb(tmport) & 0xef), tmport); 3048 3045 tmport++; 3049 3046 outb((inb(tmport) | 0x20), tmport); 3050 - if (atp_dev.chip_ver == 4) 3047 + if (atpdev->chip_ver == 4) 3051 3048 shpnt->max_id = 16; 3052 3049 else 3053 3050 shpnt->max_id = 8; ··· 3096 3093 printk("atp870u_prob:unregister\n"); 3097 3094 scsi_host_put(shpnt); 3098 3095 return -1; 3096 + err_eio: 3097 + kfree(atpdev); 3098 + return -EIO; 3099 + err_nomem: 3100 + kfree(atpdev); 3101 + return -ENOMEM; 3099 3102 } 3100 3103 3101 3104 /* The abort command does not leave the device in a clean state where
+49 -15
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 535 535 struct ibmvscsi_host_data *hostdata) 536 536 { 537 537 u64 *crq_as_u64 = (u64 *) &evt_struct->crq; 538 + int request_status; 538 539 int rc; 539 540 540 541 /* If we have exhausted our request limit, just fail this request. ··· 543 542 * (such as task management requests) that the mid layer may think we 544 543 * can handle more requests (can_queue) when we actually can't 545 544 */ 546 - if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) && 547 - (atomic_dec_if_positive(&hostdata->request_limit) < 0)) 548 - goto send_error; 545 + if (evt_struct->crq.format == VIOSRP_SRP_FORMAT) { 546 + request_status = 547 + atomic_dec_if_positive(&hostdata->request_limit); 548 + /* If request limit was -1 when we started, it is now even 549 + * less than that 550 + */ 551 + if (request_status < -1) 552 + goto send_error; 553 + /* Otherwise, if we have run out of requests */ 554 + else if (request_status < 0) 555 + goto send_busy; 556 + } 549 557 550 558 /* Copy the IU into the transfer area */ 551 559 *evt_struct->xfer_iu = evt_struct->iu; ··· 577 567 578 568 return 0; 579 569 580 - send_error: 570 + send_busy: 581 571 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 582 572 583 573 free_event_struct(&hostdata->pool, evt_struct); 584 574 return SCSI_MLQUEUE_HOST_BUSY; 575 + 576 + send_error: 577 + unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 578 + 579 + if (evt_struct->cmnd != NULL) { 580 + evt_struct->cmnd->result = DID_ERROR << 16; 581 + evt_struct->cmnd_done(evt_struct->cmnd); 582 + } else if (evt_struct->done) 583 + evt_struct->done(evt_struct); 584 + 585 + free_event_struct(&hostdata->pool, evt_struct); 586 + return 0; 585 587 } 586 588 587 589 /** ··· 1206 1184 return; 1207 1185 case 0xFF: /* Hypervisor telling us the connection is closed */ 1208 1186 scsi_block_requests(hostdata->host); 1187 + atomic_set(&hostdata->request_limit, 0); 1209 1188 if (crq->format == 0x06) { 1210 1189 /* We need to re-setup the interpartition connection */ 1211 1190 printk(KERN_INFO 1212 1191 "ibmvscsi: Re-enabling adapter!\n"); 1213 - atomic_set(&hostdata->request_limit, -1); 1214 1192 purge_requests(hostdata, DID_REQUEUE); 1215 - if (ibmvscsi_reenable_crq_queue(&hostdata->queue, 1216 - hostdata) == 0) 1217 - if (ibmvscsi_send_crq(hostdata, 1218 - 0xC001000000000000LL, 0)) 1193 + if ((ibmvscsi_reenable_crq_queue(&hostdata->queue, 1194 + hostdata) == 0) || 1195 + (ibmvscsi_send_crq(hostdata, 1196 + 0xC001000000000000LL, 0))) { 1197 + atomic_set(&hostdata->request_limit, 1198 + -1); 1219 1199 printk(KERN_ERR 1220 - "ibmvscsi: transmit error after" 1200 + "ibmvscsi: error after" 1221 1201 " enable\n"); 1202 + } 1222 1203 } else { 1223 1204 printk(KERN_INFO 1224 1205 "ibmvscsi: Virtual adapter failed rc %d!\n", 1225 1206 crq->format); 1226 1207 1227 - atomic_set(&hostdata->request_limit, -1); 1228 1208 purge_requests(hostdata, DID_ERROR); 1229 - ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); 1209 + if ((ibmvscsi_reset_crq_queue(&hostdata->queue, 1210 + hostdata)) || 1211 + (ibmvscsi_send_crq(hostdata, 1212 + 0xC001000000000000LL, 0))) { 1213 + atomic_set(&hostdata->request_limit, 1214 + -1); 1215 + printk(KERN_ERR 1216 + "ibmvscsi: error after reset\n"); 1217 + } 1230 1218 } 1231 1219 scsi_unblock_requests(hostdata->host); 1232 1220 return; ··· 1499 1467 struct Scsi_Host *host; 1500 1468 struct device *dev = &vdev->dev; 1501 1469 unsigned long wait_switch = 0; 1470 + int rc; 1502 1471 1503 1472 vdev->dev.driver_data = NULL; 1504 1473 ··· 1517 1484 atomic_set(&hostdata->request_limit, -1); 1518 1485 hostdata->host->max_sectors = 32 * 8; /* default max I/O 32 pages */ 1519 1486 1520 - if (ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, 1521 - max_requests) != 0) { 1487 + rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_requests); 1488 + if (rc != 0 && rc != H_RESOURCE) { 1522 1489 printk(KERN_ERR "ibmvscsi: couldn't initialize crq\n"); 1523 1490 goto init_crq_failed; 1524 1491 } ··· 1538 1505 * to fail if the other end is not acive. In that case we don't 1539 1506 * want to scan 1540 1507 */ 1541 - if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 0) { 1508 + if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 0 1509 + || rc == H_RESOURCE) { 1542 1510 /* 1543 1511 * Wait around max init_timeout secs for the adapter to finish 1544 1512 * initializing. When we are done initializing, we will have a
+3 -2
drivers/scsi/ibmvscsi/rpa_vscsi.c
··· 208 208 int max_requests) 209 209 { 210 210 int rc; 211 + int retrc; 211 212 struct vio_dev *vdev = to_vio_dev(hostdata->dev); 212 213 213 214 queue->msgs = (struct viosrp_crq *)get_zeroed_page(GFP_KERNEL); ··· 227 226 gather_partition_info(); 228 227 set_adapter_info(hostdata); 229 228 230 - rc = plpar_hcall_norets(H_REG_CRQ, 229 + retrc = rc = plpar_hcall_norets(H_REG_CRQ, 231 230 vdev->unit_address, 232 231 queue->msg_token, PAGE_SIZE); 233 232 if (rc == H_RESOURCE) ··· 264 263 tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task, 265 264 (unsigned long)hostdata); 266 265 267 - return 0; 266 + return retrc; 268 267 269 268 req_irq_failed: 270 269 do {
+24 -128
drivers/scsi/iscsi_tcp.c
··· 2130 2130 2131 2131 static int 2132 2132 iscsi_conn_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, 2133 - uint32_t value) 2133 + char *buf, int buflen) 2134 2134 { 2135 2135 struct iscsi_conn *conn = cls_conn->dd_data; 2136 2136 struct iscsi_session *session = conn->session; 2137 2137 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 2138 + int value; 2138 2139 2139 2140 switch(param) { 2140 2141 case ISCSI_PARAM_MAX_RECV_DLENGTH: { 2141 2142 char *saveptr = tcp_conn->data; 2142 2143 gfp_t flags = GFP_KERNEL; 2143 2144 2145 + sscanf(buf, "%d", &value); 2144 2146 if (tcp_conn->data_size >= value) { 2145 - conn->max_recv_dlength = value; 2147 + iscsi_set_param(cls_conn, param, buf, buflen); 2146 2148 break; 2147 2149 } 2148 2150 ··· 2167 2165 else 2168 2166 free_pages((unsigned long)saveptr, 2169 2167 get_order(tcp_conn->data_size)); 2170 - conn->max_recv_dlength = value; 2168 + iscsi_set_param(cls_conn, param, buf, buflen); 2171 2169 tcp_conn->data_size = value; 2170 + break; 2172 2171 } 2173 - break; 2174 - case ISCSI_PARAM_MAX_XMIT_DLENGTH: 2175 - conn->max_xmit_dlength = value; 2176 - break; 2177 2172 case ISCSI_PARAM_HDRDGST_EN: 2178 - conn->hdrdgst_en = value; 2173 + iscsi_set_param(cls_conn, param, buf, buflen); 2179 2174 tcp_conn->hdr_size = sizeof(struct iscsi_hdr); 2180 2175 if (conn->hdrdgst_en) { 2181 2176 tcp_conn->hdr_size += sizeof(__u32); ··· 2196 2197 } 2197 2198 break; 2198 2199 case ISCSI_PARAM_DATADGST_EN: 2199 - conn->datadgst_en = value; 2200 + iscsi_set_param(cls_conn, param, buf, buflen); 2200 2201 if (conn->datadgst_en) { 2201 2202 if (!tcp_conn->data_tx_tfm) 2202 2203 tcp_conn->data_tx_tfm = ··· 2219 2220 tcp_conn->sendpage = conn->datadgst_en ? 2220 2221 sock_no_sendpage : tcp_conn->sock->ops->sendpage; 2221 2222 break; 2222 - case ISCSI_PARAM_INITIAL_R2T_EN: 2223 - session->initial_r2t_en = value; 2224 - break; 2225 2223 case ISCSI_PARAM_MAX_R2T: 2224 + sscanf(buf, "%d", &value); 2226 2225 if (session->max_r2t == roundup_pow_of_two(value)) 2227 2226 break; 2228 2227 iscsi_r2tpool_free(session); 2229 - session->max_r2t = value; 2228 + iscsi_set_param(cls_conn, param, buf, buflen); 2230 2229 if (session->max_r2t & (session->max_r2t - 1)) 2231 2230 session->max_r2t = roundup_pow_of_two(session->max_r2t); 2232 2231 if (iscsi_r2tpool_alloc(session)) 2233 2232 return -ENOMEM; 2234 2233 break; 2235 - case ISCSI_PARAM_IMM_DATA_EN: 2236 - session->imm_data_en = value; 2237 - break; 2238 - case ISCSI_PARAM_FIRST_BURST: 2239 - session->first_burst = value; 2240 - break; 2241 - case ISCSI_PARAM_MAX_BURST: 2242 - session->max_burst = value; 2243 - break; 2244 - case ISCSI_PARAM_PDU_INORDER_EN: 2245 - session->pdu_inorder_en = value; 2246 - break; 2247 - case ISCSI_PARAM_DATASEQ_INORDER_EN: 2248 - session->dataseq_inorder_en = value; 2249 - break; 2250 - case ISCSI_PARAM_ERL: 2251 - session->erl = value; 2252 - break; 2253 - case ISCSI_PARAM_IFMARKER_EN: 2254 - BUG_ON(value); 2255 - session->ifmarker_en = value; 2256 - break; 2257 - case ISCSI_PARAM_OFMARKER_EN: 2258 - BUG_ON(value); 2259 - session->ofmarker_en = value; 2260 - break; 2261 - case ISCSI_PARAM_EXP_STATSN: 2262 - conn->exp_statsn = value; 2263 - break; 2264 2234 default: 2265 - break; 2235 + return iscsi_set_param(cls_conn, param, buf, buflen); 2266 2236 } 2267 2237 2268 2238 return 0; 2269 2239 } 2270 2240 2271 2241 static int 2272 - iscsi_session_get_param(struct iscsi_cls_session *cls_session, 2273 - enum iscsi_param param, uint32_t *value) 2274 - { 2275 - struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 2276 - struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 2277 - 2278 - switch(param) { 2279 - case ISCSI_PARAM_INITIAL_R2T_EN: 2280 - *value = session->initial_r2t_en; 2281 - break; 2282 - case ISCSI_PARAM_MAX_R2T: 2283 - *value = session->max_r2t; 2284 - break; 2285 - case ISCSI_PARAM_IMM_DATA_EN: 2286 - *value = session->imm_data_en; 2287 - break; 2288 - case ISCSI_PARAM_FIRST_BURST: 2289 - *value = session->first_burst; 2290 - break; 2291 - case ISCSI_PARAM_MAX_BURST: 2292 - *value = session->max_burst; 2293 - break; 2294 - case ISCSI_PARAM_PDU_INORDER_EN: 2295 - *value = session->pdu_inorder_en; 2296 - break; 2297 - case ISCSI_PARAM_DATASEQ_INORDER_EN: 2298 - *value = session->dataseq_inorder_en; 2299 - break; 2300 - case ISCSI_PARAM_ERL: 2301 - *value = session->erl; 2302 - break; 2303 - case ISCSI_PARAM_IFMARKER_EN: 2304 - *value = session->ifmarker_en; 2305 - break; 2306 - case ISCSI_PARAM_OFMARKER_EN: 2307 - *value = session->ofmarker_en; 2308 - break; 2309 - default: 2310 - return -EINVAL; 2311 - } 2312 - 2313 - return 0; 2314 - } 2315 - 2316 - static int 2317 - iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, 2318 - enum iscsi_param param, uint32_t *value) 2242 + iscsi_tcp_conn_get_param(struct iscsi_cls_conn *cls_conn, 2243 + enum iscsi_param param, char *buf) 2319 2244 { 2320 2245 struct iscsi_conn *conn = cls_conn->dd_data; 2321 2246 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 2322 2247 struct inet_sock *inet; 2248 + struct ipv6_pinfo *np; 2249 + struct sock *sk; 2250 + int len; 2323 2251 2324 2252 switch(param) { 2325 - case ISCSI_PARAM_MAX_RECV_DLENGTH: 2326 - *value = conn->max_recv_dlength; 2327 - break; 2328 - case ISCSI_PARAM_MAX_XMIT_DLENGTH: 2329 - *value = conn->max_xmit_dlength; 2330 - break; 2331 - case ISCSI_PARAM_HDRDGST_EN: 2332 - *value = conn->hdrdgst_en; 2333 - break; 2334 - case ISCSI_PARAM_DATADGST_EN: 2335 - *value = conn->datadgst_en; 2336 - break; 2337 2253 case ISCSI_PARAM_CONN_PORT: 2338 2254 mutex_lock(&conn->xmitmutex); 2339 2255 if (!tcp_conn->sock) { ··· 2257 2343 } 2258 2344 2259 2345 inet = inet_sk(tcp_conn->sock->sk); 2260 - *value = be16_to_cpu(inet->dport); 2346 + len = sprintf(buf, "%hu\n", be16_to_cpu(inet->dport)); 2261 2347 mutex_unlock(&conn->xmitmutex); 2262 - case ISCSI_PARAM_EXP_STATSN: 2263 - *value = conn->exp_statsn; 2264 2348 break; 2265 - default: 2266 - return -EINVAL; 2267 - } 2268 - 2269 - return 0; 2270 - } 2271 - 2272 - static int 2273 - iscsi_conn_get_str_param(struct iscsi_cls_conn *cls_conn, 2274 - enum iscsi_param param, char *buf) 2275 - { 2276 - struct iscsi_conn *conn = cls_conn->dd_data; 2277 - struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 2278 - struct sock *sk; 2279 - struct inet_sock *inet; 2280 - struct ipv6_pinfo *np; 2281 - int len = 0; 2282 - 2283 - switch (param) { 2284 2349 case ISCSI_PARAM_CONN_ADDRESS: 2285 2350 mutex_lock(&conn->xmitmutex); 2286 2351 if (!tcp_conn->sock) { ··· 2281 2388 mutex_unlock(&conn->xmitmutex); 2282 2389 break; 2283 2390 default: 2284 - return -EINVAL; 2391 + return iscsi_conn_get_param(cls_conn, param, buf); 2285 2392 } 2286 2393 2287 2394 return len; ··· 2394 2501 ISCSI_ERL | 2395 2502 ISCSI_CONN_PORT | 2396 2503 ISCSI_CONN_ADDRESS | 2397 - ISCSI_EXP_STATSN, 2504 + ISCSI_EXP_STATSN | 2505 + ISCSI_PERSISTENT_PORT | 2506 + ISCSI_PERSISTENT_ADDRESS | 2507 + ISCSI_TARGET_NAME | 2508 + ISCSI_TPGT, 2398 2509 .host_template = &iscsi_sht, 2399 2510 .conndata_size = sizeof(struct iscsi_conn), 2400 2511 .max_conn = 1, ··· 2411 2514 .bind_conn = iscsi_tcp_conn_bind, 2412 2515 .destroy_conn = iscsi_tcp_conn_destroy, 2413 2516 .set_param = iscsi_conn_set_param, 2414 - .get_conn_param = iscsi_conn_get_param, 2415 - .get_conn_str_param = iscsi_conn_get_str_param, 2517 + .get_conn_param = iscsi_tcp_conn_get_param, 2416 2518 .get_session_param = iscsi_session_get_param, 2417 2519 .start_conn = iscsi_conn_start, 2418 2520 .stop_conn = iscsi_conn_stop,
+186 -1
drivers/scsi/libiscsi.c
··· 1287 1287 if (scsi_add_host(shost, NULL)) 1288 1288 goto add_host_fail; 1289 1289 1290 + if (!try_module_get(iscsit->owner)) 1291 + goto cls_session_fail; 1292 + 1290 1293 cls_session = iscsi_create_session(shost, iscsit, 0); 1291 1294 if (!cls_session) 1292 - goto cls_session_fail; 1295 + goto module_put; 1293 1296 *(unsigned long*)shost->hostdata = (unsigned long)cls_session; 1294 1297 1295 1298 return cls_session; 1296 1299 1300 + module_put: 1301 + module_put(iscsit->owner); 1297 1302 cls_session_fail: 1298 1303 scsi_remove_host(shost); 1299 1304 add_host_fail: ··· 1330 1325 1331 1326 iscsi_destroy_session(cls_session); 1332 1327 scsi_host_put(shost); 1328 + module_put(cls_session->transport->owner); 1333 1329 } 1334 1330 EXPORT_SYMBOL_GPL(iscsi_session_teardown); 1335 1331 ··· 1702 1696 return 0; 1703 1697 } 1704 1698 EXPORT_SYMBOL_GPL(iscsi_conn_bind); 1699 + 1700 + 1701 + int iscsi_set_param(struct iscsi_cls_conn *cls_conn, 1702 + enum iscsi_param param, char *buf, int buflen) 1703 + { 1704 + struct iscsi_conn *conn = cls_conn->dd_data; 1705 + struct iscsi_session *session = conn->session; 1706 + uint32_t value; 1707 + 1708 + switch(param) { 1709 + case ISCSI_PARAM_MAX_RECV_DLENGTH: 1710 + sscanf(buf, "%d", &conn->max_recv_dlength); 1711 + break; 1712 + case ISCSI_PARAM_MAX_XMIT_DLENGTH: 1713 + sscanf(buf, "%d", &conn->max_xmit_dlength); 1714 + break; 1715 + case ISCSI_PARAM_HDRDGST_EN: 1716 + sscanf(buf, "%d", &conn->hdrdgst_en); 1717 + break; 1718 + case ISCSI_PARAM_DATADGST_EN: 1719 + sscanf(buf, "%d", &conn->datadgst_en); 1720 + break; 1721 + case ISCSI_PARAM_INITIAL_R2T_EN: 1722 + sscanf(buf, "%d", &session->initial_r2t_en); 1723 + break; 1724 + case ISCSI_PARAM_MAX_R2T: 1725 + sscanf(buf, "%d", &session->max_r2t); 1726 + break; 1727 + case ISCSI_PARAM_IMM_DATA_EN: 1728 + sscanf(buf, "%d", &session->imm_data_en); 1729 + break; 1730 + case ISCSI_PARAM_FIRST_BURST: 1731 + sscanf(buf, "%d", &session->first_burst); 1732 + break; 1733 + case ISCSI_PARAM_MAX_BURST: 1734 + sscanf(buf, "%d", &session->max_burst); 1735 + break; 1736 + case ISCSI_PARAM_PDU_INORDER_EN: 1737 + sscanf(buf, "%d", &session->pdu_inorder_en); 1738 + break; 1739 + case ISCSI_PARAM_DATASEQ_INORDER_EN: 1740 + sscanf(buf, "%d", &session->dataseq_inorder_en); 1741 + break; 1742 + case ISCSI_PARAM_ERL: 1743 + sscanf(buf, "%d", &session->erl); 1744 + break; 1745 + case ISCSI_PARAM_IFMARKER_EN: 1746 + sscanf(buf, "%d", &value); 1747 + BUG_ON(value); 1748 + break; 1749 + case ISCSI_PARAM_OFMARKER_EN: 1750 + sscanf(buf, "%d", &value); 1751 + BUG_ON(value); 1752 + break; 1753 + case ISCSI_PARAM_EXP_STATSN: 1754 + sscanf(buf, "%u", &conn->exp_statsn); 1755 + break; 1756 + case ISCSI_PARAM_TARGET_NAME: 1757 + /* this should not change between logins */ 1758 + if (session->targetname) 1759 + break; 1760 + 1761 + session->targetname = kstrdup(buf, GFP_KERNEL); 1762 + if (!session->targetname) 1763 + return -ENOMEM; 1764 + break; 1765 + case ISCSI_PARAM_TPGT: 1766 + sscanf(buf, "%d", &session->tpgt); 1767 + break; 1768 + case ISCSI_PARAM_PERSISTENT_PORT: 1769 + sscanf(buf, "%d", &conn->persistent_port); 1770 + break; 1771 + case ISCSI_PARAM_PERSISTENT_ADDRESS: 1772 + /* 1773 + * this is the address returned in discovery so it should 1774 + * not change between logins. 1775 + */ 1776 + if (conn->persistent_address) 1777 + break; 1778 + 1779 + conn->persistent_address = kstrdup(buf, GFP_KERNEL); 1780 + if (!conn->persistent_address) 1781 + return -ENOMEM; 1782 + break; 1783 + default: 1784 + return -ENOSYS; 1785 + } 1786 + 1787 + return 0; 1788 + } 1789 + EXPORT_SYMBOL_GPL(iscsi_set_param); 1790 + 1791 + int iscsi_session_get_param(struct iscsi_cls_session *cls_session, 1792 + enum iscsi_param param, char *buf) 1793 + { 1794 + struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 1795 + struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 1796 + int len; 1797 + 1798 + switch(param) { 1799 + case ISCSI_PARAM_INITIAL_R2T_EN: 1800 + len = sprintf(buf, "%d\n", session->initial_r2t_en); 1801 + break; 1802 + case ISCSI_PARAM_MAX_R2T: 1803 + len = sprintf(buf, "%hu\n", session->max_r2t); 1804 + break; 1805 + case ISCSI_PARAM_IMM_DATA_EN: 1806 + len = sprintf(buf, "%d\n", session->imm_data_en); 1807 + break; 1808 + case ISCSI_PARAM_FIRST_BURST: 1809 + len = sprintf(buf, "%u\n", session->first_burst); 1810 + break; 1811 + case ISCSI_PARAM_MAX_BURST: 1812 + len = sprintf(buf, "%u\n", session->max_burst); 1813 + break; 1814 + case ISCSI_PARAM_PDU_INORDER_EN: 1815 + len = sprintf(buf, "%d\n", session->pdu_inorder_en); 1816 + break; 1817 + case ISCSI_PARAM_DATASEQ_INORDER_EN: 1818 + len = sprintf(buf, "%d\n", session->dataseq_inorder_en); 1819 + break; 1820 + case ISCSI_PARAM_ERL: 1821 + len = sprintf(buf, "%d\n", session->erl); 1822 + break; 1823 + case ISCSI_PARAM_TARGET_NAME: 1824 + len = sprintf(buf, "%s\n", session->targetname); 1825 + break; 1826 + case ISCSI_PARAM_TPGT: 1827 + len = sprintf(buf, "%d\n", session->tpgt); 1828 + break; 1829 + default: 1830 + return -ENOSYS; 1831 + } 1832 + 1833 + return len; 1834 + } 1835 + EXPORT_SYMBOL_GPL(iscsi_session_get_param); 1836 + 1837 + int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, 1838 + enum iscsi_param param, char *buf) 1839 + { 1840 + struct iscsi_conn *conn = cls_conn->dd_data; 1841 + int len; 1842 + 1843 + switch(param) { 1844 + case ISCSI_PARAM_MAX_RECV_DLENGTH: 1845 + len = sprintf(buf, "%u\n", conn->max_recv_dlength); 1846 + break; 1847 + case ISCSI_PARAM_MAX_XMIT_DLENGTH: 1848 + len = sprintf(buf, "%u\n", conn->max_xmit_dlength); 1849 + break; 1850 + case ISCSI_PARAM_HDRDGST_EN: 1851 + len = sprintf(buf, "%d\n", conn->hdrdgst_en); 1852 + break; 1853 + case ISCSI_PARAM_DATADGST_EN: 1854 + len = sprintf(buf, "%d\n", conn->datadgst_en); 1855 + break; 1856 + case ISCSI_PARAM_IFMARKER_EN: 1857 + len = sprintf(buf, "%d\n", conn->ifmarker_en); 1858 + break; 1859 + case ISCSI_PARAM_OFMARKER_EN: 1860 + len = sprintf(buf, "%d\n", conn->ofmarker_en); 1861 + break; 1862 + case ISCSI_PARAM_EXP_STATSN: 1863 + len = sprintf(buf, "%u\n", conn->exp_statsn); 1864 + break; 1865 + case ISCSI_PARAM_PERSISTENT_PORT: 1866 + len = sprintf(buf, "%d\n", conn->persistent_port); 1867 + break; 1868 + case ISCSI_PARAM_PERSISTENT_ADDRESS: 1869 + len = sprintf(buf, "%s\n", conn->persistent_address); 1870 + break; 1871 + default: 1872 + return -ENOSYS; 1873 + } 1874 + 1875 + return len; 1876 + } 1877 + EXPORT_SYMBOL_GPL(iscsi_conn_get_param); 1705 1878 1706 1879 MODULE_AUTHOR("Mike Christie"); 1707 1880 MODULE_DESCRIPTION("iSCSI library functions");
-1
drivers/scsi/lpfc/lpfc.h
··· 174 174 dma_addr_t slim2p_mapping; 175 175 uint16_t pci_cfg_value; 176 176 177 - struct semaphore hba_can_block; 178 177 int32_t hba_state; 179 178 180 179 #define LPFC_STATE_UNKNOWN 0 /* HBA state is unknown */
+3 -3
drivers/scsi/lpfc/lpfc_els.c
··· 821 821 pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ 822 822 823 823 cmdsize = (sizeof (uint32_t) + sizeof (struct serv_parm)); 824 - elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, 0, did, 824 + elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, NULL, did, 825 825 ELS_CMD_PLOGI); 826 826 if (!elsiocb) 827 827 return 1; ··· 2791 2791 2792 2792 ndlp = (struct lpfc_nodelist *) pmb->context2; 2793 2793 xri = (uint16_t) ((unsigned long)(pmb->context1)); 2794 - pmb->context1 = 0; 2795 - pmb->context2 = 0; 2794 + pmb->context1 = NULL; 2795 + pmb->context2 = NULL; 2796 2796 2797 2797 if (mb->mbxStatus) { 2798 2798 mempool_free( pmb, phba->mbox_mem_pool);
+2 -3
drivers/scsi/lpfc/lpfc_init.c
··· 939 939 "10-port ", "PCIe"}; 940 940 break; 941 941 default: 942 - m = (typeof(m)){ 0 }; 942 + m = (typeof(m)){ NULL }; 943 943 break; 944 944 } 945 945 break; 946 946 default: 947 - m = (typeof(m)){ 0 }; 947 + m = (typeof(m)){ NULL }; 948 948 break; 949 949 } 950 950 ··· 1451 1451 goto out_put_host; 1452 1452 1453 1453 host->unique_id = phba->brd_no; 1454 - init_MUTEX(&phba->hba_can_block); 1455 1454 INIT_LIST_HEAD(&phba->ctrspbuflist); 1456 1455 INIT_LIST_HEAD(&phba->rnidrspbuflist); 1457 1456 INIT_LIST_HEAD(&phba->freebufList);
-20
drivers/scsi/lpfc/lpfc_scsi.c
··· 41 41 #define LPFC_ABORT_WAIT 2 42 42 43 43 44 - static inline void 45 - lpfc_block_requests(struct lpfc_hba * phba) 46 - { 47 - down(&phba->hba_can_block); 48 - scsi_block_requests(phba->host); 49 - } 50 - 51 - static inline void 52 - lpfc_unblock_requests(struct lpfc_hba * phba) 53 - { 54 - scsi_unblock_requests(phba->host); 55 - up(&phba->hba_can_block); 56 - } 57 - 58 44 /* 59 45 * This routine allocates a scsi buffer, which contains all the necessary 60 46 * information needed to initiate a SCSI I/O. The non-DMAable buffer region ··· 845 859 unsigned int loop_count = 0; 846 860 int ret = SUCCESS; 847 861 848 - lpfc_block_requests(phba); 849 862 spin_lock_irq(shost->host_lock); 850 863 851 864 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; ··· 930 945 cmnd->device->lun, cmnd->serial_number); 931 946 932 947 spin_unlock_irq(shost->host_lock); 933 - lpfc_unblock_requests(phba); 934 948 935 949 return ret; 936 950 } ··· 947 963 int ret = FAILED; 948 964 int cnt, loopcnt; 949 965 950 - lpfc_block_requests(phba); 951 966 spin_lock_irq(shost->host_lock); 952 967 /* 953 968 * If target is not in a MAPPED state, delay the reset until ··· 1048 1065 1049 1066 out: 1050 1067 spin_unlock_irq(shost->host_lock); 1051 - lpfc_unblock_requests(phba); 1052 1068 return ret; 1053 1069 } 1054 1070 ··· 1062 1080 int cnt, loopcnt; 1063 1081 struct lpfc_scsi_buf * lpfc_cmd; 1064 1082 1065 - lpfc_block_requests(phba); 1066 1083 spin_lock_irq(shost->host_lock); 1067 1084 1068 1085 lpfc_cmd = lpfc_get_scsi_buf(phba); ··· 1144 1163 phba->brd_no, ret); 1145 1164 out: 1146 1165 spin_unlock_irq(shost->host_lock); 1147 - lpfc_unblock_requests(phba); 1148 1166 return ret; 1149 1167 } 1150 1168
+24 -8
drivers/scsi/megaraid/megaraid_sas.c
··· 10 10 * 2 of the License, or (at your option) any later version. 11 11 * 12 12 * FILE : megaraid_sas.c 13 - * Version : v00.00.02.04 13 + * Version : v00.00.03.01 14 14 * 15 15 * Authors: 16 16 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com> ··· 55 55 56 56 { 57 57 PCI_VENDOR_ID_LSI_LOGIC, 58 - PCI_DEVICE_ID_LSI_SAS1064R, // xscale IOP 58 + PCI_DEVICE_ID_LSI_SAS1064R, /* xscale IOP */ 59 59 PCI_ANY_ID, 60 60 PCI_ANY_ID, 61 61 }, 62 62 { 63 63 PCI_VENDOR_ID_LSI_LOGIC, 64 - PCI_DEVICE_ID_LSI_SAS1078R, // ppc IOP 64 + PCI_DEVICE_ID_LSI_SAS1078R, /* ppc IOP */ 65 65 PCI_ANY_ID, 66 66 PCI_ANY_ID, 67 67 }, 68 68 { 69 + PCI_VENDOR_ID_LSI_LOGIC, 70 + PCI_DEVICE_ID_LSI_VERDE_ZCR, /* xscale IOP, vega */ 71 + PCI_ANY_ID, 72 + PCI_ANY_ID, 73 + }, 74 + { 69 75 PCI_VENDOR_ID_DELL, 70 - PCI_DEVICE_ID_DELL_PERC5, // xscale IOP 76 + PCI_DEVICE_ID_DELL_PERC5, /* xscale IOP */ 71 77 PCI_ANY_ID, 72 78 PCI_ANY_ID, 73 79 }, ··· 295 289 * @regs: MFI register set 296 290 */ 297 291 static inline void 298 - megasas_disable_intr(struct megasas_register_set __iomem * regs) 292 + megasas_disable_intr(struct megasas_instance *instance) 299 293 { 300 294 u32 mask = 0x1f; 295 + struct megasas_register_set __iomem *regs = instance->reg_set; 296 + 297 + if(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1078R) 298 + mask = 0xffffffff; 299 + 301 300 writel(mask, &regs->outbound_intr_mask); 302 301 303 302 /* Dummy readl to force pci flush */ ··· 1271 1260 /* 1272 1261 * Bring it to READY state; assuming max wait 2 secs 1273 1262 */ 1274 - megasas_disable_intr(instance->reg_set); 1263 + megasas_disable_intr(instance); 1275 1264 writel(MFI_INIT_READY, &instance->reg_set->inbound_doorbell); 1276 1265 1277 1266 max_wait = 10; ··· 1768 1757 init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info); 1769 1758 1770 1759 /* 1760 + * disable the intr before firing the init frame to FW 1761 + */ 1762 + megasas_disable_intr(instance); 1763 + 1764 + /* 1771 1765 * Issue the init frame in polled mode 1772 1766 */ 1773 1767 if (megasas_issue_polled(instance, cmd)) { ··· 2250 2234 megasas_mgmt_info.max_index--; 2251 2235 2252 2236 pci_set_drvdata(pdev, NULL); 2253 - megasas_disable_intr(instance->reg_set); 2237 + megasas_disable_intr(instance); 2254 2238 free_irq(instance->pdev->irq, instance); 2255 2239 2256 2240 megasas_release_mfi(instance); ··· 2380 2364 2381 2365 pci_set_drvdata(instance->pdev, NULL); 2382 2366 2383 - megasas_disable_intr(instance->reg_set); 2367 + megasas_disable_intr(instance); 2384 2368 2385 2369 free_irq(instance->pdev->irq, instance); 2386 2370
+16 -5
drivers/scsi/megaraid/megaraid_sas.h
··· 18 18 /** 19 19 * MegaRAID SAS Driver meta data 20 20 */ 21 - #define MEGASAS_VERSION "00.00.02.04" 22 - #define MEGASAS_RELDATE "Feb 03, 2006" 23 - #define MEGASAS_EXT_VERSION "Fri Feb 03 14:31:44 PST 2006" 21 + #define MEGASAS_VERSION "00.00.03.01" 22 + #define MEGASAS_RELDATE "May 14, 2006" 23 + #define MEGASAS_EXT_VERSION "Sun May 14 22:49:52 PDT 2006" 24 + 25 + /* 26 + * Device IDs 27 + */ 28 + #define PCI_DEVICE_ID_LSI_SAS1078R 0x0060 29 + #define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413 30 + 24 31 /* 25 32 * ===================================== 26 33 * MegaRAID SAS MFI firmware definitions ··· 561 554 #define MFI_POLL_TIMEOUT_SECS 10 562 555 563 556 #define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000 564 - #define PCI_DEVICE_ID_LSI_SAS1078R 0x00000060 557 + 558 + /* 559 + * register set for both 1068 and 1078 controllers 560 + * structure extended for 1078 registers 561 + */ 565 562 566 563 struct megasas_register_set { 567 564 u32 reserved_0[4]; /*0000h*/ ··· 1161 1150 struct compat_iovec sgl[MAX_IOCTL_SGE]; 1162 1151 } __attribute__ ((packed)); 1163 1152 1153 + #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket) 1164 1154 #endif 1165 1155 1166 1156 #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket) 1167 - #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket) 1168 1157 #define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen) 1169 1158 1170 1159 struct megasas_mgmt_info {
+9 -3
drivers/scsi/nsp32.c
··· 2866 2866 */ 2867 2867 nsp32_do_bus_reset(data); 2868 2868 2869 - ret = request_irq(host->irq, do_nsp32_isr, 2870 - IRQF_SHARED | IRQF_SAMPLE_RANDOM, "nsp32", data); 2869 + ret = request_irq(host->irq, do_nsp32_isr, IRQF_SHARED, "nsp32", data); 2871 2870 if (ret < 0) { 2872 2871 nsp32_msg(KERN_ERR, "Unable to allocate IRQ for NinjaSCSI32 " 2873 2872 "SCSI PCI controller. Interrupt: %d", host->irq); ··· 2885 2886 } 2886 2887 2887 2888 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 2888 - scsi_add_host (host, &PCIDEV->dev); 2889 + ret = scsi_add_host(host, &PCIDEV->dev); 2890 + if (ret) { 2891 + nsp32_msg(KERN_ERR, "failed to add scsi host"); 2892 + goto free_region; 2893 + } 2889 2894 scsi_scan_host(host); 2890 2895 #endif 2891 2896 pci_set_drvdata(PCIDEV, host); 2892 2897 return DETECT_OK; 2898 + 2899 + free_region: 2900 + release_region(host->io_port, host->n_io_port); 2893 2901 2894 2902 free_irq: 2895 2903 free_irq(host->irq, data);
+1 -1
drivers/scsi/pcmcia/nsp_cs.c
··· 1623 1623 /* Interrupt handler */ 1624 1624 link->irq.Handler = &nspintr; 1625 1625 link->irq.Instance = info; 1626 - link->irq.Attributes |= (IRQF_SHARED | IRQF_SAMPLE_RANDOM); 1626 + link->irq.Attributes |= IRQF_SHARED; 1627 1627 1628 1628 /* General socket configuration */ 1629 1629 link->conf.Attributes = CONF_ENABLE_IRQ;
+1 -1
drivers/scsi/qla1280.c
··· 4209 4209 } 4210 4210 4211 4211 4212 - static int 4212 + static int __init 4213 4213 qla1280_get_token(char *str) 4214 4214 { 4215 4215 char *sep;
+76 -44
drivers/scsi/qla2xxx/qla_attr.c
··· 16 16 { 17 17 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 18 18 struct device, kobj))); 19 + char *rbuf = (char *)ha->fw_dump; 19 20 20 21 if (ha->fw_dump_reading == 0) 21 22 return 0; 22 - if (off > ha->fw_dump_buffer_len) 23 - return 0; 24 - if (off + count > ha->fw_dump_buffer_len) 25 - count = ha->fw_dump_buffer_len - off; 23 + if (off > ha->fw_dump_len) 24 + return 0; 25 + if (off + count > ha->fw_dump_len) 26 + count = ha->fw_dump_len - off; 26 27 27 - memcpy(buf, &ha->fw_dump_buffer[off], count); 28 + memcpy(buf, &rbuf[off], count); 28 29 29 30 return (count); 30 31 } ··· 37 36 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 38 37 struct device, kobj))); 39 38 int reading; 40 - uint32_t dump_size; 41 39 42 40 if (off != 0) 43 41 return (0); ··· 44 44 reading = simple_strtol(buf, NULL, 10); 45 45 switch (reading) { 46 46 case 0: 47 - if (ha->fw_dump_reading == 1) { 48 - qla_printk(KERN_INFO, ha, 49 - "Firmware dump cleared on (%ld).\n", ha->host_no); 47 + if (!ha->fw_dump_reading) 48 + break; 50 49 51 - vfree(ha->fw_dump_buffer); 52 - ha->fw_dump_buffer = NULL; 53 - ha->fw_dump_reading = 0; 54 - ha->fw_dumped = 0; 55 - } 50 + qla_printk(KERN_INFO, ha, 51 + "Firmware dump cleared on (%ld).\n", ha->host_no); 52 + 53 + ha->fw_dump_reading = 0; 54 + ha->fw_dumped = 0; 56 55 break; 57 56 case 1: 58 57 if (ha->fw_dumped && !ha->fw_dump_reading) { 59 58 ha->fw_dump_reading = 1; 60 59 61 - if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 62 - dump_size = FW_DUMP_SIZE_24XX; 63 - else { 64 - dump_size = FW_DUMP_SIZE_1M; 65 - if (ha->fw_memory_size < 0x20000) 66 - dump_size = FW_DUMP_SIZE_128K; 67 - else if (ha->fw_memory_size < 0x80000) 68 - dump_size = FW_DUMP_SIZE_512K; 69 - } 70 - ha->fw_dump_buffer = (char *)vmalloc(dump_size); 71 - if (ha->fw_dump_buffer == NULL) { 72 - qla_printk(KERN_WARNING, ha, 73 - "Unable to allocate memory for firmware " 74 - "dump buffer (%d).\n", dump_size); 75 - 76 - ha->fw_dump_reading = 0; 77 - return (count); 78 - } 79 60 qla_printk(KERN_INFO, ha, 80 - "Firmware dump ready for read on (%ld).\n", 61 + "Raw firmware dump ready for read on (%ld).\n", 81 62 ha->host_no); 82 - memset(ha->fw_dump_buffer, 0, dump_size); 83 - ha->isp_ops.ascii_fw_dump(ha); 84 - ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer); 85 63 } 64 + break; 65 + case 2: 66 + qla2x00_alloc_fw_dump(ha); 86 67 break; 87 68 } 88 69 return (count); ··· 294 313 if (!capable(CAP_SYS_ADMIN) || off != 0) 295 314 return 0; 296 315 297 - if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 298 - return -ENOTSUPP; 299 - 300 316 /* Read NVRAM. */ 301 317 spin_lock_irqsave(&ha->hardware_lock, flags); 302 318 ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->vpd_base, ha->vpd_size); ··· 312 334 313 335 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) 314 336 return 0; 315 - 316 - if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 317 - return -ENOTSUPP; 318 337 319 338 /* Write NVRAM. */ 320 339 spin_lock_irqsave(&ha->hardware_lock, flags); ··· 332 357 .write = qla2x00_sysfs_write_vpd, 333 358 }; 334 359 360 + static ssize_t 361 + qla2x00_sysfs_read_sfp(struct kobject *kobj, char *buf, loff_t off, 362 + size_t count) 363 + { 364 + struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 365 + struct device, kobj))); 366 + uint16_t iter, addr, offset; 367 + int rval; 368 + 369 + if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2) 370 + return 0; 371 + 372 + addr = 0xa0; 373 + for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE; 374 + iter++, offset += SFP_BLOCK_SIZE) { 375 + if (iter == 4) { 376 + /* Skip to next device address. */ 377 + addr = 0xa2; 378 + offset = 0; 379 + } 380 + 381 + rval = qla2x00_read_sfp(ha, ha->sfp_data_dma, addr, offset, 382 + SFP_BLOCK_SIZE); 383 + if (rval != QLA_SUCCESS) { 384 + qla_printk(KERN_WARNING, ha, 385 + "Unable to read SFP data (%x/%x/%x).\n", rval, 386 + addr, offset); 387 + count = 0; 388 + break; 389 + } 390 + memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE); 391 + buf += SFP_BLOCK_SIZE; 392 + } 393 + 394 + return count; 395 + } 396 + 397 + static struct bin_attribute sysfs_sfp_attr = { 398 + .attr = { 399 + .name = "sfp", 400 + .mode = S_IRUSR | S_IWUSR, 401 + .owner = THIS_MODULE, 402 + }, 403 + .size = SFP_DEV_SIZE * 2, 404 + .read = qla2x00_sysfs_read_sfp, 405 + }; 406 + 335 407 void 336 408 qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 337 409 { ··· 389 367 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 390 368 sysfs_create_bin_file(&host->shost_gendev.kobj, 391 369 &sysfs_optrom_ctl_attr); 392 - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); 370 + if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 371 + sysfs_create_bin_file(&host->shost_gendev.kobj, 372 + &sysfs_vpd_attr); 373 + sysfs_create_bin_file(&host->shost_gendev.kobj, 374 + &sysfs_sfp_attr); 375 + } 393 376 } 394 377 395 378 void ··· 407 380 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 408 381 sysfs_remove_bin_file(&host->shost_gendev.kobj, 409 382 &sysfs_optrom_ctl_attr); 410 - sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); 383 + if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 384 + sysfs_remove_bin_file(&host->shost_gendev.kobj, 385 + &sysfs_vpd_attr); 386 + sysfs_remove_bin_file(&host->shost_gendev.kobj, 387 + &sysfs_sfp_attr); 388 + } 411 389 412 390 if (ha->beacon_blink_led == 1) 413 391 ha->isp_ops.beacon_off(ha);
+183 -742
drivers/scsi/qla2xxx/qla_dbg.c
··· 8 8 9 9 #include <linux/delay.h> 10 10 11 - static int qla_uprintf(char **, char *, ...); 11 + static inline void 12 + qla2xxx_prep_dump(scsi_qla_host_t *ha, struct qla2xxx_fw_dump *fw_dump) 13 + { 14 + fw_dump->fw_major_version = htonl(ha->fw_major_version); 15 + fw_dump->fw_minor_version = htonl(ha->fw_minor_version); 16 + fw_dump->fw_subminor_version = htonl(ha->fw_subminor_version); 17 + fw_dump->fw_attributes = htonl(ha->fw_attributes); 18 + 19 + fw_dump->vendor = htonl(ha->pdev->vendor); 20 + fw_dump->device = htonl(ha->pdev->device); 21 + fw_dump->subsystem_vendor = htonl(ha->pdev->subsystem_vendor); 22 + fw_dump->subsystem_device = htonl(ha->pdev->subsystem_device); 23 + } 24 + 25 + static inline void * 26 + qla2xxx_copy_queues(scsi_qla_host_t *ha, void *ptr) 27 + { 28 + /* Request queue. */ 29 + memcpy(ptr, ha->request_ring, ha->request_q_length * 30 + sizeof(request_t)); 31 + 32 + /* Response queue. */ 33 + ptr += ha->request_q_length * sizeof(request_t); 34 + memcpy(ptr, ha->response_ring, ha->response_q_length * 35 + sizeof(response_t)); 36 + 37 + return ptr + (ha->response_q_length * sizeof(response_t)); 38 + } 12 39 13 40 /** 14 41 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware. ··· 76 49 "request...\n", ha->fw_dump); 77 50 goto qla2300_fw_dump_failed; 78 51 } 79 - fw = ha->fw_dump; 52 + fw = &ha->fw_dump->isp.isp23; 53 + qla2xxx_prep_dump(ha, ha->fw_dump); 80 54 81 55 rval = QLA_SUCCESS; 82 - fw->hccr = RD_REG_WORD(&reg->hccr); 56 + fw->hccr = htons(RD_REG_WORD(&reg->hccr)); 83 57 84 58 /* Pause RISC. */ 85 59 WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC); ··· 101 73 if (rval == QLA_SUCCESS) { 102 74 dmp_reg = (uint16_t __iomem *)(reg + 0); 103 75 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 104 - fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++); 76 + fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 105 77 106 78 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10); 107 79 for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++) 108 - fw->risc_host_reg[cnt] = RD_REG_WORD(dmp_reg++); 80 + fw->risc_host_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 109 81 110 82 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x40); 111 83 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 112 - fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++); 84 + fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 113 85 114 86 WRT_REG_WORD(&reg->ctrl_status, 0x40); 115 87 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 116 88 for (cnt = 0; cnt < sizeof(fw->resp_dma_reg) / 2; cnt++) 117 - fw->resp_dma_reg[cnt] = RD_REG_WORD(dmp_reg++); 89 + fw->resp_dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 118 90 119 91 WRT_REG_WORD(&reg->ctrl_status, 0x50); 120 92 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 121 93 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 122 - fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++); 94 + fw->dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 123 95 124 96 WRT_REG_WORD(&reg->ctrl_status, 0x00); 125 97 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0); 126 98 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 127 - fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++); 99 + fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 128 100 129 101 WRT_REG_WORD(&reg->pcr, 0x2000); 130 102 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 131 103 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 132 - fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++); 104 + fw->risc_gp0_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 133 105 134 106 WRT_REG_WORD(&reg->pcr, 0x2200); 135 107 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 136 108 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 137 - fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++); 109 + fw->risc_gp1_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 138 110 139 111 WRT_REG_WORD(&reg->pcr, 0x2400); 140 112 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 141 113 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 142 - fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++); 114 + fw->risc_gp2_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 143 115 144 116 WRT_REG_WORD(&reg->pcr, 0x2600); 145 117 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 146 118 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 147 - fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++); 119 + fw->risc_gp3_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 148 120 149 121 WRT_REG_WORD(&reg->pcr, 0x2800); 150 122 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 151 123 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 152 - fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++); 124 + fw->risc_gp4_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 153 125 154 126 WRT_REG_WORD(&reg->pcr, 0x2A00); 155 127 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 156 128 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 157 - fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++); 129 + fw->risc_gp5_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 158 130 159 131 WRT_REG_WORD(&reg->pcr, 0x2C00); 160 132 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 161 133 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 162 - fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++); 134 + fw->risc_gp6_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 163 135 164 136 WRT_REG_WORD(&reg->pcr, 0x2E00); 165 137 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 166 138 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 167 - fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++); 139 + fw->risc_gp7_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 168 140 169 141 WRT_REG_WORD(&reg->ctrl_status, 0x10); 170 142 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 171 143 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 172 - fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++); 144 + fw->frame_buf_hdw_reg[cnt] = 145 + htons(RD_REG_WORD(dmp_reg++)); 173 146 174 147 WRT_REG_WORD(&reg->ctrl_status, 0x20); 175 148 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 176 149 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 177 - fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++); 150 + fw->fpm_b0_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 178 151 179 152 WRT_REG_WORD(&reg->ctrl_status, 0x30); 180 153 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 181 154 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 182 - fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++); 155 + fw->fpm_b1_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 183 156 184 157 /* Reset RISC. */ 185 158 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET); ··· 255 226 256 227 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 257 228 rval = mb0 & MBS_MASK; 258 - fw->risc_ram[cnt] = mb2; 229 + fw->risc_ram[cnt] = htons(mb2); 259 230 } else { 260 231 rval = QLA_FUNCTION_FAILED; 261 232 } ··· 314 285 315 286 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 316 287 rval = mb0 & MBS_MASK; 317 - fw->stack_ram[cnt] = mb2; 288 + fw->stack_ram[cnt] = htons(mb2); 318 289 } else { 319 290 rval = QLA_FUNCTION_FAILED; 320 291 } ··· 374 345 375 346 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 376 347 rval = mb0 & MBS_MASK; 377 - fw->data_ram[cnt] = mb2; 348 + fw->data_ram[cnt] = htons(mb2); 378 349 } else { 379 350 rval = QLA_FUNCTION_FAILED; 380 351 } 381 352 } 353 + 354 + if (rval == QLA_SUCCESS) 355 + qla2xxx_copy_queues(ha, &fw->data_ram[cnt]); 382 356 383 357 if (rval != QLA_SUCCESS) { 384 358 qla_printk(KERN_WARNING, ha, ··· 398 366 qla2300_fw_dump_failed: 399 367 if (!hardware_locked) 400 368 spin_unlock_irqrestore(&ha->hardware_lock, flags); 401 - } 402 - 403 - /** 404 - * qla2300_ascii_fw_dump() - Converts a binary firmware dump to ASCII. 405 - * @ha: HA context 406 - */ 407 - void 408 - qla2300_ascii_fw_dump(scsi_qla_host_t *ha) 409 - { 410 - uint32_t cnt; 411 - char *uiter; 412 - char fw_info[30]; 413 - struct qla2300_fw_dump *fw; 414 - uint32_t data_ram_cnt; 415 - 416 - uiter = ha->fw_dump_buffer; 417 - fw = ha->fw_dump; 418 - 419 - qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number, 420 - ha->isp_ops.fw_version_str(ha, fw_info)); 421 - 422 - qla_uprintf(&uiter, "\n[==>BEG]\n"); 423 - 424 - qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr); 425 - 426 - qla_uprintf(&uiter, "PBIU Registers:"); 427 - for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) { 428 - if (cnt % 8 == 0) { 429 - qla_uprintf(&uiter, "\n"); 430 - } 431 - qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]); 432 - } 433 - 434 - qla_uprintf(&uiter, "\n\nReqQ-RspQ-Risc2Host Status registers:"); 435 - for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) { 436 - if (cnt % 8 == 0) { 437 - qla_uprintf(&uiter, "\n"); 438 - } 439 - qla_uprintf(&uiter, "%04x ", fw->risc_host_reg[cnt]); 440 - } 441 - 442 - qla_uprintf(&uiter, "\n\nMailbox Registers:"); 443 - for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 444 - if (cnt % 8 == 0) { 445 - qla_uprintf(&uiter, "\n"); 446 - } 447 - qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]); 448 - } 449 - 450 - qla_uprintf(&uiter, "\n\nAuto Request Response DMA Registers:"); 451 - for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) { 452 - if (cnt % 8 == 0) { 453 - qla_uprintf(&uiter, "\n"); 454 - } 455 - qla_uprintf(&uiter, "%04x ", fw->resp_dma_reg[cnt]); 456 - } 457 - 458 - qla_uprintf(&uiter, "\n\nDMA Registers:"); 459 - for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) { 460 - if (cnt % 8 == 0) { 461 - qla_uprintf(&uiter, "\n"); 462 - } 463 - qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]); 464 - } 465 - 466 - qla_uprintf(&uiter, "\n\nRISC Hardware Registers:"); 467 - for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) { 468 - if (cnt % 8 == 0) { 469 - qla_uprintf(&uiter, "\n"); 470 - } 471 - qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]); 472 - } 473 - 474 - qla_uprintf(&uiter, "\n\nRISC GP0 Registers:"); 475 - for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) { 476 - if (cnt % 8 == 0) { 477 - qla_uprintf(&uiter, "\n"); 478 - } 479 - qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]); 480 - } 481 - 482 - qla_uprintf(&uiter, "\n\nRISC GP1 Registers:"); 483 - for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) { 484 - if (cnt % 8 == 0) { 485 - qla_uprintf(&uiter, "\n"); 486 - } 487 - qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]); 488 - } 489 - 490 - qla_uprintf(&uiter, "\n\nRISC GP2 Registers:"); 491 - for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) { 492 - if (cnt % 8 == 0) { 493 - qla_uprintf(&uiter, "\n"); 494 - } 495 - qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]); 496 - } 497 - 498 - qla_uprintf(&uiter, "\n\nRISC GP3 Registers:"); 499 - for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) { 500 - if (cnt % 8 == 0) { 501 - qla_uprintf(&uiter, "\n"); 502 - } 503 - qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]); 504 - } 505 - 506 - qla_uprintf(&uiter, "\n\nRISC GP4 Registers:"); 507 - for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) { 508 - if (cnt % 8 == 0) { 509 - qla_uprintf(&uiter, "\n"); 510 - } 511 - qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]); 512 - } 513 - 514 - qla_uprintf(&uiter, "\n\nRISC GP5 Registers:"); 515 - for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) { 516 - if (cnt % 8 == 0) { 517 - qla_uprintf(&uiter, "\n"); 518 - } 519 - qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]); 520 - } 521 - 522 - qla_uprintf(&uiter, "\n\nRISC GP6 Registers:"); 523 - for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) { 524 - if (cnt % 8 == 0) { 525 - qla_uprintf(&uiter, "\n"); 526 - } 527 - qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]); 528 - } 529 - 530 - qla_uprintf(&uiter, "\n\nRISC GP7 Registers:"); 531 - for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) { 532 - if (cnt % 8 == 0) { 533 - qla_uprintf(&uiter, "\n"); 534 - } 535 - qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]); 536 - } 537 - 538 - qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:"); 539 - for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) { 540 - if (cnt % 8 == 0) { 541 - qla_uprintf(&uiter, "\n"); 542 - } 543 - qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]); 544 - } 545 - 546 - qla_uprintf(&uiter, "\n\nFPM B0 Registers:"); 547 - for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) { 548 - if (cnt % 8 == 0) { 549 - qla_uprintf(&uiter, "\n"); 550 - } 551 - qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]); 552 - } 553 - 554 - qla_uprintf(&uiter, "\n\nFPM B1 Registers:"); 555 - for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) { 556 - if (cnt % 8 == 0) { 557 - qla_uprintf(&uiter, "\n"); 558 - } 559 - qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]); 560 - } 561 - 562 - qla_uprintf(&uiter, "\n\nCode RAM Dump:"); 563 - for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) { 564 - if (cnt % 8 == 0) { 565 - qla_uprintf(&uiter, "\n%04x: ", cnt + 0x0800); 566 - } 567 - qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]); 568 - } 569 - 570 - qla_uprintf(&uiter, "\n\nStack RAM Dump:"); 571 - for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) { 572 - if (cnt % 8 == 0) { 573 - qla_uprintf(&uiter, "\n%05x: ", cnt + 0x10000); 574 - } 575 - qla_uprintf(&uiter, "%04x ", fw->stack_ram[cnt]); 576 - } 577 - 578 - qla_uprintf(&uiter, "\n\nData RAM Dump:"); 579 - data_ram_cnt = ha->fw_memory_size - 0x11000 + 1; 580 - for (cnt = 0; cnt < data_ram_cnt; cnt++) { 581 - if (cnt % 8 == 0) { 582 - qla_uprintf(&uiter, "\n%05x: ", cnt + 0x11000); 583 - } 584 - qla_uprintf(&uiter, "%04x ", fw->data_ram[cnt]); 585 - } 586 - 587 - qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump."); 588 369 } 589 370 590 371 /** ··· 436 591 "request...\n", ha->fw_dump); 437 592 goto qla2100_fw_dump_failed; 438 593 } 439 - fw = ha->fw_dump; 594 + fw = &ha->fw_dump->isp.isp21; 595 + qla2xxx_prep_dump(ha, ha->fw_dump); 440 596 441 597 rval = QLA_SUCCESS; 442 - fw->hccr = RD_REG_WORD(&reg->hccr); 598 + fw->hccr = htons(RD_REG_WORD(&reg->hccr)); 443 599 444 600 /* Pause RISC. */ 445 601 WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC); ··· 454 608 if (rval == QLA_SUCCESS) { 455 609 dmp_reg = (uint16_t __iomem *)(reg + 0); 456 610 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 457 - fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++); 611 + fw->pbiu_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 458 612 459 613 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10); 460 614 for (cnt = 0; cnt < ha->mbx_count; cnt++) { 461 615 if (cnt == 8) { 462 - dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xe0); 616 + dmp_reg = (uint16_t __iomem *) 617 + ((uint8_t __iomem *)reg + 0xe0); 463 618 } 464 - fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++); 619 + fw->mailbox_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 465 620 } 466 621 467 622 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x20); 468 623 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 469 - fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++); 624 + fw->dma_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 470 625 471 626 WRT_REG_WORD(&reg->ctrl_status, 0x00); 472 627 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0); 473 628 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 474 - fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++); 629 + fw->risc_hdw_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 475 630 476 631 WRT_REG_WORD(&reg->pcr, 0x2000); 477 632 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 478 633 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 479 - fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++); 634 + fw->risc_gp0_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 480 635 481 636 WRT_REG_WORD(&reg->pcr, 0x2100); 482 637 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 483 638 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 484 - fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++); 639 + fw->risc_gp1_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 485 640 486 641 WRT_REG_WORD(&reg->pcr, 0x2200); 487 642 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 488 643 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 489 - fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++); 644 + fw->risc_gp2_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 490 645 491 646 WRT_REG_WORD(&reg->pcr, 0x2300); 492 647 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 493 648 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 494 - fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++); 649 + fw->risc_gp3_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 495 650 496 651 WRT_REG_WORD(&reg->pcr, 0x2400); 497 652 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 498 653 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 499 - fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++); 654 + fw->risc_gp4_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 500 655 501 656 WRT_REG_WORD(&reg->pcr, 0x2500); 502 657 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 503 658 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 504 - fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++); 659 + fw->risc_gp5_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 505 660 506 661 WRT_REG_WORD(&reg->pcr, 0x2600); 507 662 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 508 663 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 509 - fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++); 664 + fw->risc_gp6_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 510 665 511 666 WRT_REG_WORD(&reg->pcr, 0x2700); 512 667 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 513 668 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 514 - fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++); 669 + fw->risc_gp7_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 515 670 516 671 WRT_REG_WORD(&reg->ctrl_status, 0x10); 517 672 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 518 673 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 519 - fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++); 674 + fw->frame_buf_hdw_reg[cnt] = 675 + htons(RD_REG_WORD(dmp_reg++)); 520 676 521 677 WRT_REG_WORD(&reg->ctrl_status, 0x20); 522 678 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 523 679 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 524 - fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++); 680 + fw->fpm_b0_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 525 681 526 682 WRT_REG_WORD(&reg->ctrl_status, 0x30); 527 683 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 528 684 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 529 - fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++); 685 + fw->fpm_b1_reg[cnt] = htons(RD_REG_WORD(dmp_reg++)); 530 686 531 687 /* Reset the ISP. */ 532 688 WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET); ··· 603 755 604 756 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 605 757 rval = mb0 & MBS_MASK; 606 - fw->risc_ram[cnt] = mb2; 758 + fw->risc_ram[cnt] = htons(mb2); 607 759 } else { 608 760 rval = QLA_FUNCTION_FAILED; 609 761 } 610 762 } 763 + 764 + if (rval == QLA_SUCCESS) 765 + qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]); 611 766 612 767 if (rval != QLA_SUCCESS) { 613 768 qla_printk(KERN_WARNING, ha, ··· 629 778 spin_unlock_irqrestore(&ha->hardware_lock, flags); 630 779 } 631 780 632 - /** 633 - * qla2100_ascii_fw_dump() - Converts a binary firmware dump to ASCII. 634 - * @ha: HA context 635 - */ 636 - void 637 - qla2100_ascii_fw_dump(scsi_qla_host_t *ha) 638 - { 639 - uint32_t cnt; 640 - char *uiter; 641 - char fw_info[30]; 642 - struct qla2100_fw_dump *fw; 643 - 644 - uiter = ha->fw_dump_buffer; 645 - fw = ha->fw_dump; 646 - 647 - qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number, 648 - ha->isp_ops.fw_version_str(ha, fw_info)); 649 - 650 - qla_uprintf(&uiter, "\n[==>BEG]\n"); 651 - 652 - qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr); 653 - 654 - qla_uprintf(&uiter, "PBIU Registers:"); 655 - for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) { 656 - if (cnt % 8 == 0) { 657 - qla_uprintf(&uiter, "\n"); 658 - } 659 - qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]); 660 - } 661 - 662 - qla_uprintf(&uiter, "\n\nMailbox Registers:"); 663 - for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) { 664 - if (cnt % 8 == 0) { 665 - qla_uprintf(&uiter, "\n"); 666 - } 667 - qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]); 668 - } 669 - 670 - qla_uprintf(&uiter, "\n\nDMA Registers:"); 671 - for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) { 672 - if (cnt % 8 == 0) { 673 - qla_uprintf(&uiter, "\n"); 674 - } 675 - qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]); 676 - } 677 - 678 - qla_uprintf(&uiter, "\n\nRISC Hardware Registers:"); 679 - for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) { 680 - if (cnt % 8 == 0) { 681 - qla_uprintf(&uiter, "\n"); 682 - } 683 - qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]); 684 - } 685 - 686 - qla_uprintf(&uiter, "\n\nRISC GP0 Registers:"); 687 - for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) { 688 - if (cnt % 8 == 0) { 689 - qla_uprintf(&uiter, "\n"); 690 - } 691 - qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]); 692 - } 693 - 694 - qla_uprintf(&uiter, "\n\nRISC GP1 Registers:"); 695 - for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) { 696 - if (cnt % 8 == 0) { 697 - qla_uprintf(&uiter, "\n"); 698 - } 699 - qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]); 700 - } 701 - 702 - qla_uprintf(&uiter, "\n\nRISC GP2 Registers:"); 703 - for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) { 704 - if (cnt % 8 == 0) { 705 - qla_uprintf(&uiter, "\n"); 706 - } 707 - qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]); 708 - } 709 - 710 - qla_uprintf(&uiter, "\n\nRISC GP3 Registers:"); 711 - for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) { 712 - if (cnt % 8 == 0) { 713 - qla_uprintf(&uiter, "\n"); 714 - } 715 - qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]); 716 - } 717 - 718 - qla_uprintf(&uiter, "\n\nRISC GP4 Registers:"); 719 - for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) { 720 - if (cnt % 8 == 0) { 721 - qla_uprintf(&uiter, "\n"); 722 - } 723 - qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]); 724 - } 725 - 726 - qla_uprintf(&uiter, "\n\nRISC GP5 Registers:"); 727 - for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) { 728 - if (cnt % 8 == 0) { 729 - qla_uprintf(&uiter, "\n"); 730 - } 731 - qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]); 732 - } 733 - 734 - qla_uprintf(&uiter, "\n\nRISC GP6 Registers:"); 735 - for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) { 736 - if (cnt % 8 == 0) { 737 - qla_uprintf(&uiter, "\n"); 738 - } 739 - qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]); 740 - } 741 - 742 - qla_uprintf(&uiter, "\n\nRISC GP7 Registers:"); 743 - for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) { 744 - if (cnt % 8 == 0) { 745 - qla_uprintf(&uiter, "\n"); 746 - } 747 - qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]); 748 - } 749 - 750 - qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:"); 751 - for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) { 752 - if (cnt % 8 == 0) { 753 - qla_uprintf(&uiter, "\n"); 754 - } 755 - qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]); 756 - } 757 - 758 - qla_uprintf(&uiter, "\n\nFPM B0 Registers:"); 759 - for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) { 760 - if (cnt % 8 == 0) { 761 - qla_uprintf(&uiter, "\n"); 762 - } 763 - qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]); 764 - } 765 - 766 - qla_uprintf(&uiter, "\n\nFPM B1 Registers:"); 767 - for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) { 768 - if (cnt % 8 == 0) { 769 - qla_uprintf(&uiter, "\n"); 770 - } 771 - qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]); 772 - } 773 - 774 - qla_uprintf(&uiter, "\n\nRISC SRAM:"); 775 - for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) { 776 - if (cnt % 8 == 0) { 777 - qla_uprintf(&uiter, "\n%04x: ", cnt + 0x1000); 778 - } 779 - qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]); 780 - } 781 - 782 - qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump."); 783 - 784 - return; 785 - } 786 - 787 - static int 788 - qla_uprintf(char **uiter, char *fmt, ...) 789 - { 790 - int iter, len; 791 - char buf[128]; 792 - va_list args; 793 - 794 - va_start(args, fmt); 795 - len = vsprintf(buf, fmt, args); 796 - va_end(args); 797 - 798 - for (iter = 0; iter < len; iter++, *uiter += 1) 799 - *uiter[0] = buf[iter]; 800 - 801 - return (len); 802 - } 803 - 804 - 805 781 void 806 782 qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 807 783 { ··· 645 967 unsigned long flags; 646 968 struct qla24xx_fw_dump *fw; 647 969 uint32_t ext_mem_cnt; 970 + void *eft; 648 971 649 972 risc_address = ext_mem_cnt = 0; 650 973 memset(mb, 0, sizeof(mb)); ··· 666 987 "request...\n", ha->fw_dump); 667 988 goto qla24xx_fw_dump_failed; 668 989 } 669 - fw = ha->fw_dump; 990 + fw = &ha->fw_dump->isp.isp24; 991 + qla2xxx_prep_dump(ha, ha->fw_dump); 670 992 671 993 rval = QLA_SUCCESS; 672 - fw->host_status = RD_REG_DWORD(&reg->host_status); 994 + fw->host_status = htonl(RD_REG_DWORD(&reg->host_status)); 673 995 674 996 /* Pause RISC. */ 675 997 if ((RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE) == 0) { ··· 692 1012 /* Host interface registers. */ 693 1013 dmp_reg = (uint32_t __iomem *)(reg + 0); 694 1014 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) 695 - fw->host_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1015 + fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 696 1016 697 1017 /* Disable interrupts. */ 698 1018 WRT_REG_DWORD(&reg->ictrl, 0); ··· 704 1024 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 705 1025 WRT_REG_DWORD(dmp_reg, 0xB0000000); 706 1026 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 707 - fw->shadow_reg[0] = RD_REG_DWORD(dmp_reg); 1027 + fw->shadow_reg[0] = htonl(RD_REG_DWORD(dmp_reg)); 708 1028 709 1029 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 710 1030 WRT_REG_DWORD(dmp_reg, 0xB0100000); 711 1031 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 712 - fw->shadow_reg[1] = RD_REG_DWORD(dmp_reg); 1032 + fw->shadow_reg[1] = htonl(RD_REG_DWORD(dmp_reg)); 713 1033 714 1034 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 715 1035 WRT_REG_DWORD(dmp_reg, 0xB0200000); 716 1036 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 717 - fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg); 1037 + fw->shadow_reg[2] = htonl(RD_REG_DWORD(dmp_reg)); 718 1038 719 1039 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 720 1040 WRT_REG_DWORD(dmp_reg, 0xB0300000); 721 1041 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 722 - fw->shadow_reg[3] = RD_REG_DWORD(dmp_reg); 1042 + fw->shadow_reg[3] = htonl(RD_REG_DWORD(dmp_reg)); 723 1043 724 1044 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 725 1045 WRT_REG_DWORD(dmp_reg, 0xB0400000); 726 1046 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 727 - fw->shadow_reg[4] = RD_REG_DWORD(dmp_reg); 1047 + fw->shadow_reg[4] = htonl(RD_REG_DWORD(dmp_reg)); 728 1048 729 1049 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 730 1050 WRT_REG_DWORD(dmp_reg, 0xB0500000); 731 1051 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 732 - fw->shadow_reg[5] = RD_REG_DWORD(dmp_reg); 1052 + fw->shadow_reg[5] = htonl(RD_REG_DWORD(dmp_reg)); 733 1053 734 1054 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 735 1055 WRT_REG_DWORD(dmp_reg, 0xB0600000); 736 1056 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 737 - fw->shadow_reg[6] = RD_REG_DWORD(dmp_reg); 1057 + fw->shadow_reg[6] = htonl(RD_REG_DWORD(dmp_reg)); 738 1058 739 1059 /* Mailbox registers. */ 740 1060 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 741 1061 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 742 - fw->mailbox_reg[cnt] = RD_REG_WORD(mbx_reg++); 1062 + fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++)); 743 1063 744 1064 /* Transfer sequence registers. */ 745 1065 iter_reg = fw->xseq_gp_reg; 746 1066 WRT_REG_DWORD(&reg->iobase_addr, 0xBF00); 747 1067 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 748 1068 for (cnt = 0; cnt < 16; cnt++) 749 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1069 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 750 1070 751 1071 WRT_REG_DWORD(&reg->iobase_addr, 0xBF10); 752 1072 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 753 1073 for (cnt = 0; cnt < 16; cnt++) 754 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1074 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 755 1075 756 1076 WRT_REG_DWORD(&reg->iobase_addr, 0xBF20); 757 1077 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 758 1078 for (cnt = 0; cnt < 16; cnt++) 759 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1079 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 760 1080 761 1081 WRT_REG_DWORD(&reg->iobase_addr, 0xBF30); 762 1082 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 763 1083 for (cnt = 0; cnt < 16; cnt++) 764 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1084 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 765 1085 766 1086 WRT_REG_DWORD(&reg->iobase_addr, 0xBF40); 767 1087 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 768 1088 for (cnt = 0; cnt < 16; cnt++) 769 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1089 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 770 1090 771 1091 WRT_REG_DWORD(&reg->iobase_addr, 0xBF50); 772 1092 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 773 1093 for (cnt = 0; cnt < 16; cnt++) 774 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1094 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 775 1095 776 1096 WRT_REG_DWORD(&reg->iobase_addr, 0xBF60); 777 1097 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 778 1098 for (cnt = 0; cnt < 16; cnt++) 779 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1099 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 780 1100 781 1101 WRT_REG_DWORD(&reg->iobase_addr, 0xBF70); 782 1102 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 783 1103 for (cnt = 0; cnt < 16; cnt++) 784 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1104 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 785 1105 786 1106 WRT_REG_DWORD(&reg->iobase_addr, 0xBFE0); 787 1107 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 788 1108 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++) 789 - fw->xseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1109 + fw->xseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 790 1110 791 1111 WRT_REG_DWORD(&reg->iobase_addr, 0xBFF0); 792 1112 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 793 1113 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++) 794 - fw->xseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1114 + fw->xseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 795 1115 796 1116 /* Receive sequence registers. */ 797 1117 iter_reg = fw->rseq_gp_reg; 798 1118 WRT_REG_DWORD(&reg->iobase_addr, 0xFF00); 799 1119 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 800 1120 for (cnt = 0; cnt < 16; cnt++) 801 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1121 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 802 1122 803 1123 WRT_REG_DWORD(&reg->iobase_addr, 0xFF10); 804 1124 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 805 1125 for (cnt = 0; cnt < 16; cnt++) 806 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1126 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 807 1127 808 1128 WRT_REG_DWORD(&reg->iobase_addr, 0xFF20); 809 1129 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 810 1130 for (cnt = 0; cnt < 16; cnt++) 811 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1131 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 812 1132 813 1133 WRT_REG_DWORD(&reg->iobase_addr, 0xFF30); 814 1134 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 815 1135 for (cnt = 0; cnt < 16; cnt++) 816 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1136 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 817 1137 818 1138 WRT_REG_DWORD(&reg->iobase_addr, 0xFF40); 819 1139 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 820 1140 for (cnt = 0; cnt < 16; cnt++) 821 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1141 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 822 1142 823 1143 WRT_REG_DWORD(&reg->iobase_addr, 0xFF50); 824 1144 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 825 1145 for (cnt = 0; cnt < 16; cnt++) 826 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1146 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 827 1147 828 1148 WRT_REG_DWORD(&reg->iobase_addr, 0xFF60); 829 1149 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 830 1150 for (cnt = 0; cnt < 16; cnt++) 831 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1151 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 832 1152 833 1153 WRT_REG_DWORD(&reg->iobase_addr, 0xFF70); 834 1154 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 835 1155 for (cnt = 0; cnt < 16; cnt++) 836 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1156 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 837 1157 838 1158 WRT_REG_DWORD(&reg->iobase_addr, 0xFFD0); 839 1159 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 840 1160 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++) 841 - fw->rseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1161 + fw->rseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 842 1162 843 1163 WRT_REG_DWORD(&reg->iobase_addr, 0xFFE0); 844 1164 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 845 1165 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++) 846 - fw->rseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1166 + fw->rseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 847 1167 848 1168 WRT_REG_DWORD(&reg->iobase_addr, 0xFFF0); 849 1169 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 850 1170 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++) 851 - fw->rseq_2_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1171 + fw->rseq_2_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 852 1172 853 1173 /* Command DMA registers. */ 854 1174 WRT_REG_DWORD(&reg->iobase_addr, 0x7100); 855 1175 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 856 1176 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++) 857 - fw->cmd_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1177 + fw->cmd_dma_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 858 1178 859 1179 /* Queues. */ 860 1180 iter_reg = fw->req0_dma_reg; 861 1181 WRT_REG_DWORD(&reg->iobase_addr, 0x7200); 862 1182 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 863 1183 for (cnt = 0; cnt < 8; cnt++) 864 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1184 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 865 1185 866 1186 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 867 1187 for (cnt = 0; cnt < 7; cnt++) 868 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1188 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 869 1189 870 1190 iter_reg = fw->resp0_dma_reg; 871 1191 WRT_REG_DWORD(&reg->iobase_addr, 0x7300); 872 1192 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 873 1193 for (cnt = 0; cnt < 8; cnt++) 874 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1194 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 875 1195 876 1196 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 877 1197 for (cnt = 0; cnt < 7; cnt++) 878 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1198 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 879 1199 880 1200 iter_reg = fw->req1_dma_reg; 881 1201 WRT_REG_DWORD(&reg->iobase_addr, 0x7400); 882 1202 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 883 1203 for (cnt = 0; cnt < 8; cnt++) 884 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1204 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 885 1205 886 1206 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 887 1207 for (cnt = 0; cnt < 7; cnt++) 888 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1208 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 889 1209 890 1210 /* Transmit DMA registers. */ 891 1211 iter_reg = fw->xmt0_dma_reg; 892 1212 WRT_REG_DWORD(&reg->iobase_addr, 0x7600); 893 1213 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 894 1214 for (cnt = 0; cnt < 16; cnt++) 895 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1215 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 896 1216 897 1217 WRT_REG_DWORD(&reg->iobase_addr, 0x7610); 898 1218 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 899 1219 for (cnt = 0; cnt < 16; cnt++) 900 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1220 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 901 1221 902 1222 iter_reg = fw->xmt1_dma_reg; 903 1223 WRT_REG_DWORD(&reg->iobase_addr, 0x7620); 904 1224 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 905 1225 for (cnt = 0; cnt < 16; cnt++) 906 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1226 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 907 1227 908 1228 WRT_REG_DWORD(&reg->iobase_addr, 0x7630); 909 1229 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 910 1230 for (cnt = 0; cnt < 16; cnt++) 911 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1231 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 912 1232 913 1233 iter_reg = fw->xmt2_dma_reg; 914 1234 WRT_REG_DWORD(&reg->iobase_addr, 0x7640); 915 1235 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 916 1236 for (cnt = 0; cnt < 16; cnt++) 917 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1237 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 918 1238 919 1239 WRT_REG_DWORD(&reg->iobase_addr, 0x7650); 920 1240 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 921 1241 for (cnt = 0; cnt < 16; cnt++) 922 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1242 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 923 1243 924 1244 iter_reg = fw->xmt3_dma_reg; 925 1245 WRT_REG_DWORD(&reg->iobase_addr, 0x7660); 926 1246 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 927 1247 for (cnt = 0; cnt < 16; cnt++) 928 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1248 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 929 1249 930 1250 WRT_REG_DWORD(&reg->iobase_addr, 0x7670); 931 1251 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 932 1252 for (cnt = 0; cnt < 16; cnt++) 933 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1253 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 934 1254 935 1255 iter_reg = fw->xmt4_dma_reg; 936 1256 WRT_REG_DWORD(&reg->iobase_addr, 0x7680); 937 1257 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 938 1258 for (cnt = 0; cnt < 16; cnt++) 939 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1259 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 940 1260 941 1261 WRT_REG_DWORD(&reg->iobase_addr, 0x7690); 942 1262 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 943 1263 for (cnt = 0; cnt < 16; cnt++) 944 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1264 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 945 1265 946 1266 WRT_REG_DWORD(&reg->iobase_addr, 0x76A0); 947 1267 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 948 1268 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++) 949 - fw->xmt_data_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++); 1269 + fw->xmt_data_dma_reg[cnt] = 1270 + htonl(RD_REG_DWORD(dmp_reg++)); 950 1271 951 1272 /* Receive DMA registers. */ 952 1273 iter_reg = fw->rcvt0_data_dma_reg; 953 1274 WRT_REG_DWORD(&reg->iobase_addr, 0x7700); 954 1275 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 955 1276 for (cnt = 0; cnt < 16; cnt++) 956 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1277 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 957 1278 958 1279 WRT_REG_DWORD(&reg->iobase_addr, 0x7710); 959 1280 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 960 1281 for (cnt = 0; cnt < 16; cnt++) 961 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1282 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 962 1283 963 1284 iter_reg = fw->rcvt1_data_dma_reg; 964 1285 WRT_REG_DWORD(&reg->iobase_addr, 0x7720); 965 1286 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 966 1287 for (cnt = 0; cnt < 16; cnt++) 967 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1288 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 968 1289 969 1290 WRT_REG_DWORD(&reg->iobase_addr, 0x7730); 970 1291 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 971 1292 for (cnt = 0; cnt < 16; cnt++) 972 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1293 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 973 1294 974 1295 /* RISC registers. */ 975 1296 iter_reg = fw->risc_gp_reg; 976 1297 WRT_REG_DWORD(&reg->iobase_addr, 0x0F00); 977 1298 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 978 1299 for (cnt = 0; cnt < 16; cnt++) 979 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1300 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 980 1301 981 1302 WRT_REG_DWORD(&reg->iobase_addr, 0x0F10); 982 1303 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 983 1304 for (cnt = 0; cnt < 16; cnt++) 984 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1305 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 985 1306 986 1307 WRT_REG_DWORD(&reg->iobase_addr, 0x0F20); 987 1308 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 988 1309 for (cnt = 0; cnt < 16; cnt++) 989 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1310 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 990 1311 991 1312 WRT_REG_DWORD(&reg->iobase_addr, 0x0F30); 992 1313 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 993 1314 for (cnt = 0; cnt < 16; cnt++) 994 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1315 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 995 1316 996 1317 WRT_REG_DWORD(&reg->iobase_addr, 0x0F40); 997 1318 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 998 1319 for (cnt = 0; cnt < 16; cnt++) 999 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1320 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1000 1321 1001 1322 WRT_REG_DWORD(&reg->iobase_addr, 0x0F50); 1002 1323 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1003 1324 for (cnt = 0; cnt < 16; cnt++) 1004 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1325 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1005 1326 1006 1327 WRT_REG_DWORD(&reg->iobase_addr, 0x0F60); 1007 1328 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1008 1329 for (cnt = 0; cnt < 16; cnt++) 1009 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1330 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1010 1331 1011 1332 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70); 1012 1333 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1013 1334 for (cnt = 0; cnt < 16; cnt++) 1014 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1335 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1015 1336 1016 1337 /* Local memory controller registers. */ 1017 1338 iter_reg = fw->lmc_reg; 1018 1339 WRT_REG_DWORD(&reg->iobase_addr, 0x3000); 1019 1340 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1020 1341 for (cnt = 0; cnt < 16; cnt++) 1021 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1342 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1022 1343 1023 1344 WRT_REG_DWORD(&reg->iobase_addr, 0x3010); 1024 1345 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1025 1346 for (cnt = 0; cnt < 16; cnt++) 1026 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1347 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1027 1348 1028 1349 WRT_REG_DWORD(&reg->iobase_addr, 0x3020); 1029 1350 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1030 1351 for (cnt = 0; cnt < 16; cnt++) 1031 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1352 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1032 1353 1033 1354 WRT_REG_DWORD(&reg->iobase_addr, 0x3030); 1034 1355 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1035 1356 for (cnt = 0; cnt < 16; cnt++) 1036 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1357 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1037 1358 1038 1359 WRT_REG_DWORD(&reg->iobase_addr, 0x3040); 1039 1360 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1040 1361 for (cnt = 0; cnt < 16; cnt++) 1041 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1362 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1042 1363 1043 1364 WRT_REG_DWORD(&reg->iobase_addr, 0x3050); 1044 1365 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1045 1366 for (cnt = 0; cnt < 16; cnt++) 1046 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1367 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1047 1368 1048 1369 WRT_REG_DWORD(&reg->iobase_addr, 0x3060); 1049 1370 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1050 1371 for (cnt = 0; cnt < 16; cnt++) 1051 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1372 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1052 1373 1053 1374 /* Fibre Protocol Module registers. */ 1054 1375 iter_reg = fw->fpm_hdw_reg; 1055 1376 WRT_REG_DWORD(&reg->iobase_addr, 0x4000); 1056 1377 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1057 1378 for (cnt = 0; cnt < 16; cnt++) 1058 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1379 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1059 1380 1060 1381 WRT_REG_DWORD(&reg->iobase_addr, 0x4010); 1061 1382 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1062 1383 for (cnt = 0; cnt < 16; cnt++) 1063 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1384 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1064 1385 1065 1386 WRT_REG_DWORD(&reg->iobase_addr, 0x4020); 1066 1387 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1067 1388 for (cnt = 0; cnt < 16; cnt++) 1068 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1389 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1069 1390 1070 1391 WRT_REG_DWORD(&reg->iobase_addr, 0x4030); 1071 1392 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1072 1393 for (cnt = 0; cnt < 16; cnt++) 1073 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1394 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1074 1395 1075 1396 WRT_REG_DWORD(&reg->iobase_addr, 0x4040); 1076 1397 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1077 1398 for (cnt = 0; cnt < 16; cnt++) 1078 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1399 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1079 1400 1080 1401 WRT_REG_DWORD(&reg->iobase_addr, 0x4050); 1081 1402 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1082 1403 for (cnt = 0; cnt < 16; cnt++) 1083 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1404 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1084 1405 1085 1406 WRT_REG_DWORD(&reg->iobase_addr, 0x4060); 1086 1407 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1087 1408 for (cnt = 0; cnt < 16; cnt++) 1088 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1409 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1089 1410 1090 1411 WRT_REG_DWORD(&reg->iobase_addr, 0x4070); 1091 1412 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1092 1413 for (cnt = 0; cnt < 16; cnt++) 1093 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1414 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1094 1415 1095 1416 WRT_REG_DWORD(&reg->iobase_addr, 0x4080); 1096 1417 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1097 1418 for (cnt = 0; cnt < 16; cnt++) 1098 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1419 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1099 1420 1100 1421 WRT_REG_DWORD(&reg->iobase_addr, 0x4090); 1101 1422 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1102 1423 for (cnt = 0; cnt < 16; cnt++) 1103 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1424 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1104 1425 1105 1426 WRT_REG_DWORD(&reg->iobase_addr, 0x40A0); 1106 1427 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1107 1428 for (cnt = 0; cnt < 16; cnt++) 1108 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1429 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1109 1430 1110 1431 WRT_REG_DWORD(&reg->iobase_addr, 0x40B0); 1111 1432 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1112 1433 for (cnt = 0; cnt < 16; cnt++) 1113 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1434 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1114 1435 1115 1436 /* Frame Buffer registers. */ 1116 1437 iter_reg = fw->fb_hdw_reg; 1117 1438 WRT_REG_DWORD(&reg->iobase_addr, 0x6000); 1118 1439 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1119 1440 for (cnt = 0; cnt < 16; cnt++) 1120 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1441 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1121 1442 1122 1443 WRT_REG_DWORD(&reg->iobase_addr, 0x6010); 1123 1444 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1124 1445 for (cnt = 0; cnt < 16; cnt++) 1125 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1446 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1126 1447 1127 1448 WRT_REG_DWORD(&reg->iobase_addr, 0x6020); 1128 1449 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1129 1450 for (cnt = 0; cnt < 16; cnt++) 1130 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1451 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1131 1452 1132 1453 WRT_REG_DWORD(&reg->iobase_addr, 0x6030); 1133 1454 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1134 1455 for (cnt = 0; cnt < 16; cnt++) 1135 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1456 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1136 1457 1137 1458 WRT_REG_DWORD(&reg->iobase_addr, 0x6040); 1138 1459 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1139 1460 for (cnt = 0; cnt < 16; cnt++) 1140 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1461 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1141 1462 1142 1463 WRT_REG_DWORD(&reg->iobase_addr, 0x6100); 1143 1464 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1144 1465 for (cnt = 0; cnt < 16; cnt++) 1145 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1466 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1146 1467 1147 1468 WRT_REG_DWORD(&reg->iobase_addr, 0x6130); 1148 1469 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1149 1470 for (cnt = 0; cnt < 16; cnt++) 1150 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1471 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1151 1472 1152 1473 WRT_REG_DWORD(&reg->iobase_addr, 0x6150); 1153 1474 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1154 1475 for (cnt = 0; cnt < 16; cnt++) 1155 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1476 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1156 1477 1157 1478 WRT_REG_DWORD(&reg->iobase_addr, 0x6170); 1158 1479 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1159 1480 for (cnt = 0; cnt < 16; cnt++) 1160 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1481 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1161 1482 1162 1483 WRT_REG_DWORD(&reg->iobase_addr, 0x6190); 1163 1484 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1164 1485 for (cnt = 0; cnt < 16; cnt++) 1165 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1486 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1166 1487 1167 1488 WRT_REG_DWORD(&reg->iobase_addr, 0x61B0); 1168 1489 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1169 1490 for (cnt = 0; cnt < 16; cnt++) 1170 - *iter_reg++ = RD_REG_DWORD(dmp_reg++); 1491 + *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1171 1492 1172 1493 /* Reset RISC. */ 1173 1494 WRT_REG_DWORD(&reg->ctrl_status, ··· 1258 1577 1259 1578 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 1260 1579 rval = mb[0] & MBS_MASK; 1261 - fw->code_ram[cnt] = (mb[3] << 16) | mb[2]; 1580 + fw->code_ram[cnt] = htonl((mb[3] << 16) | mb[2]); 1262 1581 } else { 1263 1582 rval = QLA_FUNCTION_FAILED; 1264 1583 } ··· 1308 1627 1309 1628 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 1310 1629 rval = mb[0] & MBS_MASK; 1311 - fw->ext_mem[cnt] = (mb[3] << 16) | mb[2]; 1630 + fw->ext_mem[cnt] = htonl((mb[3] << 16) | mb[2]); 1312 1631 } else { 1313 1632 rval = QLA_FUNCTION_FAILED; 1314 1633 } 1634 + } 1635 + 1636 + if (rval == QLA_SUCCESS) { 1637 + eft = qla2xxx_copy_queues(ha, &fw->ext_mem[cnt]); 1638 + if (ha->eft) 1639 + memcpy(eft, ha->eft, ntohl(ha->fw_dump->eft_size)); 1315 1640 } 1316 1641 1317 1642 if (rval != QLA_SUCCESS) { ··· 1336 1649 if (!hardware_locked) 1337 1650 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1338 1651 } 1339 - 1340 - void 1341 - qla24xx_ascii_fw_dump(scsi_qla_host_t *ha) 1342 - { 1343 - uint32_t cnt; 1344 - char *uiter; 1345 - struct qla24xx_fw_dump *fw; 1346 - uint32_t ext_mem_cnt; 1347 - 1348 - uiter = ha->fw_dump_buffer; 1349 - fw = ha->fw_dump; 1350 - 1351 - qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n", 1352 - ha->fw_major_version, ha->fw_minor_version, 1353 - ha->fw_subminor_version, ha->fw_attributes); 1354 - 1355 - qla_uprintf(&uiter, "\nR2H Status Register\n%04x\n", fw->host_status); 1356 - 1357 - qla_uprintf(&uiter, "\nHost Interface Registers"); 1358 - for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) { 1359 - if (cnt % 8 == 0) 1360 - qla_uprintf(&uiter, "\n"); 1361 - 1362 - qla_uprintf(&uiter, "%08x ", fw->host_reg[cnt]); 1363 - } 1364 - 1365 - qla_uprintf(&uiter, "\n\nShadow Registers"); 1366 - for (cnt = 0; cnt < sizeof(fw->shadow_reg) / 4; cnt++) { 1367 - if (cnt % 8 == 0) 1368 - qla_uprintf(&uiter, "\n"); 1369 - 1370 - qla_uprintf(&uiter, "%08x ", fw->shadow_reg[cnt]); 1371 - } 1372 - 1373 - qla_uprintf(&uiter, "\n\nMailbox Registers"); 1374 - for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) { 1375 - if (cnt % 8 == 0) 1376 - qla_uprintf(&uiter, "\n"); 1377 - 1378 - qla_uprintf(&uiter, "%08x ", fw->mailbox_reg[cnt]); 1379 - } 1380 - 1381 - qla_uprintf(&uiter, "\n\nXSEQ GP Registers"); 1382 - for (cnt = 0; cnt < sizeof(fw->xseq_gp_reg) / 4; cnt++) { 1383 - if (cnt % 8 == 0) 1384 - qla_uprintf(&uiter, "\n"); 1385 - 1386 - qla_uprintf(&uiter, "%08x ", fw->xseq_gp_reg[cnt]); 1387 - } 1388 - 1389 - qla_uprintf(&uiter, "\n\nXSEQ-0 Registers"); 1390 - for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++) { 1391 - if (cnt % 8 == 0) 1392 - qla_uprintf(&uiter, "\n"); 1393 - 1394 - qla_uprintf(&uiter, "%08x ", fw->xseq_0_reg[cnt]); 1395 - } 1396 - 1397 - qla_uprintf(&uiter, "\n\nXSEQ-1 Registers"); 1398 - for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++) { 1399 - if (cnt % 8 == 0) 1400 - qla_uprintf(&uiter, "\n"); 1401 - 1402 - qla_uprintf(&uiter, "%08x ", fw->xseq_1_reg[cnt]); 1403 - } 1404 - 1405 - qla_uprintf(&uiter, "\n\nRSEQ GP Registers"); 1406 - for (cnt = 0; cnt < sizeof(fw->rseq_gp_reg) / 4; cnt++) { 1407 - if (cnt % 8 == 0) 1408 - qla_uprintf(&uiter, "\n"); 1409 - 1410 - qla_uprintf(&uiter, "%08x ", fw->rseq_gp_reg[cnt]); 1411 - } 1412 - 1413 - qla_uprintf(&uiter, "\n\nRSEQ-0 Registers"); 1414 - for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++) { 1415 - if (cnt % 8 == 0) 1416 - qla_uprintf(&uiter, "\n"); 1417 - 1418 - qla_uprintf(&uiter, "%08x ", fw->rseq_0_reg[cnt]); 1419 - } 1420 - 1421 - qla_uprintf(&uiter, "\n\nRSEQ-1 Registers"); 1422 - for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++) { 1423 - if (cnt % 8 == 0) 1424 - qla_uprintf(&uiter, "\n"); 1425 - 1426 - qla_uprintf(&uiter, "%08x ", fw->rseq_1_reg[cnt]); 1427 - } 1428 - 1429 - qla_uprintf(&uiter, "\n\nRSEQ-2 Registers"); 1430 - for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++) { 1431 - if (cnt % 8 == 0) 1432 - qla_uprintf(&uiter, "\n"); 1433 - 1434 - qla_uprintf(&uiter, "%08x ", fw->rseq_2_reg[cnt]); 1435 - } 1436 - 1437 - qla_uprintf(&uiter, "\n\nCommand DMA Registers"); 1438 - for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++) { 1439 - if (cnt % 8 == 0) 1440 - qla_uprintf(&uiter, "\n"); 1441 - 1442 - qla_uprintf(&uiter, "%08x ", fw->cmd_dma_reg[cnt]); 1443 - } 1444 - 1445 - qla_uprintf(&uiter, "\n\nRequest0 Queue DMA Channel Registers"); 1446 - for (cnt = 0; cnt < sizeof(fw->req0_dma_reg) / 4; cnt++) { 1447 - if (cnt % 8 == 0) 1448 - qla_uprintf(&uiter, "\n"); 1449 - 1450 - qla_uprintf(&uiter, "%08x ", fw->req0_dma_reg[cnt]); 1451 - } 1452 - 1453 - qla_uprintf(&uiter, "\n\nResponse0 Queue DMA Channel Registers"); 1454 - for (cnt = 0; cnt < sizeof(fw->resp0_dma_reg) / 4; cnt++) { 1455 - if (cnt % 8 == 0) 1456 - qla_uprintf(&uiter, "\n"); 1457 - 1458 - qla_uprintf(&uiter, "%08x ", fw->resp0_dma_reg[cnt]); 1459 - } 1460 - 1461 - qla_uprintf(&uiter, "\n\nRequest1 Queue DMA Channel Registers"); 1462 - for (cnt = 0; cnt < sizeof(fw->req1_dma_reg) / 4; cnt++) { 1463 - if (cnt % 8 == 0) 1464 - qla_uprintf(&uiter, "\n"); 1465 - 1466 - qla_uprintf(&uiter, "%08x ", fw->req1_dma_reg[cnt]); 1467 - } 1468 - 1469 - qla_uprintf(&uiter, "\n\nXMT0 Data DMA Registers"); 1470 - for (cnt = 0; cnt < sizeof(fw->xmt0_dma_reg) / 4; cnt++) { 1471 - if (cnt % 8 == 0) 1472 - qla_uprintf(&uiter, "\n"); 1473 - 1474 - qla_uprintf(&uiter, "%08x ", fw->xmt0_dma_reg[cnt]); 1475 - } 1476 - 1477 - qla_uprintf(&uiter, "\n\nXMT1 Data DMA Registers"); 1478 - for (cnt = 0; cnt < sizeof(fw->xmt1_dma_reg) / 4; cnt++) { 1479 - if (cnt % 8 == 0) 1480 - qla_uprintf(&uiter, "\n"); 1481 - 1482 - qla_uprintf(&uiter, "%08x ", fw->xmt1_dma_reg[cnt]); 1483 - } 1484 - 1485 - qla_uprintf(&uiter, "\n\nXMT2 Data DMA Registers"); 1486 - for (cnt = 0; cnt < sizeof(fw->xmt2_dma_reg) / 4; cnt++) { 1487 - if (cnt % 8 == 0) 1488 - qla_uprintf(&uiter, "\n"); 1489 - 1490 - qla_uprintf(&uiter, "%08x ", fw->xmt2_dma_reg[cnt]); 1491 - } 1492 - 1493 - qla_uprintf(&uiter, "\n\nXMT3 Data DMA Registers"); 1494 - for (cnt = 0; cnt < sizeof(fw->xmt3_dma_reg) / 4; cnt++) { 1495 - if (cnt % 8 == 0) 1496 - qla_uprintf(&uiter, "\n"); 1497 - 1498 - qla_uprintf(&uiter, "%08x ", fw->xmt3_dma_reg[cnt]); 1499 - } 1500 - 1501 - qla_uprintf(&uiter, "\n\nXMT4 Data DMA Registers"); 1502 - for (cnt = 0; cnt < sizeof(fw->xmt4_dma_reg) / 4; cnt++) { 1503 - if (cnt % 8 == 0) 1504 - qla_uprintf(&uiter, "\n"); 1505 - 1506 - qla_uprintf(&uiter, "%08x ", fw->xmt4_dma_reg[cnt]); 1507 - } 1508 - 1509 - qla_uprintf(&uiter, "\n\nXMT Data DMA Common Registers"); 1510 - for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++) { 1511 - if (cnt % 8 == 0) 1512 - qla_uprintf(&uiter, "\n"); 1513 - 1514 - qla_uprintf(&uiter, "%08x ", fw->xmt_data_dma_reg[cnt]); 1515 - } 1516 - 1517 - qla_uprintf(&uiter, "\n\nRCV Thread 0 Data DMA Registers"); 1518 - for (cnt = 0; cnt < sizeof(fw->rcvt0_data_dma_reg) / 4; cnt++) { 1519 - if (cnt % 8 == 0) 1520 - qla_uprintf(&uiter, "\n"); 1521 - 1522 - qla_uprintf(&uiter, "%08x ", fw->rcvt0_data_dma_reg[cnt]); 1523 - } 1524 - 1525 - qla_uprintf(&uiter, "\n\nRCV Thread 1 Data DMA Registers"); 1526 - for (cnt = 0; cnt < sizeof(fw->rcvt1_data_dma_reg) / 4; cnt++) { 1527 - if (cnt % 8 == 0) 1528 - qla_uprintf(&uiter, "\n"); 1529 - 1530 - qla_uprintf(&uiter, "%08x ", fw->rcvt1_data_dma_reg[cnt]); 1531 - } 1532 - 1533 - qla_uprintf(&uiter, "\n\nRISC GP Registers"); 1534 - for (cnt = 0; cnt < sizeof(fw->risc_gp_reg) / 4; cnt++) { 1535 - if (cnt % 8 == 0) 1536 - qla_uprintf(&uiter, "\n"); 1537 - 1538 - qla_uprintf(&uiter, "%08x ", fw->risc_gp_reg[cnt]); 1539 - } 1540 - 1541 - qla_uprintf(&uiter, "\n\nLMC Registers"); 1542 - for (cnt = 0; cnt < sizeof(fw->lmc_reg) / 4; cnt++) { 1543 - if (cnt % 8 == 0) 1544 - qla_uprintf(&uiter, "\n"); 1545 - 1546 - qla_uprintf(&uiter, "%08x ", fw->lmc_reg[cnt]); 1547 - } 1548 - 1549 - qla_uprintf(&uiter, "\n\nFPM Hardware Registers"); 1550 - for (cnt = 0; cnt < sizeof(fw->fpm_hdw_reg) / 4; cnt++) { 1551 - if (cnt % 8 == 0) 1552 - qla_uprintf(&uiter, "\n"); 1553 - 1554 - qla_uprintf(&uiter, "%08x ", fw->fpm_hdw_reg[cnt]); 1555 - } 1556 - 1557 - qla_uprintf(&uiter, "\n\nFB Hardware Registers"); 1558 - for (cnt = 0; cnt < sizeof(fw->fb_hdw_reg) / 4; cnt++) { 1559 - if (cnt % 8 == 0) 1560 - qla_uprintf(&uiter, "\n"); 1561 - 1562 - qla_uprintf(&uiter, "%08x ", fw->fb_hdw_reg[cnt]); 1563 - } 1564 - 1565 - qla_uprintf(&uiter, "\n\nCode RAM"); 1566 - for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) { 1567 - if (cnt % 8 == 0) { 1568 - qla_uprintf(&uiter, "\n%08x: ", cnt + 0x20000); 1569 - } 1570 - qla_uprintf(&uiter, "%08x ", fw->code_ram[cnt]); 1571 - } 1572 - 1573 - qla_uprintf(&uiter, "\n\nExternal Memory"); 1574 - ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1; 1575 - for (cnt = 0; cnt < ext_mem_cnt; cnt++) { 1576 - if (cnt % 8 == 0) { 1577 - qla_uprintf(&uiter, "\n%08x: ", cnt + 0x100000); 1578 - } 1579 - qla_uprintf(&uiter, "%08x ", fw->ext_mem[cnt]); 1580 - } 1581 - 1582 - qla_uprintf(&uiter, "\n[<==END] ISP Debug Dump"); 1583 - } 1584 - 1585 1652 1586 1653 /****************************************************************************/ 1587 1654 /* Driver Debug Functions. */
+67 -84
drivers/scsi/qla2xxx/qla_dbg.h
··· 37 37 /* 38 38 * Macros use for debugging the driver. 39 39 */ 40 - #undef ENTER_TRACE 41 - #if defined(ENTER_TRACE) 42 - #define ENTER(x) do { printk("qla2100 : Entering %s()\n", x); } while (0) 43 - #define LEAVE(x) do { printk("qla2100 : Leaving %s()\n", x); } while (0) 44 - #define ENTER_INTR(x) do { printk("qla2100 : Entering %s()\n", x); } while (0) 45 - #define LEAVE_INTR(x) do { printk("qla2100 : Leaving %s()\n", x); } while (0) 46 - #else 47 - #define ENTER(x) do {} while (0) 48 - #define LEAVE(x) do {} while (0) 49 - #define ENTER_INTR(x) do {} while (0) 50 - #define LEAVE_INTR(x) do {} while (0) 51 - #endif 52 40 53 - #if DEBUG_QLA2100 54 - #define DEBUG(x) do {x;} while (0); 55 - #else 56 - #define DEBUG(x) do {} while (0); 57 - #endif 41 + #define DEBUG(x) do { if (extended_error_logging) { x; } } while (0) 58 42 59 43 #if defined(QL_DEBUG_LEVEL_1) 60 - #define DEBUG1(x) do {x;} while (0); 44 + #define DEBUG1(x) do {x;} while (0) 61 45 #else 62 - #define DEBUG1(x) do {} while (0); 46 + #define DEBUG1(x) do {} while (0) 63 47 #endif 64 48 65 - #if defined(QL_DEBUG_LEVEL_2) 66 - #define DEBUG2(x) do {x;} while (0); 67 - #define DEBUG2_3(x) do {x;} while (0); 68 - #define DEBUG2_3_11(x) do {x;} while (0); 69 - #define DEBUG2_9_10(x) do {x;} while (0); 70 - #define DEBUG2_11(x) do {x;} while (0); 71 - #define DEBUG2_13(x) do {x;} while (0); 72 - #else 73 - #define DEBUG2(x) do {} while (0); 74 - #endif 49 + #define DEBUG2(x) do { if (extended_error_logging) { x; } } while (0) 50 + #define DEBUG2_3(x) do { if (extended_error_logging) { x; } } while (0) 51 + #define DEBUG2_3_11(x) do { if (extended_error_logging) { x; } } while (0) 52 + #define DEBUG2_9_10(x) do { if (extended_error_logging) { x; } } while (0) 53 + #define DEBUG2_11(x) do { if (extended_error_logging) { x; } } while (0) 54 + #define DEBUG2_13(x) do { if (extended_error_logging) { x; } } while (0) 75 55 76 56 #if defined(QL_DEBUG_LEVEL_3) 77 - #define DEBUG3(x) do {x;} while (0); 78 - #define DEBUG2_3(x) do {x;} while (0); 79 - #define DEBUG2_3_11(x) do {x;} while (0); 80 - #define DEBUG3_11(x) do {x;} while (0); 57 + #define DEBUG3(x) do {x;} while (0) 58 + #define DEBUG3_11(x) do {x;} while (0) 81 59 #else 82 - #define DEBUG3(x) do {} while (0); 83 - #if !defined(QL_DEBUG_LEVEL_2) 84 - #define DEBUG2_3(x) do {} while (0); 85 - #endif 60 + #define DEBUG3(x) do {} while (0) 86 61 #endif 87 62 88 63 #if defined(QL_DEBUG_LEVEL_4) 89 - #define DEBUG4(x) do {x;} while (0); 64 + #define DEBUG4(x) do {x;} while (0) 90 65 #else 91 - #define DEBUG4(x) do {} while (0); 66 + #define DEBUG4(x) do {} while (0) 92 67 #endif 93 68 94 69 #if defined(QL_DEBUG_LEVEL_5) 95 - #define DEBUG5(x) do {x;} while (0); 70 + #define DEBUG5(x) do {x;} while (0) 96 71 #else 97 - #define DEBUG5(x) do {} while (0); 72 + #define DEBUG5(x) do {} while (0) 98 73 #endif 99 74 100 75 #if defined(QL_DEBUG_LEVEL_7) 101 - #define DEBUG7(x) do {x;} while (0); 76 + #define DEBUG7(x) do {x;} while (0) 102 77 #else 103 - #define DEBUG7(x) do {} while (0); 78 + #define DEBUG7(x) do {} while (0) 104 79 #endif 105 80 106 81 #if defined(QL_DEBUG_LEVEL_9) 107 - #define DEBUG9(x) do {x;} while (0); 108 - #define DEBUG9_10(x) do {x;} while (0); 109 - #define DEBUG2_9_10(x) do {x;} while (0); 82 + #define DEBUG9(x) do {x;} while (0) 83 + #define DEBUG9_10(x) do {x;} while (0) 110 84 #else 111 - #define DEBUG9(x) do {} while (0); 85 + #define DEBUG9(x) do {} while (0) 112 86 #endif 113 87 114 88 #if defined(QL_DEBUG_LEVEL_10) 115 - #define DEBUG10(x) do {x;} while (0); 116 - #define DEBUG2_9_10(x) do {x;} while (0); 117 - #define DEBUG9_10(x) do {x;} while (0); 89 + #define DEBUG10(x) do {x;} while (0) 90 + #define DEBUG9_10(x) do {x;} while (0) 118 91 #else 119 - #define DEBUG10(x) do {} while (0); 120 - #if !defined(DEBUG2_9_10) 121 - #define DEBUG2_9_10(x) do {} while (0); 122 - #endif 92 + #define DEBUG10(x) do {} while (0) 123 93 #if !defined(DEBUG9_10) 124 - #define DEBUG9_10(x) do {} while (0); 94 + #define DEBUG9_10(x) do {} while (0) 125 95 #endif 126 96 #endif 127 97 128 98 #if defined(QL_DEBUG_LEVEL_11) 129 - #define DEBUG11(x) do{x;} while(0); 130 - #if !defined(DEBUG2_11) 131 - #define DEBUG2_11(x) do{x;} while(0); 132 - #endif 133 - #if !defined(DEBUG2_3_11) 134 - #define DEBUG2_3_11(x) do{x;} while(0); 135 - #endif 99 + #define DEBUG11(x) do{x;} while(0) 136 100 #if !defined(DEBUG3_11) 137 - #define DEBUG3_11(x) do{x;} while(0); 101 + #define DEBUG3_11(x) do{x;} while(0) 138 102 #endif 139 103 #else 140 - #define DEBUG11(x) do{} while(0); 141 - #if !defined(QL_DEBUG_LEVEL_2) 142 - #define DEBUG2_11(x) do{} while(0); 143 - #if !defined(QL_DEBUG_LEVEL_3) 144 - #define DEBUG2_3_11(x) do{} while(0); 145 - #endif 146 - #endif 104 + #define DEBUG11(x) do{} while(0) 147 105 #if !defined(QL_DEBUG_LEVEL_3) 148 - #define DEBUG3_11(x) do{} while(0); 106 + #define DEBUG3_11(x) do{} while(0) 149 107 #endif 150 108 #endif 151 109 152 110 #if defined(QL_DEBUG_LEVEL_12) 153 - #define DEBUG12(x) do {x;} while (0); 111 + #define DEBUG12(x) do {x;} while (0) 154 112 #else 155 - #define DEBUG12(x) do {} while (0); 113 + #define DEBUG12(x) do {} while (0) 156 114 #endif 157 115 158 116 #if defined(QL_DEBUG_LEVEL_13) 159 117 #define DEBUG13(x) do {x;} while (0) 160 - #if !defined(DEBUG2_13) 161 - #define DEBUG2_13(x) do {x;} while(0) 162 - #endif 163 118 #else 164 119 #define DEBUG13(x) do {} while (0) 165 - #if !defined(QL_DEBUG_LEVEL_2) 166 - #define DEBUG2_13(x) do {} while(0) 167 - #endif 168 120 #endif 169 121 170 122 #if defined(QL_DEBUG_LEVEL_14) ··· 128 176 /* 129 177 * Firmware Dump structure definition 130 178 */ 131 - #define FW_DUMP_SIZE_128K 0xBC000 132 - #define FW_DUMP_SIZE_512K 0x2FC000 133 - #define FW_DUMP_SIZE_1M 0x5FC000 134 179 135 180 struct qla2300_fw_dump { 136 181 uint16_t hccr; ··· 173 224 uint16_t risc_ram[0xf000]; 174 225 }; 175 226 176 - #define FW_DUMP_SIZE_24XX 0x2B0000 177 - 178 227 struct qla24xx_fw_dump { 179 228 uint32_t host_status; 180 229 uint32_t host_reg[32]; ··· 203 256 uint32_t fb_hdw_reg[176]; 204 257 uint32_t code_ram[0x2000]; 205 258 uint32_t ext_mem[1]; 259 + }; 260 + 261 + #define EFT_NUM_BUFFERS 4 262 + #define EFT_BYTES_PER_BUFFER 0x4000 263 + #define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS)) 264 + 265 + struct qla2xxx_fw_dump { 266 + uint8_t signature[4]; 267 + uint32_t version; 268 + 269 + uint32_t fw_major_version; 270 + uint32_t fw_minor_version; 271 + uint32_t fw_subminor_version; 272 + uint32_t fw_attributes; 273 + 274 + uint32_t vendor; 275 + uint32_t device; 276 + uint32_t subsystem_vendor; 277 + uint32_t subsystem_device; 278 + 279 + uint32_t fixed_size; 280 + uint32_t mem_size; 281 + uint32_t req_q_size; 282 + uint32_t rsp_q_size; 283 + 284 + uint32_t eft_size; 285 + uint32_t eft_addr_l; 286 + uint32_t eft_addr_h; 287 + 288 + uint32_t header_size; 289 + 290 + union { 291 + struct qla2100_fw_dump isp21; 292 + struct qla2300_fw_dump isp23; 293 + struct qla24xx_fw_dump isp24; 294 + } isp; 206 295 };
+15 -4
drivers/scsi/qla2xxx/qla_def.h
··· 608 608 #define MBC_SERDES_PARAMS 0x10 /* Serdes Tx Parameters. */ 609 609 #define MBC_GET_IOCB_STATUS 0x12 /* Get IOCB status command. */ 610 610 #define MBC_GET_TIMEOUT_PARAMS 0x22 /* Get FW timeouts. */ 611 + #define MBC_TRACE_CONTROL 0x27 /* Trace control command. */ 611 612 #define MBC_GEN_SYSTEM_ERROR 0x2a /* Generate System Error. */ 613 + #define MBC_READ_SFP 0x31 /* Read SFP Data. */ 612 614 #define MBC_SET_TIMEOUT_PARAMS 0x32 /* Set FW timeouts. */ 613 615 #define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */ 614 616 #define MBC_MID_GET_VP_DATABASE 0x49 /* MID Get VP Database. */ ··· 619 617 #define MBC_SEND_RNFT_ELS 0x5e /* Send RNFT ELS request */ 620 618 #define MBC_GET_LINK_PRIV_STATS 0x6d /* Get link & private data. */ 621 619 #define MBC_SET_VENDOR_ID 0x76 /* Set Vendor ID. */ 620 + 621 + #define TC_ENABLE 4 622 + #define TC_DISABLE 5 622 623 623 624 /* Firmware return data sizes */ 624 625 #define FCAL_MAP_SIZE 128 ··· 2002 1997 uint32_t); 2003 1998 2004 1999 void (*fw_dump) (struct scsi_qla_host *, int); 2005 - void (*ascii_fw_dump) (struct scsi_qla_host *); 2006 2000 2007 2001 int (*beacon_on) (struct scsi_qla_host *); 2008 2002 int (*beacon_off) (struct scsi_qla_host *); ··· 2045 2041 uint32_t enable_led_scheme :1; 2046 2042 uint32_t msi_enabled :1; 2047 2043 uint32_t msix_enabled :1; 2044 + uint32_t disable_serdes :1; 2048 2045 } flags; 2049 2046 2050 2047 atomic_t loop_state; ··· 2243 2238 struct sns_cmd_pkt *sns_cmd; 2244 2239 dma_addr_t sns_cmd_dma; 2245 2240 2241 + #define SFP_DEV_SIZE 256 2242 + #define SFP_BLOCK_SIZE 64 2243 + void *sfp_data; 2244 + dma_addr_t sfp_data_dma; 2245 + 2246 2246 struct task_struct *dpc_thread; 2247 2247 uint8_t dpc_active; /* DPC routine is active */ 2248 2248 ··· 2313 2303 uint16_t fw_seriallink_options24[4]; 2314 2304 2315 2305 /* Firmware dump information. */ 2316 - void *fw_dump; 2306 + struct qla2xxx_fw_dump *fw_dump; 2307 + uint32_t fw_dump_len; 2317 2308 int fw_dumped; 2318 2309 int fw_dump_reading; 2319 - char *fw_dump_buffer; 2320 - int fw_dump_buffer_len; 2310 + dma_addr_t eft_dma; 2311 + void *eft; 2321 2312 2322 2313 uint8_t host_str[16]; 2323 2314 uint32_t pci_attr;
+15 -2
drivers/scsi/qla2xxx/qla_devtbl.h
··· 1 - #define QLA_MODEL_NAMES 0x4A 1 + #define QLA_MODEL_NAMES 0x57 2 2 3 3 /* 4 4 * Adapter model names and descriptions. ··· 76 76 "QLE2440", "PCI-Express to 4Gb FC, Single Channel", /* 0x145 */ 77 77 "QLE2464", "PCI-Express to 4Gb FC, Quad Channel", /* 0x146 */ 78 78 "QLA2440", "PCI-X 2.0 to 4Gb FC, Single Channel", /* 0x147 */ 79 - " ", " ", /* 0x148 */ 79 + "HP AE369A", "PCI-X 2.0 to 4Gb FC, Dual Channel", /* 0x148 */ 80 80 "QLA2340", "Sun 133MHz PCI-X to 2Gb FC, Single Channel", /* 0x149 */ 81 + " ", " ", /* 0x14a */ 82 + " ", " ", /* 0x14b */ 83 + "QMC2432M", "IBM eServer BC 4Gb FC Expansion Card CFFE", /* 0x14c */ 84 + "QMC2422M", "IBM eServer BC 4Gb FC Expansion Card CFFX", /* 0x14d */ 85 + "QLE220", "Sun PCI-Express to 4Gb FC, Single Channel", /* 0x14e */ 86 + " ", " ", /* 0x14f */ 87 + " ", " ", /* 0x150 */ 88 + " ", " ", /* 0x151 */ 89 + "QME2462", "PCI-Express to 4Gb FC, Dual Channel Mezz HBA", /* 0x152 */ 90 + "QMH2462", "PCI-Express to 4Gb FC, Dual Channel Mezz HBA", /* 0x153 */ 91 + " ", " ", /* 0x154 */ 92 + "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x155 */ 93 + "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x156 */ 81 94 };
+2 -2
drivers/scsi/qla2xxx/qla_fw.h
··· 141 141 * BIT 2 = Enable Memory Map BIOS 142 142 * BIT 3 = Enable Selectable Boot 143 143 * BIT 4 = Disable RISC code load 144 - * BIT 5 = 144 + * BIT 5 = Disable Serdes 145 145 * BIT 6 = 146 146 * BIT 7 = 147 147 * ··· 278 278 uint16_t response_q_length; 279 279 uint16_t request_q_length; 280 280 281 - uint16_t link_down_timeout; /* Milliseconds. */ 281 + uint16_t link_down_on_nos; /* Milliseconds. */ 282 282 283 283 uint16_t prio_request_q_length; 284 284
+10 -16
drivers/scsi/qla2xxx/qla_gbl.h
··· 31 31 extern void qla24xx_update_fw_options(scsi_qla_host_t *); 32 32 extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); 33 33 extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *); 34 - extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *); 35 - 36 - extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t); 37 34 38 35 extern int qla2x00_loop_resync(scsi_qla_host_t *); 39 36 40 - extern int qla2x00_find_new_loop_id(scsi_qla_host_t *, fc_port_t *); 41 37 extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *); 42 38 extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *); 43 39 ··· 47 51 extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); 48 52 extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 49 53 54 + extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *); 55 + 50 56 /* 51 57 * Global Data in qla_os.c source file. 52 58 */ ··· 59 61 extern int ql2xplogiabsentdevice; 60 62 extern int ql2xloginretrycount; 61 63 extern int ql2xfdmienable; 64 + extern int ql2xallocfwdump; 65 + extern int extended_error_logging; 62 66 63 67 extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 64 68 ··· 80 80 /* 81 81 * Global Function Prototypes in qla_iocb.c source file. 82 82 */ 83 - extern void qla2x00_isp_cmd(scsi_qla_host_t *); 84 - 85 83 extern uint16_t qla2x00_calc_iocbs_32(uint16_t); 86 84 extern uint16_t qla2x00_calc_iocbs_64(uint16_t); 87 85 extern void qla2x00_build_scsi_iocbs_32(srb_t *, cmd_entry_t *, uint16_t); ··· 202 204 extern int 203 205 qla2x00_stop_firmware(scsi_qla_host_t *); 204 206 207 + extern int 208 + qla2x00_trace_control(scsi_qla_host_t *, uint16_t, dma_addr_t, uint16_t); 209 + 210 + extern int 211 + qla2x00_read_sfp(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t, uint16_t); 212 + 205 213 /* 206 214 * Global Function Prototypes in qla_isr.c source file. 207 215 */ ··· 258 254 extern void qla2100_fw_dump(scsi_qla_host_t *, int); 259 255 extern void qla2300_fw_dump(scsi_qla_host_t *, int); 260 256 extern void qla24xx_fw_dump(scsi_qla_host_t *, int); 261 - extern void qla2100_ascii_fw_dump(scsi_qla_host_t *); 262 - extern void qla2300_ascii_fw_dump(scsi_qla_host_t *); 263 - extern void qla24xx_ascii_fw_dump(scsi_qla_host_t *); 264 257 extern void qla2x00_dump_regs(scsi_qla_host_t *); 265 258 extern void qla2x00_dump_buffer(uint8_t *, uint32_t); 266 259 extern void qla2x00_print_scsi_cmd(struct scsi_cmnd *); ··· 279 278 extern void *qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); 280 279 extern void *qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t); 281 280 extern int qla2x00_fdmi_register(scsi_qla_host_t *); 282 - 283 - /* 284 - * Global Function Prototypes in qla_xioctl.c source file. 285 - */ 286 - #define qla2x00_enqueue_aen(ha, cmd, mode) do { } while (0) 287 - #define qla2x00_alloc_ioctl_mem(ha) (0) 288 - #define qla2x00_free_ioctl_mem(ha) do { } while (0) 289 281 290 282 /* 291 283 * Global Function Prototypes in qla_attr.c source file.
+120 -29
drivers/scsi/qla2xxx/qla_init.c
··· 39 39 40 40 static int qla2x00_restart_isp(scsi_qla_host_t *); 41 41 42 + static int qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev); 43 + 42 44 /****************************************************************************/ 43 45 /* QLogic ISP2x00 Hardware Support Functions. */ 44 46 /****************************************************************************/ ··· 90 88 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 91 89 92 90 ha->isp_ops.nvram_config(ha); 91 + 92 + if (ha->flags.disable_serdes) { 93 + /* Mask HBA via NVRAM settings? */ 94 + qla_printk(KERN_INFO, ha, "Masking HBA WWPN " 95 + "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", 96 + ha->port_name[0], ha->port_name[1], 97 + ha->port_name[2], ha->port_name[3], 98 + ha->port_name[4], ha->port_name[5], 99 + ha->port_name[6], ha->port_name[7]); 100 + return QLA_FUNCTION_FAILED; 101 + } 93 102 94 103 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 95 104 ··· 783 770 return rval; 784 771 } 785 772 786 - static void 773 + void 787 774 qla2x00_alloc_fw_dump(scsi_qla_host_t *ha) 788 775 { 789 - uint32_t dump_size = 0; 776 + int rval; 777 + uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, 778 + eft_size; 779 + dma_addr_t eft_dma; 780 + void *eft; 790 781 791 - ha->fw_dumped = 0; 792 - if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 793 - dump_size = sizeof(struct qla2100_fw_dump); 794 - } else if (IS_QLA23XX(ha)) { 795 - dump_size = sizeof(struct qla2300_fw_dump); 796 - dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t); 797 - } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 798 - dump_size = sizeof(struct qla24xx_fw_dump); 799 - dump_size += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t); 782 + if (ha->fw_dump) { 783 + qla_printk(KERN_WARNING, ha, 784 + "Firmware dump previously allocated.\n"); 785 + return; 800 786 } 801 787 788 + ha->fw_dumped = 0; 789 + fixed_size = mem_size = eft_size = 0; 790 + if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 791 + fixed_size = sizeof(struct qla2100_fw_dump); 792 + } else if (IS_QLA23XX(ha)) { 793 + fixed_size = offsetof(struct qla2300_fw_dump, data_ram); 794 + mem_size = (ha->fw_memory_size - 0x11000 + 1) * 795 + sizeof(uint16_t); 796 + } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 797 + fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); 798 + mem_size = (ha->fw_memory_size - 0x100000 + 1) * 799 + sizeof(uint32_t); 800 + 801 + /* Allocate memory for Extended Trace Buffer. */ 802 + eft = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &eft_dma, 803 + GFP_KERNEL); 804 + if (!eft) { 805 + qla_printk(KERN_WARNING, ha, "Unable to allocate " 806 + "(%d KB) for EFT.\n", EFT_SIZE / 1024); 807 + goto cont_alloc; 808 + } 809 + 810 + rval = qla2x00_trace_control(ha, TC_ENABLE, eft_dma, 811 + EFT_NUM_BUFFERS); 812 + if (rval) { 813 + qla_printk(KERN_WARNING, ha, "Unable to initialize " 814 + "EFT (%d).\n", rval); 815 + dma_free_coherent(&ha->pdev->dev, EFT_SIZE, eft, 816 + eft_dma); 817 + goto cont_alloc; 818 + } 819 + 820 + qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n", 821 + EFT_SIZE / 1024); 822 + 823 + eft_size = EFT_SIZE; 824 + memset(eft, 0, eft_size); 825 + ha->eft_dma = eft_dma; 826 + ha->eft = eft; 827 + } 828 + cont_alloc: 829 + req_q_size = ha->request_q_length * sizeof(request_t); 830 + rsp_q_size = ha->response_q_length * sizeof(response_t); 831 + 832 + dump_size = offsetof(struct qla2xxx_fw_dump, isp); 833 + dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + 834 + eft_size; 835 + 802 836 ha->fw_dump = vmalloc(dump_size); 803 - if (ha->fw_dump) 804 - qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware " 805 - "dump...\n", dump_size / 1024); 806 - else 837 + if (!ha->fw_dump) { 807 838 qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for " 808 839 "firmware dump!!!\n", dump_size / 1024); 840 + 841 + if (ha->eft) { 842 + dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft, 843 + ha->eft_dma); 844 + ha->eft = NULL; 845 + ha->eft_dma = 0; 846 + } 847 + return; 848 + } 849 + 850 + qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware dump...\n", 851 + dump_size / 1024); 852 + 853 + ha->fw_dump_len = dump_size; 854 + ha->fw_dump->signature[0] = 'Q'; 855 + ha->fw_dump->signature[1] = 'L'; 856 + ha->fw_dump->signature[2] = 'G'; 857 + ha->fw_dump->signature[3] = 'C'; 858 + ha->fw_dump->version = __constant_htonl(1); 859 + 860 + ha->fw_dump->fixed_size = htonl(fixed_size); 861 + ha->fw_dump->mem_size = htonl(mem_size); 862 + ha->fw_dump->req_q_size = htonl(req_q_size); 863 + ha->fw_dump->rsp_q_size = htonl(rsp_q_size); 864 + 865 + ha->fw_dump->eft_size = htonl(eft_size); 866 + ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); 867 + ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); 868 + 869 + ha->fw_dump->header_size = 870 + htonl(offsetof(struct qla2xxx_fw_dump, isp)); 809 871 } 810 872 811 873 /** ··· 897 809 uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM; 898 810 dma_addr_t request_dma; 899 811 request_t *request_ring; 900 - 901 - qla2x00_alloc_fw_dump(ha); 902 812 903 813 /* Valid only on recent ISPs. */ 904 814 if (IS_QLA2100(ha) || IS_QLA2200(ha)) ··· 969 883 &ha->fw_subminor_version, 970 884 &ha->fw_attributes, &ha->fw_memory_size); 971 885 qla2x00_resize_request_q(ha); 886 + 887 + if (ql2xallocfwdump) 888 + qla2x00_alloc_fw_dump(ha); 972 889 } 973 890 } else { 974 891 DEBUG2(printk(KERN_INFO ··· 1275 1186 rval = QLA_FUNCTION_FAILED; 1276 1187 1277 1188 if (atomic_read(&ha->loop_down_timer) && 1278 - (fw_state >= FSTATE_LOSS_OF_SYNC || 1279 - fw_state == FSTATE_WAIT_AL_PA)) { 1189 + fw_state != FSTATE_READY) { 1280 1190 /* Loop down. Timeout on min_wait for states 1281 1191 * other than Wait for Login. 1282 1192 */ ··· 1643 1555 /* 1644 1556 * Set host adapter parameters. 1645 1557 */ 1558 + if (nv->host_p[0] & BIT_7) 1559 + extended_error_logging = 1; 1646 1560 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); 1647 1561 /* Always load RISC code on non ISP2[12]00 chips. */ 1648 1562 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) ··· 1653 1563 ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); 1654 1564 ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); 1655 1565 ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; 1566 + ha->flags.disable_serdes = 0; 1656 1567 1657 1568 ha->operating_mode = 1658 1569 (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; ··· 1792 1701 * 1793 1702 * Returns a pointer to the allocated fcport, or NULL, if none available. 1794 1703 */ 1795 - fc_port_t * 1704 + static fc_port_t * 1796 1705 qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) 1797 1706 { 1798 1707 fc_port_t *fcport; ··· 2588 2497 * Context: 2589 2498 * Kernel context. 2590 2499 */ 2591 - int 2500 + static int 2592 2501 qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) 2593 2502 { 2594 2503 int rval; ··· 3139 3048 ha->isp_abort_cnt--; 3140 3049 DEBUG(printk("qla%ld: ISP abort - " 3141 3050 "retry remaining %d\n", 3142 - ha->host_no, ha->isp_abort_cnt);) 3051 + ha->host_no, ha->isp_abort_cnt)); 3143 3052 status = 1; 3144 3053 } 3145 3054 } else { 3146 3055 ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; 3147 3056 DEBUG(printk("qla2x00(%ld): ISP error recovery " 3148 3057 "- retrying (%d) more times\n", 3149 - ha->host_no, ha->isp_abort_cnt);) 3058 + ha->host_no, ha->isp_abort_cnt)); 3150 3059 set_bit(ISP_ABORT_RETRY, &ha->dpc_flags); 3151 3060 status = 1; 3152 3061 } ··· 3160 3069 } else { 3161 3070 DEBUG(printk(KERN_INFO 3162 3071 "qla2x00_abort_isp(%ld): exiting.\n", 3163 - ha->host_no);) 3072 + ha->host_no)); 3164 3073 } 3165 3074 3166 3075 return(status); ··· 3236 3145 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 3237 3146 if (!(status = qla2x00_fw_ready(ha))) { 3238 3147 DEBUG(printk("%s(): Start configure loop, " 3239 - "status = %d\n", __func__, status);) 3148 + "status = %d\n", __func__, status)); 3240 3149 3241 3150 /* Issue a marker after FW becomes ready. */ 3242 3151 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); ··· 3260 3169 3261 3170 DEBUG(printk("%s(): Configure loop done, status = 0x%x\n", 3262 3171 __func__, 3263 - status);) 3172 + status)); 3264 3173 } 3265 3174 return (status); 3266 3175 } ··· 3380 3289 nv->node_name[6] = 0x55; 3381 3290 nv->node_name[7] = 0x86; 3382 3291 nv->login_retry_count = __constant_cpu_to_le16(8); 3383 - nv->link_down_timeout = __constant_cpu_to_le16(200); 3384 3292 nv->interrupt_delay_timer = __constant_cpu_to_le16(0); 3385 3293 nv->login_timeout = __constant_cpu_to_le16(0); 3386 3294 nv->firmware_options_1 = ··· 3408 3318 *dptr1++ = *dptr2++; 3409 3319 3410 3320 icb->login_retry_count = nv->login_retry_count; 3411 - icb->link_down_timeout = nv->link_down_timeout; 3321 + icb->link_down_on_nos = nv->link_down_on_nos; 3412 3322 3413 3323 /* Copy 2nd segment. */ 3414 3324 dptr1 = (uint8_t *)&icb->interrupt_delay_timer; ··· 3463 3373 ha->flags.enable_lip_full_login = 1; 3464 3374 ha->flags.enable_target_reset = 1; 3465 3375 ha->flags.enable_led_scheme = 0; 3376 + ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; 3466 3377 3467 3378 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & 3468 3379 (BIT_6 | BIT_5 | BIT_4)) >> 4; ··· 3563 3472 return (rval); 3564 3473 } 3565 3474 3566 - int 3475 + static int 3567 3476 qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) 3568 3477 { 3569 3478 int rval;
+2 -1
drivers/scsi/qla2xxx/qla_iocb.c
··· 15 15 static inline cont_entry_t *qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *); 16 16 static inline cont_a64_entry_t *qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *); 17 17 static request_t *qla2x00_req_pkt(scsi_qla_host_t *ha); 18 + static void qla2x00_isp_cmd(scsi_qla_host_t *ha); 18 19 19 20 /** 20 21 * qla2x00_get_cmd_direction() - Determine control_flag data direction. ··· 575 574 * 576 575 * Note: The caller must hold the hardware lock before calling this routine. 577 576 */ 578 - void 577 + static void 579 578 qla2x00_isp_cmd(scsi_qla_host_t *ha) 580 579 { 581 580 device_reg_t __iomem *reg = ha->iobase;
+2 -22
drivers/scsi/qla2xxx/qla_isr.c
··· 395 395 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); 396 396 397 397 ha->flags.management_server_logged_in = 0; 398 - 399 - /* Update AEN queue. */ 400 - qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL); 401 - 402 398 break; 403 399 404 400 case MBA_LOOP_UP: /* Loop Up Event */ ··· 414 418 link_speed); 415 419 416 420 ha->flags.management_server_logged_in = 0; 417 - 418 - /* Update AEN queue. */ 419 - qla2x00_enqueue_aen(ha, MBA_LOOP_UP, NULL); 420 421 break; 421 422 422 423 case MBA_LOOP_DOWN: /* Loop Down Event */ ··· 432 439 ha->link_data_rate = LDR_UNKNOWN; 433 440 if (ql2xfdmienable) 434 441 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); 435 - 436 - /* Update AEN queue. */ 437 - qla2x00_enqueue_aen(ha, MBA_LOOP_DOWN, NULL); 438 442 break; 439 443 440 444 case MBA_LIP_RESET: /* LIP reset occurred */ ··· 450 460 451 461 ha->operating_mode = LOOP; 452 462 ha->flags.management_server_logged_in = 0; 453 - 454 - /* Update AEN queue. */ 455 - qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL); 456 - 457 463 break; 458 464 459 465 case MBA_POINT_TO_POINT: /* Point-to-Point */ ··· 531 545 532 546 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); 533 547 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); 534 - 535 - /* Update AEN queue. */ 536 - qla2x00_enqueue_aen(ha, MBA_PORT_UPDATE, NULL); 537 548 break; 538 549 539 550 case MBA_RSCN_UPDATE: /* State Change Registration */ ··· 567 584 568 585 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); 569 586 set_bit(RSCN_UPDATE, &ha->dpc_flags); 570 - 571 - /* Update AEN queue. */ 572 - qla2x00_enqueue_aen(ha, MBA_RSCN_UPDATE, &mb[0]); 573 587 break; 574 588 575 589 /* case MBA_RIO_RESPONSE: */ ··· 1432 1452 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n", 1433 1453 __func__, ha->host_no, pkt, pkt->handle)); 1434 1454 1435 - DEBUG9(printk("%s: ct pkt dump:\n", __func__);) 1436 - DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx));) 1455 + DEBUG9(printk("%s: ct pkt dump:\n", __func__)); 1456 + DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx))); 1437 1457 1438 1458 /* Validate handle. */ 1439 1459 if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
+180 -100
drivers/scsi/qla2xxx/qla_mbx.c
··· 13 13 { 14 14 struct semaphore *sem_ptr = (struct semaphore *)data; 15 15 16 - DEBUG11(printk("qla2x00_sem_timeout: entered.\n");) 16 + DEBUG11(printk("qla2x00_sem_timeout: entered.\n")); 17 17 18 18 if (sem_ptr != NULL) { 19 19 up(sem_ptr); 20 20 } 21 21 22 - DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n");) 22 + DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n")); 23 23 } 24 24 25 25 /* ··· 61 61 rval = QLA_SUCCESS; 62 62 abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 63 63 64 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 64 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 65 65 66 66 /* 67 67 * Wait for active mailbox commands to finish by waiting at most tov ··· 72 72 if (qla2x00_down_timeout(&ha->mbx_cmd_sem, mcp->tov * HZ)) { 73 73 /* Timeout occurred. Return error. */ 74 74 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. " 75 - "Exiting.\n", __func__, ha->host_no);) 75 + "Exiting.\n", __func__, ha->host_no)); 76 76 return QLA_FUNCTION_TIMEOUT; 77 77 } 78 78 } ··· 86 86 spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags); 87 87 88 88 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n", 89 - ha->host_no, mcp->mb[0]);) 89 + ha->host_no, mcp->mb[0])); 90 90 91 91 spin_lock_irqsave(&ha->hardware_lock, flags); 92 92 ··· 131 131 132 132 /* Unlock mbx registers and wait for interrupt */ 133 133 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. " 134 - "jiffies=%lx.\n", __func__, ha->host_no, jiffies);) 134 + "jiffies=%lx.\n", __func__, ha->host_no, jiffies)); 135 135 136 136 /* Wait for mbx cmd completion until timeout */ 137 137 138 138 if (!abort_active && io_lock_on) { 139 139 /* sleep on completion semaphore */ 140 140 DEBUG11(printk("%s(%ld): INTERRUPT MODE. Initializing timer.\n", 141 - __func__, ha->host_no);) 141 + __func__, ha->host_no)); 142 142 143 143 init_timer(&tmp_intr_timer); 144 144 tmp_intr_timer.data = (unsigned long)&ha->mbx_intr_sem; ··· 147 147 (void (*)(unsigned long))qla2x00_mbx_sem_timeout; 148 148 149 149 DEBUG11(printk("%s(%ld): Adding timer.\n", __func__, 150 - ha->host_no);) 150 + ha->host_no)); 151 151 add_timer(&tmp_intr_timer); 152 152 153 153 DEBUG11(printk("%s(%ld): going to unlock & sleep. " 154 - "time=0x%lx.\n", __func__, ha->host_no, jiffies);) 154 + "time=0x%lx.\n", __func__, ha->host_no, jiffies)); 155 155 156 156 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 157 157 ··· 170 170 down(&ha->mbx_intr_sem); 171 171 172 172 DEBUG11(printk("%s(%ld): waking up. time=0x%lx\n", __func__, 173 - ha->host_no, jiffies);) 173 + ha->host_no, jiffies)); 174 174 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 175 175 176 176 /* delete the timer */ 177 177 del_timer(&tmp_intr_timer); 178 178 } else { 179 179 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 180 - ha->host_no, command);) 180 + ha->host_no, command)); 181 181 182 182 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 183 183 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); ··· 209 209 uint16_t *iptr2; 210 210 211 211 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__, 212 - ha->host_no, command);) 212 + ha->host_no, command)); 213 213 214 214 /* Got interrupt. Clear the flag. */ 215 215 ha->flags.mbox_int = 0; ··· 266 266 267 267 if (!abort_active) { 268 268 DEBUG11(printk("%s(%ld): checking for additional resp " 269 - "interrupt.\n", __func__, ha->host_no);) 269 + "interrupt.\n", __func__, ha->host_no)); 270 270 271 271 /* polling mode for non isp_abort commands. */ 272 272 qla2x00_poll(ha); ··· 277 277 if (!io_lock_on || (mcp->flags & IOCTL_CMD)) { 278 278 /* not in dpc. schedule it for dpc to take over. */ 279 279 DEBUG(printk("%s(%ld): timeout schedule " 280 - "isp_abort_needed.\n", __func__, ha->host_no);) 280 + "isp_abort_needed.\n", __func__, ha->host_no)); 281 281 DEBUG2_3_11(printk("%s(%ld): timeout schedule " 282 - "isp_abort_needed.\n", __func__, ha->host_no);) 282 + "isp_abort_needed.\n", __func__, ha->host_no)); 283 283 qla_printk(KERN_WARNING, ha, 284 284 "Mailbox command timeout occured. Scheduling ISP " 285 285 "abort.\n"); ··· 288 288 } else if (!abort_active) { 289 289 /* call abort directly since we are in the DPC thread */ 290 290 DEBUG(printk("%s(%ld): timeout calling abort_isp\n", 291 - __func__, ha->host_no);) 291 + __func__, ha->host_no)); 292 292 DEBUG2_3_11(printk("%s(%ld): timeout calling " 293 - "abort_isp\n", __func__, ha->host_no);) 293 + "abort_isp\n", __func__, ha->host_no)); 294 294 qla_printk(KERN_WARNING, ha, 295 295 "Mailbox command timeout occured. Issuing ISP " 296 296 "abort.\n"); ··· 303 303 } 304 304 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags); 305 305 DEBUG(printk("%s(%ld): finished abort_isp\n", __func__, 306 - ha->host_no);) 306 + ha->host_no)); 307 307 DEBUG2_3_11(printk("%s(%ld): finished abort_isp\n", 308 - __func__, ha->host_no);) 308 + __func__, ha->host_no)); 309 309 } 310 310 } 311 311 ··· 316 316 if (rval) { 317 317 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, " 318 318 "mbx2=%x, cmd=%x ****\n", __func__, ha->host_no, 319 - mcp->mb[0], mcp->mb[1], mcp->mb[2], command);) 319 + mcp->mb[0], mcp->mb[1], mcp->mb[2], command)); 320 320 } else { 321 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 321 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 322 322 } 323 323 324 324 return rval; ··· 394 394 mbx_cmd_t mc; 395 395 mbx_cmd_t *mcp = &mc; 396 396 397 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 397 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 398 398 399 399 mcp->mb[0] = MBC_EXECUTE_FIRMWARE; 400 400 mcp->out_mb = MBX_0; ··· 424 424 } else { 425 425 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 426 426 DEBUG11(printk("%s(%ld): done exchanges=%x.\n", 427 - __func__, ha->host_no, mcp->mb[1]);) 427 + __func__, ha->host_no, mcp->mb[1])); 428 428 } else { 429 429 DEBUG11(printk("%s(%ld): done.\n", __func__, 430 - ha->host_no);) 430 + ha->host_no)); 431 431 } 432 432 } 433 433 ··· 611 611 mbx_cmd_t mc; 612 612 mbx_cmd_t *mcp = &mc; 613 613 614 - DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no);) 614 + DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no)); 615 615 616 616 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; 617 617 mcp->mb[1] = 0xAAAA; ··· 639 639 if (rval != QLA_SUCCESS) { 640 640 /*EMPTY*/ 641 641 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n", 642 - ha->host_no, rval);) 642 + ha->host_no, rval)); 643 643 } else { 644 644 /*EMPTY*/ 645 645 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n", 646 - ha->host_no);) 646 + ha->host_no)); 647 647 } 648 648 649 649 return rval; ··· 671 671 mbx_cmd_t mc; 672 672 mbx_cmd_t *mcp = &mc; 673 673 674 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 674 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 675 675 676 676 mcp->mb[0] = MBC_VERIFY_CHECKSUM; 677 677 mcp->out_mb = MBX_0; ··· 694 694 if (rval != QLA_SUCCESS) { 695 695 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__, 696 696 ha->host_no, rval, (IS_QLA24XX(ha) || IS_QLA54XX(ha) ? 697 - (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));) 697 + (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]))); 698 698 } else { 699 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 699 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 700 700 } 701 701 702 702 return rval; ··· 743 743 if (rval != QLA_SUCCESS) { 744 744 /*EMPTY*/ 745 745 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 746 - ha->host_no, rval);) 746 + ha->host_no, rval)); 747 747 DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n", 748 - ha->host_no, rval);) 748 + ha->host_no, rval)); 749 749 } else { 750 750 sts_entry_t *sts_entry = (sts_entry_t *) buffer; 751 751 ··· 781 781 mbx_cmd_t mc; 782 782 mbx_cmd_t *mcp = &mc; 783 783 784 - DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);) 784 + DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no)); 785 785 786 786 fcport = sp->fcport; 787 787 ··· 813 813 814 814 if (rval != QLA_SUCCESS) { 815 815 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n", 816 - ha->host_no, rval);) 816 + ha->host_no, rval)); 817 817 } else { 818 818 sp->flags |= SRB_ABORT_PENDING; 819 819 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n", 820 - ha->host_no);) 820 + ha->host_no)); 821 821 } 822 822 823 823 return rval; ··· 848 848 if (fcport == NULL) 849 849 return 0; 850 850 851 - DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no);) 851 + DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 852 852 853 853 ha = fcport->ha; 854 854 mcp->mb[0] = MBC_ABORT_TARGET; ··· 872 872 873 873 if (rval != QLA_SUCCESS) { 874 874 DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n", 875 - ha->host_no, rval);) 875 + ha->host_no, rval)); 876 876 } else { 877 877 /*EMPTY*/ 878 878 DEBUG11(printk("qla2x00_abort_target(%ld): done.\n", 879 - ha->host_no);) 879 + ha->host_no)); 880 880 } 881 881 882 882 return rval; ··· 912 912 mbx_cmd_t *mcp = &mc; 913 913 914 914 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n", 915 - ha->host_no);) 915 + ha->host_no)); 916 916 917 917 mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID; 918 918 mcp->out_mb = MBX_0; ··· 933 933 if (rval != QLA_SUCCESS) { 934 934 /*EMPTY*/ 935 935 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n", 936 - ha->host_no, rval);) 936 + ha->host_no, rval)); 937 937 } else { 938 938 /*EMPTY*/ 939 939 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n", 940 - ha->host_no);) 940 + ha->host_no)); 941 941 } 942 942 943 943 return rval; ··· 968 968 mbx_cmd_t *mcp = &mc; 969 969 970 970 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n", 971 - ha->host_no);) 971 + ha->host_no)); 972 972 973 973 mcp->mb[0] = MBC_GET_RETRY_COUNT; 974 974 mcp->out_mb = MBX_0; ··· 980 980 if (rval != QLA_SUCCESS) { 981 981 /*EMPTY*/ 982 982 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n", 983 - ha->host_no, mcp->mb[0]);) 983 + ha->host_no, mcp->mb[0])); 984 984 } else { 985 985 /* Convert returned data and check our values. */ 986 986 *r_a_tov = mcp->mb[3] / 2; ··· 992 992 } 993 993 994 994 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d " 995 - "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov);) 995 + "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov)); 996 996 } 997 997 998 998 return rval; ··· 1023 1023 mbx_cmd_t *mcp = &mc; 1024 1024 1025 1025 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n", 1026 - ha->host_no);) 1026 + ha->host_no)); 1027 1027 1028 1028 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; 1029 1029 mcp->mb[2] = MSW(ha->init_cb_dma); ··· 1043 1043 /*EMPTY*/ 1044 1044 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x " 1045 1045 "mb0=%x.\n", 1046 - ha->host_no, rval, mcp->mb[0]);) 1046 + ha->host_no, rval, mcp->mb[0])); 1047 1047 } else { 1048 1048 /*EMPTY*/ 1049 1049 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n", 1050 - ha->host_no);) 1050 + ha->host_no)); 1051 1051 } 1052 1052 1053 1053 return rval; ··· 1079 1079 struct port_database_24xx *pd24; 1080 1080 dma_addr_t pd_dma; 1081 1081 1082 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 1082 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1083 1083 1084 1084 pd24 = NULL; 1085 1085 pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); ··· 1220 1220 mbx_cmd_t *mcp = &mc; 1221 1221 1222 1222 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n", 1223 - ha->host_no);) 1223 + ha->host_no)); 1224 1224 1225 1225 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; 1226 1226 mcp->out_mb = MBX_0; ··· 1235 1235 if (rval != QLA_SUCCESS) { 1236 1236 /*EMPTY*/ 1237 1237 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): " 1238 - "failed=%x.\n", ha->host_no, rval);) 1238 + "failed=%x.\n", ha->host_no, rval)); 1239 1239 } else { 1240 1240 /*EMPTY*/ 1241 1241 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n", 1242 - ha->host_no);) 1242 + ha->host_no)); 1243 1243 } 1244 1244 1245 1245 return rval; ··· 1272 1272 mbx_cmd_t *mcp = &mc; 1273 1273 1274 1274 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n", 1275 - ha->host_no);) 1275 + ha->host_no)); 1276 1276 1277 1277 mcp->mb[0] = MBC_GET_PORT_NAME; 1278 1278 mcp->out_mb = MBX_1|MBX_0; ··· 1292 1292 if (rval != QLA_SUCCESS) { 1293 1293 /*EMPTY*/ 1294 1294 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n", 1295 - ha->host_no, rval);) 1295 + ha->host_no, rval)); 1296 1296 } else { 1297 1297 if (name != NULL) { 1298 1298 /* This function returns name in big endian. */ ··· 1307 1307 } 1308 1308 1309 1309 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n", 1310 - ha->host_no);) 1310 + ha->host_no)); 1311 1311 } 1312 1312 1313 1313 return rval; ··· 1335 1335 mbx_cmd_t mc; 1336 1336 mbx_cmd_t *mcp = &mc; 1337 1337 1338 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 1338 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1339 1339 1340 1340 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1341 1341 mcp->mb[0] = MBC_LIP_FULL_LOGIN; ··· 1364 1364 if (rval != QLA_SUCCESS) { 1365 1365 /*EMPTY*/ 1366 1366 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", 1367 - __func__, ha->host_no, rval);) 1367 + __func__, ha->host_no, rval)); 1368 1368 } else { 1369 1369 /*EMPTY*/ 1370 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 1370 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1371 1371 } 1372 1372 1373 1373 return rval; ··· 1400 1400 mbx_cmd_t *mcp = &mc; 1401 1401 1402 1402 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n", 1403 - ha->host_no);) 1403 + ha->host_no)); 1404 1404 1405 1405 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total " 1406 - "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov);) 1406 + "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov)); 1407 1407 1408 1408 mcp->mb[0] = MBC_SEND_SNS_COMMAND; 1409 1409 mcp->mb[1] = cmd_size; ··· 1421 1421 if (rval != QLA_SUCCESS) { 1422 1422 /*EMPTY*/ 1423 1423 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1424 - "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);) 1424 + "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1425 1425 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x " 1426 - "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);) 1426 + "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 1427 1427 } else { 1428 1428 /*EMPTY*/ 1429 - DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no);) 1429 + DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no)); 1430 1430 } 1431 1431 1432 1432 return rval; ··· 1442 1442 dma_addr_t lg_dma; 1443 1443 uint32_t iop[2]; 1444 1444 1445 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 1445 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1446 1446 1447 1447 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1448 1448 if (lg == NULL) { ··· 1458 1458 lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI); 1459 1459 if (opt & BIT_0) 1460 1460 lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI); 1461 + if (opt & BIT_1) 1462 + lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI); 1461 1463 lg->port_id[0] = al_pa; 1462 1464 lg->port_id[1] = area; 1463 1465 lg->port_id[2] = domain; 1464 1466 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1465 1467 if (rval != QLA_SUCCESS) { 1466 1468 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB " 1467 - "(%x).\n", __func__, ha->host_no, rval);) 1469 + "(%x).\n", __func__, ha->host_no, rval)); 1468 1470 } else if (lg->entry_status != 0) { 1469 1471 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1470 1472 "-- error status (%x).\n", __func__, ha->host_no, ··· 1507 1505 break; 1508 1506 } 1509 1507 } else { 1510 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 1508 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1511 1509 1512 1510 iop[0] = le32_to_cpu(lg->io_parameter[0]); 1513 1511 ··· 1561 1559 mbx_cmd_t mc; 1562 1560 mbx_cmd_t *mcp = &mc; 1563 1561 1564 - DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no);) 1562 + DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no)); 1565 1563 1566 1564 mcp->mb[0] = MBC_LOGIN_FABRIC_PORT; 1567 1565 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; ··· 1606 1604 /*EMPTY*/ 1607 1605 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x " 1608 1606 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval, 1609 - mcp->mb[0], mcp->mb[1], mcp->mb[2]);) 1607 + mcp->mb[0], mcp->mb[1], mcp->mb[2])); 1610 1608 } else { 1611 1609 /*EMPTY*/ 1612 1610 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n", 1613 - ha->host_no);) 1611 + ha->host_no)); 1614 1612 } 1615 1613 1616 1614 return rval; ··· 1645 1643 fcport->d_id.b.domain, fcport->d_id.b.area, 1646 1644 fcport->d_id.b.al_pa, mb_ret, opt); 1647 1645 1648 - DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 1646 + DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1649 1647 1650 1648 mcp->mb[0] = MBC_LOGIN_LOOP_PORT; 1651 1649 if (HAS_EXTENDED_IDS(ha)) ··· 1679 1677 1680 1678 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1681 1679 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1682 - mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);) 1680 + mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1683 1681 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " 1684 1682 "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval, 1685 - mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);) 1683 + mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7])); 1686 1684 } else { 1687 1685 /*EMPTY*/ 1688 - DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no);) 1686 + DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1689 1687 } 1690 1688 1691 1689 return (rval); ··· 1699 1697 struct logio_entry_24xx *lg; 1700 1698 dma_addr_t lg_dma; 1701 1699 1702 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 1700 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1703 1701 1704 1702 lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); 1705 1703 if (lg == NULL) { ··· 1720 1718 rval = qla2x00_issue_iocb(ha, lg, lg_dma, 0); 1721 1719 if (rval != QLA_SUCCESS) { 1722 1720 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB " 1723 - "(%x).\n", __func__, ha->host_no, rval);) 1721 + "(%x).\n", __func__, ha->host_no, rval)); 1724 1722 } else if (lg->entry_status != 0) { 1725 1723 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 1726 1724 "-- error status (%x).\n", __func__, ha->host_no, ··· 1731 1729 "-- completion status (%x) ioparam=%x/%x.\n", __func__, 1732 1730 ha->host_no, le16_to_cpu(lg->comp_status), 1733 1731 le32_to_cpu(lg->io_parameter[0]), 1734 - le32_to_cpu(lg->io_parameter[1]));) 1732 + le32_to_cpu(lg->io_parameter[1]))); 1735 1733 } else { 1736 1734 /*EMPTY*/ 1737 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 1735 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 1738 1736 } 1739 1737 1740 1738 dma_pool_free(ha->s_dma_pool, lg, lg_dma); ··· 1767 1765 mbx_cmd_t *mcp = &mc; 1768 1766 1769 1767 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n", 1770 - ha->host_no);) 1768 + ha->host_no)); 1771 1769 1772 1770 mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT; 1773 1771 mcp->out_mb = MBX_1|MBX_0; ··· 1787 1785 if (rval != QLA_SUCCESS) { 1788 1786 /*EMPTY*/ 1789 1787 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x " 1790 - "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1]);) 1788 + "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1])); 1791 1789 } else { 1792 1790 /*EMPTY*/ 1793 1791 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n", 1794 - ha->host_no);) 1792 + ha->host_no)); 1795 1793 } 1796 1794 1797 1795 return rval; ··· 1820 1818 mbx_cmd_t *mcp = &mc; 1821 1819 1822 1820 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n", 1823 - ha->host_no);) 1821 + ha->host_no)); 1824 1822 1825 1823 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1826 1824 mcp->mb[1] = 0; ··· 1835 1833 if (rval != QLA_SUCCESS) { 1836 1834 /*EMPTY*/ 1837 1835 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n", 1838 - ha->host_no, rval);) 1836 + ha->host_no, rval)); 1839 1837 } else { 1840 1838 /*EMPTY*/ 1841 1839 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n", 1842 - ha->host_no);) 1840 + ha->host_no)); 1843 1841 } 1844 1842 1845 1843 return rval; ··· 1866 1864 mbx_cmd_t *mcp = &mc; 1867 1865 1868 1866 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n", 1869 - ha->host_no);) 1867 + ha->host_no)); 1870 1868 1871 1869 if (id_list == NULL) 1872 1870 return QLA_FUNCTION_FAILED; ··· 1895 1893 if (rval != QLA_SUCCESS) { 1896 1894 /*EMPTY*/ 1897 1895 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n", 1898 - ha->host_no, rval);) 1896 + ha->host_no, rval)); 1899 1897 } else { 1900 1898 *entries = mcp->mb[1]; 1901 1899 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n", 1902 - ha->host_no);) 1900 + ha->host_no)); 1903 1901 } 1904 1902 1905 1903 return rval; ··· 1938 1936 if (rval != QLA_SUCCESS) { 1939 1937 /*EMPTY*/ 1940 1938 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__, 1941 - ha->host_no, mcp->mb[0]);) 1939 + ha->host_no, mcp->mb[0])); 1942 1940 } else { 1943 1941 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x " 1944 1942 "mb7=%x mb10=%x.\n", __func__, ha->host_no, ··· 2047 2045 link_stat_t *stat_buf; 2048 2046 dma_addr_t stat_buf_dma; 2049 2047 2050 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 2048 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2051 2049 2052 2050 stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma); 2053 2051 if (stat_buf == NULL) { ··· 2085 2083 if (rval == QLA_SUCCESS) { 2086 2084 if (mcp->mb[0] != MBS_COMMAND_COMPLETE) { 2087 2085 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n", 2088 - __func__, ha->host_no, mcp->mb[0]);) 2086 + __func__, ha->host_no, mcp->mb[0])); 2089 2087 status[0] = mcp->mb[0]; 2090 2088 rval = BIT_1; 2091 2089 } else { ··· 2110 2108 stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt, 2111 2109 stat_buf->prim_seq_err_cnt, 2112 2110 stat_buf->inval_xmit_word_cnt, 2113 - stat_buf->inval_crc_cnt);) 2111 + stat_buf->inval_crc_cnt)); 2114 2112 } 2115 2113 } else { 2116 2114 /* Failed. */ 2117 2115 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2118 - ha->host_no, rval);) 2116 + ha->host_no, rval)); 2119 2117 rval = BIT_1; 2120 2118 } 2121 2119 ··· 2134 2132 uint32_t *sbuf, *siter; 2135 2133 dma_addr_t sbuf_dma; 2136 2134 2137 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 2135 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2138 2136 2139 2137 if (dwords > (DMA_POOL_SIZE / 4)) { 2140 2138 DEBUG2_3_11(printk("%s(%ld): Unabled to retrieve %d DWORDs " ··· 2198 2196 dma_addr_t abt_dma; 2199 2197 uint32_t handle; 2200 2198 2201 - DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 2199 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2202 2200 2203 2201 fcport = sp->fcport; 2204 2202 ··· 2231 2229 rval = qla2x00_issue_iocb(ha, abt, abt_dma, 0); 2232 2230 if (rval != QLA_SUCCESS) { 2233 2231 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n", 2234 - __func__, ha->host_no, rval);) 2232 + __func__, ha->host_no, rval)); 2235 2233 } else if (abt->entry_status != 0) { 2236 2234 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2237 2235 "-- error status (%x).\n", __func__, ha->host_no, ··· 2240 2238 } else if (abt->nport_handle != __constant_cpu_to_le16(0)) { 2241 2239 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2242 2240 "-- completion status (%x).\n", __func__, ha->host_no, 2243 - le16_to_cpu(abt->nport_handle));) 2241 + le16_to_cpu(abt->nport_handle))); 2244 2242 rval = QLA_FUNCTION_FAILED; 2245 2243 } else { 2246 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 2244 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2247 2245 sp->flags |= SRB_ABORT_PENDING; 2248 2246 } 2249 2247 ··· 2270 2268 if (fcport == NULL) 2271 2269 return 0; 2272 2270 2273 - DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no);) 2271 + DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); 2274 2272 2275 2273 ha = fcport->ha; 2276 2274 tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); ··· 2292 2290 rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0); 2293 2291 if (rval != QLA_SUCCESS) { 2294 2292 DEBUG2_3_11(printk("%s(%ld): failed to issue Target Reset IOCB " 2295 - "(%x).\n", __func__, ha->host_no, rval);) 2293 + "(%x).\n", __func__, ha->host_no, rval)); 2296 2294 goto atarget_done; 2297 2295 } else if (tsk->p.sts.entry_status != 0) { 2298 2296 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " ··· 2304 2302 __constant_cpu_to_le16(CS_COMPLETE)) { 2305 2303 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " 2306 2304 "-- completion status (%x).\n", __func__, 2307 - ha->host_no, le16_to_cpu(tsk->p.sts.comp_status));) 2305 + ha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); 2308 2306 rval = QLA_FUNCTION_FAILED; 2309 2307 goto atarget_done; 2310 2308 } ··· 2313 2311 rval = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); 2314 2312 if (rval != QLA_SUCCESS) { 2315 2313 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " 2316 - "(%x).\n", __func__, ha->host_no, rval);) 2314 + "(%x).\n", __func__, ha->host_no, rval)); 2317 2315 } else { 2318 - DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no);) 2316 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2319 2317 } 2320 2318 2321 2319 atarget_done: ··· 2456 2454 if (rval != QLA_SUCCESS) { 2457 2455 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, 2458 2456 ha->host_no, rval)); 2457 + } else { 2458 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2459 + } 2460 + 2461 + return rval; 2462 + } 2463 + 2464 + int 2465 + qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma, 2466 + uint16_t buffers) 2467 + { 2468 + int rval; 2469 + mbx_cmd_t mc; 2470 + mbx_cmd_t *mcp = &mc; 2471 + 2472 + if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2473 + return QLA_FUNCTION_FAILED; 2474 + 2475 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2476 + 2477 + mcp->mb[0] = MBC_TRACE_CONTROL; 2478 + mcp->mb[1] = ctrl; 2479 + mcp->out_mb = MBX_1|MBX_0; 2480 + mcp->in_mb = MBX_1|MBX_0; 2481 + if (ctrl == TC_ENABLE) { 2482 + mcp->mb[2] = LSW(eft_dma); 2483 + mcp->mb[3] = MSW(eft_dma); 2484 + mcp->mb[4] = LSW(MSD(eft_dma)); 2485 + mcp->mb[5] = MSW(MSD(eft_dma)); 2486 + mcp->mb[6] = buffers; 2487 + mcp->mb[7] = buffers; 2488 + mcp->out_mb |= MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2; 2489 + } 2490 + mcp->tov = 30; 2491 + mcp->flags = 0; 2492 + rval = qla2x00_mailbox_command(ha, mcp); 2493 + 2494 + if (rval != QLA_SUCCESS) { 2495 + DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", 2496 + __func__, ha->host_no, rval, mcp->mb[0], mcp->mb[1])); 2497 + } else { 2498 + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2499 + } 2500 + 2501 + return rval; 2502 + } 2503 + 2504 + int 2505 + qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr, 2506 + uint16_t off, uint16_t count) 2507 + { 2508 + int rval; 2509 + mbx_cmd_t mc; 2510 + mbx_cmd_t *mcp = &mc; 2511 + 2512 + if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2513 + return QLA_FUNCTION_FAILED; 2514 + 2515 + DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2516 + 2517 + mcp->mb[0] = MBC_READ_SFP; 2518 + mcp->mb[1] = addr; 2519 + mcp->mb[2] = MSW(sfp_dma); 2520 + mcp->mb[3] = LSW(sfp_dma); 2521 + mcp->mb[6] = MSW(MSD(sfp_dma)); 2522 + mcp->mb[7] = LSW(MSD(sfp_dma)); 2523 + mcp->mb[8] = count; 2524 + mcp->mb[9] = off; 2525 + mcp->mb[10] = 0; 2526 + mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; 2527 + mcp->in_mb = MBX_0; 2528 + mcp->tov = 30; 2529 + mcp->flags = 0; 2530 + rval = qla2x00_mailbox_command(ha, mcp); 2531 + 2532 + if (rval != QLA_SUCCESS) { 2533 + DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, 2534 + ha->host_no, rval, mcp->mb[0])); 2459 2535 } else { 2460 2536 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 2461 2537 }
+65 -60
drivers/scsi/qla2xxx/qla_os.c
··· 39 39 int qlport_down_retry = 30; 40 40 module_param(qlport_down_retry, int, S_IRUGO|S_IRUSR); 41 41 MODULE_PARM_DESC(qlport_down_retry, 42 - "Maximum number of command retries to a port that returns" 42 + "Maximum number of command retries to a port that returns " 43 43 "a PORT-DOWN status."); 44 44 45 45 int ql2xplogiabsentdevice; 46 46 module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); 47 47 MODULE_PARM_DESC(ql2xplogiabsentdevice, 48 48 "Option to enable PLOGI to devices that are not present after " 49 - "a Fabric scan. This is needed for several broken switches." 49 + "a Fabric scan. This is needed for several broken switches. " 50 50 "Default is 0 - no PLOGI. 1 - perfom PLOGI."); 51 51 52 52 int ql2xloginretrycount = 0; 53 53 module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); 54 54 MODULE_PARM_DESC(ql2xloginretrycount, 55 55 "Specify an alternate value for the NVRAM login retry count."); 56 + 57 + int ql2xallocfwdump = 1; 58 + module_param(ql2xallocfwdump, int, S_IRUGO|S_IRUSR); 59 + MODULE_PARM_DESC(ql2xallocfwdump, 60 + "Option to enable allocation of memory for a firmware dump " 61 + "during HBA initialization. Memory allocation requirements " 62 + "vary by ISP type. Default is 1 - allocate memory."); 63 + 64 + int extended_error_logging; 65 + module_param(extended_error_logging, int, S_IRUGO|S_IRUSR); 66 + MODULE_PARM_DESC(extended_error_logging, 67 + "Option to enable extended error logging, " 68 + "Default is 0 - no logging. 1 - log errors."); 56 69 57 70 static void qla2x00_free_device(scsi_qla_host_t *); 58 71 ··· 637 624 638 625 DEBUG2(printk("%s(%ld): aborting sp %p from RISC. pid=%ld.\n", 639 626 __func__, ha->host_no, sp, serial)); 640 - DEBUG3(qla2x00_print_scsi_cmd(cmd);) 627 + DEBUG3(qla2x00_print_scsi_cmd(cmd)); 641 628 642 629 spin_unlock_irqrestore(&ha->hardware_lock, flags); 643 630 if (ha->isp_ops.abort_command(ha, sp)) { ··· 779 766 #endif 780 767 } else { 781 768 DEBUG2(printk(KERN_INFO 782 - "%s failed: loop not ready\n",__func__);) 769 + "%s failed: loop not ready\n",__func__)); 783 770 } 784 771 785 772 if (ret == FAILED) { ··· 1034 1021 /* Empty */ 1035 1022 DEBUG2_3(printk("%s(%ld): **** FAILED ****\n", 1036 1023 __func__, 1037 - ha->host_no);) 1024 + ha->host_no)); 1038 1025 } else { 1039 1026 /* Empty */ 1040 1027 DEBUG3(printk("%s(%ld): exiting normally.\n", 1041 1028 __func__, 1042 - ha->host_no);) 1029 + ha->host_no)); 1043 1030 } 1044 1031 1045 1032 return(status); ··· 1337 1324 /* 1338 1325 * PCI driver interface 1339 1326 */ 1340 - static int qla2x00_probe_one(struct pci_dev *pdev) 1327 + static int __devinit 1328 + qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) 1341 1329 { 1342 1330 int ret = -ENODEV; 1343 1331 device_reg_t __iomem *reg; ··· 1419 1405 ha->isp_ops.read_nvram = qla2x00_read_nvram_data; 1420 1406 ha->isp_ops.write_nvram = qla2x00_write_nvram_data; 1421 1407 ha->isp_ops.fw_dump = qla2100_fw_dump; 1422 - ha->isp_ops.ascii_fw_dump = qla2100_ascii_fw_dump; 1423 1408 ha->isp_ops.read_optrom = qla2x00_read_optrom_data; 1424 1409 ha->isp_ops.write_optrom = qla2x00_write_optrom_data; 1425 1410 if (IS_QLA2100(ha)) { ··· 1445 1432 ha->isp_ops.pci_config = qla2300_pci_config; 1446 1433 ha->isp_ops.intr_handler = qla2300_intr_handler; 1447 1434 ha->isp_ops.fw_dump = qla2300_fw_dump; 1448 - ha->isp_ops.ascii_fw_dump = qla2300_ascii_fw_dump; 1449 1435 ha->isp_ops.beacon_on = qla2x00_beacon_on; 1450 1436 ha->isp_ops.beacon_off = qla2x00_beacon_off; 1451 1437 ha->isp_ops.beacon_blink = qla2x00_beacon_blink; ··· 1481 1469 ha->isp_ops.read_nvram = qla24xx_read_nvram_data; 1482 1470 ha->isp_ops.write_nvram = qla24xx_write_nvram_data; 1483 1471 ha->isp_ops.fw_dump = qla24xx_fw_dump; 1484 - ha->isp_ops.ascii_fw_dump = qla24xx_ascii_fw_dump; 1485 1472 ha->isp_ops.read_optrom = qla24xx_read_optrom_data; 1486 1473 ha->isp_ops.write_optrom = qla24xx_write_optrom_data; 1487 1474 ha->isp_ops.beacon_on = qla24xx_beacon_on; ··· 1651 1640 return ret; 1652 1641 } 1653 1642 1654 - static void qla2x00_remove_one(struct pci_dev *pdev) 1643 + static void __devexit 1644 + qla2x00_remove_one(struct pci_dev *pdev) 1655 1645 { 1656 1646 scsi_qla_host_t *ha; 1657 1647 ··· 1689 1677 ha->dpc_thread = NULL; 1690 1678 kthread_stop(t); 1691 1679 } 1680 + 1681 + if (ha->eft) 1682 + qla2x00_trace_control(ha, TC_DISABLE, 0, 0); 1692 1683 1693 1684 /* Stop currently executing firmware. */ 1694 1685 qla2x00_stop_firmware(ha); ··· 1914 1899 } 1915 1900 memset(ha->init_cb, 0, ha->init_cb_size); 1916 1901 1917 - /* Allocate ioctl related memory. */ 1918 - if (qla2x00_alloc_ioctl_mem(ha)) { 1919 - qla_printk(KERN_WARNING, ha, 1920 - "Memory Allocation failed - ioctl_mem\n"); 1921 - 1922 - qla2x00_mem_free(ha); 1923 - msleep(100); 1924 - 1925 - continue; 1926 - } 1927 - 1928 1902 if (qla2x00_allocate_sp_pool(ha)) { 1929 1903 qla_printk(KERN_WARNING, ha, 1930 1904 "Memory Allocation failed - " ··· 1976 1972 continue; 1977 1973 } 1978 1974 memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt)); 1975 + 1976 + if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1977 + /* 1978 + * Get consistent memory allocated for SFP 1979 + * block. 1980 + */ 1981 + ha->sfp_data = dma_pool_alloc(ha->s_dma_pool, 1982 + GFP_KERNEL, &ha->sfp_data_dma); 1983 + if (ha->sfp_data == NULL) { 1984 + qla_printk(KERN_WARNING, ha, 1985 + "Memory Allocation failed - " 1986 + "sfp_data\n"); 1987 + 1988 + qla2x00_mem_free(ha); 1989 + msleep(100); 1990 + 1991 + continue; 1992 + } 1993 + memset(ha->sfp_data, 0, SFP_BLOCK_SIZE); 1994 + } 1979 1995 } 1980 1996 1981 1997 /* Done all allocations without any error. */ ··· 2030 2006 return; 2031 2007 } 2032 2008 2033 - /* free ioctl memory */ 2034 - qla2x00_free_ioctl_mem(ha); 2035 - 2036 2009 /* free sp pool */ 2037 2010 qla2x00_free_sp_pool(ha); 2011 + 2012 + if (ha->fw_dump) { 2013 + if (ha->eft) 2014 + dma_free_coherent(&ha->pdev->dev, 2015 + ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma); 2016 + vfree(ha->fw_dump); 2017 + } 2038 2018 2039 2019 if (ha->sns_cmd) 2040 2020 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), ··· 2047 2019 if (ha->ct_sns) 2048 2020 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), 2049 2021 ha->ct_sns, ha->ct_sns_dma); 2022 + 2023 + if (ha->sfp_data) 2024 + dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); 2050 2025 2051 2026 if (ha->ms_iocb) 2052 2027 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); ··· 2074 2043 (ha->request_q_length + 1) * sizeof(request_t), 2075 2044 ha->request_ring, ha->request_dma); 2076 2045 2046 + ha->eft = NULL; 2047 + ha->eft_dma = 0; 2077 2048 ha->sns_cmd = NULL; 2078 2049 ha->sns_cmd_dma = 0; 2079 2050 ha->ct_sns = NULL; ··· 2104 2071 } 2105 2072 INIT_LIST_HEAD(&ha->fcports); 2106 2073 2107 - vfree(ha->fw_dump); 2108 - vfree(ha->fw_dump_buffer); 2109 - 2110 2074 ha->fw_dump = NULL; 2111 2075 ha->fw_dumped = 0; 2112 2076 ha->fw_dump_reading = 0; 2113 - ha->fw_dump_buffer = NULL; 2114 2077 2115 2078 vfree(ha->optrom_buffer); 2116 2079 } ··· 2646 2617 }; 2647 2618 MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); 2648 2619 2649 - static int __devinit 2650 - qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) 2651 - { 2652 - return qla2x00_probe_one(pdev); 2653 - } 2654 - 2655 - static void __devexit 2656 - qla2xxx_remove_one(struct pci_dev *pdev) 2657 - { 2658 - qla2x00_remove_one(pdev); 2659 - } 2660 - 2661 2620 static struct pci_driver qla2xxx_pci_driver = { 2662 2621 .name = QLA2XXX_DRIVER_NAME, 2663 2622 .driver = { 2664 2623 .owner = THIS_MODULE, 2665 2624 }, 2666 2625 .id_table = qla2xxx_pci_tbl, 2667 - .probe = qla2xxx_probe_one, 2668 - .remove = __devexit_p(qla2xxx_remove_one), 2626 + .probe = qla2x00_probe_one, 2627 + .remove = __devexit_p(qla2x00_remove_one), 2669 2628 }; 2670 - 2671 - static inline int 2672 - qla2x00_pci_module_init(void) 2673 - { 2674 - return pci_module_init(&qla2xxx_pci_driver); 2675 - } 2676 - 2677 - static inline void 2678 - qla2x00_pci_module_exit(void) 2679 - { 2680 - pci_unregister_driver(&qla2xxx_pci_driver); 2681 - } 2682 2629 2683 2630 /** 2684 2631 * qla2x00_module_init - Module initialization. ··· 2675 2670 2676 2671 /* Derive version string. */ 2677 2672 strcpy(qla2x00_version_str, QLA2XXX_VERSION); 2678 - #if DEBUG_QLA2100 2679 - strcat(qla2x00_version_str, "-debug"); 2680 - #endif 2673 + if (extended_error_logging) 2674 + strcat(qla2x00_version_str, "-debug"); 2675 + 2681 2676 qla2xxx_transport_template = 2682 2677 fc_attach_transport(&qla2xxx_transport_functions); 2683 2678 if (!qla2xxx_transport_template) 2684 2679 return -ENODEV; 2685 2680 2686 2681 printk(KERN_INFO "QLogic Fibre Channel HBA Driver\n"); 2687 - ret = qla2x00_pci_module_init(); 2682 + ret = pci_register_driver(&qla2xxx_pci_driver); 2688 2683 if (ret) { 2689 2684 kmem_cache_destroy(srb_cachep); 2690 2685 fc_release_transport(qla2xxx_transport_template); ··· 2698 2693 static void __exit 2699 2694 qla2x00_module_exit(void) 2700 2695 { 2701 - qla2x00_pci_module_exit(); 2696 + pci_unregister_driver(&qla2xxx_pci_driver); 2702 2697 qla2x00_release_firmware(); 2703 2698 kmem_cache_destroy(srb_cachep); 2704 2699 fc_release_transport(qla2xxx_transport_template);
+1 -1
drivers/scsi/qla2xxx/qla_version.h
··· 7 7 /* 8 8 * Driver version 9 9 */ 10 - #define QLA2XXX_VERSION "8.01.05-k2" 10 + #define QLA2XXX_VERSION "8.01.05-k3" 11 11 12 12 #define QLA_DRIVER_MAJOR_VER 8 13 13 #define QLA_DRIVER_MINOR_VER 1
+1028 -195
drivers/scsi/scsi_debug.c
··· 50 50 #include "scsi_logging.h" 51 51 #include "scsi_debug.h" 52 52 53 - #define SCSI_DEBUG_VERSION "1.75" 54 - static const char * scsi_debug_version_date = "20050113"; 53 + #define SCSI_DEBUG_VERSION "1.79" 54 + static const char * scsi_debug_version_date = "20060604"; 55 55 56 56 /* Additional Sense Code (ASC) used */ 57 - #define NO_ADDED_SENSE 0x0 57 + #define NO_ADDITIONAL_SENSE 0x0 58 + #define LOGICAL_UNIT_NOT_READY 0x4 58 59 #define UNRECOVERED_READ_ERR 0x11 60 + #define PARAMETER_LIST_LENGTH_ERR 0x1a 59 61 #define INVALID_OPCODE 0x20 60 62 #define ADDR_OUT_OF_RANGE 0x21 61 63 #define INVALID_FIELD_IN_CDB 0x24 64 + #define INVALID_FIELD_IN_PARAM_LIST 0x26 62 65 #define POWERON_RESET 0x29 63 66 #define SAVING_PARAMS_UNSUP 0x39 64 - #define THRESHHOLD_EXCEEDED 0x5d 67 + #define THRESHOLD_EXCEEDED 0x5d 68 + #define LOW_POWER_COND_ON 0x5e 65 69 66 70 #define SDEBUG_TAGGED_QUEUING 0 /* 0 | MSG_SIMPLE_TAG | MSG_ORDERED_TAG */ 67 71 ··· 84 80 #define DEF_SCSI_LEVEL 5 /* INQUIRY, byte2 [5->SPC-3] */ 85 81 #define DEF_PTYPE 0 86 82 #define DEF_D_SENSE 0 83 + #define DEF_NO_LUN_0 0 84 + #define DEF_VIRTUAL_GB 0 87 85 88 86 /* bit mask values for scsi_debug_opts */ 89 87 #define SCSI_DEBUG_OPT_NOISE 1 ··· 112 106 /* If REPORT LUNS has luns >= 256 it can choose "flat space" (value 1) 113 107 * or "peripheral device" addressing (value 0) */ 114 108 #define SAM2_LUN_ADDRESS_METHOD 0 109 + #define SAM2_WLUN_REPORT_LUNS 0xc101 115 110 116 111 static int scsi_debug_add_host = DEF_NUM_HOST; 117 112 static int scsi_debug_delay = DEF_DELAY; ··· 125 118 static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; 126 119 static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ 127 120 static int scsi_debug_dsense = DEF_D_SENSE; 121 + static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; 122 + static int scsi_debug_virtual_gb = DEF_VIRTUAL_GB; 128 123 129 124 static int scsi_debug_cmnd_count = 0; 130 125 131 126 #define DEV_READONLY(TGT) (0) 132 127 #define DEV_REMOVEABLE(TGT) (0) 133 128 134 - static unsigned long sdebug_store_size; /* in bytes */ 129 + static unsigned int sdebug_store_size; /* in bytes */ 130 + static unsigned int sdebug_store_sectors; 135 131 static sector_t sdebug_capacity; /* in sectors */ 136 132 137 133 /* old BIOS stuff, kernel may get rid of them but some mode sense pages ··· 159 149 unsigned int target; 160 150 unsigned int lun; 161 151 struct sdebug_host_info *sdbg_host; 152 + unsigned int wlun; 162 153 char reset; 154 + char stopped; 163 155 char used; 164 156 }; 165 157 ··· 205 193 .bios_param = scsi_debug_biosparam, 206 194 .can_queue = SCSI_DEBUG_CANQUEUE, 207 195 .this_id = 7, 208 - .sg_tablesize = 64, 209 - .cmd_per_lun = 3, 210 - .max_sectors = 4096, 196 + .sg_tablesize = 256, 197 + .cmd_per_lun = 16, 198 + .max_sectors = 0xffff, 211 199 .unchecked_isa_dma = 0, 212 - .use_clustering = DISABLE_CLUSTERING, 200 + .use_clustering = ENABLE_CLUSTERING, 213 201 .module = THIS_MODULE, 214 202 }; 215 203 ··· 237 225 static const int check_condition_result = 238 226 (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 239 227 228 + static unsigned char ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0, 229 + 0, 0, 0x2, 0x4b}; 230 + static unsigned char iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0, 231 + 0, 0, 0x0, 0x0}; 232 + 240 233 /* function declarations */ 241 234 static int resp_inquiry(struct scsi_cmnd * SCpnt, int target, 242 235 struct sdebug_dev_info * devip); 243 236 static int resp_requests(struct scsi_cmnd * SCpnt, 244 237 struct sdebug_dev_info * devip); 238 + static int resp_start_stop(struct scsi_cmnd * scp, 239 + struct sdebug_dev_info * devip); 245 240 static int resp_readcap(struct scsi_cmnd * SCpnt, 246 241 struct sdebug_dev_info * devip); 247 - static int resp_mode_sense(struct scsi_cmnd * SCpnt, int target, 242 + static int resp_readcap16(struct scsi_cmnd * SCpnt, 243 + struct sdebug_dev_info * devip); 244 + static int resp_mode_sense(struct scsi_cmnd * scp, int target, 248 245 struct sdebug_dev_info * devip); 249 - static int resp_read(struct scsi_cmnd * SCpnt, int upper_blk, int block, 250 - int num, struct sdebug_dev_info * devip); 251 - static int resp_write(struct scsi_cmnd * SCpnt, int upper_blk, int block, 252 - int num, struct sdebug_dev_info * devip); 246 + static int resp_mode_select(struct scsi_cmnd * scp, int mselect6, 247 + struct sdebug_dev_info * devip); 248 + static int resp_log_sense(struct scsi_cmnd * scp, 249 + struct sdebug_dev_info * devip); 250 + static int resp_read(struct scsi_cmnd * SCpnt, unsigned long long lba, 251 + unsigned int num, struct sdebug_dev_info * devip); 252 + static int resp_write(struct scsi_cmnd * SCpnt, unsigned long long lba, 253 + unsigned int num, struct sdebug_dev_info * devip); 253 254 static int resp_report_luns(struct scsi_cmnd * SCpnt, 254 255 struct sdebug_dev_info * devip); 255 256 static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, ··· 273 248 static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev); 274 249 static void mk_sense_buffer(struct sdebug_dev_info * devip, int key, 275 250 int asc, int asq); 276 - static int check_reset(struct scsi_cmnd * SCpnt, 277 - struct sdebug_dev_info * devip); 251 + static int check_readiness(struct scsi_cmnd * SCpnt, int reset_only, 252 + struct sdebug_dev_info * devip); 278 253 static int schedule_resp(struct scsi_cmnd * cmnd, 279 254 struct sdebug_dev_info * devip, 280 255 done_funct_t done, int scsi_result, int delta_jiff); ··· 282 257 static void __init init_all_queued(void); 283 258 static void stop_all_queued(void); 284 259 static int stop_queued_cmnd(struct scsi_cmnd * cmnd); 285 - static int inquiry_evpd_83(unsigned char * arr, int dev_id_num, 286 - const char * dev_id_str, int dev_id_str_len); 260 + static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 261 + int dev_id_num, const char * dev_id_str, 262 + int dev_id_str_len); 263 + static int inquiry_evpd_88(unsigned char * arr, int target_dev_id); 287 264 static void do_create_driverfs_files(void); 288 265 static void do_remove_driverfs_files(void); 289 266 ··· 301 274 int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done) 302 275 { 303 276 unsigned char *cmd = (unsigned char *) SCpnt->cmnd; 304 - int block, upper_blk, num, k; 277 + int len, k, j; 278 + unsigned int num; 279 + unsigned long long lba; 305 280 int errsts = 0; 306 - int target = scmd_id(SCpnt); 281 + int target = SCpnt->device->id; 307 282 struct sdebug_dev_info * devip = NULL; 308 283 int inj_recovered = 0; 284 + int delay_override = 0; 309 285 310 286 if (done == NULL) 311 287 return 0; /* assume mid level reprocessing command */ 312 288 289 + SCpnt->resid = 0; 313 290 if ((SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) && cmd) { 314 291 printk(KERN_INFO "scsi_debug: cmd "); 315 - for (k = 0, num = SCpnt->cmd_len; k < num; ++k) 292 + for (k = 0, len = SCpnt->cmd_len; k < len; ++k) 316 293 printk("%02x ", (int)cmd[k]); 317 294 printk("\n"); 318 295 } ··· 327 296 DID_NO_CONNECT << 16, 0); 328 297 } 329 298 330 - if (SCpnt->device->lun >= scsi_debug_max_luns) 299 + if ((SCpnt->device->lun >= scsi_debug_max_luns) && 300 + (SCpnt->device->lun != SAM2_WLUN_REPORT_LUNS)) 331 301 return schedule_resp(SCpnt, NULL, done, 332 302 DID_NO_CONNECT << 16, 0); 333 303 devip = devInfoReg(SCpnt->device); ··· 347 315 inj_recovered = 1; /* to reads and writes below */ 348 316 } 349 317 318 + if (devip->wlun) { 319 + switch (*cmd) { 320 + case INQUIRY: 321 + case REQUEST_SENSE: 322 + case TEST_UNIT_READY: 323 + case REPORT_LUNS: 324 + break; /* only allowable wlun commands */ 325 + default: 326 + if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 327 + printk(KERN_INFO "scsi_debug: Opcode: 0x%x " 328 + "not supported for wlun\n", *cmd); 329 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 330 + INVALID_OPCODE, 0); 331 + errsts = check_condition_result; 332 + return schedule_resp(SCpnt, devip, done, errsts, 333 + 0); 334 + } 335 + } 336 + 350 337 switch (*cmd) { 351 338 case INQUIRY: /* mandatory, ignore unit attention */ 339 + delay_override = 1; 352 340 errsts = resp_inquiry(SCpnt, target, devip); 353 341 break; 354 342 case REQUEST_SENSE: /* mandatory, ignore unit attention */ 343 + delay_override = 1; 355 344 errsts = resp_requests(SCpnt, devip); 356 345 break; 357 346 case REZERO_UNIT: /* actually this is REWIND for SSC */ 358 347 case START_STOP: 359 - errsts = check_reset(SCpnt, devip); 348 + errsts = resp_start_stop(SCpnt, devip); 360 349 break; 361 350 case ALLOW_MEDIUM_REMOVAL: 362 - if ((errsts = check_reset(SCpnt, devip))) 351 + if ((errsts = check_readiness(SCpnt, 1, devip))) 363 352 break; 364 353 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 365 354 printk(KERN_INFO "scsi_debug: Medium removal %s\n", 366 355 cmd[4] ? "inhibited" : "enabled"); 367 356 break; 368 357 case SEND_DIAGNOSTIC: /* mandatory */ 369 - errsts = check_reset(SCpnt, devip); 358 + errsts = check_readiness(SCpnt, 1, devip); 370 359 break; 371 360 case TEST_UNIT_READY: /* mandatory */ 372 - errsts = check_reset(SCpnt, devip); 361 + delay_override = 1; 362 + errsts = check_readiness(SCpnt, 0, devip); 373 363 break; 374 364 case RESERVE: 375 - errsts = check_reset(SCpnt, devip); 365 + errsts = check_readiness(SCpnt, 1, devip); 376 366 break; 377 367 case RESERVE_10: 378 - errsts = check_reset(SCpnt, devip); 368 + errsts = check_readiness(SCpnt, 1, devip); 379 369 break; 380 370 case RELEASE: 381 - errsts = check_reset(SCpnt, devip); 371 + errsts = check_readiness(SCpnt, 1, devip); 382 372 break; 383 373 case RELEASE_10: 384 - errsts = check_reset(SCpnt, devip); 374 + errsts = check_readiness(SCpnt, 1, devip); 385 375 break; 386 376 case READ_CAPACITY: 387 377 errsts = resp_readcap(SCpnt, devip); 378 + break; 379 + case SERVICE_ACTION_IN: 380 + if (SAI_READ_CAPACITY_16 != cmd[1]) { 381 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 382 + INVALID_OPCODE, 0); 383 + errsts = check_condition_result; 384 + break; 385 + } 386 + errsts = resp_readcap16(SCpnt, devip); 388 387 break; 389 388 case READ_16: 390 389 case READ_12: 391 390 case READ_10: 392 391 case READ_6: 393 - if ((errsts = check_reset(SCpnt, devip))) 392 + if ((errsts = check_readiness(SCpnt, 0, devip))) 394 393 break; 395 - upper_blk = 0; 396 394 if ((*cmd) == READ_16) { 397 - upper_blk = cmd[5] + (cmd[4] << 8) + 398 - (cmd[3] << 16) + (cmd[2] << 24); 399 - block = cmd[9] + (cmd[8] << 8) + 400 - (cmd[7] << 16) + (cmd[6] << 24); 395 + for (lba = 0, j = 0; j < 8; ++j) { 396 + if (j > 0) 397 + lba <<= 8; 398 + lba += cmd[2 + j]; 399 + } 401 400 num = cmd[13] + (cmd[12] << 8) + 402 401 (cmd[11] << 16) + (cmd[10] << 24); 403 402 } else if ((*cmd) == READ_12) { 404 - block = cmd[5] + (cmd[4] << 8) + 403 + lba = cmd[5] + (cmd[4] << 8) + 405 404 (cmd[3] << 16) + (cmd[2] << 24); 406 405 num = cmd[9] + (cmd[8] << 8) + 407 406 (cmd[7] << 16) + (cmd[6] << 24); 408 407 } else if ((*cmd) == READ_10) { 409 - block = cmd[5] + (cmd[4] << 8) + 408 + lba = cmd[5] + (cmd[4] << 8) + 410 409 (cmd[3] << 16) + (cmd[2] << 24); 411 410 num = cmd[8] + (cmd[7] << 8); 412 - } else { 413 - block = cmd[3] + (cmd[2] << 8) + 411 + } else { /* READ (6) */ 412 + lba = cmd[3] + (cmd[2] << 8) + 414 413 ((cmd[1] & 0x1f) << 16); 415 - num = cmd[4]; 414 + num = (0 == cmd[4]) ? 256 : cmd[4]; 416 415 } 417 - errsts = resp_read(SCpnt, upper_blk, block, num, devip); 416 + errsts = resp_read(SCpnt, lba, num, devip); 418 417 if (inj_recovered && (0 == errsts)) { 419 418 mk_sense_buffer(devip, RECOVERED_ERROR, 420 - THRESHHOLD_EXCEEDED, 0); 419 + THRESHOLD_EXCEEDED, 0); 421 420 errsts = check_condition_result; 422 421 } 423 422 break; 424 423 case REPORT_LUNS: /* mandatory, ignore unit attention */ 424 + delay_override = 1; 425 425 errsts = resp_report_luns(SCpnt, devip); 426 426 break; 427 427 case VERIFY: /* 10 byte SBC-2 command */ 428 - errsts = check_reset(SCpnt, devip); 428 + errsts = check_readiness(SCpnt, 0, devip); 429 429 break; 430 430 case WRITE_16: 431 431 case WRITE_12: 432 432 case WRITE_10: 433 433 case WRITE_6: 434 - if ((errsts = check_reset(SCpnt, devip))) 434 + if ((errsts = check_readiness(SCpnt, 0, devip))) 435 435 break; 436 - upper_blk = 0; 437 436 if ((*cmd) == WRITE_16) { 438 - upper_blk = cmd[5] + (cmd[4] << 8) + 439 - (cmd[3] << 16) + (cmd[2] << 24); 440 - block = cmd[9] + (cmd[8] << 8) + 441 - (cmd[7] << 16) + (cmd[6] << 24); 437 + for (lba = 0, j = 0; j < 8; ++j) { 438 + if (j > 0) 439 + lba <<= 8; 440 + lba += cmd[2 + j]; 441 + } 442 442 num = cmd[13] + (cmd[12] << 8) + 443 443 (cmd[11] << 16) + (cmd[10] << 24); 444 444 } else if ((*cmd) == WRITE_12) { 445 - block = cmd[5] + (cmd[4] << 8) + 445 + lba = cmd[5] + (cmd[4] << 8) + 446 446 (cmd[3] << 16) + (cmd[2] << 24); 447 447 num = cmd[9] + (cmd[8] << 8) + 448 448 (cmd[7] << 16) + (cmd[6] << 24); 449 449 } else if ((*cmd) == WRITE_10) { 450 - block = cmd[5] + (cmd[4] << 8) + 450 + lba = cmd[5] + (cmd[4] << 8) + 451 451 (cmd[3] << 16) + (cmd[2] << 24); 452 452 num = cmd[8] + (cmd[7] << 8); 453 - } else { 454 - block = cmd[3] + (cmd[2] << 8) + 453 + } else { /* WRITE (6) */ 454 + lba = cmd[3] + (cmd[2] << 8) + 455 455 ((cmd[1] & 0x1f) << 16); 456 - num = cmd[4]; 456 + num = (0 == cmd[4]) ? 256 : cmd[4]; 457 457 } 458 - errsts = resp_write(SCpnt, upper_blk, block, num, devip); 458 + errsts = resp_write(SCpnt, lba, num, devip); 459 459 if (inj_recovered && (0 == errsts)) { 460 460 mk_sense_buffer(devip, RECOVERED_ERROR, 461 - THRESHHOLD_EXCEEDED, 0); 461 + THRESHOLD_EXCEEDED, 0); 462 462 errsts = check_condition_result; 463 463 } 464 464 break; ··· 498 434 case MODE_SENSE_10: 499 435 errsts = resp_mode_sense(SCpnt, target, devip); 500 436 break; 437 + case MODE_SELECT: 438 + errsts = resp_mode_select(SCpnt, 1, devip); 439 + break; 440 + case MODE_SELECT_10: 441 + errsts = resp_mode_select(SCpnt, 0, devip); 442 + break; 443 + case LOG_SENSE: 444 + errsts = resp_log_sense(SCpnt, devip); 445 + break; 501 446 case SYNCHRONIZE_CACHE: 502 - errsts = check_reset(SCpnt, devip); 447 + delay_override = 1; 448 + errsts = check_readiness(SCpnt, 0, devip); 503 449 break; 504 450 default: 505 451 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 506 452 printk(KERN_INFO "scsi_debug: Opcode: 0x%x not " 507 453 "supported\n", *cmd); 508 - if ((errsts = check_reset(SCpnt, devip))) 454 + if ((errsts = check_readiness(SCpnt, 1, devip))) 509 455 break; /* Unit attention takes precedence */ 510 456 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_OPCODE, 0); 511 457 errsts = check_condition_result; 512 458 break; 513 459 } 514 - return schedule_resp(SCpnt, devip, done, errsts, scsi_debug_delay); 460 + return schedule_resp(SCpnt, devip, done, errsts, 461 + (delay_override ? 0 : scsi_debug_delay)); 515 462 } 516 463 517 464 static int scsi_debug_ioctl(struct scsi_device *dev, int cmd, void __user *arg) ··· 534 459 /* return -ENOTTY; // correct return but upsets fdisk */ 535 460 } 536 461 537 - static int check_reset(struct scsi_cmnd * SCpnt, struct sdebug_dev_info * devip) 462 + static int check_readiness(struct scsi_cmnd * SCpnt, int reset_only, 463 + struct sdebug_dev_info * devip) 538 464 { 539 465 if (devip->reset) { 540 466 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) ··· 543 467 "attention: power on reset\n"); 544 468 devip->reset = 0; 545 469 mk_sense_buffer(devip, UNIT_ATTENTION, POWERON_RESET, 0); 470 + return check_condition_result; 471 + } 472 + if ((0 == reset_only) && devip->stopped) { 473 + if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 474 + printk(KERN_INFO "scsi_debug: Reporting Not " 475 + "ready: initializing command required\n"); 476 + mk_sense_buffer(devip, NOT_READY, LOGICAL_UNIT_NOT_READY, 477 + 0x2); 546 478 return check_condition_result; 547 479 } 548 480 return 0; ··· 576 492 req_len = scp->request_bufflen; 577 493 act_len = (req_len < arr_len) ? req_len : arr_len; 578 494 memcpy(scp->request_buffer, arr, act_len); 579 - scp->resid = req_len - act_len; 495 + if (scp->resid) 496 + scp->resid -= act_len; 497 + else 498 + scp->resid = req_len - act_len; 580 499 return 0; 581 500 } 582 501 sgpnt = (struct scatterlist *)scp->request_buffer; ··· 602 515 } 603 516 req_len += sgpnt->length; 604 517 } 605 - scp->resid = req_len - act_len; 518 + if (scp->resid) 519 + scp->resid -= act_len; 520 + else 521 + scp->resid = req_len - act_len; 606 522 return 0; 607 523 } 608 524 ··· 656 566 static const char * inq_product_id = "scsi_debug "; 657 567 static const char * inq_product_rev = "0004"; 658 568 659 - static int inquiry_evpd_83(unsigned char * arr, int dev_id_num, 660 - const char * dev_id_str, int dev_id_str_len) 569 + static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 570 + int dev_id_num, const char * dev_id_str, 571 + int dev_id_str_len) 661 572 { 662 - int num; 573 + int num, port_a; 574 + char b[32]; 663 575 664 - /* Two identification descriptors: */ 576 + port_a = target_dev_id + 1; 665 577 /* T10 vendor identifier field format (faked) */ 666 578 arr[0] = 0x2; /* ASCII */ 667 579 arr[1] = 0x1; ··· 674 582 num = 8 + 16 + dev_id_str_len; 675 583 arr[3] = num; 676 584 num += 4; 677 - /* NAA IEEE registered identifier (faked) */ 678 - arr[num] = 0x1; /* binary */ 679 - arr[num + 1] = 0x3; 680 - arr[num + 2] = 0x0; 681 - arr[num + 3] = 0x8; 682 - arr[num + 4] = 0x51; /* ieee company id=0x123456 (faked) */ 683 - arr[num + 5] = 0x23; 684 - arr[num + 6] = 0x45; 685 - arr[num + 7] = 0x60; 686 - arr[num + 8] = (dev_id_num >> 24); 687 - arr[num + 9] = (dev_id_num >> 16) & 0xff; 688 - arr[num + 10] = (dev_id_num >> 8) & 0xff; 689 - arr[num + 11] = dev_id_num & 0xff; 690 - return num + 12; 585 + if (dev_id_num >= 0) { 586 + /* NAA-5, Logical unit identifier (binary) */ 587 + arr[num++] = 0x1; /* binary (not necessarily sas) */ 588 + arr[num++] = 0x3; /* PIV=0, lu, naa */ 589 + arr[num++] = 0x0; 590 + arr[num++] = 0x8; 591 + arr[num++] = 0x53; /* naa-5 ieee company id=0x333333 (fake) */ 592 + arr[num++] = 0x33; 593 + arr[num++] = 0x33; 594 + arr[num++] = 0x30; 595 + arr[num++] = (dev_id_num >> 24); 596 + arr[num++] = (dev_id_num >> 16) & 0xff; 597 + arr[num++] = (dev_id_num >> 8) & 0xff; 598 + arr[num++] = dev_id_num & 0xff; 599 + /* Target relative port number */ 600 + arr[num++] = 0x61; /* proto=sas, binary */ 601 + arr[num++] = 0x94; /* PIV=1, target port, rel port */ 602 + arr[num++] = 0x0; /* reserved */ 603 + arr[num++] = 0x4; /* length */ 604 + arr[num++] = 0x0; /* reserved */ 605 + arr[num++] = 0x0; /* reserved */ 606 + arr[num++] = 0x0; 607 + arr[num++] = 0x1; /* relative port A */ 608 + } 609 + /* NAA-5, Target port identifier */ 610 + arr[num++] = 0x61; /* proto=sas, binary */ 611 + arr[num++] = 0x93; /* piv=1, target port, naa */ 612 + arr[num++] = 0x0; 613 + arr[num++] = 0x8; 614 + arr[num++] = 0x52; /* naa-5, company id=0x222222 (fake) */ 615 + arr[num++] = 0x22; 616 + arr[num++] = 0x22; 617 + arr[num++] = 0x20; 618 + arr[num++] = (port_a >> 24); 619 + arr[num++] = (port_a >> 16) & 0xff; 620 + arr[num++] = (port_a >> 8) & 0xff; 621 + arr[num++] = port_a & 0xff; 622 + /* NAA-5, Target device identifier */ 623 + arr[num++] = 0x61; /* proto=sas, binary */ 624 + arr[num++] = 0xa3; /* piv=1, target device, naa */ 625 + arr[num++] = 0x0; 626 + arr[num++] = 0x8; 627 + arr[num++] = 0x52; /* naa-5, company id=0x222222 (fake) */ 628 + arr[num++] = 0x22; 629 + arr[num++] = 0x22; 630 + arr[num++] = 0x20; 631 + arr[num++] = (target_dev_id >> 24); 632 + arr[num++] = (target_dev_id >> 16) & 0xff; 633 + arr[num++] = (target_dev_id >> 8) & 0xff; 634 + arr[num++] = target_dev_id & 0xff; 635 + /* SCSI name string: Target device identifier */ 636 + arr[num++] = 0x63; /* proto=sas, UTF-8 */ 637 + arr[num++] = 0xa8; /* piv=1, target device, SCSI name string */ 638 + arr[num++] = 0x0; 639 + arr[num++] = 24; 640 + memcpy(arr + num, "naa.52222220", 12); 641 + num += 12; 642 + snprintf(b, sizeof(b), "%08X", target_dev_id); 643 + memcpy(arr + num, b, 8); 644 + num += 8; 645 + memset(arr + num, 0, 4); 646 + num += 4; 647 + return num; 648 + } 649 + 650 + 651 + static unsigned char vpd84_data[] = { 652 + /* from 4th byte */ 0x22,0x22,0x22,0x0,0xbb,0x0, 653 + 0x22,0x22,0x22,0x0,0xbb,0x1, 654 + 0x22,0x22,0x22,0x0,0xbb,0x2, 655 + }; 656 + 657 + static int inquiry_evpd_84(unsigned char * arr) 658 + { 659 + memcpy(arr, vpd84_data, sizeof(vpd84_data)); 660 + return sizeof(vpd84_data); 661 + } 662 + 663 + static int inquiry_evpd_85(unsigned char * arr) 664 + { 665 + int num = 0; 666 + const char * na1 = "https://www.kernel.org/config"; 667 + const char * na2 = "http://www.kernel.org/log"; 668 + int plen, olen; 669 + 670 + arr[num++] = 0x1; /* lu, storage config */ 671 + arr[num++] = 0x0; /* reserved */ 672 + arr[num++] = 0x0; 673 + olen = strlen(na1); 674 + plen = olen + 1; 675 + if (plen % 4) 676 + plen = ((plen / 4) + 1) * 4; 677 + arr[num++] = plen; /* length, null termianted, padded */ 678 + memcpy(arr + num, na1, olen); 679 + memset(arr + num + olen, 0, plen - olen); 680 + num += plen; 681 + 682 + arr[num++] = 0x4; /* lu, logging */ 683 + arr[num++] = 0x0; /* reserved */ 684 + arr[num++] = 0x0; 685 + olen = strlen(na2); 686 + plen = olen + 1; 687 + if (plen % 4) 688 + plen = ((plen / 4) + 1) * 4; 689 + arr[num++] = plen; /* length, null terminated, padded */ 690 + memcpy(arr + num, na2, olen); 691 + memset(arr + num + olen, 0, plen - olen); 692 + num += plen; 693 + 694 + return num; 695 + } 696 + 697 + /* SCSI ports VPD page */ 698 + static int inquiry_evpd_88(unsigned char * arr, int target_dev_id) 699 + { 700 + int num = 0; 701 + int port_a, port_b; 702 + 703 + port_a = target_dev_id + 1; 704 + port_b = port_a + 1; 705 + arr[num++] = 0x0; /* reserved */ 706 + arr[num++] = 0x0; /* reserved */ 707 + arr[num++] = 0x0; 708 + arr[num++] = 0x1; /* relative port 1 (primary) */ 709 + memset(arr + num, 0, 6); 710 + num += 6; 711 + arr[num++] = 0x0; 712 + arr[num++] = 12; /* length tp descriptor */ 713 + /* naa-5 target port identifier (A) */ 714 + arr[num++] = 0x61; /* proto=sas, binary */ 715 + arr[num++] = 0x93; /* PIV=1, target port, NAA */ 716 + arr[num++] = 0x0; /* reserved */ 717 + arr[num++] = 0x8; /* length */ 718 + arr[num++] = 0x52; /* NAA-5, company_id=0x222222 (fake) */ 719 + arr[num++] = 0x22; 720 + arr[num++] = 0x22; 721 + arr[num++] = 0x20; 722 + arr[num++] = (port_a >> 24); 723 + arr[num++] = (port_a >> 16) & 0xff; 724 + arr[num++] = (port_a >> 8) & 0xff; 725 + arr[num++] = port_a & 0xff; 726 + 727 + arr[num++] = 0x0; /* reserved */ 728 + arr[num++] = 0x0; /* reserved */ 729 + arr[num++] = 0x0; 730 + arr[num++] = 0x2; /* relative port 2 (secondary) */ 731 + memset(arr + num, 0, 6); 732 + num += 6; 733 + arr[num++] = 0x0; 734 + arr[num++] = 12; /* length tp descriptor */ 735 + /* naa-5 target port identifier (B) */ 736 + arr[num++] = 0x61; /* proto=sas, binary */ 737 + arr[num++] = 0x93; /* PIV=1, target port, NAA */ 738 + arr[num++] = 0x0; /* reserved */ 739 + arr[num++] = 0x8; /* length */ 740 + arr[num++] = 0x52; /* NAA-5, company_id=0x222222 (fake) */ 741 + arr[num++] = 0x22; 742 + arr[num++] = 0x22; 743 + arr[num++] = 0x20; 744 + arr[num++] = (port_b >> 24); 745 + arr[num++] = (port_b >> 16) & 0xff; 746 + arr[num++] = (port_b >> 8) & 0xff; 747 + arr[num++] = port_b & 0xff; 748 + 749 + return num; 750 + } 751 + 752 + 753 + static unsigned char vpd89_data[] = { 754 + /* from 4th byte */ 0,0,0,0, 755 + 'l','i','n','u','x',' ',' ',' ', 756 + 'S','A','T',' ','s','c','s','i','_','d','e','b','u','g',' ',' ', 757 + '1','2','3','4', 758 + 0x34,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, 759 + 0xec,0,0,0, 760 + 0x5a,0xc,0xff,0x3f,0x37,0xc8,0x10,0,0,0,0,0,0x3f,0,0,0, 761 + 0,0,0,0,0x58,0x58,0x58,0x58,0x58,0x58,0x58,0x58,0x20,0x20,0x20,0x20, 762 + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0,0,0,0x40,0x4,0,0x2e,0x33, 763 + 0x38,0x31,0x20,0x20,0x20,0x20,0x54,0x53,0x38,0x33,0x30,0x30,0x33,0x31, 764 + 0x53,0x41, 765 + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 766 + 0x20,0x20, 767 + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 768 + 0x10,0x80, 769 + 0,0,0,0x2f,0,0,0,0x2,0,0x2,0x7,0,0xff,0xff,0x1,0, 770 + 0x3f,0,0xc1,0xff,0x3e,0,0x10,0x1,0xb0,0xf8,0x50,0x9,0,0,0x7,0, 771 + 0x3,0,0x78,0,0x78,0,0xf0,0,0x78,0,0,0,0,0,0,0, 772 + 0,0,0,0,0,0,0,0,0x2,0,0,0,0,0,0,0, 773 + 0x7e,0,0x1b,0,0x6b,0x34,0x1,0x7d,0x3,0x40,0x69,0x34,0x1,0x3c,0x3,0x40, 774 + 0x7f,0x40,0,0,0,0,0xfe,0xfe,0,0,0,0,0,0xfe,0,0, 775 + 0,0,0,0,0,0,0,0,0xb0,0xf8,0x50,0x9,0,0,0,0, 776 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 777 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 778 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 779 + 0x1,0,0xb0,0xf8,0x50,0x9,0xb0,0xf8,0x50,0x9,0x20,0x20,0x2,0,0xb6,0x42, 780 + 0,0x80,0x8a,0,0x6,0x3c,0xa,0x3c,0xff,0xff,0xc6,0x7,0,0x1,0,0x8, 781 + 0xf0,0xf,0,0x10,0x2,0,0x30,0,0,0,0,0,0,0,0x6,0xfe, 782 + 0,0,0x2,0,0x50,0,0x8a,0,0x4f,0x95,0,0,0x21,0,0xb,0, 783 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 784 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 785 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 786 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 787 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 788 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 789 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 790 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 791 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 792 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 793 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 794 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xa5,0x51, 795 + }; 796 + 797 + static int inquiry_evpd_89(unsigned char * arr) 798 + { 799 + memcpy(arr, vpd89_data, sizeof(vpd89_data)); 800 + return sizeof(vpd89_data); 801 + } 802 + 803 + 804 + static unsigned char vpdb0_data[] = { 805 + /* from 4th byte */ 0,0,0,4, 806 + 0,0,0x4,0, 807 + 0,0,0,64, 808 + }; 809 + 810 + static int inquiry_evpd_b0(unsigned char * arr) 811 + { 812 + memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); 813 + if (sdebug_store_sectors > 0x400) { 814 + arr[4] = (sdebug_store_sectors >> 24) & 0xff; 815 + arr[5] = (sdebug_store_sectors >> 16) & 0xff; 816 + arr[6] = (sdebug_store_sectors >> 8) & 0xff; 817 + arr[7] = sdebug_store_sectors & 0xff; 818 + } 819 + return sizeof(vpdb0_data); 691 820 } 692 821 693 822 694 823 #define SDEBUG_LONG_INQ_SZ 96 695 - #define SDEBUG_MAX_INQ_ARR_SZ 128 824 + #define SDEBUG_MAX_INQ_ARR_SZ 584 696 825 697 826 static int resp_inquiry(struct scsi_cmnd * scp, int target, 698 827 struct sdebug_dev_info * devip) ··· 921 608 unsigned char pq_pdt; 922 609 unsigned char arr[SDEBUG_MAX_INQ_ARR_SZ]; 923 610 unsigned char *cmd = (unsigned char *)scp->cmnd; 924 - int alloc_len; 611 + int alloc_len, n; 925 612 926 613 alloc_len = (cmd[3] << 8) + cmd[4]; 927 614 memset(arr, 0, SDEBUG_MAX_INQ_ARR_SZ); 928 - pq_pdt = (scsi_debug_ptype & 0x1f); 615 + if (devip->wlun) 616 + pq_pdt = 0x1e; /* present, wlun */ 617 + else if (scsi_debug_no_lun_0 && (0 == devip->lun)) 618 + pq_pdt = 0x7f; /* not present, no device type */ 619 + else 620 + pq_pdt = (scsi_debug_ptype & 0x1f); 929 621 arr[0] = pq_pdt; 930 622 if (0x2 & cmd[1]) { /* CMDDT bit set */ 931 623 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 932 624 0); 933 625 return check_condition_result; 934 626 } else if (0x1 & cmd[1]) { /* EVPD bit set */ 935 - int dev_id_num, len; 936 - char dev_id_str[6]; 627 + int lu_id_num, target_dev_id, len; 628 + char lu_id_str[6]; 629 + int host_no = devip->sdbg_host->shost->host_no; 937 630 938 - dev_id_num = ((devip->sdbg_host->shost->host_no + 1) * 2000) + 939 - (devip->target * 1000) + devip->lun; 940 - len = scnprintf(dev_id_str, 6, "%d", dev_id_num); 631 + lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) + 632 + (devip->target * 1000) + devip->lun); 633 + target_dev_id = ((host_no + 1) * 2000) + 634 + (devip->target * 1000) - 3; 635 + len = scnprintf(lu_id_str, 6, "%d", lu_id_num); 941 636 if (0 == cmd[2]) { /* supported vital product data pages */ 942 - arr[3] = 3; 943 - arr[4] = 0x0; /* this page */ 944 - arr[5] = 0x80; /* unit serial number */ 945 - arr[6] = 0x83; /* device identification */ 637 + arr[1] = cmd[2]; /*sanity */ 638 + n = 4; 639 + arr[n++] = 0x0; /* this page */ 640 + arr[n++] = 0x80; /* unit serial number */ 641 + arr[n++] = 0x83; /* device identification */ 642 + arr[n++] = 0x84; /* software interface ident. */ 643 + arr[n++] = 0x85; /* management network addresses */ 644 + arr[n++] = 0x86; /* extended inquiry */ 645 + arr[n++] = 0x87; /* mode page policy */ 646 + arr[n++] = 0x88; /* SCSI ports */ 647 + arr[n++] = 0x89; /* ATA information */ 648 + arr[n++] = 0xb0; /* Block limits (SBC) */ 649 + arr[3] = n - 4; /* number of supported VPD pages */ 946 650 } else if (0x80 == cmd[2]) { /* unit serial number */ 947 - arr[1] = 0x80; 651 + arr[1] = cmd[2]; /*sanity */ 948 652 arr[3] = len; 949 - memcpy(&arr[4], dev_id_str, len); 653 + memcpy(&arr[4], lu_id_str, len); 950 654 } else if (0x83 == cmd[2]) { /* device identification */ 951 - arr[1] = 0x83; 952 - arr[3] = inquiry_evpd_83(&arr[4], dev_id_num, 953 - dev_id_str, len); 655 + arr[1] = cmd[2]; /*sanity */ 656 + arr[3] = inquiry_evpd_83(&arr[4], target_dev_id, 657 + lu_id_num, lu_id_str, len); 658 + } else if (0x84 == cmd[2]) { /* Software interface ident. */ 659 + arr[1] = cmd[2]; /*sanity */ 660 + arr[3] = inquiry_evpd_84(&arr[4]); 661 + } else if (0x85 == cmd[2]) { /* Management network addresses */ 662 + arr[1] = cmd[2]; /*sanity */ 663 + arr[3] = inquiry_evpd_85(&arr[4]); 664 + } else if (0x86 == cmd[2]) { /* extended inquiry */ 665 + arr[1] = cmd[2]; /*sanity */ 666 + arr[3] = 0x3c; /* number of following entries */ 667 + arr[4] = 0x0; /* no protection stuff */ 668 + arr[5] = 0x7; /* head of q, ordered + simple q's */ 669 + } else if (0x87 == cmd[2]) { /* mode page policy */ 670 + arr[1] = cmd[2]; /*sanity */ 671 + arr[3] = 0x8; /* number of following entries */ 672 + arr[4] = 0x2; /* disconnect-reconnect mp */ 673 + arr[6] = 0x80; /* mlus, shared */ 674 + arr[8] = 0x18; /* protocol specific lu */ 675 + arr[10] = 0x82; /* mlus, per initiator port */ 676 + } else if (0x88 == cmd[2]) { /* SCSI Ports */ 677 + arr[1] = cmd[2]; /*sanity */ 678 + arr[3] = inquiry_evpd_88(&arr[4], target_dev_id); 679 + } else if (0x89 == cmd[2]) { /* ATA information */ 680 + arr[1] = cmd[2]; /*sanity */ 681 + n = inquiry_evpd_89(&arr[4]); 682 + arr[2] = (n >> 8); 683 + arr[3] = (n & 0xff); 684 + } else if (0xb0 == cmd[2]) { /* Block limits (SBC) */ 685 + arr[1] = cmd[2]; /*sanity */ 686 + arr[3] = inquiry_evpd_b0(&arr[4]); 954 687 } else { 955 688 /* Illegal request, invalid field in cdb */ 956 689 mk_sense_buffer(devip, ILLEGAL_REQUEST, 957 690 INVALID_FIELD_IN_CDB, 0); 958 691 return check_condition_result; 959 692 } 693 + len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); 960 694 return fill_from_dev_buffer(scp, arr, 961 - min(alloc_len, SDEBUG_MAX_INQ_ARR_SZ)); 695 + min(len, SDEBUG_MAX_INQ_ARR_SZ)); 962 696 } 963 697 /* drops through here for a standard inquiry */ 964 698 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */ 965 699 arr[2] = scsi_debug_scsi_level; 966 700 arr[3] = 2; /* response_data_format==2 */ 967 701 arr[4] = SDEBUG_LONG_INQ_SZ - 5; 968 - arr[6] = 0x1; /* claim: ADDR16 */ 702 + arr[6] = 0x10; /* claim: MultiP */ 969 703 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */ 970 - arr[7] = 0x3a; /* claim: WBUS16, SYNC, LINKED + CMDQUE */ 704 + arr[7] = 0xa; /* claim: LINKED + CMDQUE */ 971 705 memcpy(&arr[8], inq_vendor_id, 8); 972 706 memcpy(&arr[16], inq_product_id, 16); 973 707 memcpy(&arr[32], inq_product_rev, 4); 974 708 /* version descriptors (2 bytes each) follow */ 975 - arr[58] = 0x0; arr[59] = 0x40; /* SAM-2 */ 976 - arr[60] = 0x3; arr[61] = 0x0; /* SPC-3 */ 709 + arr[58] = 0x0; arr[59] = 0x77; /* SAM-3 ANSI */ 710 + arr[60] = 0x3; arr[61] = 0x14; /* SPC-3 ANSI */ 711 + n = 62; 977 712 if (scsi_debug_ptype == 0) { 978 - arr[62] = 0x1; arr[63] = 0x80; /* SBC */ 713 + arr[n++] = 0x3; arr[n++] = 0x3d; /* SBC-2 ANSI */ 979 714 } else if (scsi_debug_ptype == 1) { 980 - arr[62] = 0x2; arr[63] = 0x00; /* SSC */ 715 + arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */ 981 716 } 717 + arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */ 982 718 return fill_from_dev_buffer(scp, arr, 983 719 min(alloc_len, SDEBUG_LONG_INQ_SZ)); 984 720 } ··· 1038 676 unsigned char * sbuff; 1039 677 unsigned char *cmd = (unsigned char *)scp->cmnd; 1040 678 unsigned char arr[SDEBUG_SENSE_LEN]; 679 + int want_dsense; 1041 680 int len = 18; 1042 681 1043 - memset(arr, 0, SDEBUG_SENSE_LEN); 682 + memset(arr, 0, sizeof(arr)); 1044 683 if (devip->reset == 1) 1045 - mk_sense_buffer(devip, 0, NO_ADDED_SENSE, 0); 684 + mk_sense_buffer(devip, 0, NO_ADDITIONAL_SENSE, 0); 685 + want_dsense = !!(cmd[1] & 1) || scsi_debug_dsense; 1046 686 sbuff = devip->sense_buff; 1047 - if ((cmd[1] & 1) && (! scsi_debug_dsense)) { 1048 - /* DESC bit set and sense_buff in fixed format */ 1049 - arr[0] = 0x72; 1050 - arr[1] = sbuff[2]; /* sense key */ 1051 - arr[2] = sbuff[12]; /* asc */ 1052 - arr[3] = sbuff[13]; /* ascq */ 1053 - len = 8; 1054 - } else 687 + if ((iec_m_pg[2] & 0x4) && (6 == (iec_m_pg[3] & 0xf))) { 688 + if (want_dsense) { 689 + arr[0] = 0x72; 690 + arr[1] = 0x0; /* NO_SENSE in sense_key */ 691 + arr[2] = THRESHOLD_EXCEEDED; 692 + arr[3] = 0xff; /* TEST set and MRIE==6 */ 693 + } else { 694 + arr[0] = 0x70; 695 + arr[2] = 0x0; /* NO_SENSE in sense_key */ 696 + arr[7] = 0xa; /* 18 byte sense buffer */ 697 + arr[12] = THRESHOLD_EXCEEDED; 698 + arr[13] = 0xff; /* TEST set and MRIE==6 */ 699 + } 700 + } else if (devip->stopped) { 701 + if (want_dsense) { 702 + arr[0] = 0x72; 703 + arr[1] = 0x0; /* NO_SENSE in sense_key */ 704 + arr[2] = LOW_POWER_COND_ON; 705 + arr[3] = 0x0; /* TEST set and MRIE==6 */ 706 + } else { 707 + arr[0] = 0x70; 708 + arr[2] = 0x0; /* NO_SENSE in sense_key */ 709 + arr[7] = 0xa; /* 18 byte sense buffer */ 710 + arr[12] = LOW_POWER_COND_ON; 711 + arr[13] = 0x0; /* TEST set and MRIE==6 */ 712 + } 713 + } else { 1055 714 memcpy(arr, sbuff, SDEBUG_SENSE_LEN); 1056 - mk_sense_buffer(devip, 0, NO_ADDED_SENSE, 0); 715 + if ((cmd[1] & 1) && (! scsi_debug_dsense)) { 716 + /* DESC bit set and sense_buff in fixed format */ 717 + memset(arr, 0, sizeof(arr)); 718 + arr[0] = 0x72; 719 + arr[1] = sbuff[2]; /* sense key */ 720 + arr[2] = sbuff[12]; /* asc */ 721 + arr[3] = sbuff[13]; /* ascq */ 722 + len = 8; 723 + } 724 + } 725 + mk_sense_buffer(devip, 0, NO_ADDITIONAL_SENSE, 0); 1057 726 return fill_from_dev_buffer(scp, arr, len); 727 + } 728 + 729 + static int resp_start_stop(struct scsi_cmnd * scp, 730 + struct sdebug_dev_info * devip) 731 + { 732 + unsigned char *cmd = (unsigned char *)scp->cmnd; 733 + int power_cond, errsts, start; 734 + 735 + if ((errsts = check_readiness(scp, 1, devip))) 736 + return errsts; 737 + power_cond = (cmd[4] & 0xf0) >> 4; 738 + if (power_cond) { 739 + mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 740 + 0); 741 + return check_condition_result; 742 + } 743 + start = cmd[4] & 1; 744 + if (start == devip->stopped) 745 + devip->stopped = !start; 746 + return 0; 1058 747 } 1059 748 1060 749 #define SDEBUG_READCAP_ARR_SZ 8 ··· 1113 700 struct sdebug_dev_info * devip) 1114 701 { 1115 702 unsigned char arr[SDEBUG_READCAP_ARR_SZ]; 1116 - unsigned long capac; 703 + unsigned int capac; 1117 704 int errsts; 1118 705 1119 - if ((errsts = check_reset(scp, devip))) 706 + if ((errsts = check_readiness(scp, 1, devip))) 1120 707 return errsts; 708 + /* following just in case virtual_gb changed */ 709 + if (scsi_debug_virtual_gb > 0) { 710 + sdebug_capacity = 2048 * 1024; 711 + sdebug_capacity *= scsi_debug_virtual_gb; 712 + } else 713 + sdebug_capacity = sdebug_store_sectors; 1121 714 memset(arr, 0, SDEBUG_READCAP_ARR_SZ); 1122 - capac = (unsigned long)sdebug_capacity - 1; 1123 - arr[0] = (capac >> 24); 1124 - arr[1] = (capac >> 16) & 0xff; 1125 - arr[2] = (capac >> 8) & 0xff; 1126 - arr[3] = capac & 0xff; 715 + if (sdebug_capacity < 0xffffffff) { 716 + capac = (unsigned int)sdebug_capacity - 1; 717 + arr[0] = (capac >> 24); 718 + arr[1] = (capac >> 16) & 0xff; 719 + arr[2] = (capac >> 8) & 0xff; 720 + arr[3] = capac & 0xff; 721 + } else { 722 + arr[0] = 0xff; 723 + arr[1] = 0xff; 724 + arr[2] = 0xff; 725 + arr[3] = 0xff; 726 + } 1127 727 arr[6] = (SECT_SIZE_PER(target) >> 8) & 0xff; 1128 728 arr[7] = SECT_SIZE_PER(target) & 0xff; 1129 729 return fill_from_dev_buffer(scp, arr, SDEBUG_READCAP_ARR_SZ); 730 + } 731 + 732 + #define SDEBUG_READCAP16_ARR_SZ 32 733 + static int resp_readcap16(struct scsi_cmnd * scp, 734 + struct sdebug_dev_info * devip) 735 + { 736 + unsigned char *cmd = (unsigned char *)scp->cmnd; 737 + unsigned char arr[SDEBUG_READCAP16_ARR_SZ]; 738 + unsigned long long capac; 739 + int errsts, k, alloc_len; 740 + 741 + if ((errsts = check_readiness(scp, 1, devip))) 742 + return errsts; 743 + alloc_len = ((cmd[10] << 24) + (cmd[11] << 16) + (cmd[12] << 8) 744 + + cmd[13]); 745 + /* following just in case virtual_gb changed */ 746 + if (scsi_debug_virtual_gb > 0) { 747 + sdebug_capacity = 2048 * 1024; 748 + sdebug_capacity *= scsi_debug_virtual_gb; 749 + } else 750 + sdebug_capacity = sdebug_store_sectors; 751 + memset(arr, 0, SDEBUG_READCAP16_ARR_SZ); 752 + capac = sdebug_capacity - 1; 753 + for (k = 0; k < 8; ++k, capac >>= 8) 754 + arr[7 - k] = capac & 0xff; 755 + arr[8] = (SECT_SIZE_PER(target) >> 24) & 0xff; 756 + arr[9] = (SECT_SIZE_PER(target) >> 16) & 0xff; 757 + arr[10] = (SECT_SIZE_PER(target) >> 8) & 0xff; 758 + arr[11] = SECT_SIZE_PER(target) & 0xff; 759 + return fill_from_dev_buffer(scp, arr, 760 + min(alloc_len, SDEBUG_READCAP16_ARR_SZ)); 1130 761 } 1131 762 1132 763 /* <<Following mode page info copied from ST318451LW>> */ ··· 1228 771 1229 772 static int resp_ctrl_m_pg(unsigned char * p, int pcontrol, int target) 1230 773 { /* Control mode page for mode_sense */ 1231 - unsigned char ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0, 774 + unsigned char ch_ctrl_m_pg[] = {/* 0xa, 10, */ 0x6, 0, 0, 0, 0, 0, 775 + 0, 0, 0, 0}; 776 + unsigned char d_ctrl_m_pg[] = {0xa, 10, 2, 0, 0, 0, 0, 0, 1232 777 0, 0, 0x2, 0x4b}; 1233 778 1234 779 if (scsi_debug_dsense) 1235 780 ctrl_m_pg[2] |= 0x4; 781 + else 782 + ctrl_m_pg[2] &= ~0x4; 1236 783 memcpy(p, ctrl_m_pg, sizeof(ctrl_m_pg)); 1237 784 if (1 == pcontrol) 1238 - memset(p + 2, 0, sizeof(ctrl_m_pg) - 2); 785 + memcpy(p + 2, ch_ctrl_m_pg, sizeof(ch_ctrl_m_pg)); 786 + else if (2 == pcontrol) 787 + memcpy(p, d_ctrl_m_pg, sizeof(d_ctrl_m_pg)); 1239 788 return sizeof(ctrl_m_pg); 1240 789 } 1241 790 791 + 1242 792 static int resp_iec_m_pg(unsigned char * p, int pcontrol, int target) 1243 793 { /* Informational Exceptions control mode page for mode_sense */ 1244 - unsigned char iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0, 1245 - 0, 0, 0x0, 0x0}; 794 + unsigned char ch_iec_m_pg[] = {/* 0x1c, 0xa, */ 0x4, 0xf, 0, 0, 0, 0, 795 + 0, 0, 0x0, 0x0}; 796 + unsigned char d_iec_m_pg[] = {0x1c, 0xa, 0x08, 0, 0, 0, 0, 0, 797 + 0, 0, 0x0, 0x0}; 798 + 1246 799 memcpy(p, iec_m_pg, sizeof(iec_m_pg)); 1247 800 if (1 == pcontrol) 1248 - memset(p + 2, 0, sizeof(iec_m_pg) - 2); 801 + memcpy(p + 2, ch_iec_m_pg, sizeof(ch_iec_m_pg)); 802 + else if (2 == pcontrol) 803 + memcpy(p, d_iec_m_pg, sizeof(d_iec_m_pg)); 1249 804 return sizeof(iec_m_pg); 805 + } 806 + 807 + static int resp_sas_sf_m_pg(unsigned char * p, int pcontrol, int target) 808 + { /* SAS SSP mode page - short format for mode_sense */ 809 + unsigned char sas_sf_m_pg[] = {0x19, 0x6, 810 + 0x6, 0x0, 0x7, 0xd0, 0x0, 0x0}; 811 + 812 + memcpy(p, sas_sf_m_pg, sizeof(sas_sf_m_pg)); 813 + if (1 == pcontrol) 814 + memset(p + 2, 0, sizeof(sas_sf_m_pg) - 2); 815 + return sizeof(sas_sf_m_pg); 816 + } 817 + 818 + 819 + static int resp_sas_pcd_m_spg(unsigned char * p, int pcontrol, int target, 820 + int target_dev_id) 821 + { /* SAS phy control and discover mode page for mode_sense */ 822 + unsigned char sas_pcd_m_pg[] = {0x59, 0x1, 0, 0x64, 0, 0x6, 0, 2, 823 + 0, 0, 0, 0, 0x10, 0x9, 0x8, 0x0, 824 + 0x52, 0x22, 0x22, 0x20, 0x0, 0x0, 0x0, 0x0, 825 + 0x51, 0x11, 0x11, 0x10, 0x0, 0x0, 0x0, 0x1, 826 + 0x2, 0, 0, 0, 0, 0, 0, 0, 827 + 0x88, 0x99, 0, 0, 0, 0, 0, 0, 828 + 0, 0, 0, 0, 0, 0, 0, 0, 829 + 0, 1, 0, 0, 0x10, 0x9, 0x8, 0x0, 830 + 0x52, 0x22, 0x22, 0x20, 0x0, 0x0, 0x0, 0x0, 831 + 0x51, 0x11, 0x11, 0x10, 0x0, 0x0, 0x0, 0x1, 832 + 0x3, 0, 0, 0, 0, 0, 0, 0, 833 + 0x88, 0x99, 0, 0, 0, 0, 0, 0, 834 + 0, 0, 0, 0, 0, 0, 0, 0, 835 + }; 836 + int port_a, port_b; 837 + 838 + port_a = target_dev_id + 1; 839 + port_b = port_a + 1; 840 + memcpy(p, sas_pcd_m_pg, sizeof(sas_pcd_m_pg)); 841 + p[20] = (port_a >> 24); 842 + p[21] = (port_a >> 16) & 0xff; 843 + p[22] = (port_a >> 8) & 0xff; 844 + p[23] = port_a & 0xff; 845 + p[48 + 20] = (port_b >> 24); 846 + p[48 + 21] = (port_b >> 16) & 0xff; 847 + p[48 + 22] = (port_b >> 8) & 0xff; 848 + p[48 + 23] = port_b & 0xff; 849 + if (1 == pcontrol) 850 + memset(p + 4, 0, sizeof(sas_pcd_m_pg) - 4); 851 + return sizeof(sas_pcd_m_pg); 852 + } 853 + 854 + static int resp_sas_sha_m_spg(unsigned char * p, int pcontrol) 855 + { /* SAS SSP shared protocol specific port mode subpage */ 856 + unsigned char sas_sha_m_pg[] = {0x59, 0x2, 0, 0xc, 0, 0x6, 0x10, 0, 857 + 0, 0, 0, 0, 0, 0, 0, 0, 858 + }; 859 + 860 + memcpy(p, sas_sha_m_pg, sizeof(sas_sha_m_pg)); 861 + if (1 == pcontrol) 862 + memset(p + 4, 0, sizeof(sas_sha_m_pg) - 4); 863 + return sizeof(sas_sha_m_pg); 1250 864 } 1251 865 1252 866 #define SDEBUG_MAX_MSENSE_SZ 256 ··· 1328 800 unsigned char dbd; 1329 801 int pcontrol, pcode, subpcode; 1330 802 unsigned char dev_spec; 1331 - int alloc_len, msense_6, offset, len, errsts; 803 + int alloc_len, msense_6, offset, len, errsts, target_dev_id; 1332 804 unsigned char * ap; 1333 805 unsigned char arr[SDEBUG_MAX_MSENSE_SZ]; 1334 806 unsigned char *cmd = (unsigned char *)scp->cmnd; 1335 807 1336 - if ((errsts = check_reset(scp, devip))) 808 + if ((errsts = check_readiness(scp, 1, devip))) 1337 809 return errsts; 1338 810 dbd = cmd[1] & 0x8; 1339 811 pcontrol = (cmd[2] & 0xc0) >> 6; ··· 1347 819 0); 1348 820 return check_condition_result; 1349 821 } 822 + target_dev_id = ((devip->sdbg_host->shost->host_no + 1) * 2000) + 823 + (devip->target * 1000) - 3; 1350 824 dev_spec = DEV_READONLY(target) ? 0x80 : 0x0; 1351 825 if (msense_6) { 1352 826 arr[2] = dev_spec; ··· 1359 829 } 1360 830 ap = arr + offset; 1361 831 1362 - if (0 != subpcode) { /* TODO: Control Extension page */ 832 + if ((subpcode > 0x0) && (subpcode < 0xff) && (0x19 != pcode)) { 833 + /* TODO: Control Extension page */ 1363 834 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 1364 835 0); 1365 836 return check_condition_result; ··· 1386 855 len = resp_ctrl_m_pg(ap, pcontrol, target); 1387 856 offset += len; 1388 857 break; 858 + case 0x19: /* if spc==1 then sas phy, control+discover */ 859 + if ((subpcode > 0x2) && (subpcode < 0xff)) { 860 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 861 + INVALID_FIELD_IN_CDB, 0); 862 + return check_condition_result; 863 + } 864 + len = 0; 865 + if ((0x0 == subpcode) || (0xff == subpcode)) 866 + len += resp_sas_sf_m_pg(ap + len, pcontrol, target); 867 + if ((0x1 == subpcode) || (0xff == subpcode)) 868 + len += resp_sas_pcd_m_spg(ap + len, pcontrol, target, 869 + target_dev_id); 870 + if ((0x2 == subpcode) || (0xff == subpcode)) 871 + len += resp_sas_sha_m_spg(ap + len, pcontrol); 872 + offset += len; 873 + break; 1389 874 case 0x1c: /* Informational Exceptions Mode page, all devices */ 1390 875 len = resp_iec_m_pg(ap, pcontrol, target); 1391 876 offset += len; 1392 877 break; 1393 878 case 0x3f: /* Read all Mode pages */ 1394 - len = resp_err_recov_pg(ap, pcontrol, target); 1395 - len += resp_disconnect_pg(ap + len, pcontrol, target); 1396 - len += resp_format_pg(ap + len, pcontrol, target); 1397 - len += resp_caching_pg(ap + len, pcontrol, target); 1398 - len += resp_ctrl_m_pg(ap + len, pcontrol, target); 1399 - len += resp_iec_m_pg(ap + len, pcontrol, target); 879 + if ((0 == subpcode) || (0xff == subpcode)) { 880 + len = resp_err_recov_pg(ap, pcontrol, target); 881 + len += resp_disconnect_pg(ap + len, pcontrol, target); 882 + len += resp_format_pg(ap + len, pcontrol, target); 883 + len += resp_caching_pg(ap + len, pcontrol, target); 884 + len += resp_ctrl_m_pg(ap + len, pcontrol, target); 885 + len += resp_sas_sf_m_pg(ap + len, pcontrol, target); 886 + if (0xff == subpcode) { 887 + len += resp_sas_pcd_m_spg(ap + len, pcontrol, 888 + target, target_dev_id); 889 + len += resp_sas_sha_m_spg(ap + len, pcontrol); 890 + } 891 + len += resp_iec_m_pg(ap + len, pcontrol, target); 892 + } else { 893 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 894 + INVALID_FIELD_IN_CDB, 0); 895 + return check_condition_result; 896 + } 1400 897 offset += len; 1401 898 break; 1402 899 default: ··· 1441 882 return fill_from_dev_buffer(scp, arr, min(alloc_len, offset)); 1442 883 } 1443 884 1444 - static int resp_read(struct scsi_cmnd * SCpnt, int upper_blk, int block, 1445 - int num, struct sdebug_dev_info * devip) 885 + #define SDEBUG_MAX_MSELECT_SZ 512 886 + 887 + static int resp_mode_select(struct scsi_cmnd * scp, int mselect6, 888 + struct sdebug_dev_info * devip) 889 + { 890 + int pf, sp, ps, md_len, bd_len, off, spf, pg_len; 891 + int param_len, res, errsts, mpage; 892 + unsigned char arr[SDEBUG_MAX_MSELECT_SZ]; 893 + unsigned char *cmd = (unsigned char *)scp->cmnd; 894 + 895 + if ((errsts = check_readiness(scp, 1, devip))) 896 + return errsts; 897 + memset(arr, 0, sizeof(arr)); 898 + pf = cmd[1] & 0x10; 899 + sp = cmd[1] & 0x1; 900 + param_len = mselect6 ? cmd[4] : ((cmd[7] << 8) + cmd[8]); 901 + if ((0 == pf) || sp || (param_len > SDEBUG_MAX_MSELECT_SZ)) { 902 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 903 + INVALID_FIELD_IN_CDB, 0); 904 + return check_condition_result; 905 + } 906 + res = fetch_to_dev_buffer(scp, arr, param_len); 907 + if (-1 == res) 908 + return (DID_ERROR << 16); 909 + else if ((res < param_len) && 910 + (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) 911 + printk(KERN_INFO "scsi_debug: mode_select: cdb indicated=%d, " 912 + " IO sent=%d bytes\n", param_len, res); 913 + md_len = mselect6 ? (arr[0] + 1) : ((arr[0] << 8) + arr[1] + 2); 914 + bd_len = mselect6 ? arr[3] : ((arr[6] << 8) + arr[7]); 915 + if ((md_len > 2) || (0 != bd_len)) { 916 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 917 + INVALID_FIELD_IN_PARAM_LIST, 0); 918 + return check_condition_result; 919 + } 920 + off = bd_len + (mselect6 ? 4 : 8); 921 + mpage = arr[off] & 0x3f; 922 + ps = !!(arr[off] & 0x80); 923 + if (ps) { 924 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 925 + INVALID_FIELD_IN_PARAM_LIST, 0); 926 + return check_condition_result; 927 + } 928 + spf = !!(arr[off] & 0x40); 929 + pg_len = spf ? ((arr[off + 2] << 8) + arr[off + 3] + 4) : 930 + (arr[off + 1] + 2); 931 + if ((pg_len + off) > param_len) { 932 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 933 + PARAMETER_LIST_LENGTH_ERR, 0); 934 + return check_condition_result; 935 + } 936 + switch (mpage) { 937 + case 0xa: /* Control Mode page */ 938 + if (ctrl_m_pg[1] == arr[off + 1]) { 939 + memcpy(ctrl_m_pg + 2, arr + off + 2, 940 + sizeof(ctrl_m_pg) - 2); 941 + scsi_debug_dsense = !!(ctrl_m_pg[2] & 0x4); 942 + return 0; 943 + } 944 + break; 945 + case 0x1c: /* Informational Exceptions Mode page */ 946 + if (iec_m_pg[1] == arr[off + 1]) { 947 + memcpy(iec_m_pg + 2, arr + off + 2, 948 + sizeof(iec_m_pg) - 2); 949 + return 0; 950 + } 951 + break; 952 + default: 953 + break; 954 + } 955 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 956 + INVALID_FIELD_IN_PARAM_LIST, 0); 957 + return check_condition_result; 958 + } 959 + 960 + static int resp_temp_l_pg(unsigned char * arr) 961 + { 962 + unsigned char temp_l_pg[] = {0x0, 0x0, 0x3, 0x2, 0x0, 38, 963 + 0x0, 0x1, 0x3, 0x2, 0x0, 65, 964 + }; 965 + 966 + memcpy(arr, temp_l_pg, sizeof(temp_l_pg)); 967 + return sizeof(temp_l_pg); 968 + } 969 + 970 + static int resp_ie_l_pg(unsigned char * arr) 971 + { 972 + unsigned char ie_l_pg[] = {0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 38, 973 + }; 974 + 975 + memcpy(arr, ie_l_pg, sizeof(ie_l_pg)); 976 + if (iec_m_pg[2] & 0x4) { /* TEST bit set */ 977 + arr[4] = THRESHOLD_EXCEEDED; 978 + arr[5] = 0xff; 979 + } 980 + return sizeof(ie_l_pg); 981 + } 982 + 983 + #define SDEBUG_MAX_LSENSE_SZ 512 984 + 985 + static int resp_log_sense(struct scsi_cmnd * scp, 986 + struct sdebug_dev_info * devip) 987 + { 988 + int ppc, sp, pcontrol, pcode, alloc_len, errsts, len, n; 989 + unsigned char arr[SDEBUG_MAX_LSENSE_SZ]; 990 + unsigned char *cmd = (unsigned char *)scp->cmnd; 991 + 992 + if ((errsts = check_readiness(scp, 1, devip))) 993 + return errsts; 994 + memset(arr, 0, sizeof(arr)); 995 + ppc = cmd[1] & 0x2; 996 + sp = cmd[1] & 0x1; 997 + if (ppc || sp) { 998 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 999 + INVALID_FIELD_IN_CDB, 0); 1000 + return check_condition_result; 1001 + } 1002 + pcontrol = (cmd[2] & 0xc0) >> 6; 1003 + pcode = cmd[2] & 0x3f; 1004 + alloc_len = (cmd[7] << 8) + cmd[8]; 1005 + arr[0] = pcode; 1006 + switch (pcode) { 1007 + case 0x0: /* Supported log pages log page */ 1008 + n = 4; 1009 + arr[n++] = 0x0; /* this page */ 1010 + arr[n++] = 0xd; /* Temperature */ 1011 + arr[n++] = 0x2f; /* Informational exceptions */ 1012 + arr[3] = n - 4; 1013 + break; 1014 + case 0xd: /* Temperature log page */ 1015 + arr[3] = resp_temp_l_pg(arr + 4); 1016 + break; 1017 + case 0x2f: /* Informational exceptions log page */ 1018 + arr[3] = resp_ie_l_pg(arr + 4); 1019 + break; 1020 + default: 1021 + mk_sense_buffer(devip, ILLEGAL_REQUEST, 1022 + INVALID_FIELD_IN_CDB, 0); 1023 + return check_condition_result; 1024 + } 1025 + len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); 1026 + return fill_from_dev_buffer(scp, arr, 1027 + min(len, SDEBUG_MAX_INQ_ARR_SZ)); 1028 + } 1029 + 1030 + static int resp_read(struct scsi_cmnd * SCpnt, unsigned long long lba, 1031 + unsigned int num, struct sdebug_dev_info * devip) 1446 1032 { 1447 1033 unsigned long iflags; 1034 + unsigned int block, from_bottom; 1035 + unsigned long long u; 1448 1036 int ret; 1449 1037 1450 - if (upper_blk || (block + num > sdebug_capacity)) { 1038 + if (lba + num > sdebug_capacity) { 1451 1039 mk_sense_buffer(devip, ILLEGAL_REQUEST, ADDR_OUT_OF_RANGE, 1040 + 0); 1041 + return check_condition_result; 1042 + } 1043 + /* transfer length excessive (tie in to block limits VPD page) */ 1044 + if (num > sdebug_store_sectors) { 1045 + mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 1452 1046 0); 1453 1047 return check_condition_result; 1454 1048 } 1455 1049 if ((SCSI_DEBUG_OPT_MEDIUM_ERR & scsi_debug_opts) && 1456 - (block <= OPT_MEDIUM_ERR_ADDR) && 1457 - ((block + num) > OPT_MEDIUM_ERR_ADDR)) { 1050 + (lba <= OPT_MEDIUM_ERR_ADDR) && 1051 + ((lba + num) > OPT_MEDIUM_ERR_ADDR)) { 1052 + /* claim unrecoverable read error */ 1458 1053 mk_sense_buffer(devip, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 1459 1054 0); 1460 - /* claim unrecoverable read error */ 1055 + /* set info field and valid bit for fixed descriptor */ 1056 + if (0x70 == (devip->sense_buff[0] & 0x7f)) { 1057 + devip->sense_buff[0] |= 0x80; /* Valid bit */ 1058 + ret = OPT_MEDIUM_ERR_ADDR; 1059 + devip->sense_buff[3] = (ret >> 24) & 0xff; 1060 + devip->sense_buff[4] = (ret >> 16) & 0xff; 1061 + devip->sense_buff[5] = (ret >> 8) & 0xff; 1062 + devip->sense_buff[6] = ret & 0xff; 1063 + } 1461 1064 return check_condition_result; 1462 1065 } 1463 1066 read_lock_irqsave(&atomic_rw, iflags); 1464 - ret = fill_from_dev_buffer(SCpnt, fake_storep + (block * SECT_SIZE), 1465 - num * SECT_SIZE); 1067 + if ((lba + num) <= sdebug_store_sectors) 1068 + ret = fill_from_dev_buffer(SCpnt, 1069 + fake_storep + (lba * SECT_SIZE), 1070 + num * SECT_SIZE); 1071 + else { 1072 + /* modulo when one arg is 64 bits needs do_div() */ 1073 + u = lba; 1074 + block = do_div(u, sdebug_store_sectors); 1075 + from_bottom = 0; 1076 + if ((block + num) > sdebug_store_sectors) 1077 + from_bottom = (block + num) - sdebug_store_sectors; 1078 + ret = fill_from_dev_buffer(SCpnt, 1079 + fake_storep + (block * SECT_SIZE), 1080 + (num - from_bottom) * SECT_SIZE); 1081 + if ((0 == ret) && (from_bottom > 0)) 1082 + ret = fill_from_dev_buffer(SCpnt, fake_storep, 1083 + from_bottom * SECT_SIZE); 1084 + } 1466 1085 read_unlock_irqrestore(&atomic_rw, iflags); 1467 1086 return ret; 1468 1087 } 1469 1088 1470 - static int resp_write(struct scsi_cmnd * SCpnt, int upper_blk, int block, 1471 - int num, struct sdebug_dev_info * devip) 1089 + static int resp_write(struct scsi_cmnd * SCpnt, unsigned long long lba, 1090 + unsigned int num, struct sdebug_dev_info * devip) 1472 1091 { 1473 1092 unsigned long iflags; 1093 + unsigned int block, to_bottom; 1094 + unsigned long long u; 1474 1095 int res; 1475 1096 1476 - if (upper_blk || (block + num > sdebug_capacity)) { 1097 + if (lba + num > sdebug_capacity) { 1477 1098 mk_sense_buffer(devip, ILLEGAL_REQUEST, ADDR_OUT_OF_RANGE, 1478 1099 0); 1479 1100 return check_condition_result; 1480 1101 } 1102 + /* transfer length excessive (tie in to block limits VPD page) */ 1103 + if (num > sdebug_store_sectors) { 1104 + mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 1105 + 0); 1106 + return check_condition_result; 1107 + } 1481 1108 1482 1109 write_lock_irqsave(&atomic_rw, iflags); 1483 - res = fetch_to_dev_buffer(SCpnt, fake_storep + (block * SECT_SIZE), 1484 - num * SECT_SIZE); 1110 + if ((lba + num) <= sdebug_store_sectors) 1111 + res = fetch_to_dev_buffer(SCpnt, 1112 + fake_storep + (lba * SECT_SIZE), 1113 + num * SECT_SIZE); 1114 + else { 1115 + /* modulo when one arg is 64 bits needs do_div() */ 1116 + u = lba; 1117 + block = do_div(u, sdebug_store_sectors); 1118 + to_bottom = 0; 1119 + if ((block + num) > sdebug_store_sectors) 1120 + to_bottom = (block + num) - sdebug_store_sectors; 1121 + res = fetch_to_dev_buffer(SCpnt, 1122 + fake_storep + (block * SECT_SIZE), 1123 + (num - to_bottom) * SECT_SIZE); 1124 + if ((0 == res) && (to_bottom > 0)) 1125 + res = fetch_to_dev_buffer(SCpnt, fake_storep, 1126 + to_bottom * SECT_SIZE); 1127 + } 1485 1128 write_unlock_irqrestore(&atomic_rw, iflags); 1486 1129 if (-1 == res) 1487 1130 return (DID_ERROR << 16); 1488 1131 else if ((res < (num * SECT_SIZE)) && 1489 1132 (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) 1490 - printk(KERN_INFO "scsi_debug: write: cdb indicated=%d, " 1133 + printk(KERN_INFO "scsi_debug: write: cdb indicated=%u, " 1491 1134 " IO sent=%d bytes\n", num * SECT_SIZE, res); 1492 1135 return 0; 1493 1136 } 1494 1137 1495 - #define SDEBUG_RLUN_ARR_SZ 128 1138 + #define SDEBUG_RLUN_ARR_SZ 256 1496 1139 1497 1140 static int resp_report_luns(struct scsi_cmnd * scp, 1498 1141 struct sdebug_dev_info * devip) 1499 1142 { 1500 1143 unsigned int alloc_len; 1501 - int lun_cnt, i, upper; 1144 + int lun_cnt, i, upper, num, n, wlun, lun; 1502 1145 unsigned char *cmd = (unsigned char *)scp->cmnd; 1503 1146 int select_report = (int)cmd[2]; 1504 1147 struct scsi_lun *one_lun; 1505 1148 unsigned char arr[SDEBUG_RLUN_ARR_SZ]; 1149 + unsigned char * max_addr; 1506 1150 1507 1151 alloc_len = cmd[9] + (cmd[8] << 8) + (cmd[7] << 16) + (cmd[6] << 24); 1508 - if ((alloc_len < 16) || (select_report > 2)) { 1152 + if ((alloc_len < 4) || (select_report > 2)) { 1509 1153 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 1510 1154 0); 1511 1155 return check_condition_result; ··· 1716 954 /* can produce response with up to 16k luns (lun 0 to lun 16383) */ 1717 955 memset(arr, 0, SDEBUG_RLUN_ARR_SZ); 1718 956 lun_cnt = scsi_debug_max_luns; 1719 - arr[2] = ((sizeof(struct scsi_lun) * lun_cnt) >> 8) & 0xff; 1720 - arr[3] = (sizeof(struct scsi_lun) * lun_cnt) & 0xff; 1721 - lun_cnt = min((int)((SDEBUG_RLUN_ARR_SZ - 8) / 1722 - sizeof(struct scsi_lun)), lun_cnt); 957 + if (1 == select_report) 958 + lun_cnt = 0; 959 + else if (scsi_debug_no_lun_0 && (lun_cnt > 0)) 960 + --lun_cnt; 961 + wlun = (select_report > 0) ? 1 : 0; 962 + num = lun_cnt + wlun; 963 + arr[2] = ((sizeof(struct scsi_lun) * num) >> 8) & 0xff; 964 + arr[3] = (sizeof(struct scsi_lun) * num) & 0xff; 965 + n = min((int)((SDEBUG_RLUN_ARR_SZ - 8) / 966 + sizeof(struct scsi_lun)), num); 967 + if (n < num) { 968 + wlun = 0; 969 + lun_cnt = n; 970 + } 1723 971 one_lun = (struct scsi_lun *) &arr[8]; 1724 - for (i = 0; i < lun_cnt; i++) { 1725 - upper = (i >> 8) & 0x3f; 972 + max_addr = arr + SDEBUG_RLUN_ARR_SZ; 973 + for (i = 0, lun = (scsi_debug_no_lun_0 ? 1 : 0); 974 + ((i < lun_cnt) && ((unsigned char *)(one_lun + i) < max_addr)); 975 + i++, lun++) { 976 + upper = (lun >> 8) & 0x3f; 1726 977 if (upper) 1727 978 one_lun[i].scsi_lun[0] = 1728 979 (upper | (SAM2_LUN_ADDRESS_METHOD << 6)); 1729 - one_lun[i].scsi_lun[1] = i & 0xff; 980 + one_lun[i].scsi_lun[1] = lun & 0xff; 1730 981 } 982 + if (wlun) { 983 + one_lun[i].scsi_lun[0] = (SAM2_WLUN_REPORT_LUNS >> 8) & 0xff; 984 + one_lun[i].scsi_lun[1] = SAM2_WLUN_REPORT_LUNS & 0xff; 985 + i++; 986 + } 987 + alloc_len = (unsigned char *)(one_lun + i) - arr; 1731 988 return fill_from_dev_buffer(scp, arr, 1732 989 min((int)alloc_len, SDEBUG_RLUN_ARR_SZ)); 1733 990 } ··· 1782 1001 static int scsi_debug_slave_alloc(struct scsi_device * sdp) 1783 1002 { 1784 1003 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 1785 - sdev_printk(KERN_INFO, sdp, "scsi_debug: slave_alloc\n"); 1004 + printk(KERN_INFO "scsi_debug: slave_alloc <%u %u %u %u>\n", 1005 + sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); 1786 1006 return 0; 1787 1007 } 1788 1008 ··· 1792 1010 struct sdebug_dev_info * devip; 1793 1011 1794 1012 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 1795 - sdev_printk(KERN_INFO, sdp, "scsi_debug: slave_configure\n"); 1013 + printk(KERN_INFO "scsi_debug: slave_configure <%u %u %u %u>\n", 1014 + sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); 1796 1015 if (sdp->host->max_cmd_len != SCSI_DEBUG_MAX_CMD_LEN) 1797 1016 sdp->host->max_cmd_len = SCSI_DEBUG_MAX_CMD_LEN; 1798 1017 devip = devInfoReg(sdp); ··· 1801 1018 if (sdp->host->cmd_per_lun) 1802 1019 scsi_adjust_queue_depth(sdp, SDEBUG_TAGGED_QUEUING, 1803 1020 sdp->host->cmd_per_lun); 1021 + blk_queue_max_segment_size(sdp->request_queue, 256 * 1024); 1804 1022 return 0; 1805 1023 } 1806 1024 ··· 1811 1027 (struct sdebug_dev_info *)sdp->hostdata; 1812 1028 1813 1029 if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) 1814 - sdev_printk(KERN_INFO, sdp, "scsi_debug: slave_destroy\n"); 1030 + printk(KERN_INFO "scsi_debug: slave_destroy <%u %u %u %u>\n", 1031 + sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); 1815 1032 if (devip) { 1816 1033 /* make this slot avaliable for re-use */ 1817 1034 devip->used = 0; ··· 1869 1084 open_devip->sense_buff[0] = 0x70; 1870 1085 open_devip->sense_buff[7] = 0xa; 1871 1086 } 1087 + if (sdev->lun == SAM2_WLUN_REPORT_LUNS) 1088 + open_devip->wlun = SAM2_WLUN_REPORT_LUNS & 0xff; 1872 1089 return open_devip; 1873 1090 } 1874 1091 return NULL; ··· 2059 1272 printk(KERN_WARNING "scsi_debug:build_parts: reducing " 2060 1273 "partitions to %d\n", SDEBUG_MAX_PARTS); 2061 1274 } 2062 - num_sectors = (int)(sdebug_store_size / SECT_SIZE); 1275 + num_sectors = (int)sdebug_store_sectors; 2063 1276 sectors_per_part = (num_sectors - sdebug_sectors_per) 2064 1277 / scsi_debug_num_parts; 2065 1278 heads_by_sects = sdebug_heads * sdebug_sectors_per; ··· 2102 1315 if (scsi_result) { 2103 1316 struct scsi_device * sdp = cmnd->device; 2104 1317 2105 - sdev_printk(KERN_INFO, sdp, 2106 - "non-zero result=0x%x\n", 2107 - scsi_result); 1318 + printk(KERN_INFO "scsi_debug: <%u %u %u %u> " 1319 + "non-zero result=0x%x\n", sdp->host->host_no, 1320 + sdp->channel, sdp->id, sdp->lun, scsi_result); 2108 1321 } 2109 1322 } 2110 1323 if (cmnd && devip) { ··· 2151 1364 } 2152 1365 } 2153 1366 2154 - /* Set 'perm' (4th argument) to 0 to disable module_param's definition 2155 - * of sysfs parameters (which module_param doesn't yet support). 2156 - * Sysfs parameters defined explicitly below. 2157 - */ 2158 - module_param_named(add_host, scsi_debug_add_host, int, 0); /* perm=0644 */ 2159 - module_param_named(delay, scsi_debug_delay, int, 0); /* perm=0644 */ 2160 - module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, 0); 2161 - module_param_named(dsense, scsi_debug_dsense, int, 0); 2162 - module_param_named(every_nth, scsi_debug_every_nth, int, 0); 2163 - module_param_named(max_luns, scsi_debug_max_luns, int, 0); 2164 - module_param_named(num_parts, scsi_debug_num_parts, int, 0); 2165 - module_param_named(num_tgts, scsi_debug_num_tgts, int, 0); 2166 - module_param_named(opts, scsi_debug_opts, int, 0); /* perm=0644 */ 2167 - module_param_named(ptype, scsi_debug_ptype, int, 0); 2168 - module_param_named(scsi_level, scsi_debug_scsi_level, int, 0); 1367 + module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); 1368 + module_param_named(delay, scsi_debug_delay, int, S_IRUGO | S_IWUSR); 1369 + module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, S_IRUGO); 1370 + module_param_named(dsense, scsi_debug_dsense, int, S_IRUGO | S_IWUSR); 1371 + module_param_named(every_nth, scsi_debug_every_nth, int, S_IRUGO | S_IWUSR); 1372 + module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); 1373 + module_param_named(no_lun_0, scsi_debug_no_lun_0, int, S_IRUGO | S_IWUSR); 1374 + module_param_named(num_parts, scsi_debug_num_parts, int, S_IRUGO); 1375 + module_param_named(num_tgts, scsi_debug_num_tgts, int, S_IRUGO | S_IWUSR); 1376 + module_param_named(opts, scsi_debug_opts, int, S_IRUGO | S_IWUSR); 1377 + module_param_named(ptype, scsi_debug_ptype, int, S_IRUGO | S_IWUSR); 1378 + module_param_named(scsi_level, scsi_debug_scsi_level, int, S_IRUGO); 1379 + module_param_named(virtual_gb, scsi_debug_virtual_gb, int, S_IRUGO | S_IWUSR); 2169 1380 2170 1381 MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); 2171 1382 MODULE_DESCRIPTION("SCSI debug adapter driver"); ··· 2172 1387 2173 1388 MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); 2174 1389 MODULE_PARM_DESC(delay, "# of jiffies to delay response(def=1)"); 2175 - MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs"); 2176 - MODULE_PARM_DESC(dsense, "use descriptor sense format(def: fixed)"); 1390 + MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs(def=8)"); 1391 + MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); 2177 1392 MODULE_PARM_DESC(every_nth, "timeout every nth command(def=100)"); 2178 - MODULE_PARM_DESC(max_luns, "number of SCSI LUNs per target to simulate"); 1393 + MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); 1394 + MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)"); 2179 1395 MODULE_PARM_DESC(num_parts, "number of partitions(def=0)"); 2180 - MODULE_PARM_DESC(num_tgts, "number of SCSI targets per host to simulate"); 2181 - MODULE_PARM_DESC(opts, "1->noise, 2->medium_error, 4->..."); 1396 + MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); 1397 + MODULE_PARM_DESC(opts, "1->noise, 2->medium_error, 4->... (def=0)"); 2182 1398 MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); 2183 1399 MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); 1400 + MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); 2184 1401 2185 1402 2186 1403 static char sdebug_info[256]; ··· 2334 1547 DRIVER_ATTR(dsense, S_IRUGO | S_IWUSR, sdebug_dsense_show, 2335 1548 sdebug_dsense_store); 2336 1549 1550 + static ssize_t sdebug_no_lun_0_show(struct device_driver * ddp, char * buf) 1551 + { 1552 + return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_lun_0); 1553 + } 1554 + static ssize_t sdebug_no_lun_0_store(struct device_driver * ddp, 1555 + const char * buf, size_t count) 1556 + { 1557 + int n; 1558 + 1559 + if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { 1560 + scsi_debug_no_lun_0 = n; 1561 + return count; 1562 + } 1563 + return -EINVAL; 1564 + } 1565 + DRIVER_ATTR(no_lun_0, S_IRUGO | S_IWUSR, sdebug_no_lun_0_show, 1566 + sdebug_no_lun_0_store); 1567 + 2337 1568 static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf) 2338 1569 { 2339 1570 return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts); ··· 2427 1622 } 2428 1623 DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL); 2429 1624 1625 + static ssize_t sdebug_virtual_gb_show(struct device_driver * ddp, char * buf) 1626 + { 1627 + return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb); 1628 + } 1629 + static ssize_t sdebug_virtual_gb_store(struct device_driver * ddp, 1630 + const char * buf, size_t count) 1631 + { 1632 + int n; 1633 + 1634 + if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { 1635 + scsi_debug_virtual_gb = n; 1636 + if (scsi_debug_virtual_gb > 0) { 1637 + sdebug_capacity = 2048 * 1024; 1638 + sdebug_capacity *= scsi_debug_virtual_gb; 1639 + } else 1640 + sdebug_capacity = sdebug_store_sectors; 1641 + return count; 1642 + } 1643 + return -EINVAL; 1644 + } 1645 + DRIVER_ATTR(virtual_gb, S_IRUGO | S_IWUSR, sdebug_virtual_gb_show, 1646 + sdebug_virtual_gb_store); 1647 + 2430 1648 static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf) 2431 1649 { 2432 1650 return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host); ··· 2519 1691 2520 1692 static int __init scsi_debug_init(void) 2521 1693 { 2522 - unsigned long sz; 1694 + unsigned int sz; 2523 1695 int host_to_add; 2524 1696 int k; 2525 1697 2526 1698 if (scsi_debug_dev_size_mb < 1) 2527 1699 scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ 2528 - sdebug_store_size = (unsigned long)scsi_debug_dev_size_mb * 1048576; 2529 - sdebug_capacity = sdebug_store_size / SECT_SIZE; 1700 + sdebug_store_size = (unsigned int)scsi_debug_dev_size_mb * 1048576; 1701 + sdebug_store_sectors = sdebug_store_size / SECT_SIZE; 1702 + if (scsi_debug_virtual_gb > 0) { 1703 + sdebug_capacity = 2048 * 1024; 1704 + sdebug_capacity *= scsi_debug_virtual_gb; 1705 + } else 1706 + sdebug_capacity = sdebug_store_sectors; 2530 1707 2531 1708 /* play around with geometry, don't waste too much on track 0 */ 2532 1709 sdebug_heads = 8; ··· 2645 1812 struct sdebug_dev_info *sdbg_devinfo; 2646 1813 struct list_head *lh, *lh_sf; 2647 1814 2648 - sdbg_host = kzalloc(sizeof(*sdbg_host), GFP_KERNEL); 1815 + sdbg_host = kzalloc(sizeof(*sdbg_host),GFP_KERNEL); 2649 1816 2650 1817 if (NULL == sdbg_host) { 2651 1818 printk(KERN_ERR "%s: out of memory at line %d\n", ··· 2657 1824 2658 1825 devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns; 2659 1826 for (k = 0; k < devs_per_host; k++) { 2660 - sdbg_devinfo = kzalloc(sizeof(*sdbg_devinfo), GFP_KERNEL); 1827 + sdbg_devinfo = kzalloc(sizeof(*sdbg_devinfo),GFP_KERNEL); 2661 1828 if (NULL == sdbg_devinfo) { 2662 1829 printk(KERN_ERR "%s: out of memory at line %d\n", 2663 1830 __FUNCTION__, __LINE__); ··· 2738 1905 hpnt->max_id = scsi_debug_num_tgts + 1; 2739 1906 else 2740 1907 hpnt->max_id = scsi_debug_num_tgts; 2741 - hpnt->max_lun = scsi_debug_max_luns; 1908 + hpnt->max_lun = SAM2_WLUN_REPORT_LUNS; /* = scsi_debug_max_luns; */ 2742 1909 2743 1910 error = scsi_add_host(hpnt, &sdbg_host->dev); 2744 1911 if (error) { ··· 2792 1959 hpnt->max_id = scsi_debug_num_tgts + 1; 2793 1960 else 2794 1961 hpnt->max_id = scsi_debug_num_tgts; 2795 - hpnt->max_lun = scsi_debug_max_luns; 1962 + hpnt->max_lun = SAM2_WLUN_REPORT_LUNS; /* scsi_debug_max_luns; */ 2796 1963 } 2797 1964 spin_unlock(&sdebug_host_list_lock); 2798 1965 }
+1 -1
drivers/scsi/scsi_devinfo.c
··· 162 162 {"HITACHI", "DISK-SUBSYSTEM", "*", BLIST_ATTACH_PQ3 | BLIST_SPARSELUN | BLIST_LARGELUN}, 163 163 {"HITACHI", "OPEN-E", "*", BLIST_ATTACH_PQ3 | BLIST_SPARSELUN | BLIST_LARGELUN}, 164 164 {"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP VA7400 */ 165 - {"HP", "OPEN-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP XP Arrays */ 165 + {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */ 166 166 {"HP", "NetRAID-4M", NULL, BLIST_FORCELUN}, 167 167 {"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, 168 168 {"HP", "C1557A", NULL, BLIST_FORCELUN},
+22
drivers/scsi/scsi_error.c
··· 1672 1672 scsi_reset_provider(struct scsi_device *dev, int flag) 1673 1673 { 1674 1674 struct scsi_cmnd *scmd = scsi_get_command(dev, GFP_KERNEL); 1675 + struct Scsi_Host *shost = dev->host; 1675 1676 struct request req; 1677 + unsigned long flags; 1676 1678 int rtn; 1677 1679 1678 1680 scmd->request = &req; ··· 1701 1699 */ 1702 1700 scmd->pid = 0; 1703 1701 1702 + spin_lock_irqsave(shost->host_lock, flags); 1703 + shost->tmf_in_progress = 1; 1704 + spin_unlock_irqrestore(shost->host_lock, flags); 1705 + 1704 1706 switch (flag) { 1705 1707 case SCSI_TRY_RESET_DEVICE: 1706 1708 rtn = scsi_try_bus_device_reset(scmd); ··· 1722 1716 default: 1723 1717 rtn = FAILED; 1724 1718 } 1719 + 1720 + spin_lock_irqsave(shost->host_lock, flags); 1721 + shost->tmf_in_progress = 0; 1722 + spin_unlock_irqrestore(shost->host_lock, flags); 1723 + 1724 + /* 1725 + * be sure to wake up anyone who was sleeping or had their queue 1726 + * suspended while we performed the TMF. 1727 + */ 1728 + SCSI_LOG_ERROR_RECOVERY(3, 1729 + printk("%s: waking up host to restart after TMF\n", 1730 + __FUNCTION__)); 1731 + 1732 + wake_up(&shost->host_wait); 1733 + 1734 + scsi_run_host_queues(shost); 1725 1735 1726 1736 scsi_next_command(scmd); 1727 1737 return rtn;
+51 -73
drivers/scsi/scsi_lib.c
··· 855 855 * b) We can just use scsi_requeue_command() here. This would 856 856 * be used if we just wanted to retry, for example. 857 857 */ 858 - void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, 859 - unsigned int block_bytes) 858 + void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) 860 859 { 861 860 int result = cmd->result; 862 861 int this_count = cmd->bufflen; ··· 920 921 * Next deal with any sectors which we were able to correctly 921 922 * handle. 922 923 */ 923 - if (good_bytes >= 0) { 924 - SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n", 925 - req->nr_sectors, good_bytes)); 926 - SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg)); 924 + SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, " 925 + "%d bytes done.\n", 926 + req->nr_sectors, good_bytes)); 927 + SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg)); 927 928 928 - if (clear_errors) 929 - req->errors = 0; 930 - /* 931 - * If multiple sectors are requested in one buffer, then 932 - * they will have been finished off by the first command. 933 - * If not, then we have a multi-buffer command. 934 - * 935 - * If block_bytes != 0, it means we had a medium error 936 - * of some sort, and that we want to mark some number of 937 - * sectors as not uptodate. Thus we want to inhibit 938 - * requeueing right here - we will requeue down below 939 - * when we handle the bad sectors. 940 - */ 929 + if (clear_errors) 930 + req->errors = 0; 941 931 942 - /* 943 - * If the command completed without error, then either 944 - * finish off the rest of the command, or start a new one. 945 - */ 946 - if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL) 947 - return; 948 - } 949 - /* 950 - * Now, if we were good little boys and girls, Santa left us a request 951 - * sense buffer. We can extract information from this, so we 952 - * can choose a block to remap, etc. 932 + /* A number of bytes were successfully read. If there 933 + * are leftovers and there is some kind of error 934 + * (result != 0), retry the rest. 935 + */ 936 + if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL) 937 + return; 938 + 939 + /* good_bytes = 0, or (inclusive) there were leftovers and 940 + * result = 0, so scsi_end_request couldn't retry. 953 941 */ 954 942 if (sense_valid && !sense_deferred) { 955 943 switch (sshdr.sense_key) { 956 944 case UNIT_ATTENTION: 957 945 if (cmd->device->removable) { 958 - /* detected disc change. set a bit 946 + /* Detected disc change. Set a bit 959 947 * and quietly refuse further access. 960 948 */ 961 949 cmd->device->changed = 1; 962 - scsi_end_request(cmd, 0, 963 - this_count, 1); 950 + scsi_end_request(cmd, 0, this_count, 1); 964 951 return; 965 952 } else { 966 - /* 967 - * Must have been a power glitch, or a 968 - * bus reset. Could not have been a 969 - * media change, so we just retry the 970 - * request and see what happens. 971 - */ 953 + /* Must have been a power glitch, or a 954 + * bus reset. Could not have been a 955 + * media change, so we just retry the 956 + * request and see what happens. 957 + */ 972 958 scsi_requeue_command(q, cmd); 973 959 return; 974 960 } 975 961 break; 976 962 case ILLEGAL_REQUEST: 977 - /* 978 - * If we had an ILLEGAL REQUEST returned, then we may 979 - * have performed an unsupported command. The only 980 - * thing this should be would be a ten byte read where 981 - * only a six byte read was supported. Also, on a 982 - * system where READ CAPACITY failed, we may have read 983 - * past the end of the disk. 984 - */ 963 + /* If we had an ILLEGAL REQUEST returned, then 964 + * we may have performed an unsupported 965 + * command. The only thing this should be 966 + * would be a ten byte read where only a six 967 + * byte read was supported. Also, on a system 968 + * where READ CAPACITY failed, we may have 969 + * read past the end of the disk. 970 + */ 985 971 if ((cmd->device->use_10_for_rw && 986 972 sshdr.asc == 0x20 && sshdr.ascq == 0x00) && 987 973 (cmd->cmnd[0] == READ_10 || 988 974 cmd->cmnd[0] == WRITE_10)) { 989 975 cmd->device->use_10_for_rw = 0; 990 - /* 991 - * This will cause a retry with a 6-byte 992 - * command. 976 + /* This will cause a retry with a 977 + * 6-byte command. 993 978 */ 994 979 scsi_requeue_command(q, cmd); 995 - result = 0; 980 + return; 996 981 } else { 997 982 scsi_end_request(cmd, 0, this_count, 1); 998 983 return; 999 984 } 1000 985 break; 1001 986 case NOT_READY: 1002 - /* 1003 - * If the device is in the process of becoming 987 + /* If the device is in the process of becoming 1004 988 * ready, or has a temporary blockage, retry. 1005 989 */ 1006 990 if (sshdr.asc == 0x04) { ··· 1003 1021 } 1004 1022 if (!(req->flags & REQ_QUIET)) { 1005 1023 scmd_printk(KERN_INFO, cmd, 1006 - "Device not ready: "); 1024 + "Device not ready: "); 1007 1025 scsi_print_sense_hdr("", &sshdr); 1008 1026 } 1009 1027 scsi_end_request(cmd, 0, this_count, 1); ··· 1011 1029 case VOLUME_OVERFLOW: 1012 1030 if (!(req->flags & REQ_QUIET)) { 1013 1031 scmd_printk(KERN_INFO, cmd, 1014 - "Volume overflow, CDB: "); 1032 + "Volume overflow, CDB: "); 1015 1033 __scsi_print_command(cmd->data_cmnd); 1016 1034 scsi_print_sense("", cmd); 1017 1035 } 1018 - scsi_end_request(cmd, 0, block_bytes, 1); 1036 + /* See SSC3rXX or current. */ 1037 + scsi_end_request(cmd, 0, this_count, 1); 1019 1038 return; 1020 1039 default: 1021 1040 break; 1022 1041 } 1023 - } /* driver byte != 0 */ 1042 + } 1024 1043 if (host_byte(result) == DID_RESET) { 1025 - /* 1026 - * Third party bus reset or reset for error 1027 - * recovery reasons. Just retry the request 1028 - * and see what happens. 1044 + /* Third party bus reset or reset for error recovery 1045 + * reasons. Just retry the request and see what 1046 + * happens. 1029 1047 */ 1030 1048 scsi_requeue_command(q, cmd); 1031 1049 return; ··· 1033 1051 if (result) { 1034 1052 if (!(req->flags & REQ_QUIET)) { 1035 1053 scmd_printk(KERN_INFO, cmd, 1036 - "SCSI error: return code = 0x%x\n", result); 1037 - 1054 + "SCSI error: return code = 0x%08x\n", 1055 + result); 1038 1056 if (driver_byte(result) & DRIVER_SENSE) 1039 1057 scsi_print_sense("", cmd); 1040 1058 } 1041 - /* 1042 - * Mark a single buffer as not uptodate. Queue the remainder. 1043 - * We sometimes get this cruft in the event that a medium error 1044 - * isn't properly reported. 1045 - */ 1046 - block_bytes = req->hard_cur_sectors << 9; 1047 - if (!block_bytes) 1048 - block_bytes = req->data_len; 1049 - scsi_end_request(cmd, 0, block_bytes, 1); 1050 1059 } 1060 + scsi_end_request(cmd, 0, this_count, !result); 1051 1061 } 1052 1062 EXPORT_SYMBOL(scsi_io_completion); 1053 1063 ··· 1143 1169 * successfully. Since this is a REQ_BLOCK_PC command the 1144 1170 * caller should check the request's errors value 1145 1171 */ 1146 - scsi_io_completion(cmd, cmd->bufflen, 0); 1172 + scsi_io_completion(cmd, cmd->bufflen); 1147 1173 } 1148 1174 1149 1175 static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) ··· 2024 2050 switch (oldstate) { 2025 2051 case SDEV_CREATED: 2026 2052 case SDEV_RUNNING: 2053 + case SDEV_QUIESCE: 2027 2054 case SDEV_OFFLINE: 2028 2055 case SDEV_BLOCK: 2029 2056 break; ··· 2035 2060 2036 2061 case SDEV_DEL: 2037 2062 switch (oldstate) { 2063 + case SDEV_CREATED: 2064 + case SDEV_RUNNING: 2065 + case SDEV_OFFLINE: 2038 2066 case SDEV_CANCEL: 2039 2067 break; 2040 2068 default:
+1 -1
drivers/scsi/scsi_priv.h
··· 116 116 * classes. 117 117 */ 118 118 119 - #define SCSI_DEVICE_BLOCK_MAX_TIMEOUT (HZ*60) 119 + #define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */ 120 120 extern int scsi_internal_device_block(struct scsi_device *sdev); 121 121 extern int scsi_internal_device_unblock(struct scsi_device *sdev); 122 122
+7 -3
drivers/scsi/scsi_sas_internal.h
··· 2 2 #define _SCSI_SAS_INTERNAL_H 3 3 4 4 #define SAS_HOST_ATTRS 0 5 - #define SAS_PORT_ATTRS 17 5 + #define SAS_PHY_ATTRS 17 6 + #define SAS_PORT_ATTRS 1 6 7 #define SAS_RPORT_ATTRS 7 7 8 #define SAS_END_DEV_ATTRS 3 8 9 #define SAS_EXPANDER_ATTRS 7 ··· 14 13 struct sas_domain_function_template *dft; 15 14 16 15 struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS]; 17 - struct class_device_attribute private_phy_attrs[SAS_PORT_ATTRS]; 16 + struct class_device_attribute private_phy_attrs[SAS_PHY_ATTRS]; 17 + struct class_device_attribute private_port_attrs[SAS_PORT_ATTRS]; 18 18 struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS]; 19 19 struct class_device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS]; 20 20 struct class_device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS]; 21 21 22 22 struct transport_container phy_attr_cont; 23 + struct transport_container port_attr_cont; 23 24 struct transport_container rphy_attr_cont; 24 25 struct transport_container end_dev_attr_cont; 25 26 struct transport_container expander_attr_cont; ··· 31 28 * needed by scsi_sysfs.c 32 29 */ 33 30 struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1]; 34 - struct class_device_attribute *phy_attrs[SAS_PORT_ATTRS + 1]; 31 + struct class_device_attribute *phy_attrs[SAS_PHY_ATTRS + 1]; 32 + struct class_device_attribute *port_attrs[SAS_PORT_ATTRS + 1]; 35 33 struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1]; 36 34 struct class_device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1]; 37 35 struct class_device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1];
+1
drivers/scsi/scsi_scan.c
··· 809 809 810 810 static inline void scsi_destroy_sdev(struct scsi_device *sdev) 811 811 { 812 + scsi_device_set_state(sdev, SDEV_DEL); 812 813 if (sdev->host->hostt->slave_destroy) 813 814 sdev->host->hostt->slave_destroy(sdev); 814 815 transport_destroy_device(&sdev->sdev_gendev);
+22 -20
drivers/scsi/scsi_transport_fc.c
··· 368 368 * should insulate the loss of a remote port. 369 369 * The maximum will be capped by the value of SCSI_DEVICE_BLOCK_MAX_TIMEOUT. 370 370 */ 371 - static unsigned int fc_dev_loss_tmo = SCSI_DEVICE_BLOCK_MAX_TIMEOUT; 371 + static unsigned int fc_dev_loss_tmo = 60; /* seconds */ 372 372 373 373 module_param_named(dev_loss_tmo, fc_dev_loss_tmo, int, S_IRUGO|S_IWUSR); 374 374 MODULE_PARM_DESC(dev_loss_tmo, ··· 1284 1284 * @work: Work to queue for execution. 1285 1285 * 1286 1286 * Return value: 1287 - * 0 on success / != 0 for error 1287 + * 1 - work queued for execution 1288 + * 0 - work is already queued 1289 + * -EINVAL - work queue doesn't exist 1288 1290 **/ 1289 1291 static int 1290 1292 fc_queue_work(struct Scsi_Host *shost, struct work_struct *work) ··· 1436 1434 struct Scsi_Host *shost = rport_to_shost(rport); 1437 1435 unsigned long flags; 1438 1436 1439 - scsi_target_unblock(&rport->dev); 1440 - 1441 1437 spin_lock_irqsave(shost->host_lock, flags); 1442 1438 if (rport->flags & FC_RPORT_DEVLOSS_PENDING) { 1443 1439 spin_unlock_irqrestore(shost->host_lock, flags); ··· 1476 1476 transport_remove_device(dev); 1477 1477 device_del(dev); 1478 1478 transport_destroy_device(dev); 1479 - put_device(&shost->shost_gendev); 1479 + put_device(&shost->shost_gendev); /* for fc_host->rport list */ 1480 + put_device(dev); /* for self-reference */ 1480 1481 } 1481 1482 1482 1483 ··· 1538 1537 else 1539 1538 rport->scsi_target_id = -1; 1540 1539 list_add_tail(&rport->peers, &fc_host->rports); 1541 - get_device(&shost->shost_gendev); 1540 + get_device(&shost->shost_gendev); /* for fc_host->rport list */ 1542 1541 1543 1542 spin_unlock_irqrestore(shost->host_lock, flags); 1544 1543 1545 1544 dev = &rport->dev; 1546 - device_initialize(dev); 1547 - dev->parent = get_device(&shost->shost_gendev); 1545 + device_initialize(dev); /* takes self reference */ 1546 + dev->parent = get_device(&shost->shost_gendev); /* parent reference */ 1548 1547 dev->release = fc_rport_dev_release; 1549 1548 sprintf(dev->bus_id, "rport-%d:%d-%d", 1550 1549 shost->host_no, channel, rport->number); ··· 1568 1567 1569 1568 delete_rport: 1570 1569 transport_destroy_device(dev); 1571 - put_device(dev->parent); 1572 1570 spin_lock_irqsave(shost->host_lock, flags); 1573 1571 list_del(&rport->peers); 1574 - put_device(&shost->shost_gendev); 1572 + put_device(&shost->shost_gendev); /* for fc_host->rport list */ 1575 1573 spin_unlock_irqrestore(shost->host_lock, flags); 1576 1574 put_device(dev->parent); 1577 1575 kfree(rport); ··· 1707 1707 1708 1708 spin_unlock_irqrestore(shost->host_lock, flags); 1709 1709 1710 + scsi_target_unblock(&rport->dev); 1711 + 1710 1712 return rport; 1711 1713 } 1712 1714 } ··· 1764 1762 /* initiate a scan of the target */ 1765 1763 rport->flags |= FC_RPORT_SCAN_PENDING; 1766 1764 scsi_queue_work(shost, &rport->scan_work); 1767 - } 1768 - 1769 - spin_unlock_irqrestore(shost->host_lock, flags); 1765 + spin_unlock_irqrestore(shost->host_lock, flags); 1766 + scsi_target_unblock(&rport->dev); 1767 + } else 1768 + spin_unlock_irqrestore(shost->host_lock, flags); 1770 1769 1771 1770 return rport; 1772 1771 } ··· 1941 1938 rport->flags |= FC_RPORT_SCAN_PENDING; 1942 1939 scsi_queue_work(shost, &rport->scan_work); 1943 1940 spin_unlock_irqrestore(shost->host_lock, flags); 1941 + scsi_target_unblock(&rport->dev); 1944 1942 } 1945 1943 } 1946 1944 EXPORT_SYMBOL(fc_remote_port_rolechg); ··· 1974 1970 dev_printk(KERN_ERR, &rport->dev, 1975 1971 "blocked FC remote port time out: no longer" 1976 1972 " a FCP target, removing starget\n"); 1977 - fc_queue_work(shost, &rport->stgt_delete_work); 1978 1973 spin_unlock_irqrestore(shost->host_lock, flags); 1974 + scsi_target_unblock(&rport->dev); 1975 + fc_queue_work(shost, &rport->stgt_delete_work); 1979 1976 return; 1980 1977 } 1981 1978 ··· 2040 2035 * went away and didn't come back - we'll remove 2041 2036 * all attached scsi devices. 2042 2037 */ 2043 - fc_queue_work(shost, &rport->stgt_delete_work); 2044 - 2045 2038 spin_unlock_irqrestore(shost->host_lock, flags); 2039 + 2040 + scsi_target_unblock(&rport->dev); 2041 + fc_queue_work(shost, &rport->stgt_delete_work); 2046 2042 } 2047 2043 2048 2044 /** 2049 2045 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port. 2050 - * 2051 - * Will unblock the target (in case it went away and has now come back), 2052 - * then invoke a scan. 2053 2046 * 2054 2047 * @data: remote port to be scanned. 2055 2048 **/ ··· 2060 2057 2061 2058 if ((rport->port_state == FC_PORTSTATE_ONLINE) && 2062 2059 (rport->roles & FC_RPORT_ROLE_FCP_TARGET)) { 2063 - scsi_target_unblock(&rport->dev); 2064 2060 scsi_scan_target(&rport->dev, rport->channel, 2065 2061 rport->scsi_target_id, SCAN_WILD_CARD, 1); 2066 2062 }
+382 -310
drivers/scsi/scsi_transport_iscsi.c
··· 228 228 static void iscsi_session_release(struct device *dev) 229 229 { 230 230 struct iscsi_cls_session *session = iscsi_dev_to_session(dev); 231 - struct iscsi_transport *transport = session->transport; 232 231 struct Scsi_Host *shost; 233 232 234 233 shost = iscsi_session_to_shost(session); 235 234 scsi_host_put(shost); 236 - kfree(session->targetname); 237 235 kfree(session); 238 - module_put(transport->owner); 239 236 } 240 237 241 238 static int iscsi_is_session_dev(const struct device *dev) ··· 248 251 249 252 mutex_lock(&ihost->mutex); 250 253 list_for_each_entry(session, &ihost->sessions, host_list) { 251 - if ((channel == SCAN_WILD_CARD || 252 - channel == session->channel) && 254 + if ((channel == SCAN_WILD_CARD || channel == 0) && 253 255 (id == SCAN_WILD_CARD || id == session->target_id)) 254 - scsi_scan_target(&session->dev, session->channel, 256 + scsi_scan_target(&session->dev, 0, 255 257 session->target_id, lun, 1); 256 258 } 257 259 mutex_unlock(&ihost->mutex); ··· 287 291 } 288 292 EXPORT_SYMBOL_GPL(iscsi_block_session); 289 293 294 + struct iscsi_cls_session * 295 + iscsi_alloc_session(struct Scsi_Host *shost, 296 + struct iscsi_transport *transport) 297 + { 298 + struct iscsi_cls_session *session; 299 + 300 + session = kzalloc(sizeof(*session) + transport->sessiondata_size, 301 + GFP_KERNEL); 302 + if (!session) 303 + return NULL; 304 + 305 + session->transport = transport; 306 + session->recovery_tmo = 120; 307 + INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 308 + INIT_LIST_HEAD(&session->host_list); 309 + INIT_LIST_HEAD(&session->sess_list); 310 + 311 + /* this is released in the dev's release function */ 312 + scsi_host_get(shost); 313 + session->dev.parent = &shost->shost_gendev; 314 + session->dev.release = iscsi_session_release; 315 + device_initialize(&session->dev); 316 + if (transport->sessiondata_size) 317 + session->dd_data = &session[1]; 318 + return session; 319 + } 320 + EXPORT_SYMBOL_GPL(iscsi_alloc_session); 321 + 322 + int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id) 323 + { 324 + struct Scsi_Host *shost = iscsi_session_to_shost(session); 325 + struct iscsi_host *ihost; 326 + int err; 327 + 328 + ihost = shost->shost_data; 329 + session->sid = iscsi_session_nr++; 330 + session->target_id = target_id; 331 + 332 + snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", 333 + session->sid); 334 + err = device_add(&session->dev); 335 + if (err) { 336 + dev_printk(KERN_ERR, &session->dev, "iscsi: could not " 337 + "register session's dev\n"); 338 + goto release_host; 339 + } 340 + transport_register_device(&session->dev); 341 + 342 + mutex_lock(&ihost->mutex); 343 + list_add(&session->host_list, &ihost->sessions); 344 + mutex_unlock(&ihost->mutex); 345 + return 0; 346 + 347 + release_host: 348 + scsi_host_put(shost); 349 + return err; 350 + } 351 + EXPORT_SYMBOL_GPL(iscsi_add_session); 352 + 290 353 /** 291 354 * iscsi_create_session - create iscsi class session 292 355 * @shost: scsi host ··· 355 300 **/ 356 301 struct iscsi_cls_session * 357 302 iscsi_create_session(struct Scsi_Host *shost, 358 - struct iscsi_transport *transport, int channel) 303 + struct iscsi_transport *transport, 304 + unsigned int target_id) 359 305 { 360 - struct iscsi_host *ihost; 361 306 struct iscsi_cls_session *session; 362 - int err; 363 307 364 - if (!try_module_get(transport->owner)) 308 + session = iscsi_alloc_session(shost, transport); 309 + if (!session) 365 310 return NULL; 366 311 367 - session = kzalloc(sizeof(*session) + transport->sessiondata_size, 368 - GFP_KERNEL); 369 - if (!session) 370 - goto module_put; 371 - session->transport = transport; 372 - session->recovery_tmo = 120; 373 - INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 374 - INIT_LIST_HEAD(&session->host_list); 375 - INIT_LIST_HEAD(&session->sess_list); 376 - 377 - if (transport->sessiondata_size) 378 - session->dd_data = &session[1]; 379 - 380 - /* this is released in the dev's release function */ 381 - scsi_host_get(shost); 382 - ihost = shost->shost_data; 383 - 384 - session->sid = iscsi_session_nr++; 385 - session->channel = channel; 386 - session->target_id = ihost->next_target_id++; 387 - 388 - snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", 389 - session->sid); 390 - session->dev.parent = &shost->shost_gendev; 391 - session->dev.release = iscsi_session_release; 392 - err = device_register(&session->dev); 393 - if (err) { 394 - dev_printk(KERN_ERR, &session->dev, "iscsi: could not " 395 - "register session's dev\n"); 396 - goto free_session; 312 + if (iscsi_add_session(session, target_id)) { 313 + iscsi_free_session(session); 314 + return NULL; 397 315 } 398 - transport_register_device(&session->dev); 399 - 400 - mutex_lock(&ihost->mutex); 401 - list_add(&session->host_list, &ihost->sessions); 402 - mutex_unlock(&ihost->mutex); 403 - 404 316 return session; 405 - 406 - free_session: 407 - kfree(session); 408 - module_put: 409 - module_put(transport->owner); 410 - return NULL; 411 317 } 412 - 413 318 EXPORT_SYMBOL_GPL(iscsi_create_session); 414 319 415 - /** 416 - * iscsi_destroy_session - destroy iscsi session 417 - * @session: iscsi_session 418 - * 419 - * Can be called by a LLD or iscsi_transport. There must not be 420 - * any running connections. 421 - **/ 422 - int iscsi_destroy_session(struct iscsi_cls_session *session) 320 + void iscsi_remove_session(struct iscsi_cls_session *session) 423 321 { 424 322 struct Scsi_Host *shost = iscsi_session_to_shost(session); 425 323 struct iscsi_host *ihost = shost->shost_data; ··· 384 376 list_del(&session->host_list); 385 377 mutex_unlock(&ihost->mutex); 386 378 379 + scsi_remove_target(&session->dev); 380 + 387 381 transport_unregister_device(&session->dev); 388 - device_unregister(&session->dev); 389 - return 0; 382 + device_del(&session->dev); 383 + } 384 + EXPORT_SYMBOL_GPL(iscsi_remove_session); 385 + 386 + void iscsi_free_session(struct iscsi_cls_session *session) 387 + { 388 + put_device(&session->dev); 390 389 } 391 390 391 + EXPORT_SYMBOL_GPL(iscsi_free_session); 392 + 393 + /** 394 + * iscsi_destroy_session - destroy iscsi session 395 + * @session: iscsi_session 396 + * 397 + * Can be called by a LLD or iscsi_transport. There must not be 398 + * any running connections. 399 + **/ 400 + int iscsi_destroy_session(struct iscsi_cls_session *session) 401 + { 402 + iscsi_remove_session(session); 403 + iscsi_free_session(session); 404 + return 0; 405 + } 392 406 EXPORT_SYMBOL_GPL(iscsi_destroy_session); 407 + 408 + static void mempool_zone_destroy(struct mempool_zone *zp) 409 + { 410 + mempool_destroy(zp->pool); 411 + kfree(zp); 412 + } 413 + 414 + static void* 415 + mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data) 416 + { 417 + struct mempool_zone *zone = pool_data; 418 + 419 + return alloc_skb(zone->size, gfp_mask); 420 + } 421 + 422 + static void 423 + mempool_zone_free_skb(void *element, void *pool_data) 424 + { 425 + kfree_skb(element); 426 + } 427 + 428 + static struct mempool_zone * 429 + mempool_zone_init(unsigned max, unsigned size, unsigned hiwat) 430 + { 431 + struct mempool_zone *zp; 432 + 433 + zp = kzalloc(sizeof(*zp), GFP_KERNEL); 434 + if (!zp) 435 + return NULL; 436 + 437 + zp->size = size; 438 + zp->hiwat = hiwat; 439 + INIT_LIST_HEAD(&zp->freequeue); 440 + spin_lock_init(&zp->freelock); 441 + atomic_set(&zp->allocated, 0); 442 + 443 + zp->pool = mempool_create(max, mempool_zone_alloc_skb, 444 + mempool_zone_free_skb, zp); 445 + if (!zp->pool) { 446 + kfree(zp); 447 + return NULL; 448 + } 449 + 450 + return zp; 451 + } 393 452 394 453 static void iscsi_conn_release(struct device *dev) 395 454 { 396 455 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); 397 456 struct device *parent = conn->dev.parent; 398 457 399 - kfree(conn->persistent_address); 458 + mempool_zone_destroy(conn->z_pdu); 459 + mempool_zone_destroy(conn->z_error); 460 + 400 461 kfree(conn); 401 462 put_device(parent); 402 463 } ··· 473 396 static int iscsi_is_conn_dev(const struct device *dev) 474 397 { 475 398 return dev->release == iscsi_conn_release; 399 + } 400 + 401 + static int iscsi_create_event_pools(struct iscsi_cls_conn *conn) 402 + { 403 + conn->z_pdu = mempool_zone_init(Z_MAX_PDU, 404 + NLMSG_SPACE(sizeof(struct iscsi_uevent) + 405 + sizeof(struct iscsi_hdr) + 406 + DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH), 407 + Z_HIWAT_PDU); 408 + if (!conn->z_pdu) { 409 + dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate " 410 + "pdu zone for new conn\n"); 411 + return -ENOMEM; 412 + } 413 + 414 + conn->z_error = mempool_zone_init(Z_MAX_ERROR, 415 + NLMSG_SPACE(sizeof(struct iscsi_uevent)), 416 + Z_HIWAT_ERROR); 417 + if (!conn->z_error) { 418 + dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate " 419 + "error zone for new conn\n"); 420 + mempool_zone_destroy(conn->z_pdu); 421 + return -ENOMEM; 422 + } 423 + return 0; 476 424 } 477 425 478 426 /** ··· 532 430 conn->transport = transport; 533 431 conn->cid = cid; 534 432 433 + if (iscsi_create_event_pools(conn)) 434 + goto free_conn; 435 + 535 436 /* this is released in the dev's release function */ 536 437 if (!get_device(&session->dev)) 537 - goto free_conn; 438 + goto free_conn_pools; 538 439 539 440 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 540 441 session->sid, cid); ··· 554 449 555 450 release_parent_ref: 556 451 put_device(&session->dev); 452 + free_conn_pools: 453 + 557 454 free_conn: 558 455 kfree(conn); 559 456 return NULL; ··· 603 496 return (struct list_head *)&skb->cb; 604 497 } 605 498 606 - static void* 607 - mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data) 608 - { 609 - struct mempool_zone *zone = pool_data; 610 - 611 - return alloc_skb(zone->size, gfp_mask); 612 - } 613 - 614 - static void 615 - mempool_zone_free_skb(void *element, void *pool_data) 616 - { 617 - kfree_skb(element); 618 - } 619 - 620 499 static void 621 500 mempool_zone_complete(struct mempool_zone *zone) 622 501 { ··· 622 529 spin_unlock_irqrestore(&zone->freelock, flags); 623 530 } 624 531 625 - static struct mempool_zone * 626 - mempool_zone_init(unsigned max, unsigned size, unsigned hiwat) 627 - { 628 - struct mempool_zone *zp; 629 - 630 - zp = kzalloc(sizeof(*zp), GFP_KERNEL); 631 - if (!zp) 632 - return NULL; 633 - 634 - zp->size = size; 635 - zp->hiwat = hiwat; 636 - INIT_LIST_HEAD(&zp->freequeue); 637 - spin_lock_init(&zp->freelock); 638 - atomic_set(&zp->allocated, 0); 639 - 640 - zp->pool = mempool_create(max, mempool_zone_alloc_skb, 641 - mempool_zone_free_skb, zp); 642 - if (!zp->pool) { 643 - kfree(zp); 644 - return NULL; 645 - } 646 - 647 - return zp; 648 - } 649 - 650 - static void mempool_zone_destroy(struct mempool_zone *zp) 651 - { 652 - mempool_destroy(zp->pool); 653 - kfree(zp); 654 - } 655 - 656 532 static struct sk_buff* 657 533 mempool_zone_get_skb(struct mempool_zone *zone) 658 534 { ··· 631 569 if (skb) 632 570 atomic_inc(&zone->allocated); 633 571 return skb; 572 + } 573 + 574 + static int 575 + iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb) 576 + { 577 + unsigned long flags; 578 + int rc; 579 + 580 + skb_get(skb); 581 + rc = netlink_broadcast(nls, skb, 0, 1, GFP_KERNEL); 582 + if (rc < 0) { 583 + mempool_free(skb, zone->pool); 584 + printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc); 585 + return rc; 586 + } 587 + 588 + spin_lock_irqsave(&zone->freelock, flags); 589 + INIT_LIST_HEAD(skb_to_lh(skb)); 590 + list_add(skb_to_lh(skb), &zone->freequeue); 591 + spin_unlock_irqrestore(&zone->freelock, flags); 592 + return 0; 634 593 } 635 594 636 595 static int ··· 749 666 ev->r.connerror.cid = conn->cid; 750 667 ev->r.connerror.sid = iscsi_conn_get_sid(conn); 751 668 752 - iscsi_unicast_skb(conn->z_error, skb, priv->daemon_pid); 669 + iscsi_broadcast_skb(conn->z_error, skb); 753 670 754 671 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n", 755 672 error); ··· 850 767 return err; 851 768 } 852 769 770 + /** 771 + * iscsi_if_destroy_session_done - send session destr. completion event 772 + * @conn: last connection for session 773 + * 774 + * This is called by HW iscsi LLDs to notify userpsace that its HW has 775 + * removed a session. 776 + **/ 777 + int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn) 778 + { 779 + struct iscsi_internal *priv; 780 + struct iscsi_cls_session *session; 781 + struct Scsi_Host *shost; 782 + struct iscsi_uevent *ev; 783 + struct sk_buff *skb; 784 + struct nlmsghdr *nlh; 785 + unsigned long flags; 786 + int rc, len = NLMSG_SPACE(sizeof(*ev)); 787 + 788 + priv = iscsi_if_transport_lookup(conn->transport); 789 + if (!priv) 790 + return -EINVAL; 791 + 792 + session = iscsi_dev_to_session(conn->dev.parent); 793 + shost = iscsi_session_to_shost(session); 794 + 795 + mempool_zone_complete(conn->z_pdu); 796 + 797 + skb = mempool_zone_get_skb(conn->z_pdu); 798 + if (!skb) { 799 + dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 800 + "session creation event\n"); 801 + return -ENOMEM; 802 + } 803 + 804 + nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0); 805 + ev = NLMSG_DATA(nlh); 806 + ev->transport_handle = iscsi_handle(conn->transport); 807 + ev->type = ISCSI_KEVENT_DESTROY_SESSION; 808 + ev->r.d_session.host_no = shost->host_no; 809 + ev->r.d_session.sid = session->sid; 810 + 811 + /* 812 + * this will occur if the daemon is not up, so we just warn 813 + * the user and when the daemon is restarted it will handle it 814 + */ 815 + rc = iscsi_broadcast_skb(conn->z_pdu, skb); 816 + if (rc < 0) 817 + dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 818 + "session destruction event. Check iscsi daemon\n"); 819 + 820 + spin_lock_irqsave(&sesslock, flags); 821 + list_del(&session->sess_list); 822 + spin_unlock_irqrestore(&sesslock, flags); 823 + 824 + spin_lock_irqsave(&connlock, flags); 825 + conn->active = 0; 826 + list_del(&conn->conn_list); 827 + spin_unlock_irqrestore(&connlock, flags); 828 + 829 + return rc; 830 + } 831 + EXPORT_SYMBOL_GPL(iscsi_if_destroy_session_done); 832 + 833 + /** 834 + * iscsi_if_create_session_done - send session creation completion event 835 + * @conn: leading connection for session 836 + * 837 + * This is called by HW iscsi LLDs to notify userpsace that its HW has 838 + * created a session or a existing session is back in the logged in state. 839 + **/ 840 + int iscsi_if_create_session_done(struct iscsi_cls_conn *conn) 841 + { 842 + struct iscsi_internal *priv; 843 + struct iscsi_cls_session *session; 844 + struct Scsi_Host *shost; 845 + struct iscsi_uevent *ev; 846 + struct sk_buff *skb; 847 + struct nlmsghdr *nlh; 848 + unsigned long flags; 849 + int rc, len = NLMSG_SPACE(sizeof(*ev)); 850 + 851 + priv = iscsi_if_transport_lookup(conn->transport); 852 + if (!priv) 853 + return -EINVAL; 854 + 855 + session = iscsi_dev_to_session(conn->dev.parent); 856 + shost = iscsi_session_to_shost(session); 857 + 858 + mempool_zone_complete(conn->z_pdu); 859 + 860 + skb = mempool_zone_get_skb(conn->z_pdu); 861 + if (!skb) { 862 + dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 863 + "session creation event\n"); 864 + return -ENOMEM; 865 + } 866 + 867 + nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0); 868 + ev = NLMSG_DATA(nlh); 869 + ev->transport_handle = iscsi_handle(conn->transport); 870 + ev->type = ISCSI_UEVENT_CREATE_SESSION; 871 + ev->r.c_session_ret.host_no = shost->host_no; 872 + ev->r.c_session_ret.sid = session->sid; 873 + 874 + /* 875 + * this will occur if the daemon is not up, so we just warn 876 + * the user and when the daemon is restarted it will handle it 877 + */ 878 + rc = iscsi_broadcast_skb(conn->z_pdu, skb); 879 + if (rc < 0) 880 + dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 881 + "session creation event. Check iscsi daemon\n"); 882 + 883 + spin_lock_irqsave(&sesslock, flags); 884 + list_add(&session->sess_list, &sesslist); 885 + spin_unlock_irqrestore(&sesslock, flags); 886 + 887 + spin_lock_irqsave(&connlock, flags); 888 + list_add(&conn->conn_list, &connlist); 889 + conn->active = 1; 890 + spin_unlock_irqrestore(&connlock, flags); 891 + return rc; 892 + } 893 + EXPORT_SYMBOL_GPL(iscsi_if_create_session_done); 894 + 853 895 static int 854 896 iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev) 855 897 { ··· 1020 812 return -ENOMEM; 1021 813 } 1022 814 1023 - conn->z_pdu = mempool_zone_init(Z_MAX_PDU, 1024 - NLMSG_SPACE(sizeof(struct iscsi_uevent) + 1025 - sizeof(struct iscsi_hdr) + 1026 - DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH), 1027 - Z_HIWAT_PDU); 1028 - if (!conn->z_pdu) { 1029 - dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate " 1030 - "pdu zone for new conn\n"); 1031 - goto destroy_conn; 1032 - } 1033 - 1034 - conn->z_error = mempool_zone_init(Z_MAX_ERROR, 1035 - NLMSG_SPACE(sizeof(struct iscsi_uevent)), 1036 - Z_HIWAT_ERROR); 1037 - if (!conn->z_error) { 1038 - dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate " 1039 - "error zone for new conn\n"); 1040 - goto free_pdu_pool; 1041 - } 1042 - 1043 815 ev->r.c_conn_ret.sid = session->sid; 1044 816 ev->r.c_conn_ret.cid = conn->cid; 1045 817 ··· 1029 841 spin_unlock_irqrestore(&connlock, flags); 1030 842 1031 843 return 0; 1032 - 1033 - free_pdu_pool: 1034 - mempool_zone_destroy(conn->z_pdu); 1035 - destroy_conn: 1036 - if (transport->destroy_conn) 1037 - transport->destroy_conn(conn->dd_data); 1038 - return -ENOMEM; 1039 844 } 1040 845 1041 846 static int ··· 1036 855 { 1037 856 unsigned long flags; 1038 857 struct iscsi_cls_conn *conn; 1039 - struct mempool_zone *z_error, *z_pdu; 1040 858 1041 859 conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid); 1042 860 if (!conn) ··· 1045 865 list_del(&conn->conn_list); 1046 866 spin_unlock_irqrestore(&connlock, flags); 1047 867 1048 - z_pdu = conn->z_pdu; 1049 - z_error = conn->z_error; 1050 - 1051 868 if (transport->destroy_conn) 1052 869 transport->destroy_conn(conn); 1053 - 1054 - mempool_zone_destroy(z_pdu); 1055 - mempool_zone_destroy(z_error); 1056 - 1057 870 return 0; 1058 - } 1059 - 1060 - static void 1061 - iscsi_copy_param(struct iscsi_uevent *ev, uint32_t *value, char *data) 1062 - { 1063 - if (ev->u.set_param.len != sizeof(uint32_t)) 1064 - BUG(); 1065 - memcpy(value, data, min_t(uint32_t, sizeof(uint32_t), 1066 - ev->u.set_param.len)); 1067 871 } 1068 872 1069 873 static int ··· 1056 892 char *data = (char*)ev + sizeof(*ev); 1057 893 struct iscsi_cls_conn *conn; 1058 894 struct iscsi_cls_session *session; 1059 - int err = 0; 1060 - uint32_t value = 0; 895 + int err = 0, value = 0; 1061 896 1062 897 session = iscsi_session_lookup(ev->u.set_param.sid); 1063 898 conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid); ··· 1065 902 1066 903 switch (ev->u.set_param.param) { 1067 904 case ISCSI_PARAM_SESS_RECOVERY_TMO: 1068 - iscsi_copy_param(ev, &value, data); 905 + sscanf(data, "%d", &value); 1069 906 if (value != 0) 1070 907 session->recovery_tmo = value; 1071 908 break; 1072 - case ISCSI_PARAM_TARGET_NAME: 1073 - /* this should not change between logins */ 1074 - if (session->targetname) 1075 - return 0; 1076 - 1077 - session->targetname = kstrdup(data, GFP_KERNEL); 1078 - if (!session->targetname) 1079 - return -ENOMEM; 1080 - break; 1081 - case ISCSI_PARAM_TPGT: 1082 - iscsi_copy_param(ev, &value, data); 1083 - session->tpgt = value; 1084 - break; 1085 - case ISCSI_PARAM_PERSISTENT_PORT: 1086 - iscsi_copy_param(ev, &value, data); 1087 - conn->persistent_port = value; 1088 - break; 1089 - case ISCSI_PARAM_PERSISTENT_ADDRESS: 1090 - /* 1091 - * this is the address returned in discovery so it should 1092 - * not change between logins. 1093 - */ 1094 - if (conn->persistent_address) 1095 - return 0; 1096 - 1097 - conn->persistent_address = kstrdup(data, GFP_KERNEL); 1098 - if (!conn->persistent_address) 1099 - return -ENOMEM; 1100 - break; 1101 909 default: 1102 - iscsi_copy_param(ev, &value, data); 1103 - err = transport->set_param(conn, ev->u.set_param.param, value); 910 + err = transport->set_param(conn, ev->u.set_param.param, 911 + data, ev->u.set_param.len); 1104 912 } 1105 913 1106 914 return err; ··· 1109 975 break; 1110 976 } 1111 977 return rc; 978 + } 979 + 980 + static int 981 + iscsi_tgt_dscvr(struct iscsi_transport *transport, 982 + struct iscsi_uevent *ev) 983 + { 984 + struct sockaddr *dst_addr; 985 + 986 + if (!transport->tgt_dscvr) 987 + return -EINVAL; 988 + 989 + dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev)); 990 + return transport->tgt_dscvr(ev->u.tgt_dscvr.type, 991 + ev->u.tgt_dscvr.host_no, 992 + ev->u.tgt_dscvr.enable, dst_addr); 1112 993 } 1113 994 1114 995 static int ··· 1214 1065 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: 1215 1066 err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type); 1216 1067 break; 1068 + case ISCSI_UEVENT_TGT_DSCVR: 1069 + err = iscsi_tgt_dscvr(transport, ev); 1070 + break; 1217 1071 default: 1218 1072 err = -EINVAL; 1219 1073 break; ··· 1299 1147 /* 1300 1148 * iSCSI connection attrs 1301 1149 */ 1302 - #define iscsi_conn_int_attr_show(param, format) \ 1150 + #define iscsi_conn_attr_show(param) \ 1303 1151 static ssize_t \ 1304 - show_conn_int_param_##param(struct class_device *cdev, char *buf) \ 1305 - { \ 1306 - uint32_t value = 0; \ 1307 - struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ 1308 - struct iscsi_transport *t = conn->transport; \ 1309 - \ 1310 - t->get_conn_param(conn, param, &value); \ 1311 - return snprintf(buf, 20, format"\n", value); \ 1312 - } 1313 - 1314 - #define iscsi_conn_int_attr(field, param, format) \ 1315 - iscsi_conn_int_attr_show(param, format) \ 1316 - static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_int_param_##param, \ 1317 - NULL); 1318 - 1319 - iscsi_conn_int_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH, "%u"); 1320 - iscsi_conn_int_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH, "%u"); 1321 - iscsi_conn_int_attr(header_digest, ISCSI_PARAM_HDRDGST_EN, "%d"); 1322 - iscsi_conn_int_attr(data_digest, ISCSI_PARAM_DATADGST_EN, "%d"); 1323 - iscsi_conn_int_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN, "%d"); 1324 - iscsi_conn_int_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN, "%d"); 1325 - iscsi_conn_int_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT, "%d"); 1326 - iscsi_conn_int_attr(port, ISCSI_PARAM_CONN_PORT, "%d"); 1327 - iscsi_conn_int_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN, "%u"); 1328 - 1329 - #define iscsi_conn_str_attr_show(param) \ 1330 - static ssize_t \ 1331 - show_conn_str_param_##param(struct class_device *cdev, char *buf) \ 1152 + show_conn_param_##param(struct class_device *cdev, char *buf) \ 1332 1153 { \ 1333 1154 struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ 1334 1155 struct iscsi_transport *t = conn->transport; \ 1335 - return t->get_conn_str_param(conn, param, buf); \ 1156 + return t->get_conn_param(conn, param, buf); \ 1336 1157 } 1337 1158 1338 - #define iscsi_conn_str_attr(field, param) \ 1339 - iscsi_conn_str_attr_show(param) \ 1340 - static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_str_param_##param, \ 1159 + #define iscsi_conn_attr(field, param) \ 1160 + iscsi_conn_attr_show(param) \ 1161 + static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_param_##param, \ 1341 1162 NULL); 1342 1163 1343 - iscsi_conn_str_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS); 1344 - iscsi_conn_str_attr(address, ISCSI_PARAM_CONN_ADDRESS); 1164 + iscsi_conn_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH); 1165 + iscsi_conn_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH); 1166 + iscsi_conn_attr(header_digest, ISCSI_PARAM_HDRDGST_EN); 1167 + iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN); 1168 + iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN); 1169 + iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN); 1170 + iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT); 1171 + iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT); 1172 + iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN); 1173 + iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS); 1174 + iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); 1345 1175 1346 1176 #define iscsi_cdev_to_session(_cdev) \ 1347 1177 iscsi_dev_to_session(_cdev->dev) ··· 1331 1197 /* 1332 1198 * iSCSI session attrs 1333 1199 */ 1334 - #define iscsi_session_int_attr_show(param, format) \ 1200 + #define iscsi_session_attr_show(param) \ 1335 1201 static ssize_t \ 1336 - show_session_int_param_##param(struct class_device *cdev, char *buf) \ 1337 - { \ 1338 - uint32_t value = 0; \ 1339 - struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ 1340 - struct iscsi_transport *t = session->transport; \ 1341 - \ 1342 - t->get_session_param(session, param, &value); \ 1343 - return snprintf(buf, 20, format"\n", value); \ 1344 - } 1345 - 1346 - #define iscsi_session_int_attr(field, param, format) \ 1347 - iscsi_session_int_attr_show(param, format) \ 1348 - static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_int_param_##param, \ 1349 - NULL); 1350 - 1351 - iscsi_session_int_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN, "%d"); 1352 - iscsi_session_int_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T, "%hu"); 1353 - iscsi_session_int_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN, "%d"); 1354 - iscsi_session_int_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST, "%u"); 1355 - iscsi_session_int_attr(max_burst_len, ISCSI_PARAM_MAX_BURST, "%u"); 1356 - iscsi_session_int_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN, "%d"); 1357 - iscsi_session_int_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN, "%d"); 1358 - iscsi_session_int_attr(erl, ISCSI_PARAM_ERL, "%d"); 1359 - iscsi_session_int_attr(tpgt, ISCSI_PARAM_TPGT, "%d"); 1360 - 1361 - #define iscsi_session_str_attr_show(param) \ 1362 - static ssize_t \ 1363 - show_session_str_param_##param(struct class_device *cdev, char *buf) \ 1202 + show_session_param_##param(struct class_device *cdev, char *buf) \ 1364 1203 { \ 1365 1204 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ 1366 1205 struct iscsi_transport *t = session->transport; \ 1367 - return t->get_session_str_param(session, param, buf); \ 1206 + return t->get_session_param(session, param, buf); \ 1368 1207 } 1369 1208 1370 - #define iscsi_session_str_attr(field, param) \ 1371 - iscsi_session_str_attr_show(param) \ 1372 - static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_str_param_##param, \ 1209 + #define iscsi_session_attr(field, param) \ 1210 + iscsi_session_attr_show(param) \ 1211 + static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \ 1373 1212 NULL); 1374 1213 1375 - iscsi_session_str_attr(targetname, ISCSI_PARAM_TARGET_NAME); 1214 + iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME); 1215 + iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN); 1216 + iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T); 1217 + iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN); 1218 + iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST); 1219 + iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST); 1220 + iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN); 1221 + iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN); 1222 + iscsi_session_attr(erl, ISCSI_PARAM_ERL); 1223 + iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT); 1376 1224 1377 - /* 1378 - * Private session and conn attrs. userspace uses several iscsi values 1379 - * to identify each session between reboots. Some of these values may not 1380 - * be present in the iscsi_transport/LLD driver becuase userspace handles 1381 - * login (and failback for login redirect) so for these type of drivers 1382 - * the class manages the attrs and values for the iscsi_transport/LLD 1383 - */ 1384 1225 #define iscsi_priv_session_attr_show(field, format) \ 1385 1226 static ssize_t \ 1386 - show_priv_session_##field(struct class_device *cdev, char *buf) \ 1227 + show_priv_session_##field(struct class_device *cdev, char *buf) \ 1387 1228 { \ 1388 - struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ 1229 + struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ 1389 1230 return sprintf(buf, format"\n", session->field); \ 1390 1231 } 1391 1232 ··· 1368 1259 iscsi_priv_session_attr_show(field, format) \ 1369 1260 static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO, show_priv_session_##field, \ 1370 1261 NULL) 1371 - iscsi_priv_session_attr(targetname, "%s"); 1372 - iscsi_priv_session_attr(tpgt, "%d"); 1373 1262 iscsi_priv_session_attr(recovery_tmo, "%d"); 1374 - 1375 - #define iscsi_priv_conn_attr_show(field, format) \ 1376 - static ssize_t \ 1377 - show_priv_conn_##field(struct class_device *cdev, char *buf) \ 1378 - { \ 1379 - struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ 1380 - return sprintf(buf, format"\n", conn->field); \ 1381 - } 1382 - 1383 - #define iscsi_priv_conn_attr(field, format) \ 1384 - iscsi_priv_conn_attr_show(field, format) \ 1385 - static ISCSI_CLASS_ATTR(priv_conn, field, S_IRUGO, show_priv_conn_##field, \ 1386 - NULL) 1387 - iscsi_priv_conn_attr(persistent_address, "%s"); 1388 - iscsi_priv_conn_attr(persistent_port, "%d"); 1389 1263 1390 1264 #define SETUP_PRIV_SESSION_RD_ATTR(field) \ 1391 1265 do { \ ··· 1376 1284 count++; \ 1377 1285 } while (0) 1378 1286 1287 + 1379 1288 #define SETUP_SESSION_RD_ATTR(field, param_flag) \ 1380 1289 do { \ 1381 1290 if (tt->param_mask & param_flag) { \ 1382 1291 priv->session_attrs[count] = &class_device_attr_sess_##field; \ 1383 1292 count++; \ 1384 1293 } \ 1385 - } while (0) 1386 - 1387 - #define SETUP_PRIV_CONN_RD_ATTR(field) \ 1388 - do { \ 1389 - priv->conn_attrs[count] = &class_device_attr_priv_conn_##field; \ 1390 - count++; \ 1391 1294 } while (0) 1392 1295 1393 1296 #define SETUP_CONN_RD_ATTR(field, param_flag) \ ··· 1475 1388 if (!priv) 1476 1389 return NULL; 1477 1390 INIT_LIST_HEAD(&priv->list); 1391 + priv->daemon_pid = -1; 1478 1392 priv->iscsi_transport = tt; 1479 1393 priv->t.user_scan = iscsi_user_scan; 1480 1394 ··· 1512 1424 SETUP_CONN_RD_ATTR(address, ISCSI_CONN_ADDRESS); 1513 1425 SETUP_CONN_RD_ATTR(port, ISCSI_CONN_PORT); 1514 1426 SETUP_CONN_RD_ATTR(exp_statsn, ISCSI_EXP_STATSN); 1515 - 1516 - if (tt->param_mask & ISCSI_PERSISTENT_ADDRESS) 1517 - SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS); 1518 - else 1519 - SETUP_PRIV_CONN_RD_ATTR(persistent_address); 1520 - 1521 - if (tt->param_mask & ISCSI_PERSISTENT_PORT) 1522 - SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT); 1523 - else 1524 - SETUP_PRIV_CONN_RD_ATTR(persistent_port); 1427 + SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS); 1428 + SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT); 1525 1429 1526 1430 BUG_ON(count > ISCSI_CONN_ATTRS); 1527 1431 priv->conn_attrs[count] = NULL; ··· 1533 1453 SETUP_SESSION_RD_ATTR(data_pdu_in_order, ISCSI_PDU_INORDER_EN); 1534 1454 SETUP_SESSION_RD_ATTR(data_seq_in_order, ISCSI_DATASEQ_INORDER_EN); 1535 1455 SETUP_SESSION_RD_ATTR(erl, ISCSI_ERL); 1456 + SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME); 1457 + SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT); 1536 1458 SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo); 1537 - 1538 - if (tt->param_mask & ISCSI_TARGET_NAME) 1539 - SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME); 1540 - else 1541 - SETUP_PRIV_SESSION_RD_ATTR(targetname); 1542 - 1543 - if (tt->param_mask & ISCSI_TPGT) 1544 - SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT); 1545 - else 1546 - SETUP_PRIV_SESSION_RD_ATTR(tpgt); 1547 1459 1548 1460 BUG_ON(count > ISCSI_SESSION_ATTRS); 1549 1461 priv->session_attrs[count] = NULL;
+332 -37
drivers/scsi/scsi_transport_sas.c
··· 174 174 175 175 static int do_sas_phy_delete(struct device *dev, void *data) 176 176 { 177 - if (scsi_is_sas_phy(dev)) 177 + int pass = (int)(unsigned long)data; 178 + 179 + if (pass == 0 && scsi_is_sas_port(dev)) 180 + sas_port_delete(dev_to_sas_port(dev)); 181 + else if (pass == 1 && scsi_is_sas_phy(dev)) 178 182 sas_phy_delete(dev_to_phy(dev)); 179 183 return 0; 180 184 } 185 + 186 + /** 187 + * sas_remove_children -- tear down a devices SAS data structures 188 + * @dev: device belonging to the sas object 189 + * 190 + * Removes all SAS PHYs and remote PHYs for a given object 191 + */ 192 + void sas_remove_children(struct device *dev) 193 + { 194 + device_for_each_child(dev, (void *)0, do_sas_phy_delete); 195 + device_for_each_child(dev, (void *)1, do_sas_phy_delete); 196 + } 197 + EXPORT_SYMBOL(sas_remove_children); 181 198 182 199 /** 183 200 * sas_remove_host -- tear down a Scsi_Host's SAS data structures ··· 205 188 */ 206 189 void sas_remove_host(struct Scsi_Host *shost) 207 190 { 208 - device_for_each_child(&shost->shost_gendev, NULL, do_sas_phy_delete); 191 + sas_remove_children(&shost->shost_gendev); 209 192 } 210 193 EXPORT_SYMBOL(sas_remove_host); 211 194 212 195 213 196 /* 214 - * SAS Port attributes 197 + * SAS Phy attributes 215 198 */ 216 199 217 200 #define sas_phy_show_simple(field, name, format_string, cast) \ ··· 327 310 sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n", 328 311 unsigned long long); 329 312 sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8); 330 - sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8); 313 + //sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8); 331 314 sas_phy_linkspeed_attr(negotiated_linkrate); 332 315 sas_phy_linkspeed_attr(minimum_linkrate_hw); 333 316 sas_phy_linkspeed_attr(minimum_linkrate); ··· 395 378 device_initialize(&phy->dev); 396 379 phy->dev.parent = get_device(parent); 397 380 phy->dev.release = sas_phy_release; 381 + INIT_LIST_HEAD(&phy->port_siblings); 398 382 if (scsi_is_sas_expander_device(parent)) { 399 383 struct sas_rphy *rphy = dev_to_rphy(parent); 400 - sprintf(phy->dev.bus_id, "phy-%d-%d:%d", shost->host_no, 384 + sprintf(phy->dev.bus_id, "phy-%d:%d:%d", shost->host_no, 401 385 rphy->scsi_target_id, number); 402 386 } else 403 387 sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number); ··· 458 440 { 459 441 struct device *dev = &phy->dev; 460 442 461 - if (phy->rphy) 462 - sas_rphy_delete(phy->rphy); 443 + /* this happens if the phy is still part of a port when deleted */ 444 + BUG_ON(!list_empty(&phy->port_siblings)); 463 445 464 446 transport_remove_device(dev); 465 447 device_del(dev); ··· 480 462 return dev->release == sas_phy_release; 481 463 } 482 464 EXPORT_SYMBOL(scsi_is_sas_phy); 465 + 466 + /* 467 + * SAS Port attributes 468 + */ 469 + #define sas_port_show_simple(field, name, format_string, cast) \ 470 + static ssize_t \ 471 + show_sas_port_##name(struct class_device *cdev, char *buf) \ 472 + { \ 473 + struct sas_port *port = transport_class_to_sas_port(cdev); \ 474 + \ 475 + return snprintf(buf, 20, format_string, cast port->field); \ 476 + } 477 + 478 + #define sas_port_simple_attr(field, name, format_string, type) \ 479 + sas_port_show_simple(field, name, format_string, (type)) \ 480 + static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL) 481 + 482 + sas_port_simple_attr(num_phys, num_phys, "%d\n", int); 483 + 484 + static DECLARE_TRANSPORT_CLASS(sas_port_class, 485 + "sas_port", NULL, NULL, NULL); 486 + 487 + static int sas_port_match(struct attribute_container *cont, struct device *dev) 488 + { 489 + struct Scsi_Host *shost; 490 + struct sas_internal *i; 491 + 492 + if (!scsi_is_sas_port(dev)) 493 + return 0; 494 + shost = dev_to_shost(dev->parent); 495 + 496 + if (!shost->transportt) 497 + return 0; 498 + if (shost->transportt->host_attrs.ac.class != 499 + &sas_host_class.class) 500 + return 0; 501 + 502 + i = to_sas_internal(shost->transportt); 503 + return &i->port_attr_cont.ac == cont; 504 + } 505 + 506 + 507 + static void sas_port_release(struct device *dev) 508 + { 509 + struct sas_port *port = dev_to_sas_port(dev); 510 + 511 + BUG_ON(!list_empty(&port->phy_list)); 512 + 513 + put_device(dev->parent); 514 + kfree(port); 515 + } 516 + 517 + static void sas_port_create_link(struct sas_port *port, 518 + struct sas_phy *phy) 519 + { 520 + sysfs_create_link(&port->dev.kobj, &phy->dev.kobj, phy->dev.bus_id); 521 + sysfs_create_link(&phy->dev.kobj, &port->dev.kobj, "port"); 522 + } 523 + 524 + static void sas_port_delete_link(struct sas_port *port, 525 + struct sas_phy *phy) 526 + { 527 + sysfs_remove_link(&port->dev.kobj, phy->dev.bus_id); 528 + sysfs_remove_link(&phy->dev.kobj, "port"); 529 + } 530 + 531 + /** sas_port_alloc - allocate and initialize a SAS port structure 532 + * 533 + * @parent: parent device 534 + * @port_id: port number 535 + * 536 + * Allocates a SAS port structure. It will be added to the device tree 537 + * below the device specified by @parent which must be either a Scsi_Host 538 + * or a sas_expander_device. 539 + * 540 + * Returns %NULL on error 541 + */ 542 + struct sas_port *sas_port_alloc(struct device *parent, int port_id) 543 + { 544 + struct Scsi_Host *shost = dev_to_shost(parent); 545 + struct sas_port *port; 546 + 547 + port = kzalloc(sizeof(*port), GFP_KERNEL); 548 + if (!port) 549 + return NULL; 550 + 551 + port->port_identifier = port_id; 552 + 553 + device_initialize(&port->dev); 554 + 555 + port->dev.parent = get_device(parent); 556 + port->dev.release = sas_port_release; 557 + 558 + mutex_init(&port->phy_list_mutex); 559 + INIT_LIST_HEAD(&port->phy_list); 560 + 561 + if (scsi_is_sas_expander_device(parent)) { 562 + struct sas_rphy *rphy = dev_to_rphy(parent); 563 + sprintf(port->dev.bus_id, "port-%d:%d:%d", shost->host_no, 564 + rphy->scsi_target_id, port->port_identifier); 565 + } else 566 + sprintf(port->dev.bus_id, "port-%d:%d", shost->host_no, 567 + port->port_identifier); 568 + 569 + transport_setup_device(&port->dev); 570 + 571 + return port; 572 + } 573 + EXPORT_SYMBOL(sas_port_alloc); 574 + 575 + /** 576 + * sas_port_add - add a SAS port to the device hierarchy 577 + * 578 + * @port: port to be added 579 + * 580 + * publishes a port to the rest of the system 581 + */ 582 + int sas_port_add(struct sas_port *port) 583 + { 584 + int error; 585 + 586 + /* No phys should be added until this is made visible */ 587 + BUG_ON(!list_empty(&port->phy_list)); 588 + 589 + error = device_add(&port->dev); 590 + 591 + if (error) 592 + return error; 593 + 594 + transport_add_device(&port->dev); 595 + transport_configure_device(&port->dev); 596 + 597 + return 0; 598 + } 599 + EXPORT_SYMBOL(sas_port_add); 600 + 601 + /** 602 + * sas_port_free -- free a SAS PORT 603 + * @port: SAS PORT to free 604 + * 605 + * Frees the specified SAS PORT. 606 + * 607 + * Note: 608 + * This function must only be called on a PORT that has not 609 + * sucessfully been added using sas_port_add(). 610 + */ 611 + void sas_port_free(struct sas_port *port) 612 + { 613 + transport_destroy_device(&port->dev); 614 + put_device(&port->dev); 615 + } 616 + EXPORT_SYMBOL(sas_port_free); 617 + 618 + /** 619 + * sas_port_delete -- remove SAS PORT 620 + * @port: SAS PORT to remove 621 + * 622 + * Removes the specified SAS PORT. If the SAS PORT has an 623 + * associated phys, unlink them from the port as well. 624 + */ 625 + void sas_port_delete(struct sas_port *port) 626 + { 627 + struct device *dev = &port->dev; 628 + struct sas_phy *phy, *tmp_phy; 629 + 630 + if (port->rphy) { 631 + sas_rphy_delete(port->rphy); 632 + port->rphy = NULL; 633 + } 634 + 635 + mutex_lock(&port->phy_list_mutex); 636 + list_for_each_entry_safe(phy, tmp_phy, &port->phy_list, 637 + port_siblings) { 638 + sas_port_delete_link(port, phy); 639 + list_del_init(&phy->port_siblings); 640 + } 641 + mutex_unlock(&port->phy_list_mutex); 642 + 643 + transport_remove_device(dev); 644 + device_del(dev); 645 + transport_destroy_device(dev); 646 + put_device(dev); 647 + } 648 + EXPORT_SYMBOL(sas_port_delete); 649 + 650 + /** 651 + * scsi_is_sas_port -- check if a struct device represents a SAS port 652 + * @dev: device to check 653 + * 654 + * Returns: 655 + * %1 if the device represents a SAS Port, %0 else 656 + */ 657 + int scsi_is_sas_port(const struct device *dev) 658 + { 659 + return dev->release == sas_port_release; 660 + } 661 + EXPORT_SYMBOL(scsi_is_sas_port); 662 + 663 + /** 664 + * sas_port_add_phy - add another phy to a port to form a wide port 665 + * @port: port to add the phy to 666 + * @phy: phy to add 667 + * 668 + * When a port is initially created, it is empty (has no phys). All 669 + * ports must have at least one phy to operated, and all wide ports 670 + * must have at least two. The current code makes no difference 671 + * between ports and wide ports, but the only object that can be 672 + * connected to a remote device is a port, so ports must be formed on 673 + * all devices with phys if they're connected to anything. 674 + */ 675 + void sas_port_add_phy(struct sas_port *port, struct sas_phy *phy) 676 + { 677 + mutex_lock(&port->phy_list_mutex); 678 + if (unlikely(!list_empty(&phy->port_siblings))) { 679 + /* make sure we're already on this port */ 680 + struct sas_phy *tmp; 681 + 682 + list_for_each_entry(tmp, &port->phy_list, port_siblings) 683 + if (tmp == phy) 684 + break; 685 + /* If this trips, you added a phy that was already 686 + * part of a different port */ 687 + if (unlikely(tmp != phy)) { 688 + dev_printk(KERN_ERR, &port->dev, "trying to add phy %s fails: it's already part of another port\n", phy->dev.bus_id); 689 + BUG(); 690 + } 691 + } else { 692 + sas_port_create_link(port, phy); 693 + list_add_tail(&phy->port_siblings, &port->phy_list); 694 + port->num_phys++; 695 + } 696 + mutex_unlock(&port->phy_list_mutex); 697 + } 698 + EXPORT_SYMBOL(sas_port_add_phy); 699 + 700 + /** 701 + * sas_port_delete_phy - remove a phy from a port or wide port 702 + * @port: port to remove the phy from 703 + * @phy: phy to remove 704 + * 705 + * This operation is used for tearing down ports again. It must be 706 + * done to every port or wide port before calling sas_port_delete. 707 + */ 708 + void sas_port_delete_phy(struct sas_port *port, struct sas_phy *phy) 709 + { 710 + mutex_lock(&port->phy_list_mutex); 711 + sas_port_delete_link(port, phy); 712 + list_del_init(&phy->port_siblings); 713 + port->num_phys--; 714 + mutex_unlock(&port->phy_list_mutex); 715 + } 716 + EXPORT_SYMBOL(sas_port_delete_phy); 483 717 484 718 /* 485 719 * SAS remote PHY attributes. ··· 1037 767 * Returns: 1038 768 * SAS PHY allocated or %NULL if the allocation failed. 1039 769 */ 1040 - struct sas_rphy *sas_end_device_alloc(struct sas_phy *parent) 770 + struct sas_rphy *sas_end_device_alloc(struct sas_port *parent) 1041 771 { 1042 772 struct Scsi_Host *shost = dev_to_shost(&parent->dev); 1043 773 struct sas_end_device *rdev; ··· 1050 780 device_initialize(&rdev->rphy.dev); 1051 781 rdev->rphy.dev.parent = get_device(&parent->dev); 1052 782 rdev->rphy.dev.release = sas_end_device_release; 1053 - sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d", 1054 - shost->host_no, parent->port_identifier, parent->number); 783 + if (scsi_is_sas_expander_device(parent->dev.parent)) { 784 + struct sas_rphy *rphy = dev_to_rphy(parent->dev.parent); 785 + sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d:%d", 786 + shost->host_no, rphy->scsi_target_id, parent->port_identifier); 787 + } else 788 + sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d", 789 + shost->host_no, parent->port_identifier); 1055 790 rdev->rphy.identify.device_type = SAS_END_DEVICE; 1056 791 sas_rphy_initialize(&rdev->rphy); 1057 792 transport_setup_device(&rdev->rphy.dev); ··· 1073 798 * Returns: 1074 799 * SAS PHY allocated or %NULL if the allocation failed. 1075 800 */ 1076 - struct sas_rphy *sas_expander_alloc(struct sas_phy *parent, 801 + struct sas_rphy *sas_expander_alloc(struct sas_port *parent, 1077 802 enum sas_device_type type) 1078 803 { 1079 804 struct Scsi_Host *shost = dev_to_shost(&parent->dev); ··· 1112 837 */ 1113 838 int sas_rphy_add(struct sas_rphy *rphy) 1114 839 { 1115 - struct sas_phy *parent = dev_to_phy(rphy->dev.parent); 840 + struct sas_port *parent = dev_to_sas_port(rphy->dev.parent); 1116 841 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent); 1117 842 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 1118 843 struct sas_identify *identify = &rphy->identify; ··· 1185 910 sas_rphy_delete(struct sas_rphy *rphy) 1186 911 { 1187 912 struct device *dev = &rphy->dev; 1188 - struct sas_phy *parent = dev_to_phy(dev->parent); 913 + struct sas_port *parent = dev_to_sas_port(dev->parent); 1189 914 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent); 1190 915 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 1191 916 ··· 1195 920 break; 1196 921 case SAS_EDGE_EXPANDER_DEVICE: 1197 922 case SAS_FANOUT_EXPANDER_DEVICE: 1198 - device_for_each_child(dev, NULL, do_sas_phy_delete); 923 + sas_remove_children(dev); 1199 924 break; 1200 925 default: 1201 926 break; ··· 1242 967 1243 968 mutex_lock(&sas_host->lock); 1244 969 list_for_each_entry(rphy, &sas_host->rphy_list, list) { 1245 - struct sas_phy *parent = dev_to_phy(rphy->dev.parent); 970 + struct sas_port *parent = dev_to_sas_port(rphy->dev.parent); 1246 971 1247 972 if (rphy->identify.device_type != SAS_END_DEVICE || 1248 973 rphy->scsi_target_id == -1) ··· 1278 1003 #define SETUP_OPTIONAL_RPORT_ATTRIBUTE(field, func) \ 1279 1004 SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, i->f->func) 1280 1005 1281 - #define SETUP_PORT_ATTRIBUTE(field) \ 1006 + #define SETUP_PHY_ATTRIBUTE(field) \ 1282 1007 SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, 1) 1283 1008 1284 - #define SETUP_OPTIONAL_PORT_ATTRIBUTE(field, func) \ 1009 + #define SETUP_PORT_ATTRIBUTE(field) \ 1010 + SETUP_TEMPLATE(port_attrs, field, S_IRUGO, 1) 1011 + 1012 + #define SETUP_OPTIONAL_PHY_ATTRIBUTE(field, func) \ 1285 1013 SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, i->f->func) 1286 1014 1287 - #define SETUP_PORT_ATTRIBUTE_WRONLY(field) \ 1015 + #define SETUP_PHY_ATTRIBUTE_WRONLY(field) \ 1288 1016 SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, 1) 1289 1017 1290 - #define SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(field, func) \ 1018 + #define SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(field, func) \ 1291 1019 SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, i->f->func) 1292 1020 1293 1021 #define SETUP_END_DEV_ATTRIBUTE(field) \ ··· 1326 1048 i->phy_attr_cont.ac.match = sas_phy_match; 1327 1049 transport_container_register(&i->phy_attr_cont); 1328 1050 1051 + i->port_attr_cont.ac.class = &sas_port_class.class; 1052 + i->port_attr_cont.ac.attrs = &i->port_attrs[0]; 1053 + i->port_attr_cont.ac.match = sas_port_match; 1054 + transport_container_register(&i->port_attr_cont); 1055 + 1329 1056 i->rphy_attr_cont.ac.class = &sas_rphy_class.class; 1330 1057 i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0]; 1331 1058 i->rphy_attr_cont.ac.match = sas_rphy_match; ··· 1349 1066 i->f = ft; 1350 1067 1351 1068 count = 0; 1069 + SETUP_PORT_ATTRIBUTE(num_phys); 1352 1070 i->host_attrs[count] = NULL; 1353 1071 1354 1072 count = 0; 1355 - SETUP_PORT_ATTRIBUTE(initiator_port_protocols); 1356 - SETUP_PORT_ATTRIBUTE(target_port_protocols); 1357 - SETUP_PORT_ATTRIBUTE(device_type); 1358 - SETUP_PORT_ATTRIBUTE(sas_address); 1359 - SETUP_PORT_ATTRIBUTE(phy_identifier); 1360 - SETUP_PORT_ATTRIBUTE(port_identifier); 1361 - SETUP_PORT_ATTRIBUTE(negotiated_linkrate); 1362 - SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw); 1363 - SETUP_PORT_ATTRIBUTE(minimum_linkrate); 1364 - SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw); 1365 - SETUP_PORT_ATTRIBUTE(maximum_linkrate); 1073 + SETUP_PHY_ATTRIBUTE(initiator_port_protocols); 1074 + SETUP_PHY_ATTRIBUTE(target_port_protocols); 1075 + SETUP_PHY_ATTRIBUTE(device_type); 1076 + SETUP_PHY_ATTRIBUTE(sas_address); 1077 + SETUP_PHY_ATTRIBUTE(phy_identifier); 1078 + //SETUP_PHY_ATTRIBUTE(port_identifier); 1079 + SETUP_PHY_ATTRIBUTE(negotiated_linkrate); 1080 + SETUP_PHY_ATTRIBUTE(minimum_linkrate_hw); 1081 + SETUP_PHY_ATTRIBUTE(minimum_linkrate); 1082 + SETUP_PHY_ATTRIBUTE(maximum_linkrate_hw); 1083 + SETUP_PHY_ATTRIBUTE(maximum_linkrate); 1366 1084 1367 - SETUP_PORT_ATTRIBUTE(invalid_dword_count); 1368 - SETUP_PORT_ATTRIBUTE(running_disparity_error_count); 1369 - SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count); 1370 - SETUP_PORT_ATTRIBUTE(phy_reset_problem_count); 1371 - SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(link_reset, phy_reset); 1372 - SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(hard_reset, phy_reset); 1085 + SETUP_PHY_ATTRIBUTE(invalid_dword_count); 1086 + SETUP_PHY_ATTRIBUTE(running_disparity_error_count); 1087 + SETUP_PHY_ATTRIBUTE(loss_of_dword_sync_count); 1088 + SETUP_PHY_ATTRIBUTE(phy_reset_problem_count); 1089 + SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(link_reset, phy_reset); 1090 + SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(hard_reset, phy_reset); 1373 1091 i->phy_attrs[count] = NULL; 1092 + 1093 + count = 0; 1094 + SETUP_PORT_ATTRIBUTE(num_phys); 1095 + i->port_attrs[count] = NULL; 1374 1096 1375 1097 count = 0; 1376 1098 SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols); ··· 1419 1131 1420 1132 transport_container_unregister(&i->t.host_attrs); 1421 1133 transport_container_unregister(&i->phy_attr_cont); 1134 + transport_container_unregister(&i->port_attr_cont); 1422 1135 transport_container_unregister(&i->rphy_attr_cont); 1423 1136 transport_container_unregister(&i->end_dev_attr_cont); 1424 1137 transport_container_unregister(&i->expander_attr_cont); ··· 1438 1149 error = transport_class_register(&sas_phy_class); 1439 1150 if (error) 1440 1151 goto out_unregister_transport; 1441 - error = transport_class_register(&sas_rphy_class); 1152 + error = transport_class_register(&sas_port_class); 1442 1153 if (error) 1443 1154 goto out_unregister_phy; 1155 + error = transport_class_register(&sas_rphy_class); 1156 + if (error) 1157 + goto out_unregister_port; 1444 1158 error = transport_class_register(&sas_end_dev_class); 1445 1159 if (error) 1446 1160 goto out_unregister_rphy; ··· 1457 1165 transport_class_unregister(&sas_end_dev_class); 1458 1166 out_unregister_rphy: 1459 1167 transport_class_unregister(&sas_rphy_class); 1168 + out_unregister_port: 1169 + transport_class_unregister(&sas_port_class); 1460 1170 out_unregister_phy: 1461 1171 transport_class_unregister(&sas_phy_class); 1462 1172 out_unregister_transport: ··· 1472 1178 { 1473 1179 transport_class_unregister(&sas_host_class); 1474 1180 transport_class_unregister(&sas_phy_class); 1181 + transport_class_unregister(&sas_port_class); 1475 1182 transport_class_unregister(&sas_rphy_class); 1476 1183 transport_class_unregister(&sas_end_dev_class); 1477 1184 transport_class_unregister(&sas_expander_class);
+2 -1
drivers/scsi/scsicam.c
··· 57 57 int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip) 58 58 { 59 59 unsigned char *p; 60 + u64 capacity64 = capacity; /* Suppress gcc warning */ 60 61 int ret; 61 62 62 63 p = scsi_bios_ptable(bdev); ··· 69 68 (unsigned int *)ip + 0, (unsigned int *)ip + 1); 70 69 kfree(p); 71 70 72 - if (ret == -1) { 71 + if (ret == -1 && capacity64 < (1ULL << 32)) { 73 72 /* pick some standard mapping with at most 1024 cylinders, 74 73 and at most 62 sectors per track - this works up to 75 74 7905 MB */
+88 -81
drivers/scsi/sd.c
··· 207 207 return count; 208 208 } 209 209 210 + static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf, 211 + size_t count) 212 + { 213 + struct scsi_disk *sdkp = to_scsi_disk(cdev); 214 + struct scsi_device *sdp = sdkp->device; 215 + 216 + if (!capable(CAP_SYS_ADMIN)) 217 + return -EACCES; 218 + 219 + if (sdp->type != TYPE_DISK) 220 + return -EINVAL; 221 + 222 + sdp->allow_restart = simple_strtoul(buf, NULL, 10); 223 + 224 + return count; 225 + } 226 + 210 227 static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf) 211 228 { 212 229 struct scsi_disk *sdkp = to_scsi_disk(cdev); ··· 239 222 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); 240 223 } 241 224 225 + static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf) 226 + { 227 + struct scsi_disk *sdkp = to_scsi_disk(cdev); 228 + 229 + return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); 230 + } 231 + 242 232 static struct class_device_attribute sd_disk_attrs[] = { 243 233 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 244 234 sd_store_cache_type), 245 235 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL), 236 + __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart, 237 + sd_store_allow_restart), 246 238 __ATTR_NULL, 247 239 }; 248 240 ··· 916 890 static void sd_rw_intr(struct scsi_cmnd * SCpnt) 917 891 { 918 892 int result = SCpnt->result; 919 - int this_count = SCpnt->request_bufflen; 920 - int good_bytes = (result == 0 ? this_count : 0); 921 - sector_t block_sectors = 1; 922 - u64 first_err_block; 923 - sector_t error_sector; 893 + unsigned int xfer_size = SCpnt->request_bufflen; 894 + unsigned int good_bytes = result ? 0 : xfer_size; 895 + u64 start_lba = SCpnt->request->sector; 896 + u64 bad_lba; 924 897 struct scsi_sense_hdr sshdr; 925 898 int sense_valid = 0; 926 899 int sense_deferred = 0; ··· 930 905 if (sense_valid) 931 906 sense_deferred = scsi_sense_is_deferred(&sshdr); 932 907 } 933 - 934 908 #ifdef CONFIG_SCSI_LOGGING 935 909 SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: %s: res=0x%x\n", 936 910 SCpnt->request->rq_disk->disk_name, result)); ··· 939 915 sshdr.sense_key, sshdr.asc, sshdr.ascq)); 940 916 } 941 917 #endif 942 - /* 943 - Handle MEDIUM ERRORs that indicate partial success. Since this is a 944 - relatively rare error condition, no care is taken to avoid 945 - unnecessary additional work such as memcpy's that could be avoided. 946 - */ 947 - if (driver_byte(result) != 0 && 948 - sense_valid && !sense_deferred) { 949 - switch (sshdr.sense_key) { 950 - case MEDIUM_ERROR: 951 - if (!blk_fs_request(SCpnt->request)) 952 - break; 953 - info_valid = scsi_get_sense_info_fld( 954 - SCpnt->sense_buffer, SCSI_SENSE_BUFFERSIZE, 955 - &first_err_block); 956 - /* 957 - * May want to warn and skip if following cast results 958 - * in actual truncation (if sector_t < 64 bits) 959 - */ 960 - error_sector = (sector_t)first_err_block; 961 - if (SCpnt->request->bio != NULL) 962 - block_sectors = bio_sectors(SCpnt->request->bio); 963 - switch (SCpnt->device->sector_size) { 964 - case 1024: 965 - error_sector <<= 1; 966 - if (block_sectors < 2) 967 - block_sectors = 2; 968 - break; 969 - case 2048: 970 - error_sector <<= 2; 971 - if (block_sectors < 4) 972 - block_sectors = 4; 973 - break; 974 - case 4096: 975 - error_sector <<=3; 976 - if (block_sectors < 8) 977 - block_sectors = 8; 978 - break; 979 - case 256: 980 - error_sector >>= 1; 981 - break; 982 - default: 983 - break; 984 - } 918 + if (driver_byte(result) != DRIVER_SENSE && 919 + (!sense_valid || sense_deferred)) 920 + goto out; 985 921 986 - error_sector &= ~(block_sectors - 1); 987 - good_bytes = (error_sector - SCpnt->request->sector) << 9; 988 - if (good_bytes < 0 || good_bytes >= this_count) 989 - good_bytes = 0; 922 + switch (sshdr.sense_key) { 923 + case HARDWARE_ERROR: 924 + case MEDIUM_ERROR: 925 + if (!blk_fs_request(SCpnt->request)) 926 + goto out; 927 + info_valid = scsi_get_sense_info_fld(SCpnt->sense_buffer, 928 + SCSI_SENSE_BUFFERSIZE, 929 + &bad_lba); 930 + if (!info_valid) 931 + goto out; 932 + if (xfer_size <= SCpnt->device->sector_size) 933 + goto out; 934 + switch (SCpnt->device->sector_size) { 935 + case 256: 936 + start_lba <<= 1; 990 937 break; 991 - 992 - case RECOVERED_ERROR: /* an error occurred, but it recovered */ 993 - case NO_SENSE: /* LLDD got sense data */ 994 - /* 995 - * Inform the user, but make sure that it's not treated 996 - * as a hard error. 997 - */ 998 - scsi_print_sense("sd", SCpnt); 999 - SCpnt->result = 0; 1000 - memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 1001 - good_bytes = this_count; 938 + case 512: 1002 939 break; 1003 - 1004 - case ILLEGAL_REQUEST: 1005 - if (SCpnt->device->use_10_for_rw && 1006 - (SCpnt->cmnd[0] == READ_10 || 1007 - SCpnt->cmnd[0] == WRITE_10)) 1008 - SCpnt->device->use_10_for_rw = 0; 1009 - if (SCpnt->device->use_10_for_ms && 1010 - (SCpnt->cmnd[0] == MODE_SENSE_10 || 1011 - SCpnt->cmnd[0] == MODE_SELECT_10)) 1012 - SCpnt->device->use_10_for_ms = 0; 940 + case 1024: 941 + start_lba >>= 1; 1013 942 break; 1014 - 943 + case 2048: 944 + start_lba >>= 2; 945 + break; 946 + case 4096: 947 + start_lba >>= 3; 948 + break; 1015 949 default: 950 + /* Print something here with limiting frequency. */ 951 + goto out; 1016 952 break; 1017 953 } 954 + /* This computation should always be done in terms of 955 + * the resolution of the device's medium. 956 + */ 957 + good_bytes = (bad_lba - start_lba)*SCpnt->device->sector_size; 958 + break; 959 + case RECOVERED_ERROR: 960 + case NO_SENSE: 961 + /* Inform the user, but make sure that it's not treated 962 + * as a hard error. 963 + */ 964 + scsi_print_sense("sd", SCpnt); 965 + SCpnt->result = 0; 966 + memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 967 + good_bytes = xfer_size; 968 + break; 969 + case ILLEGAL_REQUEST: 970 + if (SCpnt->device->use_10_for_rw && 971 + (SCpnt->cmnd[0] == READ_10 || 972 + SCpnt->cmnd[0] == WRITE_10)) 973 + SCpnt->device->use_10_for_rw = 0; 974 + if (SCpnt->device->use_10_for_ms && 975 + (SCpnt->cmnd[0] == MODE_SENSE_10 || 976 + SCpnt->cmnd[0] == MODE_SELECT_10)) 977 + SCpnt->device->use_10_for_ms = 0; 978 + break; 979 + default: 980 + break; 1018 981 } 1019 - /* 1020 - * This calls the generic completion function, now that we know 1021 - * how many actual sectors finished, and how many sectors we need 1022 - * to say have failed. 1023 - */ 1024 - scsi_io_completion(SCpnt, good_bytes, block_sectors << 9); 982 + out: 983 + scsi_io_completion(SCpnt, good_bytes); 1025 984 } 1026 985 1027 986 static int media_not_present(struct scsi_disk *sdkp,
+9 -1
drivers/scsi/sg.c
··· 1401 1401 Sg_device *sdp = NULL; 1402 1402 struct cdev * cdev = NULL; 1403 1403 int error, k; 1404 + unsigned long iflags; 1404 1405 1405 1406 disk = alloc_disk(1); 1406 1407 if (!disk) { ··· 1429 1428 1430 1429 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); 1431 1430 if (error) 1432 - goto out; 1431 + goto cdev_add_err; 1433 1432 1434 1433 sdp->cdev = cdev; 1435 1434 if (sg_sysfs_valid) { ··· 1455 1454 "Attached scsi generic sg%d type %d\n", k,scsidp->type); 1456 1455 1457 1456 return 0; 1457 + 1458 + cdev_add_err: 1459 + write_lock_irqsave(&sg_dev_arr_lock, iflags); 1460 + kfree(sg_dev_arr[k]); 1461 + sg_dev_arr[k] = NULL; 1462 + sg_nr_dev--; 1463 + write_unlock_irqrestore(&sg_dev_arr_lock, iflags); 1458 1464 1459 1465 out: 1460 1466 put_disk(disk);
+1 -1
drivers/scsi/sr.c
··· 292 292 * how many actual sectors finished, and how many sectors we need 293 293 * to say have failed. 294 294 */ 295 - scsi_io_completion(SCpnt, good_bytes, block_sectors << 9); 295 + scsi_io_completion(SCpnt, good_bytes); 296 296 } 297 297 298 298 static int sr_init_command(struct scsi_cmnd * SCpnt)
-1
drivers/scsi/st.c
··· 3599 3599 tb->use_sg = max_sg; 3600 3600 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); 3601 3601 3602 - tb->in_use = 1; 3603 3602 tb->dma = need_dma; 3604 3603 tb->buffer_size = got; 3605 3604
-1
drivers/scsi/st.h
··· 31 31 32 32 /* The tape buffer descriptor. */ 33 33 struct st_buffer { 34 - unsigned char in_use; 35 34 unsigned char dma; /* DMA-able buffer */ 36 35 unsigned char do_dio; /* direct i/o set up? */ 37 36 int buffer_size;
+24
include/scsi/iscsi_if.h
··· 47 47 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13, 48 48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14, 49 49 50 + ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, 51 + 50 52 /* up events */ 51 53 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, 52 54 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2, 53 55 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3, 56 + ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4, 57 + }; 58 + 59 + enum iscsi_tgt_dscvr { 60 + ISCSI_TGT_DSCVR_SEND_TARGETS = 1, 61 + ISCSI_TGT_DSCVR_ISNS = 2, 62 + ISCSI_TGT_DSCVR_SLP = 3, 54 63 }; 55 64 56 65 struct iscsi_uevent { ··· 125 116 struct msg_transport_disconnect { 126 117 uint64_t ep_handle; 127 118 } ep_disconnect; 119 + struct msg_tgt_dscvr { 120 + enum iscsi_tgt_dscvr type; 121 + uint32_t host_no; 122 + /* 123 + * enable = 1 to establish a new connection 124 + * with the server. enable = 0 to disconnect 125 + * from the server. Used primarily to switch 126 + * from one iSNS server to another. 127 + */ 128 + uint32_t enable; 129 + } tgt_dscvr; 128 130 } u; 129 131 union { 130 132 /* messages k -> u */ ··· 158 138 uint32_t cid; 159 139 uint32_t error; /* enum iscsi_err */ 160 140 } connerror; 141 + struct msg_session_destroyed { 142 + uint32_t host_no; 143 + uint32_t sid; 144 + } d_session; 161 145 struct msg_transport_connect_ret { 162 146 uint64_t handle; 163 147 } ep_connect_ret;
+13 -2
include/scsi/libiscsi.h
··· 157 157 int max_xmit_dlength; /* target_max_recv_dsl */ 158 158 int hdrdgst_en; 159 159 int datadgst_en; 160 + int ifmarker_en; 161 + int ofmarker_en; 162 + /* values userspace uses to id a conn */ 163 + int persistent_port; 164 + char *persistent_address; 160 165 161 166 /* MIB-statistics */ 162 167 uint64_t txdata_octets; ··· 201 196 int pdu_inorder_en; 202 197 int dataseq_inorder_en; 203 198 int erl; 204 - int ifmarker_en; 205 - int ofmarker_en; 199 + int tpgt; 200 + char *targetname; 206 201 207 202 /* control data */ 208 203 struct iscsi_transport *tt; ··· 245 240 extern void iscsi_session_teardown(struct iscsi_cls_session *); 246 241 extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *); 247 242 extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *); 243 + extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn, 244 + enum iscsi_param param, char *buf, int buflen); 245 + extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session, 246 + enum iscsi_param param, char *buf); 248 247 249 248 #define session_to_cls(_sess) \ 250 249 hostdata_session(_sess->host->hostdata) ··· 264 255 extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *, 265 256 int); 266 257 extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err); 258 + extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, 259 + enum iscsi_param param, char *buf); 267 260 268 261 /* 269 262 * pdu and task processing
+1 -1
include/scsi/scsi_cmnd.h
··· 143 143 144 144 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 145 145 extern void scsi_put_command(struct scsi_cmnd *); 146 - extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); 146 + extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); 147 147 extern void scsi_finish_command(struct scsi_cmnd *cmd); 148 148 extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); 149 149
+5 -1
include/scsi/scsi_host.h
··· 542 542 */ 543 543 unsigned ordered_tag:1; 544 544 545 + /* task mgmt function in progress */ 546 + unsigned tmf_in_progress:1; 547 + 545 548 /* 546 549 * Optional work queue to be utilized by the transport 547 550 */ ··· 622 619 { 623 620 return shost->shost_state == SHOST_RECOVERY || 624 621 shost->shost_state == SHOST_CANCEL_RECOVERY || 625 - shost->shost_state == SHOST_DEL_RECOVERY; 622 + shost->shost_state == SHOST_DEL_RECOVERY || 623 + shost->tmf_in_progress; 626 624 } 627 625 628 626 extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *);
+26 -22
include/scsi/scsi_transport_iscsi.h
··· 34 34 struct iscsi_conn; 35 35 struct iscsi_cmd_task; 36 36 struct iscsi_mgmt_task; 37 + struct sockaddr; 37 38 38 39 /** 39 40 * struct iscsi_transport - iSCSI Transport template ··· 47 46 * @bind_conn: associate this connection with existing iSCSI session 48 47 * and specified transport descriptor 49 48 * @destroy_conn: destroy inactive iSCSI connection 50 - * @set_param: set iSCSI Data-Path operational parameter 49 + * @set_param: set iSCSI parameter. Return 0 on success, -ENODATA 50 + * when param is not supported, and a -Exx value on other 51 + * error. 52 + * @get_param get iSCSI parameter. Must return number of bytes 53 + * copied to buffer on success, -ENODATA when param 54 + * is not supported, and a -Exx value on other error 51 55 * @start_conn: set connection to be operational 52 56 * @stop_conn: suspend/recover/terminate connection 53 57 * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. ··· 103 97 void (*stop_conn) (struct iscsi_cls_conn *conn, int flag); 104 98 void (*destroy_conn) (struct iscsi_cls_conn *conn); 105 99 int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param, 106 - uint32_t value); 100 + char *buf, int buflen); 107 101 int (*get_conn_param) (struct iscsi_cls_conn *conn, 108 - enum iscsi_param param, uint32_t *value); 102 + enum iscsi_param param, char *buf); 109 103 int (*get_session_param) (struct iscsi_cls_session *session, 110 - enum iscsi_param param, uint32_t *value); 111 - int (*get_conn_str_param) (struct iscsi_cls_conn *conn, 112 - enum iscsi_param param, char *buf); 113 - int (*get_session_str_param) (struct iscsi_cls_session *session, 114 - enum iscsi_param param, char *buf); 104 + enum iscsi_param param, char *buf); 115 105 int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, 116 106 char *data, uint32_t data_size); 117 107 void (*get_stats) (struct iscsi_cls_conn *conn, ··· 129 127 uint64_t *ep_handle); 130 128 int (*ep_poll) (uint64_t ep_handle, int timeout_ms); 131 129 void (*ep_disconnect) (uint64_t ep_handle); 130 + int (*tgt_dscvr) (enum iscsi_tgt_dscvr type, uint32_t host_no, 131 + uint32_t enable, struct sockaddr *dst_addr); 132 132 }; 133 133 134 134 /* ··· 159 155 struct iscsi_transport *transport; 160 156 uint32_t cid; /* connection id */ 161 157 162 - /* portal/group values we got during discovery */ 163 - char *persistent_address; 164 - int persistent_port; 165 - /* portal/group values we are currently using */ 166 - char *address; 167 - int port; 168 - 169 158 int active; /* must be accessed with the connlock */ 170 159 struct device dev; /* sysfs transport/container device */ 171 160 struct mempool_zone *z_error; ··· 182 185 struct list_head host_list; 183 186 struct iscsi_transport *transport; 184 187 185 - /* iSCSI values used as unique id by userspace. */ 186 - char *targetname; 187 - int tpgt; 188 - 189 188 /* recovery fields */ 190 189 int recovery_tmo; 191 190 struct work_struct recovery_work; 192 191 193 192 int target_id; 194 - int channel; 195 193 196 194 int sid; /* session id */ 197 195 void *dd_data; /* LLD private data */ ··· 199 207 #define iscsi_session_to_shost(_session) \ 200 208 dev_to_shost(_session->dev.parent) 201 209 210 + #define starget_to_session(_stgt) \ 211 + iscsi_dev_to_session(_stgt->dev.parent) 212 + 202 213 struct iscsi_host { 203 - int next_target_id; 204 214 struct list_head sessions; 205 215 struct mutex mutex; 206 216 }; ··· 210 216 /* 211 217 * session and connection functions that can be used by HW iSCSI LLDs 212 218 */ 219 + extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, 220 + struct iscsi_transport *transport); 221 + extern int iscsi_add_session(struct iscsi_cls_session *session, 222 + unsigned int target_id); 223 + extern int iscsi_if_create_session_done(struct iscsi_cls_conn *conn); 224 + extern int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn); 213 225 extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, 214 - struct iscsi_transport *t, int channel); 226 + struct iscsi_transport *t, 227 + unsigned int target_id); 228 + extern void iscsi_remove_session(struct iscsi_cls_session *session); 229 + extern void iscsi_free_session(struct iscsi_cls_session *session); 215 230 extern int iscsi_destroy_session(struct iscsi_cls_session *session); 216 231 extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, 217 232 uint32_t cid); 218 233 extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); 219 234 extern void iscsi_unblock_session(struct iscsi_cls_session *session); 220 235 extern void iscsi_block_session(struct iscsi_cls_session *session); 236 + 221 237 222 238 #endif
+32 -5
include/scsi/scsi_transport_sas.h
··· 3 3 4 4 #include <linux/transport_class.h> 5 5 #include <linux/types.h> 6 + #include <linux/mutex.h> 6 7 7 8 struct scsi_transport_template; 8 9 struct sas_rphy; ··· 56 55 enum sas_linkrate minimum_linkrate; 57 56 enum sas_linkrate maximum_linkrate_hw; 58 57 enum sas_linkrate maximum_linkrate; 59 - u8 port_identifier; 60 58 61 59 /* internal state */ 62 60 unsigned int local_attached : 1; ··· 66 66 u32 loss_of_dword_sync_count; 67 67 u32 phy_reset_problem_count; 68 68 69 - /* the other end of the link */ 70 - struct sas_rphy *rphy; 69 + /* for the list of phys belonging to a port */ 70 + struct list_head port_siblings; 71 71 }; 72 72 73 73 #define dev_to_phy(d) \ ··· 124 124 #define rphy_to_expander_device(r) \ 125 125 container_of((r), struct sas_expander_device, rphy) 126 126 127 + struct sas_port { 128 + struct device dev; 129 + 130 + u8 port_identifier; 131 + int num_phys; 132 + 133 + /* the other end of the link */ 134 + struct sas_rphy *rphy; 135 + 136 + struct mutex phy_list_mutex; 137 + struct list_head phy_list; 138 + }; 139 + 140 + #define dev_to_sas_port(d) \ 141 + container_of((d), struct sas_port, dev) 142 + #define transport_class_to_sas_port(cdev) \ 143 + dev_to_sas_port((cdev)->dev) 144 + 127 145 /* The functions by which the transport class and the driver communicate */ 128 146 struct sas_function_template { 129 147 int (*get_linkerrors)(struct sas_phy *); ··· 151 133 }; 152 134 153 135 136 + void sas_remove_children(struct device *); 154 137 extern void sas_remove_host(struct Scsi_Host *); 155 138 156 139 extern struct sas_phy *sas_phy_alloc(struct device *, int); ··· 160 141 extern void sas_phy_delete(struct sas_phy *); 161 142 extern int scsi_is_sas_phy(const struct device *); 162 143 163 - extern struct sas_rphy *sas_end_device_alloc(struct sas_phy *); 164 - extern struct sas_rphy *sas_expander_alloc(struct sas_phy *, enum sas_device_type); 144 + extern struct sas_rphy *sas_end_device_alloc(struct sas_port *); 145 + extern struct sas_rphy *sas_expander_alloc(struct sas_port *, enum sas_device_type); 165 146 void sas_rphy_free(struct sas_rphy *); 166 147 extern int sas_rphy_add(struct sas_rphy *); 167 148 extern void sas_rphy_delete(struct sas_rphy *); 168 149 extern int scsi_is_sas_rphy(const struct device *); 150 + 151 + struct sas_port *sas_port_alloc(struct device *, int); 152 + int sas_port_add(struct sas_port *); 153 + void sas_port_free(struct sas_port *); 154 + void sas_port_delete(struct sas_port *); 155 + void sas_port_add_phy(struct sas_port *, struct sas_phy *); 156 + void sas_port_delete_phy(struct sas_port *, struct sas_phy *); 157 + int scsi_is_sas_port(const struct device *); 169 158 170 159 extern struct scsi_transport_template * 171 160 sas_attach_transport(struct sas_function_template *);