Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] vmw_pvscsi: Try setting host->max_id as suggested by the device.

Fetch the config page from the device to learn max target id to set
host->max_id.

Also, fix some indentation issues and update the 'Maintained by' field.

Signed-off-by: Arvind Kumar <arvindkumar@vmware.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Arvind Kumar and committed by
James Bottomley
a9310735 3f0bc3b3

+149 -25
+64 -1
drivers/scsi/vmw_pvscsi.c
··· 17 17 * along with this program; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 19 * 20 - * Maintained by: Alok N Kataria <akataria@vmware.com> 20 + * Maintained by: Arvind Kumar <arvindkumar@vmware.com> 21 21 * 22 22 */ 23 23 ··· 1178 1178 return 0; 1179 1179 } 1180 1180 1181 + /* 1182 + * Query the device, fetch the config info and return the 1183 + * maximum number of targets on the adapter. In case of 1184 + * failure due to any reason return default i.e. 16. 1185 + */ 1186 + static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) 1187 + { 1188 + struct PVSCSICmdDescConfigCmd cmd; 1189 + struct PVSCSIConfigPageHeader *header; 1190 + struct device *dev; 1191 + dma_addr_t configPagePA; 1192 + void *config_page; 1193 + u32 numPhys = 16; 1194 + 1195 + dev = pvscsi_dev(adapter); 1196 + config_page = pci_alloc_consistent(adapter->dev, PAGE_SIZE, 1197 + &configPagePA); 1198 + if (!config_page) { 1199 + dev_warn(dev, "vmw_pvscsi: failed to allocate memory for config page\n"); 1200 + goto exit; 1201 + } 1202 + BUG_ON(configPagePA & ~PAGE_MASK); 1203 + 1204 + /* Fetch config info from the device. */ 1205 + cmd.configPageAddress = ((u64)PVSCSI_CONFIG_CONTROLLER_ADDRESS) << 32; 1206 + cmd.configPageNum = PVSCSI_CONFIG_PAGE_CONTROLLER; 1207 + cmd.cmpAddr = configPagePA; 1208 + cmd._pad = 0; 1209 + 1210 + /* 1211 + * Mark the completion page header with error values. If the device 1212 + * completes the command successfully, it sets the status values to 1213 + * indicate success. 1214 + */ 1215 + header = config_page; 1216 + memset(header, 0, sizeof *header); 1217 + header->hostStatus = BTSTAT_INVPARAM; 1218 + header->scsiStatus = SDSTAT_CHECK; 1219 + 1220 + pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_CONFIG, &cmd, sizeof cmd); 1221 + 1222 + if (header->hostStatus == BTSTAT_SUCCESS && 1223 + header->scsiStatus == SDSTAT_GOOD) { 1224 + struct PVSCSIConfigPageController *config; 1225 + 1226 + config = config_page; 1227 + numPhys = config->numPhys; 1228 + } else 1229 + dev_warn(dev, "vmw_pvscsi: PVSCSI_CMD_CONFIG failed. hostStatus = 0x%x, scsiStatus = 0x%x\n", 1230 + header->hostStatus, header->scsiStatus); 1231 + pci_free_consistent(adapter->dev, PAGE_SIZE, config_page, configPagePA); 1232 + exit: 1233 + return numPhys; 1234 + } 1235 + 1181 1236 static int __devinit pvscsi_probe(struct pci_dev *pdev, 1182 1237 const struct pci_device_id *id) 1183 1238 { 1184 1239 struct pvscsi_adapter *adapter; 1185 1240 struct Scsi_Host *host; 1241 + struct device *dev; 1186 1242 unsigned int i; 1187 1243 unsigned long flags = 0; 1188 1244 int error; ··· 1326 1270 printk(KERN_ERR "vmw_pvscsi: unable to allocate ring memory\n"); 1327 1271 goto out_release_resources; 1328 1272 } 1273 + 1274 + /* 1275 + * Ask the device for max number of targets. 1276 + */ 1277 + host->max_id = pvscsi_get_max_targets(adapter); 1278 + dev = pvscsi_dev(adapter); 1279 + dev_info(dev, "vmw_pvscsi: host->max_id: %u\n", host->max_id); 1329 1280 1330 1281 /* 1331 1282 * From this point on we should reset the adapter if anything goes
+85 -24
drivers/scsi/vmw_pvscsi.h
··· 17 17 * along with this program; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 19 * 20 - * Maintained by: Alok N Kataria <akataria@vmware.com> 20 + * Maintained by: Arvind Kumar <arvindkumar@vmware.com> 21 21 * 22 22 */ 23 23 ··· 26 26 27 27 #include <linux/types.h> 28 28 29 - #define PVSCSI_DRIVER_VERSION_STRING "1.0.1.0-k" 29 + #define PVSCSI_DRIVER_VERSION_STRING "1.0.2.0-k" 30 30 31 31 #define PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT 128 32 32 ··· 39 39 * host adapter status/error codes 40 40 */ 41 41 enum HostBusAdapterStatus { 42 - BTSTAT_SUCCESS = 0x00, /* CCB complete normally with no errors */ 43 - BTSTAT_LINKED_COMMAND_COMPLETED = 0x0a, 44 - BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG = 0x0b, 45 - BTSTAT_DATA_UNDERRUN = 0x0c, 46 - BTSTAT_SELTIMEO = 0x11, /* SCSI selection timeout */ 47 - BTSTAT_DATARUN = 0x12, /* data overrun/underrun */ 48 - BTSTAT_BUSFREE = 0x13, /* unexpected bus free */ 49 - BTSTAT_INVPHASE = 0x14, /* invalid bus phase or sequence requested by target */ 50 - BTSTAT_LUNMISMATCH = 0x17, /* linked CCB has different LUN from first CCB */ 51 - BTSTAT_SENSFAILED = 0x1b, /* auto request sense failed */ 52 - BTSTAT_TAGREJECT = 0x1c, /* SCSI II tagged queueing message rejected by target */ 53 - BTSTAT_BADMSG = 0x1d, /* unsupported message received by the host adapter */ 54 - BTSTAT_HAHARDWARE = 0x20, /* host adapter hardware failed */ 55 - BTSTAT_NORESPONSE = 0x21, /* target did not respond to SCSI ATN, sent a SCSI RST */ 56 - BTSTAT_SENTRST = 0x22, /* host adapter asserted a SCSI RST */ 57 - BTSTAT_RECVRST = 0x23, /* other SCSI devices asserted a SCSI RST */ 58 - BTSTAT_DISCONNECT = 0x24, /* target device reconnected improperly (w/o tag) */ 59 - BTSTAT_BUSRESET = 0x25, /* host adapter issued BUS device reset */ 60 - BTSTAT_ABORTQUEUE = 0x26, /* abort queue generated */ 61 - BTSTAT_HASOFTWARE = 0x27, /* host adapter software error */ 62 - BTSTAT_HATIMEOUT = 0x30, /* host adapter hardware timeout error */ 63 - BTSTAT_SCSIPARITY = 0x34, /* SCSI parity error detected */ 42 + BTSTAT_SUCCESS = 0x00, /* CCB complete normally with no errors */ 43 + BTSTAT_LINKED_COMMAND_COMPLETED = 0x0a, 44 + BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG = 0x0b, 45 + BTSTAT_DATA_UNDERRUN = 0x0c, 46 + BTSTAT_SELTIMEO = 0x11, /* SCSI selection timeout */ 47 + BTSTAT_DATARUN = 0x12, /* data overrun/underrun */ 48 + BTSTAT_BUSFREE = 0x13, /* unexpected bus free */ 49 + BTSTAT_INVPHASE = 0x14, /* invalid bus phase or sequence 50 + * requested by target */ 51 + BTSTAT_LUNMISMATCH = 0x17, /* linked CCB has different LUN from 52 + * first CCB */ 53 + BTSTAT_INVPARAM = 0x1a, /* invalid parameter in CCB or segment 54 + * list */ 55 + BTSTAT_SENSFAILED = 0x1b, /* auto request sense failed */ 56 + BTSTAT_TAGREJECT = 0x1c, /* SCSI II tagged queueing message 57 + * rejected by target */ 58 + BTSTAT_BADMSG = 0x1d, /* unsupported message received by the 59 + * host adapter */ 60 + BTSTAT_HAHARDWARE = 0x20, /* host adapter hardware failed */ 61 + BTSTAT_NORESPONSE = 0x21, /* target did not respond to SCSI ATN, 62 + * sent a SCSI RST */ 63 + BTSTAT_SENTRST = 0x22, /* host adapter asserted a SCSI RST */ 64 + BTSTAT_RECVRST = 0x23, /* other SCSI devices asserted a SCSI 65 + * RST */ 66 + BTSTAT_DISCONNECT = 0x24, /* target device reconnected improperly 67 + * (w/o tag) */ 68 + BTSTAT_BUSRESET = 0x25, /* host adapter issued BUS device reset */ 69 + BTSTAT_ABORTQUEUE = 0x26, /* abort queue generated */ 70 + BTSTAT_HASOFTWARE = 0x27, /* host adapter software error */ 71 + BTSTAT_HATIMEOUT = 0x30, /* host adapter hardware timeout error */ 72 + BTSTAT_SCSIPARITY = 0x34, /* SCSI parity error detected */ 73 + }; 74 + 75 + /* 76 + * SCSI device status values. 77 + */ 78 + enum ScsiDeviceStatus { 79 + SDSTAT_GOOD = 0x00, /* No errors. */ 80 + SDSTAT_CHECK = 0x02, /* Check condition. */ 64 81 }; 65 82 66 83 /* ··· 129 112 u32 target; 130 113 u8 lun[8]; 131 114 } __packed; 115 + 116 + /* 117 + * Command descriptor for PVSCSI_CMD_CONFIG -- 118 + */ 119 + 120 + struct PVSCSICmdDescConfigCmd { 121 + u64 cmpAddr; 122 + u64 configPageAddress; 123 + u32 configPageNum; 124 + u32 _pad; 125 + } __packed; 126 + 127 + enum PVSCSIConfigPageType { 128 + PVSCSI_CONFIG_PAGE_CONTROLLER = 0x1958, 129 + PVSCSI_CONFIG_PAGE_PHY = 0x1959, 130 + PVSCSI_CONFIG_PAGE_DEVICE = 0x195a, 131 + }; 132 + 133 + enum PVSCSIConfigPageAddressType { 134 + PVSCSI_CONFIG_CONTROLLER_ADDRESS = 0x2120, 135 + PVSCSI_CONFIG_BUSTARGET_ADDRESS = 0x2121, 136 + PVSCSI_CONFIG_PHY_ADDRESS = 0x2122, 137 + }; 132 138 133 139 /* 134 140 * Command descriptor for PVSCSI_CMD_ABORT_CMD -- ··· 370 330 u16 hostStatus; 371 331 u16 scsiStatus; 372 332 u32 _pad[2]; 333 + } __packed; 334 + 335 + struct PVSCSIConfigPageHeader { 336 + u32 pageNum; 337 + u16 numDwords; 338 + u16 hostStatus; 339 + u16 scsiStatus; 340 + u16 reserved[3]; 341 + } __packed; 342 + 343 + struct PVSCSIConfigPageController { 344 + struct PVSCSIConfigPageHeader header; 345 + u64 nodeWWN; /* Device name as defined in the SAS spec. */ 346 + u16 manufacturer[64]; 347 + u16 serialNumber[64]; 348 + u16 opromVersion[32]; 349 + u16 hwVersion[32]; 350 + u16 firmwareVersion[32]; 351 + u32 numPhys; 352 + u8 useConsecutivePhyWWNs; 353 + u8 reserved[3]; 373 354 } __packed; 374 355 375 356 /*