Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6199602imm; Mon, 27 Aug 2018 11:25:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaMo7d9zCJ6btUiFrRurVZ1K3gq/17yCP9BLzMQiYUHcclizg9posAkPicBxwfawwRWZTdj X-Received: by 2002:a65:60cf:: with SMTP id r15-v6mr13362107pgv.41.1535394324399; Mon, 27 Aug 2018 11:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535394324; cv=none; d=google.com; s=arc-20160816; b=pqWfyujjQZrVWuTE0ZJB7Xk3Cwvu1/rZF/0i0EBifl/ElxsOS1qz9Yj9gP3mvDfJLu llZoY4s4haNzwwVR22Dy+ea0GQW6mR9/sc+XzsHvaszOLK8oBOXqU6kdUtn9b60sFakw eqpl9v4sSgFaY3EDK5RikwKFLzxe4s8bRYjvNkg1ETL5qLae4dX6JM590u0ztVMAtyLZ +iUudxhdMVGOEqSGDlIGsIyREL12dyI+YAcgDUh8jxqPl99kfhK/CtfMa+YbKZhKOvb0 35ozCYZ6TxyPCYu6ZAdqmoyRvcVE/wQ9nnwRkJBfgWXvLDuPvnWARedSIeyr0dWyvWQB AZ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature :arc-authentication-results; bh=ogFCRVWGoIPGQHMTcU33CTu3h5C534AwkRyxUF383wI=; b=cfXwHsZjUaOp52vJQnurbpbyv6KztwI4z1n12vq87xrzdLQ36d12EZ0sEbMJosuzGr 120wlKG+iC6Lcb1GKEQ40yoDyeBJ7+GerHqJ+0mPpEBmAcimnQL8KrWOZhId+lQXrUtv iB0U0p6XQ4MSaHDVQe6tMdOYQUt/uDhwUp8xDpiy5a+lfP7Kb4HQukH80TUDg4pH6U9y nhRY+wR8aX7ytwF4vkn0zyuHgRKdluEnpbvc//ZSBEgXDkWpWj2EbCNybv+FFQ+y/kqy C9SsPQXFbm0h212bsW37wruckiUODp1NVsSakNYdJJRKdN+1HVotBP735b6iCQGgAIqY XQ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cGtu0S41; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si13593162pfh.346.2018.08.27.11.25.09; Mon, 27 Aug 2018 11:25:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cGtu0S41; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbeH0WL1 (ORCPT + 99 others); Mon, 27 Aug 2018 18:11:27 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:48160 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727489AbeH0WL0 (ORCPT ); Mon, 27 Aug 2018 18:11:26 -0400 Received: by mail-pf1-f201.google.com with SMTP id x19-v6so12351126pfh.15 for ; Mon, 27 Aug 2018 11:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ogFCRVWGoIPGQHMTcU33CTu3h5C534AwkRyxUF383wI=; b=cGtu0S41uW7xVIOuaFZXqL+6S/QvOS9oB1pbXzWebOafhgzHITmyZTl5QcnO7eLTUY iDNzi9h7Zi26QwY5nIuQ50BdvW0kSU4fzOBeqxKlASI5PFk2EOLLhil11sq3Tva2hZda Nx7TkOzug1AW33WeKLx5oW40a7k2vidu/B9FjiaQSBvU1WlUSQWSMacss9fhVQg1+DH1 MakK4GlPqq5mW5C16HjaXO8Ht0hR6CQvdxGzmUAgSkotA1+qRV2+5nKlL82THjm67Zab 6ZrToegS/xnjG0ZqLM27Ft9RhSF/2osxojI4Sm36tTpCuqP8OFgn7kqiUQG8ek9ejzRi 73MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ogFCRVWGoIPGQHMTcU33CTu3h5C534AwkRyxUF383wI=; b=H7OEgedZTgI8bMDUdDcy6XqkoWd+BU3kg0YuIroo8f0zNBaueaT7q1Vlw5kt1gKnBs 36afGrGL7BoBTvaI1ZsDYd2oAqleF2uVZl+aT8qYsVXoz3CsIhVsJJZ3VhpZvB5+jZOL 7zRU8DdcGiN4pUKcswDnr9qfubZzZaHSJQIwe5zjKhYCOBYzzOtnppiSVicF/PI8uOUt mx/jvTp4tYq9u+uLTSFvfiQFN+nABDouFldbnWkbBzh0hKknB30RmNCpMwabQ85bQlMk 8MRCZggvW39xP9sfarQyqy/+hTou+ruvdkbF+SrYDlnUbbth5SYWwc5hJsJonnH5XcHh GHeQ== X-Gm-Message-State: APzg51Az4k4n3ubd0MWkUYgE5WVeTnJSiXJ+XftXjZIj4h4pOD7Fm5OT KG5Y4oaZjKjw1baiEQRq5mkQijuw X-Received: by 2002:a63:c0f:: with SMTP id b15-v6mr3415332pgl.80.1535394224148; Mon, 27 Aug 2018 11:23:44 -0700 (PDT) Date: Mon, 27 Aug 2018 11:22:59 -0700 In-Reply-To: <20180827182315.126345-1-rkir@google.com> Message-Id: <20180827182315.126345-4-rkir@google.com> Mime-Version: 1.0 References: <20180827182315.126345-1-rkir@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog Subject: [PATCH 04/20] platform: goldfish: pipe: Separate the host interface to a separate header From: rkir@google.com To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, tkjos@google.com, Roman Kiryanov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Kiryanov 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 --- 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 #include #include +#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