Commit 4d3e568d authored by Charles Jacobsen's avatar Charles Jacobsen
Browse files

lcd: rpc kernel test is working.

Fixed bug that checks if a message has been received.

I switched to spinlocks to make it just slightly faster, and make
the channel headers leaner.
parent fcc645f1
......@@ -77,15 +77,15 @@ tx_msg_to_idx(struct fipc_ring_channel *rc, struct fipc_message *msg)
return msg - rc->tx.buffer;
}
static inline int check_rx_slot_available(struct fipc_message *slot)
static inline int check_rx_slot_msg_waiting(struct fipc_message *slot)
{
return (likely(slot->msg_status != FIPC_MSG_STATUS_SENT));
return slot->msg_status == FIPC_MSG_STATUS_SENT;
}
static inline int check_tx_slot_available(struct fipc_message *slot)
{
return unlikely(slot->msg_status != FIPC_MSG_STATUS_AVAILABLE);
return slot->msg_status == FIPC_MSG_STATUS_AVAILABLE;
}
static inline unsigned long nr_slots(unsigned int buf_order)
......@@ -140,7 +140,7 @@ int fipc_ring_channel_init(struct fipc_ring_channel *chnl,
* Checks at compile time
*/
BUILD_BUG_ON_NOT_POWER_OF_2(FIPC_CACHE_LINE_SIZE);
BUILD_BUG_ON(sizeof(struct fipc_ring_buf) != 2 * FIPC_CACHE_LINE_SIZE);
BUILD_BUG_ON(sizeof(struct fipc_ring_buf) != FIPC_CACHE_LINE_SIZE);
BUILD_BUG_ON(sizeof(struct fipc_message) != FIPC_CACHE_LINE_SIZE);
/*
* Buffers must be as big as one ipc message slot
......@@ -213,7 +213,7 @@ static int recv_msg_peek(struct fipc_ring_channel *chnl,
{
int ret = -EWOULDBLOCK;
if (check_rx_slot_available(get_current_rx_slot(chnl))) {
if (check_rx_slot_msg_waiting(get_current_rx_slot(chnl))) {
*msg = get_current_rx_slot(chnl);
ret = 0;
......
......@@ -17,7 +17,7 @@
#define FIPC_DEBUG_ERR 1
#define FIPC_DEBUG_VERB 2
#define FIPC_DEBUG_LVL FIPC_DEBUG_VERB
#define FIPC_DEBUG_LVL FIPC_DEBUG_NONE
#define fipc_debug(fmt, ...) __fipc_debug(fmt,##__VA_ARGS__)
......
......@@ -58,7 +58,7 @@ struct fipc_message {
* it to be double cacheline sized.
*/
#define FIPC_RING_BUF_PADDING \
(2 * FIPC_CACHE_LINE_SIZE - \
(FIPC_CACHE_LINE_SIZE - \
(3 * sizeof(unsigned long) + sizeof(fipc_mutex_t)))
struct fipc_ring_buf {
/**
......
......@@ -18,19 +18,19 @@
static inline int __fipc_mutex_init(fipc_mutex_t *mutex)
{
mutex_init(mutex);
spin_lock_init(mutex);
return 0;
}
static inline int __fipc_mutex_lock(fipc_mutex_t *mutex)
{
mutex_lock(mutex);
spin_lock(mutex);
return 0;
}
static inline int __fipc_mutex_unlock(fipc_mutex_t *mutex)
{
mutex_unlock(mutex);
spin_unlock(mutex);
return 0;
}
......
......@@ -8,9 +8,9 @@
#ifndef LIBFIPC_PLATFORM_TYPES_H
#define LIBFIPC_PLATFORM_TYPES_H
#include <linux/mutex.h>
#include <linux/spinlock.h>
typedef struct mutex fipc_mutex_t;
typedef spinlock_t fipc_mutex_t;
#endif /* LIBFIPC_PLATFORM_TYPES_H */
......@@ -11,4 +11,4 @@ libfipc_test_rpc-y += main.o callee.o caller.o
libfipc_test_rpc-y += ../$(LIBFIPC_PATH) # libfipc.a is relative to tests/
# Add -DCHECK_MESSAGES to check that message values contain what is expected
ccflags-y += $(CFLAGS) $(AM_CPPFLAGS) -DCHECK_MESSAGES
ccflags-y += $(CFLAGS) $(AM_CPPFLAGS)
......@@ -159,6 +159,7 @@ int callee(void *_callee_channel_header)
break;
default:
pr_err("Bad function type %d, exiting...\n", type);
ret = -EINVAL;
goto out;
}
/*
......
......@@ -7,6 +7,7 @@
#include <libfipc.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include "../test_helpers.h"
#include "rpc.h"
......@@ -35,7 +36,7 @@ static int setup_and_run_test(void)
ret = test_fipc_create_channel(CHANNEL_ORDER, &caller_header,
&callee_header);
if (ret) {
pr_err("Error creating channel, ret = %d", ret);
pr_err("Error creating channel, ret = %d\n", ret);
goto fail1;
}
/*
......@@ -45,14 +46,14 @@ static int setup_and_run_test(void)
caller,
CALLER_CPU);
if (!caller_thread) {
pr_err("Error setting up caller thread");
pr_err("Error setting up caller thread\n");
goto fail2;
}
callee_thread = test_fipc_spawn_thread_with_channel(callee_header,
callee,
CALLEE_CPU);
if (!callee_thread) {
pr_err("Error setting up callee thread");
pr_err("Error setting up callee thread\n");
goto fail3;
}
/*
......@@ -60,6 +61,7 @@ static int setup_and_run_test(void)
*/
wake_up_process(caller_thread);
wake_up_process(callee_thread);
msleep(1000);
/*
* Wait for them to complete, so we can tear things down
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment