Re: [Qemu-devel] [PATCH] memory: update coalesced_range on transaction_commit

2018-11-28 Thread Atsushi Nemoto
On Wed, 28 Nov 2018 17:30:59 +0100, Paolo Bonzini  wrote:
>> The e1000 driver calls memory_region_add_coalescing but
>> kvm_coalesce_mmio_region never been called for those regions.
>> 
>> Update coalesced_range on memory_region_transaction_commit to fix this.
>> 
>> It seems very old bug since memory region API
>> was merged on commit 093bc2cd885e ("Hierarchical memory region API").
>> 
>> Signed-off-by: Atsushi Nemoto 
> 
> I attach the patch I came up with.  What do you think?

Thank you for the alternative fix.
It works well and looks good to me.

---
Atsushi Nemoto





[Qemu-devel] [PATCH] memory: update coalesced_range on transaction_commit

2018-11-28 Thread Atsushi Nemoto
The e1000 driver calls memory_region_add_coalescing but
kvm_coalesce_mmio_region never been called for those regions.

Update coalesced_range on memory_region_transaction_commit to fix this.

It seems very old bug since memory region API
was merged on commit 093bc2cd885e ("Hierarchical memory region API").

Signed-off-by: Atsushi Nemoto 
---
 memory.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/memory.c b/memory.c
index d14c6dec1d..f773b0be50 100644
--- a/memory.c
+++ b/memory.c
@@ -1021,6 +1021,8 @@ void memory_region_transaction_begin(void)
 ++memory_region_transaction_depth;
 }
 
+static void memory_region_update_coalesced_range_as(MemoryRegion *mr, 
AddressSpace *as);
+
 void memory_region_transaction_commit(void)
 {
 AddressSpace *as;
@@ -1038,6 +1040,7 @@ void memory_region_transaction_commit(void)
 QTAILQ_FOREACH(as, _spaces, address_spaces_link) {
 address_space_set_flatview(as);
 address_space_update_ioeventfds(as);
+memory_region_update_coalesced_range_as(NULL, as);
 }
 memory_region_update_pending = false;
 ioeventfd_update_pending = false;
@@ -2142,7 +2145,7 @@ static void 
memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
 
 view = address_space_get_flatview(as);
 FOR_EACH_FLAT_RANGE(fr, view) {
-if (fr->mr == mr) {
+if (fr->mr == mr || (!mr && !QTAILQ_EMPTY(>mr->coalesced))) {
 section = (MemoryRegionSection) {
 .fv = view,
 .offset_within_address_space = int128_get64(fr->addr.start),
@@ -2152,7 +2155,7 @@ static void 
memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
 MEMORY_LISTENER_CALL(as, coalesced_io_del, Reverse, ,
  int128_get64(fr->addr.start),
  int128_get64(fr->addr.size));
-QTAILQ_FOREACH(cmr, >coalesced, link) {
+QTAILQ_FOREACH(cmr, >mr->coalesced, link) {
 tmp = addrrange_shift(cmr->addr,
   int128_sub(fr->addr.start,
  
int128_make64(fr->offset_in_region)));
-- 
2.11.0






Re: [Qemu-devel] [PATCH] lan9118: Ignore write to MAC_VLAN1 register

2011-04-05 Thread Atsushi Nemoto
On Mon, 4 Apr 2011 20:15:30 +0200, Aurelien Jarno aurel...@aurel32.net wrote:
 Is it really safe ignoring write to this register? If yes, it's probably
 a good idea to explain why in a comment. In any case, if supporting this
 register is easy to do, it would be the best option.

I think it is safe.  Please see an updated comment below.

And though implementing this register might be possible, I suppose it
is not worth to supporting FrameTooLong detection, for now at least.

Thank you for comments.

8-
From: Atsushi Nemoto an...@mba.ocn.ne.jp
Date: Tue, 5 Apr 2011 23:12:07 +0900
Subject: [PATCH] lan9118: Ignore write to MAC_VLAN1 register

Since linux 2.6.38, smsc911x driver writes to VLAN1 registger.
Since this register only affects FrameTooLong detection, ignoring
write to this register should be safe.

Signed-off-by: Atsushi Nemoto an...@mba.ocn.ne.jp
---
 hw/lan9118.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/lan9118.c b/hw/lan9118.c
index af6949f..2dc8d18 100644
--- a/hw/lan9118.c
+++ b/hw/lan9118.c
@@ -785,6 +785,12 @@ static void do_mac_write(lan9118_state *s, int reg, 
uint32_t val)
 case MAC_FLOW:
 s-mac_flow = val  0x;
 break;
+case MAC_VLAN1:
+/* Writing to this register changes a condition for
+ * FrameTooLong bit in rx_status.  Since we do not set
+ * FrameTooLong anyway, just ignore write to this.
+ */
+break;
 default:
 hw_error(lan9118: Unimplemented MAC register write: %d = 0x%x\n,
  s-mac_cmd  0xf, val);
-- 
1.5.6.5




[Qemu-devel] [PATCH] lan9118: Ignore write to MAC_VLAN1 register

2011-03-29 Thread Atsushi Nemoto
Since kernel 2.6.38, smsc911x driver writes to VLAN1 registger.

Signed-off-by: Atsushi Nemoto an...@mba.ocn.ne.jp
---
 hw/lan9118.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/lan9118.c b/hw/lan9118.c
index af6949f..62aead3 100644
--- a/hw/lan9118.c
+++ b/hw/lan9118.c
@@ -785,6 +785,8 @@ static void do_mac_write(lan9118_state *s, int reg, 
uint32_t val)
 case MAC_FLOW:
 s-mac_flow = val  0x;
 break;
+case MAC_VLAN1:
+break; /* just ignore */
 default:
 hw_error(lan9118: Unimplemented MAC register write: %d = 0x%x\n,
  s-mac_cmd  0xf, val);
-- 
1.5.6.5