From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web12.667.1586885760480893088 for ; Tue, 14 Apr 2020 10:36:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=VZkikQBO; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: nikita.leshchenko@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03EHAAxj173249; Tue, 14 Apr 2020 17:35:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=VEmMVW+RxzGOXHCqEconI731/LohXpyxFIP24UCOr+8=; b=VZkikQBO3iE2n6yD1W1AyEOH9iVdrlnjz3JIGjYnsdC6Vg527GpmBH+du8W70YqLY+Ru E0XGOYZAVkFJl8O/Sn3VnGVqF1a1U/+RMYw7w6el/3uc+BnZ6D6AhMjHp/lHy2ajSQ1b vl406NTuwWIAOf+sk7nC4wH67JHVTBRxA2IzOvIkrPof3aKAuhB9AvFXzUnV3W8HIjcr 36LiIc+pw4n6BKpnQP0qQstu+helnCahskREb/jSl+gDJg6waJp7Yndm34vHbfwzyujM m0Yx6dJQpCoXv9xKToFDUzjJRGnqk5LcK+QsAQdaPYB864weLy/WSEeLtvmTuJ4djMB9 6A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 30b5um69ut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:35:56 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03EH7Eou116420; Tue, 14 Apr 2020 17:35:56 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 30ctaarrfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:35:56 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03EHZtrs022333; Tue, 14 Apr 2020 17:35:55 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 14 Apr 2020 10:35:55 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v4 12/13] OvmfPkg/MptScsiDxe: Report multiple targets Date: Tue, 14 Apr 2020 20:38:12 +0300 Message-Id: <20200414173813.7715-13-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414173813.7715-1-nikita.leshchenko@oracle.com> References: <20200414173813.7715-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 bulkscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 Content-Transfer-Encoding: 8bit The controller supports up to 8 targets (Not reported by the controller, but based on the implementation of the virtual device), report them in GetNextTarget and GetNextTargetLun. The firmware will then try to communicate with them and create a block device for each one that responds. Support for multiple LUNs will be implemented in another series. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko Reviewed-by: Liran Alon --- OvmfPkg/MptScsiDxe/MptScsi.c | 38 ++++++++++++++++++++++++------- OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 1 + OvmfPkg/OvmfPkg.dec | 4 ++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index fcdaa4c338a4..3ea08857df5d 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -46,6 +46,7 @@ typedef struct { EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; UINT32 StallPerPollUsec; + UINT8 MaxTarget; MPT_SCSI_DMA_BUFFER *Dma; EFI_PHYSICAL_ADDRESS DmaPhysical; VOID *DmaMapping; @@ -159,6 +160,7 @@ MptScsiInit ( UINT32 ReplyWord; Dev->StallPerPollUsec = PcdGet32 (PcdMptScsiStallPerPollUsec); + Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit); Status = MptScsiReset (Dev); if (EFI_ERROR (Status)) { @@ -169,7 +171,7 @@ MptScsiInit ( ZeroMem (&Reply, sizeof (Reply)); Req.Data.WhoInit = MPT_IOC_WHOINIT_ROM_BIOS; Req.Data.Function = MPT_MESSAGE_HDR_FUNCTION_IOC_INIT; - Req.Data.MaxDevices = 1; + Req.Data.MaxDevices = Dev->MaxTarget + 1; Req.Data.MaxBuses = 1; Req.Data.ReplyFrameSize = sizeof (MPT_SCSI_IO_REPLY); @@ -240,7 +242,7 @@ MptScsiPopulateRequest ( return EFI_UNSUPPORTED; } - if (Target > 0 || Lun > 0 || + if (Target > Dev->MaxTarget || Lun > 0 || Packet->DataDirection > EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL || // // Trying to receive, but destination pointer is NULL, or contradicting @@ -552,12 +554,22 @@ MptScsiGetNextTargetLun ( IN OUT UINT64 *Lun ) { + MPT_SCSI_DEV *Dev; + + Dev = MPT_SCSI_FROM_PASS_THRU (This); // - // Currently support only target 0 LUN 0, so hardcode it + // Currently support only LUN 0, so hardcode it // if (!IsTargetInitialized (*Target)) { ZeroMem (*Target, TARGET_MAX_BYTES); *Lun = 0; + } else if (**Target < Dev->MaxTarget) { + // + // This device support 256 targets only, so it's enough to increment + // the LSB of Target, as it will never overflow. + // + **Target += 1; + *Lun = 0; } else { return EFI_NOT_FOUND; } @@ -573,11 +585,17 @@ MptScsiGetNextTarget ( IN OUT UINT8 **Target ) { - // - // Currently support only target 0 LUN 0, so hardcode it - // + MPT_SCSI_DEV *Dev; + + Dev = MPT_SCSI_FROM_PASS_THRU (This); if (!IsTargetInitialized (*Target)) { ZeroMem (*Target, TARGET_MAX_BYTES); + } else if (**Target < Dev->MaxTarget) { + // + // This device support 256 targets only, so it's enough to increment + // the LSB of Target, as it will never overflow. + // + **Target += 1; } else { return EFI_NOT_FOUND; } @@ -595,6 +613,7 @@ MptScsiBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) { + MPT_SCSI_DEV *Dev; SCSI_DEVICE_PATH *ScsiDevicePath; if (DevicePath == NULL) { @@ -605,7 +624,8 @@ MptScsiBuildDevicePath ( // This device support 256 targets only, so it's enough to dereference // the LSB of Target. // - if (*Target > 0 || Lun > 0) { + Dev = MPT_SCSI_FROM_PASS_THRU (This); + if (*Target > Dev->MaxTarget || Lun > 0) { return EFI_NOT_FOUND; } @@ -635,6 +655,7 @@ MptScsiGetTargetLun ( OUT UINT64 *Lun ) { + MPT_SCSI_DEV *Dev; SCSI_DEVICE_PATH *ScsiDevicePath; if (DevicePath == NULL || @@ -647,8 +668,9 @@ MptScsiGetTargetLun ( return EFI_UNSUPPORTED; } + Dev = MPT_SCSI_FROM_PASS_THRU (This); ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath; - if (ScsiDevicePath->Pun > 0 || + if (ScsiDevicePath->Pun > Dev->MaxTarget || ScsiDevicePath->Lun > 0) { return EFI_NOT_FOUND; } diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf index ef1f6a5ebb3a..26aca7f95315 100644 --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf @@ -37,3 +37,4 @@ [Protocols] [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiStallPerPollUsec ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit ## CONSUMES diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 7fa1581f2101..7b56998abc9b 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -273,6 +273,10 @@ [PcdsFixedAtBuild] ## Microseconds to stall between polling for MptScsi request result gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiStallPerPollUsec|5|UINT32|0x39 + ## Set the *inclusive* number of targets that MptScsi exposes for scan + # by ScsiBusDxe. + gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit|7|UINT8|0x40 + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 -- 2.20.1