qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 07/10] qtest/ide-test: Test short and long PRDTs
Date: Wed,  8 May 2013 16:29:01 +0200	[thread overview]
Message-ID: <1368023344-29731-8-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1368023344-29731-1-git-send-email-kwolf@redhat.com>

This tests the behaviour of the DMA engine when the given PRDT contains
physical region descriptors for either more or less bytes than the
IDE request is for.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/ide-test.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index 5fc496f..bdc1da7 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -77,6 +77,8 @@ enum {
     CMD_READ_DMA    = 0xc8,
     CMD_WRITE_DMA   = 0xca,
     CMD_IDENTIFY    = 0xec,
+
+    CMDF_ABORT      = 0x100,
 };
 
 enum {
@@ -170,9 +172,13 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
     size_t len;
     bool from_dev;
     uint8_t status;
+    int flags;
 
     dev = get_pci_device(&bmdma_base);
 
+    flags = cmd & ~0xff;
+    cmd &= 0xff;
+
     switch (cmd) {
     case CMD_READ_DMA:
         from_dev = true;
@@ -209,6 +215,10 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
     /* Start DMA transfer */
     outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
 
+    if (flags & CMDF_ABORT) {
+        outb(bmdma_base + bmreg_cmd, 0);
+    }
+
     /* Wait for the DMA transfer to complete */
     do {
         status = inb(bmdma_base + bmreg_status);
@@ -289,6 +299,48 @@ static void test_bmdma_simple_rw(void)
     g_free(cmpbuf);
 }
 
+static void test_bmdma_short_prdt(void)
+{
+    uint8_t status;
+
+    PrdtEntry prdt[] = {
+        { .addr = 0, .size = 0x10 | PRDT_EOT },
+    };
+
+    /* Normal request */
+    status = send_dma_request(CMD_READ_DMA, 0, 1,
+                              prdt, ARRAY_SIZE(prdt));
+    g_assert_cmphex(status, ==, 0);
+    assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+
+    /* Abort the request before it completes */
+    status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1,
+                              prdt, ARRAY_SIZE(prdt));
+    g_assert_cmphex(status, ==, 0);
+    assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+}
+
+static void test_bmdma_long_prdt(void)
+{
+    uint8_t status;
+
+    PrdtEntry prdt[] = {
+        { .addr = 0, .size = 0x1000 | PRDT_EOT },
+    };
+
+    /* Normal request */
+    status = send_dma_request(CMD_READ_DMA, 0, 1,
+                              prdt, ARRAY_SIZE(prdt));
+    g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR);
+    assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+
+    /* Abort the request before it completes */
+    status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1,
+                              prdt, ARRAY_SIZE(prdt));
+    g_assert_cmphex(status, ==, BM_STS_INTR);
+    assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+}
+
 static void test_bmdma_setup(void)
 {
     ide_test_start(
@@ -375,6 +427,8 @@ int main(int argc, char **argv)
 
     qtest_add_func("/ide/bmdma/setup", test_bmdma_setup);
     qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw);
+    qtest_add_func("/ide/bmdma/short_prdt", test_bmdma_short_prdt);
+    qtest_add_func("/ide/bmdma/long_prdt", test_bmdma_long_prdt);
     qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown);
 
     ret = g_test_run();
-- 
1.8.1.4

  parent reply	other threads:[~2013-05-08 14:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-08 14:28 [Qemu-devel] [PULL 1.5 00/10] Block patches for 1.5.0-rc1 Kevin Wolf
2013-05-08 14:28 ` [Qemu-devel] [PATCH 01/10] ahci: Don't allow creating slave drives Kevin Wolf
2013-05-08 14:28 ` [Qemu-devel] [PATCH 02/10] de_DE.po: Add missing leading spaces Kevin Wolf
2013-05-08 14:28 ` [Qemu-devel] [PATCH 03/10] ide: Reset BMIDEA bit when the bus master is stopped Kevin Wolf
2013-05-08 14:28 ` [Qemu-devel] [PATCH 04/10] libqos/pci: Enable bus mastering Kevin Wolf
2013-05-08 14:28 ` [Qemu-devel] [PATCH 05/10] qtest: Add IDE test case Kevin Wolf
2013-05-08 14:29 ` [Qemu-devel] [PATCH 06/10] qtest/ide-test: Add simple DMA read/write " Kevin Wolf
2013-05-08 14:29 ` Kevin Wolf [this message]
2013-05-08 14:29 ` [Qemu-devel] [PATCH 08/10] qemu-iotests: exclude vmdk for test 042 Kevin Wolf
2013-05-08 14:29 ` [Qemu-devel] [PATCH 09/10] qemu-iotests: exclude vmdk and qcow from 043 Kevin Wolf
2013-05-08 14:29 ` [Qemu-devel] [PATCH 10/10] qemu-iotests: fix 017 018 for vmdk Kevin Wolf

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=1368023344-29731-8-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /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).