kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
To: 孙世龙 sunshilong <sunshilong369@gmail.com>
Cc: Kernelnewbies@kernelnewbies.org
Subject: Re: Why does “page allocation failure” occur whereas there are still “58*4096kB (C)” could be used?
Date: Sat, 20 Jun 2020 05:51:43 -0400	[thread overview]
Message-ID: <547715.1592646703@turing-police> (raw)
In-Reply-To: <CAAvDm6YgHBmbzBPO=-Vhf5m-85wL-vrHWya=nx6LQH8dAOQxxQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2001 bytes --]

> How can I know whether scatter/gather is available or not?
> In another word, when it's available and when it's not?
> I do not intend to ask the behavior of gadget driver.
> I just wonder how I can confirm it in general.

The following applies for device features in general, not just scatter/gather.

Sometimes you get lucky, and the bus standard in use (PCI, USB, SPI/I2C, etc)
mandates that the feature is supported in a standard way.

So if you're writing a device driver for a specific card that uses a Wombat
9348j chipset, you'll probably need to get in touch with the company that makes
the Wombat 9348j chipset and get the data sheet for it, and that will hopefully
have the chipset programming details needed.

If you're unlucky, the company won't give you the datasheet, or it won't
contain the info, so you get to reverse engineer the chipset. One popular
technique is to look at *other* chips in the Wombat 93 series, determine via
some means whether those chipsets support scatter-gather, and how it's enabled.

Then you put the same code in your driver, and see what happens.

Possibility 1: Scatter-gather works just fine and the 16K I/O ends up in the 4
pages you allocated. Success!

Possibility 2: It doesn't work,and the 16K of I/O hits your first 4K page, and
the next 3 sequential pages even though they're something else, and your kernel
crashes and burns because you just overlaid 12K worth of page tables or struct
tasks or something important.

Possibility 3: It doesn't work, but it takes you a while to find out because
during your tests, the 4 pages happened to be allocated next to each other.
It has happened that nobody notices until the driver is part of the mainline
kernel, which is usually embarrassing...

Possibility 4: It doesn't work, and the bit that says "use scatter/gather" in
the IO command structure on the other chipsets actually enables the
undocumented auto-defenestration capability of the chipset. This is usually
worse than just embarrassing...


[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

      reply	other threads:[~2020-06-20  9:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18  6:21 Why does “page allocation failure” occur whereas there are still “58*4096kB (C)” could be used? 孙世龙
2020-06-19  4:48 ` Valdis Klētnieks
2020-06-19  6:56   ` 孙世龙 sunshilong
2020-06-19  7:14     ` Valdis Klētnieks
2020-06-20  5:53       ` 孙世龙 sunshilong
2020-06-20  9:51         ` Valdis Klētnieks [this message]

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-all 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=547715.1592646703@turing-police \
    --to=valdis.kletnieks@vt.edu \
    --cc=Kernelnewbies@kernelnewbies.org \
    --cc=sunshilong369@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).