public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tomas Pilar (tpilar)" <tpilar@solarflare.com>
To: Laszlo Ersek <lersek@redhat.com>,
	"edk2-devel@lists.01.org" <edk2-devel@ml01.01.org>
Subject: Re: SNP_INIT while in TPL_NOTIFY
Date: Mon, 30 Jan 2017 10:51:03 +0000	[thread overview]
Message-ID: <a069541c-1439-07b2-1244-1dbd88791590@solarflare.com> (raw)
In-Reply-To: <cf34540c-4585-bf35-fea4-0cf1b5d89781@redhat.com>

Thanks Laszlo,

I am glad I wasn't going insane there. I'll turn it into a simple busy poll.

Cheers,
Tom


On 27/01/17 18:12, Laszlo Ersek wrote:
> On 01/27/17 17:51, Tomas Pilar (tpilar) wrote:
>> Hi,
>>
>> I am currently maintaining our network driver written using the EDKII
>> framework. Our network device implements a MCDI (mc-driver interface)
>> which is (in theory) asynchronous (DMA doorbell-messagebox
>> communication), although the majority of the calls take less than a
>> jiffy. So for example, the setting up of TX and RX queues on the NIC
>> requires some MCDI calls which the driver then has to wait for. I've
>> implemented this using the gSB->SetTimer event system.
>>
>> My problem is that the SimpleNetworkInitialize() method is called by the
>> UEFI platform network core (network core finds a new NIC with SNP ->
>> tries to open -> not initialised, so it tries to INIT) using a
>> TPL_NOTIFY context,
> This looks like a bug, in the code that calls SimpleNetworkInitialize().
> According to "Table 24. TPL Restrictions", for Simple Network Protocol
> methods, the TPL must be <= TPL_CALLBACK. Meaning, an SNP implementation
> mustn't raise the TPL above TPL_CALLBACK, but also that any client can't
> call SNP methods while executing on a TPL > TPL_CALLBACK.
>
> Worse, even staying at TPL_CALLBACK wouldn't be good enough for calling
> gBS->SetTimer(). SetTimer is < TPL_HIGH_LEVEL, so that'd be fine, but
> gBS->WaitForEvent() is strictly = TPL_APPLICATION. So WaitForEvent()
> can't be called when running on TPL_CALLBACK level.
>
>> where the code is not allowed to sleep (I assume
>> that this is the MNP generic one second network poll timer). I could in
>> theory initialise the NIC earlier, during probe, but the SNP allows for
>> specification of extra buffer space for TX and RX during init. The
>> network core might conceivable use that. Or the MNP might want to change
>> station address using SNP or call for a reset which again requires
>> asynchronous NIC operation.
>>
>> Has anyone encountered something similar? Is there a canonical solution
>> to this issue?
> I think you can poll the NIC in a busy loop, or if that's excessive, use
> gBS->Stall() between polls. Stall() is <= TPL_HIGH_LEVEL, so it should
> be safe. OTOH, "Execution of the processor is not yielded for the
> duration of the stall".
>
> Thanks
> Laszlo
>
>> Cheers,
>> Tomas Pilar
>>
>>
>> The information contained in this message is confidential and is
>> intended for the addressee(s) only. If you have received this message in
>> error, please notify the sender immediately and delete the message.
>> Unless you are an addressee (or authorized to receive for an addressee),
>> you may not use, copy or disclose to anyone this message or any
>> information contained in this message. The unauthorized use, disclosure,
>> copying or alteration of this message is strictly prohibited.
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel

The information contained in this message is confidential and is intended for the addressee(s) only. If you have received this message in error, please notify the sender immediately and delete the message. Unless you are an addressee (or authorized to receive for an addressee), you may not use, copy or disclose to anyone this message or any information contained in this message. The unauthorized use, disclosure, copying or alteration of this message is strictly prohibited.


  reply	other threads:[~2017-01-30 16:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 16:51 SNP_INIT while in TPL_NOTIFY Tomas Pilar (tpilar)
2017-01-27 18:12 ` Laszlo Ersek
2017-01-30 10:51   ` Tomas Pilar (tpilar) [this message]
2017-01-30 17:51   ` Andrew Fish
2017-02-06  6:10   ` Ye, Ting
2017-02-06 14:58     ` Tomas Pilar (tpilar)
2017-02-07  3:31       ` Ye, Ting

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=a069541c-1439-07b2-1244-1dbd88791590@solarflare.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