qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: FelixCuioc <FelixCui-oc@zhaoxin.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	 Eduardo Habkost <ehabkost@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>
Cc: RaymondPang-oc@zhaoxin.com, qemu-devel@nongnu.org,
	CobeChen-oc@zhaoxin.com
Subject: [PATCH 1/1] Remove flatview_simplify()
Date: Mon, 29 Mar 2021 20:14:08 +0800	[thread overview]
Message-ID: <20210329121408.17862-2-FelixCui-oc@zhaoxin.com> (raw)
In-Reply-To: <20210329121408.17862-1-FelixCui-oc@zhaoxin.com>

Flatview_simplify() can merge many small memory ranges
into a large one and contains EHCI dma buffers.
For example,the merged range maybe0xc0000-0xbfffffff.
When seabios write PAM register to change the properties
of part of the merged range from RW to readonly,
this action cause the merged IOVA mapping will be
unmapped.But EHCI device still send DMA cycles
and then IOMMU blocks the DMA cycles of EHCI device.

Because the merged range is too large,there will be
problems even if EHCI device is configured to not
allocate buffers in low memory.
So this patch wants to remove flatview_simplify() completely.

Signed-off-by: FelixCuioc <FelixCui-oc@zhaoxin.com>
---
 softmmu/memory.c | 37 -------------------------------------
 1 file changed, 37 deletions(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index d4493ef9e4..aaace8c03f 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -314,42 +314,6 @@ void flatview_unref(FlatView *view)
     }
 }
 
-static bool can_merge(FlatRange *r1, FlatRange *r2)
-{
-    return int128_eq(addrrange_end(r1->addr), r2->addr.start)
-        && r1->mr == r2->mr
-        && int128_eq(int128_add(int128_make64(r1->offset_in_region),
-                                r1->addr.size),
-                     int128_make64(r2->offset_in_region))
-        && r1->dirty_log_mask == r2->dirty_log_mask
-        && r1->romd_mode == r2->romd_mode
-        && r1->readonly == r2->readonly
-        && r1->nonvolatile == r2->nonvolatile;
-}
-
-/* Attempt to simplify a view by merging adjacent ranges */
-static void flatview_simplify(FlatView *view)
-{
-    unsigned i, j, k;
-
-    i = 0;
-    while (i < view->nr) {
-        j = i + 1;
-        while (j < view->nr
-               && can_merge(&view->ranges[j-1], &view->ranges[j])) {
-            int128_addto(&view->ranges[i].addr.size, view->ranges[j].addr.size);
-            ++j;
-        }
-        ++i;
-        for (k = i; k < j; k++) {
-            memory_region_unref(view->ranges[k].mr);
-        }
-        memmove(&view->ranges[i], &view->ranges[j],
-                (view->nr - j) * sizeof(view->ranges[j]));
-        view->nr -= j - i;
-    }
-}
-
 static bool memory_region_big_endian(MemoryRegion *mr)
 {
 #ifdef TARGET_WORDS_BIGENDIAN
@@ -735,7 +699,6 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
                              addrrange_make(int128_zero(), int128_2_64()),
                              false, false);
     }
-    flatview_simplify(view);
 
     view->dispatch = address_space_dispatch_new(view);
     for (i = 0; i < view->nr; i++) {
-- 
2.17.1



  reply	other threads:[~2021-03-29 12:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:14 [PATCH 0/1] Remove flatview_simplify() FelixCuioc
2021-03-29 12:14 ` FelixCuioc [this message]
2021-03-30 16:33   ` [PATCH 1/1] " Richard Henderson
2021-03-30 16:35     ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2020-12-06  8:21 [PATCH 0/1] " FelixCuioc
2020-12-06  8:21 ` [PATCH 1/1] " FelixCuioc
2020-12-06 10:10   ` Paolo Bonzini

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=20210329121408.17862-2-FelixCui-oc@zhaoxin.com \
    --to=felixcui-oc@zhaoxin.com \
    --cc=CobeChen-oc@zhaoxin.com \
    --cc=RaymondPang-oc@zhaoxin.com \
    --cc=alex.williamson@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).