Re: [PATCH 2/3] dm: completely remove enable_bar()/disable_bar() functions


Peter Fang
 

-----Original Message-----
From: Liu, Shuo A
Sent: Saturday, April 20, 2019 7:53 PM
To: Fang, Peter <peter.fang@...>
Cc: acrn-dev@...
Subject: Re: [acrn-dev] [PATCH 2/3] dm: completely remove
enable_bar()/disable_bar() functions

On Wed 17.Apr'19 at 0:13:44 -0700, Peter Fang wrote:
Following up on d648df766c263512c93356a55ff97cb3e23fe3e4, surgically
remove all the functions related to enable_bar()/disable_bar() that got
introduced in 8787b65fdee622639925ad75fe920913e0e7f102.

Tracked-On: #2902
Signed-off-by: Peter Fang <peter.fang@...>
Minor comment inline.

Reviewed-by: Shuo A Liu <shuo.a.liu@...>

---
devicemodel/core/inout.c | 44 -------------------
devicemodel/core/mem.c | 88 ++++---------------------------------
devicemodel/include/inout.h | 2 -
devicemodel/include/mem.h | 5 +--
4 files changed, 9 insertions(+), 130 deletions(-)

diff --git a/devicemodel/core/inout.c b/devicemodel/core/inout.c index
daa8add9..a16f3db5 100644
--- a/devicemodel/core/inout.c
+++ b/devicemodel/core/inout.c
@@ -26,7 +26,6 @@
* $FreeBSD$
*/

-#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
@@ -45,7 +44,6 @@ static struct {
int flags;
inout_func_t handler;
void *arg;
- bool enabled;
} inout_handlers[MAX_IOPORTS];

static int
@@ -115,11 +113,6 @@ emulate_inout(struct vmctx *ctx, int *pvcpu,
struct pio_request *pio_request)
if (!(flags & IOPORT_F_OUT))
return -1;
}
-
- if (inout_handlers[port].enabled == false) {
- return -1;
- }
-
retval = handler(ctx, *pvcpu, in, port, bytes,
(uint32_t *)&(pio_request->value), arg);
return retval;
@@ -148,42 +141,6 @@ init_inout(void)
}
}

-int
-disable_inout(struct inout_port *iop)
-{
- int i;
-
- if (!VERIFY_IOPORT(iop->port, iop->size)) {
- printf("invalid input: port:0x%x, size:%d",
- iop->port, iop->size);
- return -1;
- }
-
- for (i = iop->port; i < iop->port + iop->size; i++) {
- inout_handlers[i].enabled = false;
- }
-
- return 0;
-}
-
-int
-enable_inout(struct inout_port *iop)
-{
- int i;
-
- if (!VERIFY_IOPORT(iop->port, iop->size)) {
- printf("invalid input: port:0x%x, size:%d",
- iop->port, iop->size);
- return -1;
- }
-
- for (i = iop->port; i < iop->port + iop->size; i++) {
- inout_handlers[i].enabled = true;
- }
-
- return 0;
-}
-
int
register_inout(struct inout_port *iop) { @@ -211,7 +168,6 @@
register_inout(struct inout_port *iop)
inout_handlers[i].flags = iop->flags;
inout_handlers[i].handler = iop->handler;
inout_handlers[i].arg = iop->arg;
- inout_handlers[i].enabled = true;
}

return 0;
diff --git a/devicemodel/core/mem.c b/devicemodel/core/mem.c index
4994eb22..fffaeda9 100644
--- a/devicemodel/core/mem.c
+++ b/devicemodel/core/mem.c
@@ -33,7 +33,6 @@
*/

#include <errno.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -51,7 +50,6 @@ struct mmio_rb_range {
struct mem_range mr_param;
uint64_t mr_base;
uint64_t mr_end;
- bool enabled;
};

static RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root,
mmio_rb_fallback; @@ -168,25 +166,18 @@ emulate_mem(struct vmctx
*ctx, struct mmio_request *mmio_req)
if (mmio_hint && paddr >= mmio_hint->mr_base &&
paddr <= mmio_hint->mr_end)
entry = mmio_hint;
-
- if (entry == NULL) {
- if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
- /* Update the per-VMU cache */
- mmio_hint = entry;
- else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry))
{
- pthread_rwlock_unlock(&mmio_rwlock);
- return -ESRCH;
- }
- }
-
- assert(entry != NULL);
-
- if (entry->enabled == false) {
+ else if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
+ /* Update the per-VMU cache */
per-VM?
Thanks for catching that. It'll be fixed in the PR. :-)


+ mmio_hint = entry;
+ else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
pthread_rwlock_unlock(&mmio_rwlock);
- return -1;
+ return -ESRCH;
}
+
pthread_rwlock_unlock(&mmio_rwlock);

+ assert(entry != NULL);
+
if (mmio_req->direction == REQUEST_READ)
err = mem_read(ctx, 0, paddr, (uint64_t *)&mmio_req-
value,
size, &entry->mr_param);

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.