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.web12.11962.1594109803565168564 for ; Tue, 07 Jul 2020 01:16:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EjGVx3nE; 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=1594109802; 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=m5OW7k7t1f7kRqjUhCbLWVRCfmQzWNXSj2A43O4BXzc=; b=EjGVx3nEeXQ1aQ+9nqRu3694/YWlbFUwKpKFiDN6iqN5meZGE1/g2J9h0TBt2VXg+rRNXU h89L8Es+8HtjN7UtnRgTxQNMtZ8LR7gI8thSWmxiFgZfznS+DVNEv8ic2CWO0wS7sRKuYg gDjAi/AnD7axEuK4bFbH7/tb3KWXq/w= 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-476-3dHVnDQeNCGwvbICMuPo9A-1; Tue, 07 Jul 2020 04:16:41 -0400 X-MC-Unique: 3dHVnDQeNCGwvbICMuPo9A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D1DE1006B0A; Tue, 7 Jul 2020 08:16:36 +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 E95C027DE60; Tue, 7 Jul 2020 08:16:34 +0000 (UTC) Subject: Re: [PATCH 04/11] OvmfPkg/LsiScsiDxe: Probe PCI devices and look for LsiScsi From: "Laszlo Ersek" 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> <70bbf8ce-4f34-192e-8115-53d53864f773@redhat.com> Message-ID: <9fbaef5a-2c17-76a3-9bce-38f7cc467e96@redhat.com> Date: Tue, 7 Jul 2020 10:16:34 +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: <70bbf8ce-4f34-192e-8115-53d53864f773@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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/07/20 10:15, Laszlo Ersek wrote: > 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 > (I've checked PCI_VENDOR_ID_LSI_LOGIC in QEMU's "include/hw/pci/pci_ids.h" and "hw/scsi/lsi53c895a.c". Also checked PCI_DEVICE_ID_LSI_53C895A in the QEMU source.)