public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Nikita Leshenko <nikita.leshchenko@oracle.com>
Cc: devel@edk2.groups.io, liran.alon@oracle.com,
	aaron.young@oracle.com, Jordan Justen <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@arm.com>
Subject: Re: [edk2-devel] [PATCH v4 10/13] OvmfPkg/MptScsiDxe: Initialize hardware
Date: Mon, 20 Apr 2020 13:58:56 +0200	[thread overview]
Message-ID: <978d788b-c4c3-9402-eca4-44abe622fd00@redhat.com> (raw)
In-Reply-To: <DFF6CD19-C013-44B1-8B0E-DE1C1A891BBF@oracle.com>

On 04/16/20 18:00, Nikita Leshenko wrote:
> 
> 
>> On 16 Apr 2020, at 12:53, Laszlo Ersek <lersek@redhat.com> wrote:
>>
>> On 04/14/20 19:38, Nikita Leshenko wrote:

[...]

> I break out the inner structs into separate typedefs, wrap all of them in
> #pragma pack (1) / pack () and then create the wrapping aligning unions?

>> (7a) either send "Req.Data" (rather than "Req") to the device in this
>> function,

> I wasn't aware of this padding, so I will update the code to use suggestion (7a).

OK, thanks!

>> (11) Please repeat the statement from the commit message here -- as a
>> code comment -- that the reply is only read to complete the doorbell
>> function of the device, and that we intentionally ignore the contents.
>>
>> (BTW, if we do not parse the response even at the end of this series,
>> then saving the response into the "Reply" variable looks useless -- I
>> guess we could remove the "Reply" variable altogether, in that case. But
>> I'll have to see the rest of the patches.)

> We must read the reply fully to initialise the device (the device would reset the
> interrupt status only after the host has fetched the entire reply). We could discard
> the reply, but I thought it would be nicer to keep it on the stack temporary in
> case someone would like to use it in later changes or in debugging (since the
> reply is very small and should be hot in the cache, I don't this has any
> performance impact).

Makes sense. The comment will help. Thanks!

>> (12) So in general I would have suggested that, in case the
>> initialization fails and we take an early "return" branch in this
>> function, we should first jump to an error handling label, and reset the
>> device. (Because, when we return an error code from the function, we
>> shouldn't leave the device in half-initialized state.)
>>
>> *But*, it seems like the reset operation *itself* occurs through the
>> doorbell register and the MPT_REG_ISTATUS register -- and if any step in
>> MptScsiInit() fails, then it's exactly those registers that are
>> (apparently) in unknown / unreliable state. In other words, if
>> MptScsiInit() fails, then we *can't* (expect to) reset the device
>> (successfully).
>>
>> Can you please confirm my understanding? (Again, just a question, not a
>> code change request.)

> Your understanding it correct. In VirtualBox it looks like you can't write a
> reset command to the doorbell while a handshake is in progress. In any case, wonder
> what could realistically cause the initialization to fail. On EDK2 side, we're just
> talking about a bunch of "in/out" opcodes (the API for which could fail, but I would
> assume that if it fails then further "in/out"s will fail as well). On the hypervisor
> side, the QEMU and VirtualBox don't even have a failure path for the init call.
> So failure seems very theoretical here and I couldn't find anything realistically
> helpful to do if the initialization fails in the middle.

Thank you for explaining. I'm proceeding with the v4 review.

Laszlo


  reply	other threads:[~2020-04-20 11:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 17:38 [PATCH v4 00/13] OvmfPkg: Support booting from Fusion-MPT SCSI controllers Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 01/13] OvmfPkg/MptScsiDxe: Create empty driver Nikita Leshenko
2020-04-15  6:31   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 02/13] OvmfPkg/MptScsiDxe: Install DriverBinding Protocol Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 03/13] OvmfPkg/MptScsiDxe: Report name of driver Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 05/13] OvmfPkg/MptScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Nikita Leshenko
2020-04-15  6:54   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 06/13] OvmfPkg/MptScsiDxe: Report one Target and one LUN Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 07/13] OvmfPkg/MptScsiDxe: Build and decode DevicePath Nikita Leshenko
2020-04-15 12:03   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 08/13] OvmfPkg/MptScsiDxe: Open PciIo protocol for later use Nikita Leshenko
2020-04-16  8:05   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 09/13] OvmfPkg/MptScsiDxe: Set and restore PCI attributes Nikita Leshenko
2020-04-16  8:11   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 10/13] OvmfPkg/MptScsiDxe: Initialize hardware Nikita Leshenko
2020-04-16  9:53   ` [edk2-devel] " Laszlo Ersek
2020-04-16 16:00     ` Nikita Leshenko
2020-04-20 11:58       ` Laszlo Ersek [this message]
2020-04-20 14:10   ` Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 11/13] OvmfPkg/MptScsiDxe: Implement the PassThru method Nikita Leshenko
2020-04-20 17:30   ` [edk2-devel] " Laszlo Ersek
2020-04-24 17:03     ` Nikita Leshenko
2020-04-14 17:38 ` [PATCH v4 12/13] OvmfPkg/MptScsiDxe: Report multiple targets Nikita Leshenko
2020-04-20 18:31   ` [edk2-devel] " Laszlo Ersek
2020-04-14 17:38 ` [PATCH v4 13/13] OvmfPkg/MptScsiDxe: Reset device on ExitBootServices() Nikita Leshenko
2020-04-20 19:02   ` [edk2-devel] " Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=978d788b-c4c3-9402-eca4-44abe622fd00@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox