Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm align with u...
details: https://anonhg.NetBSD.org/src/rev/d4a75692fa13
branches: trunk
changeset: 1006661:d4a75692fa13
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Wed Jan 22 19:15:49 2020 +0000
description:
align with upstream for 64bit compatibility.
diffstat:
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c | 21 +-
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c | 44 +-
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c | 323 +++++----
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h | 43 +-
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c | 8 +-
sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c | 15 +-
6 files changed, 245 insertions(+), 209 deletions(-)
diffs (truncated from 1196 to 300 lines):
diff -r 3711097ea2fc -r d4a75692fa13 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
--- a/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c Wed Jan 22 17:55:41 2020 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c Wed Jan 22 19:15:49 2020 +0000
@@ -57,6 +57,9 @@
#include "vchiq_netbsd.h"
#include "vchiq_connected.h"
+#define VCPAGE_OFFSET 0x0fff
+#define VCPAGE_SHIFT 12
+
#define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2)
typedef struct vchiq_2835_state_struct {
@@ -146,7 +149,7 @@
vchiq_log_info(vchiq_arm_log_level,
"%s: slot_phys = %lx\n", __func__, slot_phys);
- WARN_ON(((int)slot_mem & (PAGE_SIZE - 1)) != 0);
+ WARN_ON(((uintptr_t)slot_mem & (PAGE_SIZE - 1)) != 0);
vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size);
if (!vchiq_slot_zero) {
@@ -187,12 +190,12 @@
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
vchiq_log_info(vchiq_arm_log_level,
- "vchiq_init - done (slots %x, phys %x)",
- (unsigned int)vchiq_slot_zero, (unsigned int)slot_phys);
+ "vchiq_init - done (slots %p, phys %x)",
+ vchiq_slot_zero, (unsigned int)slot_phys);
vchiq_call_connected_callbacks();
- return 0;
+ return 0;
failed_vchiq_init:
failed_init_slots:
@@ -355,7 +358,7 @@
pagelist->type = (dir == VCHIQ_BULK_RECEIVE) ?
PAGELIST_READ : PAGELIST_WRITE;
pagelist->length = size;
- pagelist->offset = va & L2_S_OFFSET;
+ pagelist->offset = va & VCPAGE_OFFSET;
/*
* busdma already coalesces contiguous pages for us
@@ -363,10 +366,10 @@
for (int i = 0; i < bi->dmamap->dm_nsegs; i++) {
bus_addr_t addr = bi->dmamap->dm_segs[i].ds_addr;
bus_size_t len = bi->dmamap->dm_segs[i].ds_len;
- bus_size_t off = addr & L2_S_OFFSET;
- int npgs = ((off + len + L2_S_OFFSET) >> L2_S_SHIFT);
+ bus_size_t off = addr & VCPAGE_OFFSET;
+ int npgs = ((off + len + VCPAGE_OFFSET) >> VCPAGE_SHIFT);
- pagelist->addrs[i] = addr & ~L2_S_OFFSET;
+ pagelist->addrs[i] = addr & ~VCPAGE_OFFSET;
pagelist->addrs[i] |= npgs - 1;
}
@@ -443,7 +446,7 @@
PAGELIST_T *pagelist = bi->pagelist;
vchiq_log_trace(vchiq_arm_log_level,
- "free_pagelist - %x, %d", (unsigned int)pagelist, actual);
+ "free_pagelist - %p, %d", pagelist, actual);
bus_dmamap_sync(dma_tag, bi->pagelist_map, 0,
bi->pagelist_size, BUS_DMASYNC_POSTWRITE);
diff -r 3711097ea2fc -r d4a75692fa13 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
--- a/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c Wed Jan 22 17:55:41 2020 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c Wed Jan 22 19:15:49 2020 +0000
@@ -461,8 +461,8 @@
#define _IOC_TYPE(x) IOCGROUP(x)
vchiq_log_trace(vchiq_arm_log_level,
- "vchiq_ioctl - instance %x, cmd %s, arg %p",
- (unsigned int)instance,
+ "vchiq_ioctl - instance %p, cmd %s, arg %p",
+ instance,
((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg);
@@ -755,8 +755,8 @@
break;
}
vchiq_log_info(vchiq_arm_log_level,
- "found bulk_waiter %x for pid %d",
- (unsigned int)waiter, current->l_proc->p_pid);
+ "found bulk_waiter %p for pid %d",
+ waiter, current->l_proc->p_pid);
args.userdata = &waiter->bulk_waiter;
}
status = vchiq_bulk_transfer
@@ -786,8 +786,8 @@
list_add(&waiter->list, &instance->bulk_waiter_list);
lmutex_unlock(&instance->bulk_waiter_list_mutex);
vchiq_log_info(vchiq_arm_log_level,
- "saved bulk_waiter %x for pid %d",
- (unsigned int)waiter, current->l_proc->p_pid);
+ "saved bulk_waiter %p for pid %d",
+ waiter, current->l_proc->p_pid);
pargs->mode = mode_waiting;
}
@@ -864,9 +864,9 @@
if (args.msgbufsize < msglen) {
vchiq_log_error(
vchiq_arm_log_level,
- "header %x: msgbufsize"
+ "header %p: msgbufsize"
" %x < msglen %x",
- (unsigned int)header,
+ header,
args.msgbufsize,
msglen);
WARN(1, "invalid message "
@@ -1010,8 +1010,8 @@
ret = -EFAULT;
} else {
vchiq_log_error(vchiq_arm_log_level,
- "header %x: bufsize %x < size %x",
- (unsigned int)header, args.bufsize,
+ "header %p: bufsize %x < size %x",
+ header, args.bufsize,
header->size);
WARN(1, "invalid size\n");
ret = -EMSGSIZE;
@@ -1070,7 +1070,7 @@
} break;
case VCHIQ_IOC_LIB_VERSION: {
- unsigned int lib_version = (unsigned int)arg;
+ unsigned int lib_version = (uintptr_t)arg;
if (lib_version < VCHIQ_VERSION_MIN)
ret = -EINVAL;
@@ -1148,7 +1148,15 @@
/* XXXBSD: do we really need this check? */
if (device_lookup_private(&vchiq_cd, minor(dev)) != NULL) {
- VCHIQ_STATE_T *state = vchiq_get_state();
+ VCHIQ_STATE_T *state;
+ int i;
+
+ for (i=0; i<10; ++i) {
+ state = vchiq_get_state();
+ if (state)
+ break;
+ delay(500);
+ }
if (!state) {
vchiq_log_error(vchiq_arm_log_level,
@@ -1313,9 +1321,9 @@
list);
list_del(pos);
vchiq_log_info(vchiq_arm_log_level,
- "bulk_waiter - cleaned up %x "
+ "bulk_waiter - cleaned up %p "
"for pid %d",
- (unsigned int)waiter, waiter->pid);
+ waiter, waiter->pid);
_sema_destroy(&waiter->bulk_waiter.event);
kfree(waiter);
}
@@ -1406,9 +1414,9 @@
instance = service->instance;
if (instance && !instance->mark) {
len = snprintf(buf, sizeof(buf),
- "Instance %x: pid %d,%s completions "
+ "Instance %p: pid %d,%s completions "
"%d/%d",
- (unsigned int)instance, instance->pid,
+ instance, instance->pid,
instance->connected ? " connected, " :
"",
instance->completion_insert -
@@ -1436,8 +1444,8 @@
char buf[80];
int len;
- len = snprintf(buf, sizeof(buf), " instance %x",
- (unsigned int)service->instance);
+ len = snprintf(buf, sizeof(buf), " instance %p",
+ service->instance);
if ((service->base.callback == service_callback) &&
user_service->is_vchi) {
diff -r 3711097ea2fc -r d4a75692fa13 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
--- a/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c Wed Jan 22 17:55:41 2020 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c Wed Jan 22 19:15:49 2020 +0000
@@ -294,30 +294,37 @@
lock_service(VCHIQ_SERVICE_T *service)
{
spin_lock(&service_spinlock);
- BUG_ON(!service || (service->ref_count == 0));
- if (service)
+ BUG_ON(!service);
+ if (service) {
+ BUG_ON(service->ref_count == 0);
service->ref_count++;
+ }
spin_unlock(&service_spinlock);
}
void
unlock_service(VCHIQ_SERVICE_T *service)
{
- VCHIQ_STATE_T *state = service->state;
spin_lock(&service_spinlock);
- BUG_ON(!service || (service->ref_count == 0));
- if (service && service->ref_count) {
- service->ref_count--;
- if (!service->ref_count) {
- BUG_ON(service->srvstate != VCHIQ_SRVSTATE_FREE);
- state->services[service->localport] = NULL;
-
- _sema_destroy(&service->remove_event);
- _sema_destroy(&service->bulk_remove_event);
- lmutex_destroy(&service->bulk_mutex);
- } else
- service = NULL;
+ if (!service) {
+ vchiq_log_warning(vchiq_core_log_level,
+ "%s: service is NULL\n", __func__);
+ goto unlock;
+ }
+ if (!service->ref_count) {
+ vchiq_log_warning(vchiq_core_log_level,
+ "%s: ref_count is zero\n", __func__);
+ goto unlock;
}
+ service->ref_count--;
+ if (!service->ref_count) {
+ VCHIQ_STATE_T *state = service->state;
+
+ WARN_ON(service->srvstate != VCHIQ_SRVSTATE_FREE);
+ state->services[service->localport] = NULL;
+ } else
+ service = NULL;
+unlock:
spin_unlock(&service_spinlock);
if (service && service->userdata_term)
@@ -391,9 +398,10 @@
VCHIQ_HEADER_T *header, void *bulk_userdata)
{
VCHIQ_STATUS_T status;
- vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %x, %x)",
+
+ vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %p, %p)",
service->state->id, service->localport, reason_names[reason],
- (unsigned int)header, (unsigned int)bulk_userdata);
+ header, bulk_userdata);
status = service->base.callback(reason, header, service->handle,
bulk_userdata);
if (status == VCHIQ_ERROR) {
@@ -409,6 +417,7 @@
vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate)
{
VCHIQ_CONNSTATE_T oldstate = state->conn_state;
+
vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id,
conn_state_names[oldstate],
conn_state_names[newstate]);
@@ -417,28 +426,24 @@
}
static inline void
-remote_event_create(REMOTE_EVENT_T *event)
+remote_event_create(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event)
{
event->armed = 0;
/* Don't clear the 'fired' flag because it may already have been set
** by the other side. */
- _sema_init(event->event, 0);
-}
-
-__unused static inline void
-remote_event_destroy(REMOTE_EVENT_T *event)
-{
- (void)event;
+ _sema_init((struct semaphore *)((char *)state + event->event), 0);
}
static inline int
-remote_event_wait(REMOTE_EVENT_T *event)
+remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event)
{
if (!event->fired) {
event->armed = 1;
dsb();
if (!event->fired) {
- if (down_interruptible(event->event) != 0) {
+ if (down_interruptible(
+ (struct semaphore *)
+ ((char *)state + event->event)) != 0) {
event->armed = 0;
Home |
Main Index |
Thread Index |
Old Index