From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.12098.1594109727969764273 for ; Tue, 07 Jul 2020 01:15:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EaK3Ri60; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594109727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1HXIlkPGYvfRl21vcbjtESYO2B8ujgllscquYyUl57o=; b=EaK3Ri605NAbh3T3KZNmNdutCgDqO32IP3btTNPk7mHiZcPYeO8WxQQswZCIZ1EF6SFH3w OJjd0gq9jdfhHc3/dvTZ7i6otmFftZOtMDZuxl5UOBnwHvPuX8v2R0ovf+mA7TgEGwjLL1 Vmcf9cxJNiTJEPjxupZ4+EASGHz/ecM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-k4xHGMeqO8eGS3wInpa3rQ-1; Tue, 07 Jul 2020 04:15:24 -0400 X-MC-Unique: k4xHGMeqO8eGS3wInpa3rQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF457100A8EC; Tue, 7 Jul 2020 08:15:22 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-90.ams2.redhat.com [10.36.114.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96B755C1B2; Tue, 7 Jul 2020 08:15:21 +0000 (UTC) Subject: Re: [PATCH 04/11] OvmfPkg/LsiScsiDxe: Probe PCI devices and look for LsiScsi To: Gary Lin , devel@edk2.groups.io Cc: Jordan Justen , Ard Biesheuvel References: <20200701040448.14871-1-glin@suse.com> <20200701040448.14871-5-glin@suse.com> From: "Laszlo Ersek" Message-ID: <70bbf8ce-4f34-192e-8115-53d53864f773@redhat.com> Date: Tue, 7 Jul 2020 10:15:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200701040448.14871-5-glin@suse.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 07/01/20 06:04, Gary Lin wrote: > Implement LsiScsiControllerSupported() to probe the PCI ID and look for > LSI 53C895A. > > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Signed-off-by: Gary Lin > --- > OvmfPkg/Include/IndustryStandard/LsiScsi.h | 20 +++++++++ > OvmfPkg/LsiScsiDxe/LsiScsi.c | 48 +++++++++++++++++++++- > OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf | 6 +++ > 3 files changed, 73 insertions(+), 1 deletion(-) > create mode 100644 OvmfPkg/Include/IndustryStandard/LsiScsi.h > > diff --git a/OvmfPkg/Include/IndustryStandard/LsiScsi.h b/OvmfPkg/Include/IndustryStandard/LsiScsi.h > new file mode 100644 > index 000000000000..c09e864a1f39 > --- /dev/null > +++ b/OvmfPkg/Include/IndustryStandard/LsiScsi.h > @@ -0,0 +1,20 @@ > +/** @file > + > + Macros and type definitions for LSI 53C895A SCSI devices. > + > + Copyright (C) 2020, SUSE LLC. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef _LSI_SCSI_H_ > +#define _LSI_SCSI_H_ > + > +// > +// Device ID > +// > +#define LSI_LOGIC_PCI_VENDOR_ID 0x1000 > +#define LSI_53C895A_PCI_DEVICE_ID 0x0012 > + > +#endif // _LSI_SCSI_H_ > diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.c b/OvmfPkg/LsiScsiDxe/LsiScsi.c > index 62daa3ab99bf..5bca85bd75eb 100644 > --- a/OvmfPkg/LsiScsiDxe/LsiScsi.c > +++ b/OvmfPkg/LsiScsiDxe/LsiScsi.c > @@ -9,7 +9,12 @@ > > **/ > > +#include > +#include > +#include > #include > +#include > +#include > #include > > #include "LsiScsi.h" > @@ -31,7 +36,48 @@ LsiScsiControllerSupported ( > IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL > ) > { > - return EFI_UNSUPPORTED; > + EFI_STATUS Status; > + EFI_PCI_IO_PROTOCOL *PciIo; > + PCI_TYPE00 Pci; > + > + Status = gBS->OpenProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + (VOID **)&PciIo, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status = PciIo->Pci.Read ( > + PciIo, > + EfiPciIoWidthUint32, > + 0, > + sizeof (Pci) / sizeof (UINT32), > + &Pci > + ); > + if (EFI_ERROR (Status)) { > + goto Done; > + } > + > + if (Pci.Hdr.VendorId == LSI_LOGIC_PCI_VENDOR_ID && > + Pci.Hdr.DeviceId == LSI_53C895A_PCI_DEVICE_ID) { > + Status = EFI_SUCCESS; > + } else { > + Status = EFI_UNSUPPORTED; > + } > + > +Done: > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); > + return Status; > } > > EFI_STATUS > diff --git a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf b/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > index 444ceb78e9ca..e86c626a61aa 100644 > --- a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > +++ b/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > @@ -22,7 +22,13 @@ [Sources] > > [Packages] > MdePkg/MdePkg.dec > + OvmfPkg/OvmfPkg.dec > > [LibraryClasses] > + BaseLib > + UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > + > +[Protocols] > + gEfiPciIoProtocolGuid ## TO_START > Reviewed-by: Laszlo Ersek