From: rkir@google.com
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, tkjos@google.com,
Roman Kiryanov <rkir@google.com>
Subject: [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header
Date: Mon, 27 Aug 2018 11:22:59 -0700 [thread overview]
Message-ID: <20180827182315.126345-4-rkir@google.com> (raw)
In-Reply-To: <20180827182315.126345-1-rkir@google.com>
From: Roman Kiryanov <rkir@google.com>
These are several enums that must kept in sync with the host side.
This change explicitly separates them into a dedicated header file.
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
drivers/platform/goldfish/goldfish_pipe.c | 69 +----------
.../platform/goldfish/goldfish_pipe_qemu.h | 112 ++++++++++++++++++
2 files changed, 113 insertions(+), 68 deletions(-)
create mode 100644 drivers/platform/goldfish/goldfish_pipe_qemu.h
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 4e7e100dc7a0..caf514aafb21 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -64,6 +64,7 @@
#include <linux/dma-mapping.h>
#include <linux/mm.h>
#include <linux/acpi.h>
+#include "goldfish_pipe_qemu.h"
/*
* Update this when something changes in the driver's behavior so the host
@@ -74,74 +75,6 @@ enum {
PIPE_CURRENT_DEVICE_VERSION = 2
};
-/*
- * IMPORTANT: The following constants must match the ones used and defined
- * in external/qemu/hw/goldfish_pipe.c in the Android source tree.
- */
-
-/* List of bitflags returned in status of CMD_POLL command */
-enum PipePollFlags {
- PIPE_POLL_IN = 1 << 0,
- PIPE_POLL_OUT = 1 << 1,
- PIPE_POLL_HUP = 1 << 2
-};
-
-/*
- * Possible status values used to signal errors
- * see: goldfish_pipe_error_convert
- */
-enum PipeErrors {
- PIPE_ERROR_INVAL = -1,
- PIPE_ERROR_AGAIN = -2,
- PIPE_ERROR_NOMEM = -3,
- PIPE_ERROR_IO = -4
-};
-
-/* Bit-flags used to signal events from the emulator */
-enum PipeWakeFlags {
- PIPE_WAKE_CLOSED = 1 << 0, /* emulator closed pipe */
- PIPE_WAKE_READ = 1 << 1, /* pipe can now be read from */
- PIPE_WAKE_WRITE = 1 << 2 /* pipe can now be written to */
-};
-
-/* Bit flags for the 'flags' field */
-enum PipeFlagsBits {
- BIT_CLOSED_ON_HOST = 0, /* pipe closed by host */
- BIT_WAKE_ON_WRITE = 1, /* want to be woken on writes */
- BIT_WAKE_ON_READ = 2, /* want to be woken on reads */
-};
-
-enum PipeRegs {
- PIPE_REG_CMD = 0,
-
- PIPE_REG_SIGNAL_BUFFER_HIGH = 4,
- PIPE_REG_SIGNAL_BUFFER = 8,
- PIPE_REG_SIGNAL_BUFFER_COUNT = 12,
-
- PIPE_REG_OPEN_BUFFER_HIGH = 20,
- PIPE_REG_OPEN_BUFFER = 24,
-
- PIPE_REG_VERSION = 36,
-
- PIPE_REG_GET_SIGNALLED = 48,
-};
-
-enum PipeCmdCode {
- PIPE_CMD_OPEN = 1, /* to be used by the pipe device itself */
- PIPE_CMD_CLOSE,
- PIPE_CMD_POLL,
- PIPE_CMD_WRITE,
- PIPE_CMD_WAKE_ON_WRITE,
- PIPE_CMD_READ,
- PIPE_CMD_WAKE_ON_READ,
-
- /*
- * TODO(zyy): implement a deferred read/write execution to allow
- * parallel processing of pipe operations on the host.
- */
- PIPE_CMD_WAKE_ON_DONE_IO,
-};
-
enum {
MAX_BUFFERS_PER_COMMAND = 336,
MAX_SIGNALLED_PIPES = 64,
diff --git a/drivers/platform/goldfish/goldfish_pipe_qemu.h b/drivers/platform/goldfish/goldfish_pipe_qemu.h
new file mode 100644
index 000000000000..c272e11c5433
--- /dev/null
+++ b/drivers/platform/goldfish/goldfish_pipe_qemu.h
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * IMPORTANT: The following constants must match the ones used and defined in
+ * external/qemu/include/hw/misc/goldfish_pipe.h
+ */
+
+#ifndef GOLDFISH_PIPE_QEMU_H
+#define GOLDFISH_PIPE_QEMU_H
+
+/* List of bitflags returned in status of CMD_POLL command */
+enum PipePollFlags {
+ PIPE_POLL_IN = 1 << 0,
+ PIPE_POLL_OUT = 1 << 1,
+ PIPE_POLL_HUP = 1 << 2
+};
+
+/* Possible status values used to signal errors */
+enum PipeErrors {
+ PIPE_ERROR_INVAL = -1,
+ PIPE_ERROR_AGAIN = -2,
+ PIPE_ERROR_NOMEM = -3,
+ PIPE_ERROR_IO = -4
+};
+
+/* Bit-flags used to signal events from the emulator */
+enum PipeWakeFlags {
+ /* emulator closed pipe */
+ PIPE_WAKE_CLOSED = 1 << 0,
+
+ /* pipe can now be read from */
+ PIPE_WAKE_READ = 1 << 1,
+
+ /* pipe can now be written to */
+ PIPE_WAKE_WRITE = 1 << 2,
+
+ /* unlock this pipe's DMA buffer */
+ PIPE_WAKE_UNLOCK_DMA = 1 << 3,
+
+ /* unlock DMA buffer of the pipe shared to this pipe */
+ PIPE_WAKE_UNLOCK_DMA_SHARED = 1 << 4,
+};
+
+/* Possible pipe closing reasons */
+enum PipeCloseReason {
+ /* guest sent a close command */
+ PIPE_CLOSE_GRACEFUL = 0,
+
+ /* guest rebooted, we're closing the pipes */
+ PIPE_CLOSE_REBOOT = 1,
+
+ /* close old pipes on snapshot load */
+ PIPE_CLOSE_LOAD_SNAPSHOT = 2,
+
+ /* some unrecoverable error on the pipe */
+ PIPE_CLOSE_ERROR = 3,
+};
+
+/* Bit flags for the 'flags' field */
+enum PipeFlagsBits {
+ BIT_CLOSED_ON_HOST = 0, /* pipe closed by host */
+ BIT_WAKE_ON_WRITE = 1, /* want to be woken on writes */
+ BIT_WAKE_ON_READ = 2, /* want to be woken on reads */
+};
+
+enum PipeRegs {
+ PIPE_REG_CMD = 0,
+
+ PIPE_REG_SIGNAL_BUFFER_HIGH = 4,
+ PIPE_REG_SIGNAL_BUFFER = 8,
+ PIPE_REG_SIGNAL_BUFFER_COUNT = 12,
+
+ PIPE_REG_OPEN_BUFFER_HIGH = 20,
+ PIPE_REG_OPEN_BUFFER = 24,
+
+ PIPE_REG_VERSION = 36,
+
+ PIPE_REG_GET_SIGNALLED = 48,
+};
+
+enum PipeCmdCode {
+ /* to be used by the pipe device itself */
+ PIPE_CMD_OPEN = 1,
+
+ PIPE_CMD_CLOSE,
+ PIPE_CMD_POLL,
+ PIPE_CMD_WRITE,
+ PIPE_CMD_WAKE_ON_WRITE,
+ PIPE_CMD_READ,
+ PIPE_CMD_WAKE_ON_READ,
+
+ /*
+ * TODO(zyy): implement a deferred read/write execution to allow
+ * parallel processing of pipe operations on the host.
+ */
+ PIPE_CMD_WAKE_ON_DONE_IO,
+};
+
+#endif /* GOLDFISH_PIPE_QEMU_H */
--
2.19.0.rc0.228.g281dcd1b4d0-goog
next prev parent reply other threads:[~2018-08-27 18:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 18:22 [PATCH 01/20] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
2018-08-27 18:22 ` [PATCH 02/20] platform: goldfish: pipe: Update license rkir
2018-08-27 18:22 ` [PATCH 03/20] platform: goldfish: pipe: Move an opening brace to the next line rkir
2018-08-27 18:22 ` rkir [this message]
2018-09-14 13:29 ` [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header Greg KH
2018-08-27 18:23 ` [PATCH 05/20] platform: goldfish: pipe: Update the comment for GFP_ATOMIC rkir
2018-08-27 18:23 ` [PATCH 06/20] platform: goldfish: pipe: Fail compilation if structs are too large rkir
2018-08-27 18:23 ` [PATCH 07/20] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
2018-09-14 13:30 ` Greg KH
2018-09-14 16:42 ` Roman Kiryanov
2018-09-14 19:20 ` Greg KH
2018-08-27 18:23 ` [PATCH 08/20] platform: goldfish: pipe: Replace pr_ with dev_ for logging rkir
2018-08-27 18:23 ` [PATCH 09/20] platform: goldfish: pipe: Add blank lines to separate struct members rkir
2018-08-27 18:23 ` [PATCH 10/20] platform: goldfish: pipe: Remove a redundant variable rkir
2018-08-27 18:23 ` [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call rkir
2018-08-27 18:23 ` [PATCH 12/20] platform: goldfish: pipe: Remove reduntant casting rkir
2018-08-27 18:23 ` [PATCH 13/20] platform: goldfish: pipe: Remove a blank line before '}' rkir
2018-08-27 18:23 ` [PATCH 14/20] platform: goldfish: pipe: Rename 'wakeBit' to 'wake_bit' rkir
2018-08-27 18:23 ` [PATCH 15/20] platform: goldfish: pipe: Remove reduntant casting to (void) rkir
2018-08-27 18:23 ` [PATCH 16/20] platform: goldfish: pipe: Rename goldfish_x to goldfish_pipe_x rkir
2018-08-27 18:23 ` [PATCH 17/20] platform: goldfish: pipe: Fix lines to not end an opening bracket rkir
2018-08-27 18:23 ` [PATCH 18/20] platform: goldfish: pipe: Fix alignment to match parenthesis rkir
2018-08-27 18:23 ` [PATCH 19/20] platform: goldfish: pipe: Move logical ops to the end of the prev line rkir
2018-08-27 18:23 ` [PATCH 20/20] platform: goldfish: pipe: Replace "x==NULL" to "!x" rkir
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=20180827182315.126345-4-rkir@google.com \
--to=rkir@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tkjos@google.com \
/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).