From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbbEDGp4 (ORCPT ); Mon, 4 May 2015 02:45:56 -0400 Received: from mga11.intel.com ([192.55.52.93]:56318 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752043AbbEDGpU (ORCPT ); Mon, 4 May 2015 02:45:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,365,1427785200"; d="scan'208";a="704744063" From: Tomas Winkler To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, Alexander Usyskin , Tomas Winkler Subject: [char-misc-next 6/9 V2] mei: connection to fixed address clients from user-space Date: Mon, 4 May 2015 09:43:57 +0300 Message-Id: <1430721840-11562-6-git-send-email-tomas.winkler@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430721840-11562-1-git-send-email-tomas.winkler@intel.com> References: <1430721840-11562-1-git-send-email-tomas.winkler@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin This should be used for debug only. The feaure is gated by "allow_fixed_address" control exposed in debugfs. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- V2: fix permission on debugfs enntry drivers/misc/mei/debugfs.c | 6 ++++++ drivers/misc/mei/main.c | 8 +++++++- drivers/misc/mei/mei_dev.h | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c index 3f6d855a7ecb..88f5fd0b6dd7 100644 --- a/drivers/misc/mei/debugfs.c +++ b/drivers/misc/mei/debugfs.c @@ -209,6 +209,12 @@ int mei_dbgfs_register(struct mei_device *dev, const char *name) dev_err(dev->dev, "devstate: registration failed\n"); goto err; } + f = debugfs_create_bool("allow_fixed_address", S_IRUSR | S_IWUSR, dir, + &dev->allow_fixed_address); + if (!f) { + dev_err(dev->dev, "allow_fixed_address: registration failed\n"); + goto err; + } dev->dbgfs_dir = dir; return 0; err: diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index a69636594150..2887e5607cd6 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -215,6 +215,11 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, cb = mei_cl_read_cb(cl, file); if (!cb) { + if (mei_cl_is_fixed_address(cl) && dev->allow_fixed_address) { + cb = mei_cl_read_cb(cl, NULL); + if (cb) + goto copy_buffer; + } rets = 0; goto out; } @@ -389,7 +394,8 @@ static int mei_ioctl_connect_client(struct file *file, /* find ME client we're trying to connect to */ me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid); - if (!me_cl || me_cl->props.fixed_address) { + if (!me_cl || + (me_cl->props.fixed_address && !dev->allow_fixed_address)) { dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n", &data->in_client_uuid); mei_me_cl_put(me_cl); diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 96c0290da5fb..fa5ce1de20f6 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -476,6 +476,8 @@ const char *mei_pg_state_str(enum mei_pg_state state); * @host_clients_map : host clients id pool * @me_client_index : last FW client index in enumeration * + * @allow_fixed_address: allow user space to connect a fixed client + * * @wd_cl : watchdog client * @wd_state : watchdog client state * @wd_pending : watchdog command is pending @@ -567,6 +569,8 @@ struct mei_device { DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX); unsigned long me_client_index; + u32 allow_fixed_address; + struct mei_cl wd_cl; enum mei_wd_states wd_state; bool wd_pending; -- 2.1.0