Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1207087 > unrolled thread

[RFC][PATCH 0/2] usb: gadget: add MTP function and Uevent userspace notifications

Started byAmit Pundir <amit.pundir@linaro.org>
First post2015-08-13 21:20 +0200
Last post2015-08-14 12:00 +0200
Articles 9 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [RFC][PATCH 0/2] usb: gadget: add MTP function and Uevent userspace notifications Amit Pundir <amit.pundir@linaro.org> - 2015-08-13 21:20 +0200
    [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes Amit Pundir <amit.pundir@linaro.org> - 2015-08-13 21:20 +0200
      Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb  state changes Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-08-13 21:50 +0200
        Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb  state changes Felipe Balbi <balbi@ti.com> - 2015-08-14 00:10 +0200
    Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-08-13 21:40 +0200
      Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-13 22:00 +0200
        Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-08-13 22:30 +0200
        Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-08-13 22:50 +0200
          Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function Amit Pundir <amit.pundir@linaro.org> - 2015-08-14 12:00 +0200

#1207087 — [RFC][PATCH 0/2] usb: gadget: add MTP function and Uevent userspace notifications

FromAmit Pundir <amit.pundir@linaro.org>
Date2015-08-13 21:20 +0200
Subject[RFC][PATCH 0/2] usb: gadget: add MTP function and Uevent userspace notifications
Message-ID<pX6cG-43o-29@gated-at.bofh.it>
RFC on Android's ConfigFS based MTP function implementation and usage
of Uevents to notify the userspace about the USB state changes.

The MTP function is based on years of work originally done in the
Android kernel tree by:
    Mike Lockwood <lockwood@android.com>
    Benoit Goby <benoit@android.com>
    Colin Cross <ccross@android.com>
    Arve Hjønnevåg <arve@android.com>
    Peter Oh <poh@broadcom.com>
    Greg Hackmann <ghackmann@google.com>
    Badhri Jagan Sridharan <Badhri@google.com>

The Uevent notification patch is more of an RFC than an actual
submission. It is based on Android patchset originaly authored by
Badhri to send uevent notifications to Android userpace for USB
state changes.

I've folded the series up to make it easier to review, provided a
coherent patch description and modified it enough that I don't want
them to be blamed for any mistakes I've made condensing their patches
down.

Thoughts and feedback would be appreciated.

Thanks,
Amit Pundir

Cc: Mike Lockwood <lockwood@android.com>
Cc: Benoit Goby <benoit@android.com>
Cc: Colin Cross <ccross@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Peter Oh <poh@broadcom.com>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Badhri Jagan Sridharan <Badhri@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Philippe Reynes <tremyfr@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>

Amit Pundir (2):
  usb: gadget: configfs: add MTP function
  usb: gadget: configfs: notify userspace of usb state changes

 Documentation/ABI/testing/configfs-usb-gadget-mtp |    7 +
 Documentation/usb/gadget-testing.txt              |   24 +
 drivers/usb/gadget/Kconfig                        |   21 +
 drivers/usb/gadget/configfs.c                     |  201 ++-
 drivers/usb/gadget/function/Makefile              |    2 +
 drivers/usb/gadget/function/f_mtp.c               | 1365 +++++++++++++++++++++
 include/linux/usb/f_mtp.h                         |   23 +
 include/uapi/linux/usb/f_mtp.h                    |   61 +
 8 files changed, 1702 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-mtp
 create mode 100644 drivers/usb/gadget/function/f_mtp.c
 create mode 100644 include/linux/usb/f_mtp.h
 create mode 100644 include/uapi/linux/usb/f_mtp.h

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1207090 — [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes

FromAmit Pundir <amit.pundir@linaro.org>
Date2015-08-13 21:20 +0200
Subject[RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes
Message-ID<pX6cG-43o-39@gated-at.bofh.it>
In reply to#1207087
This is more of an RFC than an actual submission. There are few
scattered #ifdefs..#endifs here and there which still need to be
taken care of before going for actual submission.

Currently there is no way with the upstream ConfigFS gadget to
communicate state changes (connected, disconnected, configured), at
the gadget level. Instead such state changes are handled function by
function independently I presume. This is problematic, because some
coordination between the functions, across the state changes, may be
desired at the userspace level. Thus to address this issue, this
patch send uevents to allow userspace to be notified of these usb
state changes, allowing userspace to respond and configure the
configfs gadget appropriately.

This patch is based on an Android patchset originaly authored by
Badhri Jagan Sridharan <Badhri@google.com> to send uevent notifications
to Android userpace for USB state changes. I've folded his patches
together and modified it enough that I don't want him to be blamed for
any mistakes I've made condensing his patches down.

This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace
notifications of usb state changes, and add setup and disconnect
functions to intercept the setup requests from the usb_core. It also
creates a sysfs device class entry and a device attribute (state) to
read and respond to gadget's current state from userspace. As of now
this sysfs device class (/sys/class/android_usb) and gadget device
(/sys/class/android_usb/android0) with state attribute
(/sys/class/android_usb/android0/state) are strictly tied up to
facilitate Android userspace requests. But going forward we may want
to bring all function devices (hid, printer etc) under a unified usb
gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc..

Also I think it make sense to add this state attribute to the configfs
usb gadget itself i.e. have something like /config/usb_gadget/g1/state
to read USB gadget's current state. Since it is going to be consistent
throughout all the functions tied up to that gadget.

Again this is just an initial RFC, thoughts and feedback would be
greatly appreciated.

Cc: Mike Lockwood <lockwood@android.com>
Cc: Benoit Goby <benoit@android.com>
Cc: Colin Cross <ccross@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Peter Oh <poh@broadcom.com>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Badhri Jagan Sridharan <Badhri@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Philippe Reynes <tremyfr@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 drivers/usb/gadget/Kconfig    |   8 ++
 drivers/usb/gadget/configfs.c | 201 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 207 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 65d110d..e1d1fc1 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -464,6 +464,14 @@ config USB_CONFIGFS_F_MTP
 	  the file level. Thus exposing the relevant content but hiding
 	  the system/restricted files.
 
+config USB_CONFIGFS_UEVENT
+	bool "Uevent notification of Gadget state"
+	depends on USB_CONFIGFS
+	help
+	  Enable uevent notifications to userspace when the gadget
+	  state changes. The gadget can be in any of the following
+	  three states: "CONNECTED/DISCONNECTED/CONFIGURED"
+
 source "drivers/usb/gadget/legacy/Kconfig"
 
 endchoice
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 289e201..1575343 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -9,6 +9,15 @@
 #include "u_f.h"
 #include "u_os_desc.h"
 
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+#include <linux/platform_device.h>
+#include <linux/kdev_t.h>
+#include <linux/usb/ch9.h>
+
+static struct class *usb_gadget_class;
+static struct device *usb_gadget_device;
+#endif
+
 int check_user_usb_string(const char *name,
 		struct usb_gadget_strings *stringtab_dev)
 {
@@ -63,6 +72,12 @@ struct gadget_info {
 	bool use_os_desc;
 	char b_vendor_code;
 	char qw_sign[OS_STRING_QW_SIGN_LEN];
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	bool connected;
+	bool sw_connected;
+	struct work_struct work;
+	struct device *dev;
+#endif
 };
 
 struct config_usb_cfg {
@@ -1444,13 +1459,143 @@ static void configfs_composite_unbind(struct usb_gadget *gadget)
 	set_gadget_data(gadget, NULL);
 }
 
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+static ssize_t state_show(struct device *pdev, struct device_attribute *attr,
+			char *buf)
+{
+	struct gadget_info *dev = dev_get_drvdata(pdev);
+	struct usb_composite_dev *cdev;
+	char *state = "DISCONNECTED";
+	unsigned long flags;
+
+	if (!dev)
+		goto out;
+
+	cdev = &dev->cdev;
+
+	if (!cdev)
+		goto out;
+
+	spin_lock_irqsave(&cdev->lock, flags);
+	if (cdev->config)
+		state = "CONFIGURED";
+	else if (dev->connected)
+		state = "CONNECTED";
+	spin_unlock_irqrestore(&cdev->lock, flags);
+out:
+	return sprintf(buf, "%s\n", state);
+}
+
+static DEVICE_ATTR(state, S_IRUGO, state_show, NULL);
+
+static struct device_attribute *cfs_usb_attributes[] = {
+	&dev_attr_state,
+	NULL
+};
+
+static void cfs_uevent_work(struct work_struct *data)
+{
+	struct gadget_info *gi = container_of(data, struct gadget_info, work);
+	struct usb_composite_dev *cdev = &gi->cdev;
+	char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL };
+	char *connected[2]    = { "USB_STATE=CONNECTED", NULL };
+	char *configured[2]   = { "USB_STATE=CONFIGURED", NULL };
+	/* 0-connected 1-configured 2-disconnected*/
+	bool status[3] = { false, false, false };
+	unsigned long flags;
+	bool uevent_sent = false;
+
+	spin_lock_irqsave(&cdev->lock, flags);
+	if (cdev->config)
+		status[1] = true;
+
+	if (gi->connected != gi->sw_connected) {
+		if (gi->connected)
+			status[0] = true;
+		else
+			status[2] = true;
+		gi->sw_connected = gi->connected;
+	}
+	spin_unlock_irqrestore(&cdev->lock, flags);
+
+	if (status[0]) {
+		kobject_uevent_env(&usb_gadget_device->kobj,
+					KOBJ_CHANGE, connected);
+		pr_info("%s: sent uevent %s\n", __func__, connected[0]);
+		uevent_sent = true;
+	}
+
+	if (status[1]) {
+		kobject_uevent_env(&usb_gadget_device->kobj,
+					KOBJ_CHANGE, configured);
+		pr_info("%s: sent uevent %s\n", __func__, configured[0]);
+		uevent_sent = true;
+	}
+
+	if (status[2]) {
+		kobject_uevent_env(&usb_gadget_device->kobj,
+					KOBJ_CHANGE, disconnected);
+		pr_info("%s: sent uevent %s\n", __func__, disconnected[0]);
+		uevent_sent = true;
+	}
+
+	if (!uevent_sent) {
+		pr_info("%s: did not send uevent (%d %d %p)\n", __func__,
+			gi->connected, gi->sw_connected, cdev->config);
+	}
+}
+
+static int cfs_uevent_setup(struct usb_gadget *gadget,
+			const struct usb_ctrlrequest *c)
+{
+	struct usb_composite_dev *cdev = get_gadget_data(gadget);
+	unsigned long flags;
+	struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
+	int value = -EOPNOTSUPP;
+
+	spin_lock_irqsave(&cdev->lock, flags);
+	if (!gi->connected) {
+		gi->connected = 1;
+		schedule_work(&gi->work);
+	}
+	spin_unlock_irqrestore(&cdev->lock, flags);
+
+	value = composite_setup(gadget, c);
+
+	spin_lock_irqsave(&cdev->lock, flags);
+	if (c->bRequest == USB_REQ_SET_CONFIGURATION &&
+						cdev->config) {
+		schedule_work(&gi->work);
+	}
+	spin_unlock_irqrestore(&cdev->lock, flags);
+
+	return value;
+}
+
+static void cfs_uevent_disconnect(struct usb_gadget *gadget)
+{
+	struct usb_composite_dev *cdev = get_gadget_data(gadget);
+	struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev);
+
+	gi->connected = 0;
+	schedule_work(&gi->work);
+	composite_disconnect(gadget);
+}
+#endif
+
 static const struct usb_gadget_driver configfs_driver_template = {
 	.bind           = configfs_composite_bind,
 	.unbind         = configfs_composite_unbind,
 
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	.setup          = cfs_uevent_setup,
+	.reset          = cfs_uevent_disconnect,
+	.disconnect     = cfs_uevent_disconnect,
+#else
 	.setup          = composite_setup,
 	.reset          = composite_disconnect,
 	.disconnect     = composite_disconnect,
+#endif
 
 	.suspend	= composite_suspend,
 	.resume		= composite_resume,
@@ -1462,16 +1607,21 @@ static const struct usb_gadget_driver configfs_driver_template = {
 	},
 };
 
+
 static struct config_group *gadgets_make(
 		struct config_group *group,
 		const char *name)
 {
 	struct gadget_info *gi;
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	struct device_attribute **attrs;
+	struct device_attribute *attr;
+	int err;
+#endif
 
 	gi = kzalloc(sizeof(*gi), GFP_KERNEL);
 	if (!gi)
 		return ERR_PTR(-ENOMEM);
-
 	gi->group.default_groups = gi->default_groups;
 	gi->group.default_groups[0] = &gi->functions_group;
 	gi->group.default_groups[1] = &gi->configs_group;
@@ -1507,9 +1657,26 @@ static struct config_group *gadgets_make(
 	gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
 	gi->composite.name = gi->composite.gadget_driver.function;
 
-	if (!gi->composite.gadget_driver.function)
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	INIT_WORK(&gi->work, cfs_uevent_work);
+	usb_gadget_device = device_create(usb_gadget_class, NULL,
+				MKDEV(0, 0), NULL, "android0");
+	if (IS_ERR(usb_gadget_device))
 		goto err;
 
+	dev_set_drvdata(usb_gadget_device, gi);
+
+	attrs = cfs_usb_attributes;
+	while ((attr = *attrs++)) {
+		err = device_create_file(usb_gadget_device, attr);
+		if (err)
+			goto err1;
+	}
+#endif
+
+	if (!gi->composite.gadget_driver.function)
+		goto err1;
+
 #ifdef CONFIG_USB_OTG
 	gi->otg.bLength = sizeof(struct usb_otg_descriptor);
 	gi->otg.bDescriptorType = USB_DT_OTG;
@@ -1519,13 +1686,31 @@ static struct config_group *gadgets_make(
 	config_group_init_type_name(&gi->group, name,
 				&gadget_root_type);
 	return &gi->group;
+
+err1:
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	attrs = cfs_usb_attributes;
+	while ((attr = *attrs++))
+		device_remove_file(usb_gadget_device, attr);
+	device_destroy(usb_gadget_device->class, usb_gadget_device->devt);
 err:
+#endif
 	kfree(gi);
 	return ERR_PTR(-ENOMEM);
 }
 
 static void gadgets_drop(struct config_group *group, struct config_item *item)
 {
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	struct device_attribute **attrs;
+	struct device_attribute *attr;
+
+	attrs = cfs_usb_attributes;
+	while ((attr = *attrs++))
+		device_remove_file(usb_gadget_device, attr);
+	device_destroy(usb_gadget_device->class, usb_gadget_device->devt);
+#endif
+
 	config_item_put(item);
 }
 
@@ -1564,6 +1749,13 @@ static int __init gadget_cfs_init(void)
 	config_group_init(&gadget_subsys.su_group);
 
 	ret = configfs_register_subsystem(&gadget_subsys);
+
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	usb_gadget_class = class_create(THIS_MODULE, "android_usb");
+	if (IS_ERR(usb_gadget_class))
+		return PTR_ERR(usb_gadget_class);
+#endif
+
 	return ret;
 }
 module_init(gadget_cfs_init);
@@ -1571,5 +1763,10 @@ module_init(gadget_cfs_init);
 static void __exit gadget_cfs_exit(void)
 {
 	configfs_unregister_subsystem(&gadget_subsys);
+#ifdef CONFIG_USB_CONFIGFS_UEVENT
+	if (!IS_ERR(usb_gadget_class))
+		class_destroy(usb_gadget_class);
+#endif
+
 }
 module_exit(gadget_cfs_exit);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207136 — Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2015-08-13 21:50 +0200
SubjectRe: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes
Message-ID<pX6FH-4Hv-11@gated-at.bofh.it>
In reply to#1207090
Hello,

On 08/13/2015 09:12 PM, Amit Pundir wrote:
> This is more of an RFC than an actual submission. There are few
> scattered #ifdefs..#endifs here and there which still need to be
> taken care of before going for actual submission.
>
> Currently there is no way with the upstream ConfigFS gadget to
> communicate state changes (connected, disconnected, configured), at
> the gadget level. Instead such state changes are handled function by
> function independently I presume. This is problematic, because some
> coordination between the functions, across the state changes, may be
> desired at the userspace level. Thus to address this issue, this
> patch send uevents to allow userspace to be notified of these usb
> state changes, allowing userspace to respond and configure the
> configfs gadget appropriately.
>
> This patch is based on an Android patchset originaly authored by
> Badhri Jagan Sridharan<Badhri@google.com>  to send uevent notifications
> to Android userpace for USB state changes. I've folded his patches
> together and modified it enough that I don't want him to be blamed for
> any mistakes I've made condensing his patches down.
>
> This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace
> notifications of usb state changes, and add setup and disconnect
> functions to intercept the setup requests from the usb_core. It also
> creates a sysfs device class entry and a device attribute (state) to
> read and respond to gadget's current state from userspace. As of now
> this sysfs device class (/sys/class/android_usb) and gadget device
> (/sys/class/android_usb/android0) with state attribute
> (/sys/class/android_usb/android0/state) are strictly tied up to
> facilitate Android userspace requests. But going forward we may want
> to bring all function devices (hid, printer etc) under a unified usb
> gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc..
>
> Also I think it make sense to add this state attribute to the configfs
> usb gadget itself i.e. have something like /config/usb_gadget/g1/state
> to read USB gadget's current state. Since it is going to be consistent
> throughout all the functions tied up to that gadget.
>
> Again this is just an initial RFC, thoughts and feedback would be
> greatly appreciated.
>
> Cc: Mike Lockwood<lockwood@android.com>
> Cc: Benoit Goby<benoit@android.com>
> Cc: Colin Cross<ccross@android.com>
> Cc: Arve Hjønnevåg<arve@android.com>
> Cc: Peter Oh<poh@broadcom.com>
> Cc: Greg Hackmann<ghackmann@google.com>
> Cc: Badhri Jagan Sridharan<Badhri@google.com>
> Cc: Android Kernel Team<kernel-team@android.com>
> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
> Cc: Jonathan Corbet<corbet@lwn.net>
> Cc: Felipe Balbi<balbi@ti.com>
> Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
> Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
> Cc: Yegor Yefremov<yegorslists@googlemail.com>
> Cc: Philippe Reynes<tremyfr@gmail.com>
> Cc: John Stultz<john.stultz@linaro.org>
> Cc: Sumit Semwal<sumit.semwal@linaro.org>
> Signed-off-by: Amit Pundir<amit.pundir@linaro.org>

Generally I agree that there should be some way of notifying userspace 
about gadget state but I'm not sure if this is proper way to go. In my 
opinion gadget-bus which has been discussed some time ago on linux-usb 
makes much more sense than this.

Maybe I will be wrong but I guess that you are adding this feature to 
make android mtp-responder working properly in Linux (not android). 
Again if we use FFS instead of adding mtp function we don't need this 
notification as mtp-responder can get all the required informations 
about gadget (function) via ep0 using functionfs events.

Best regards,

-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207203 — Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes

FromFelipe Balbi <balbi@ti.com>
Date2015-08-14 00:10 +0200
SubjectRe: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes
Message-ID<pX8Rc-7Xe-9@gated-at.bofh.it>
In reply to#1207136

[Multipart message — attachments visible in raw view] — view raw

Hi,

On Thu, Aug 13, 2015 at 09:42:17PM +0200, Krzysztof Opasiak wrote:
> Hello,
> 
> On 08/13/2015 09:12 PM, Amit Pundir wrote:
> >This is more of an RFC than an actual submission. There are few
> >scattered #ifdefs..#endifs here and there which still need to be
> >taken care of before going for actual submission.
> >
> >Currently there is no way with the upstream ConfigFS gadget to
> >communicate state changes (connected, disconnected, configured), at
> >the gadget level. Instead such state changes are handled function by
> >function independently I presume. This is problematic, because some
> >coordination between the functions, across the state changes, may be
> >desired at the userspace level. Thus to address this issue, this
> >patch send uevents to allow userspace to be notified of these usb
> >state changes, allowing userspace to respond and configure the
> >configfs gadget appropriately.
> >
> >This patch is based on an Android patchset originaly authored by
> >Badhri Jagan Sridharan<Badhri@google.com>  to send uevent notifications
> >to Android userpace for USB state changes. I've folded his patches
> >together and modified it enough that I don't want him to be blamed for
> >any mistakes I've made condensing his patches down.
> >
> >This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace
> >notifications of usb state changes, and add setup and disconnect
> >functions to intercept the setup requests from the usb_core. It also
> >creates a sysfs device class entry and a device attribute (state) to
> >read and respond to gadget's current state from userspace. As of now
> >this sysfs device class (/sys/class/android_usb) and gadget device
> >(/sys/class/android_usb/android0) with state attribute
> >(/sys/class/android_usb/android0/state) are strictly tied up to
> >facilitate Android userspace requests. But going forward we may want
> >to bring all function devices (hid, printer etc) under a unified usb
> >gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc..
> >
> >Also I think it make sense to add this state attribute to the configfs
> >usb gadget itself i.e. have something like /config/usb_gadget/g1/state
> >to read USB gadget's current state. Since it is going to be consistent
> >throughout all the functions tied up to that gadget.
> >
> >Again this is just an initial RFC, thoughts and feedback would be
> >greatly appreciated.
> >
> >Cc: Mike Lockwood<lockwood@android.com>
> >Cc: Benoit Goby<benoit@android.com>
> >Cc: Colin Cross<ccross@android.com>
> >Cc: Arve Hjønnevåg<arve@android.com>
> >Cc: Peter Oh<poh@broadcom.com>
> >Cc: Greg Hackmann<ghackmann@google.com>
> >Cc: Badhri Jagan Sridharan<Badhri@google.com>
> >Cc: Android Kernel Team<kernel-team@android.com>
> >Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
> >Cc: Jonathan Corbet<corbet@lwn.net>
> >Cc: Felipe Balbi<balbi@ti.com>
> >Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
> >Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
> >Cc: Yegor Yefremov<yegorslists@googlemail.com>
> >Cc: Philippe Reynes<tremyfr@gmail.com>
> >Cc: John Stultz<john.stultz@linaro.org>
> >Cc: Sumit Semwal<sumit.semwal@linaro.org>
> >Signed-off-by: Amit Pundir<amit.pundir@linaro.org>
> 
> Generally I agree that there should be some way of notifying userspace about

yes, and we already have a sysfs file for that. See udc-core.c:

static void usb_gadget_state_work(struct work_struct *work)
{
	struct usb_gadget *gadget = work_to_gadget(work);
	struct usb_udc *udc = gadget->udc;

	if (udc)
		sysfs_notify(&udc->dev.kobj, NULL, "state");
}

void usb_gadget_set_state(struct usb_gadget *gadget,
		enum usb_device_state state)
{
	gadget->state = state;
	schedule_work(&gadget->work);
}
EXPORT_SYMBOL_GPL(usb_gadget_set_state);

If it's not working for any UDC, it just means the UDC needs to be
patched and if we're missing any state, it means that either the UDC
can't provide that IRQ, or we need to add more states to that
enumeration (which I find unlikely).

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1207112 — Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2015-08-13 21:40 +0200
SubjectRe: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function
Message-ID<pX6w2-4uZ-1@gated-at.bofh.it>
In reply to#1207087
Hello,

On 08/13/2015 09:12 PM, Amit Pundir wrote:
> his MTP function is based on years of work originally done in the
> Android kernel tree by:
>      Mike Lockwood<lockwood@android.com>
>      Benoit Goby<benoit@android.com>
>      Colin Cross<ccross@android.com>
>      Arve Hjønnevåg<arve@android.com>
>      Peter Oh<poh@broadcom.com>
>      Greg Hackmann<ghackmann@google.com>
>      Badhri Jagan Sridharan<Badhri@google.com>
> I've folded the series up to make it easier to review, and to provide
> a coherent patch description.
>
> Post Gingerbread (Android v2.3), Android dropped USB Mass Storage
> in favor of Media Transfer Protocal (MTP), which is widely used for
> transferring media files to digital music players and similar
> applications. This USB gadget function implements MTP functionalty.
>
> Historically this function has been a part of Android composite
> gadget driver. Android composite driver was Android's solution
> for dynamic gadget function switching prior to the ConfigFS gadget
> being merged. There were failed few attempts in past
> http://marc.info/?l=linux-usb&m=132451695808552  to upstream Android
> composite driver as well. Now this Android MTP gadget function has been
> re-implemented so as to be used as a generic ConfigFS function instead.
>
> Again, many thanks to Mike, Benoit, Colin, Arve, Peter, Greg and Badhri,
> as they are the real authors of this work. However, I've folded their
> patches together and modified it enough that I don't want them to be
> blamed for any mistakes I've made condensing their patches down.
>
> Cc: Mike Lockwood<lockwood@android.com>
> Cc: Benoit Goby<benoit@android.com>
> Cc: Colin Cross<ccross@android.com>
> Cc: Arve Hjønnevåg<arve@android.com>
> Cc: Peter Oh<poh@broadcom.com>
> Cc: Greg Hackmann<ghackmann@google.com>
> Cc: Badhri Jagan Sridharan<Badhri@google.com>
> Cc: Android Kernel Team<kernel-team@android.com>
> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
> Cc: Jonathan Corbet<corbet@lwn.net>
> Cc: Felipe Balbi<balbi@ti.com>
> Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
> Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
> Cc: Yegor Yefremov<yegorslists@googlemail.com>
> Cc: Philippe Reynes<tremyfr@gmail.com>
> Cc: John Stultz<john.stultz@linaro.org>
> Cc: Sumit Semwal<sumit.semwal@linaro.org>
> Signed-off-by: Amit Pundir<amit.pundir@linaro.org>

In my humble opinion adding such function to Linux kernel doesn't make 
any sense. By design, MTP is a protocol which requires access to 
userspace features esp. file system. It is very important to run MTP 
daemon with suitable user and LSM label and many many other issues which 
should be handled by userspace access policy.

Moreover this is not a fully functional USB function but only some 
interface which can be used by mtp-responder (mtp-daemon - call it as 
you like) to communicate with host. As we have FunctionFS which allows 
to implement any USB function in as a userspace service. As MTP nature 
is more related to userspace I think that porting MTP daemon to use this 
is a right way to go. This should be much more reasonable than adding 
new function which also requires daemon for proper working. So why add 
another interface while we can use a generic one?

Best regards,
-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207140 — Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2015-08-13 22:00 +0200
SubjectRe: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function
Message-ID<pX6Po-4SL-19@gated-at.bofh.it>
In reply to#1207112
On Thu, Aug 13, 2015 at 09:34:46PM +0200, Krzysztof Opasiak wrote:
> Hello,
> 
> On 08/13/2015 09:12 PM, Amit Pundir wrote:
> >his MTP function is based on years of work originally done in the
> >Android kernel tree by:
> >     Mike Lockwood<lockwood@android.com>
> >     Benoit Goby<benoit@android.com>
> >     Colin Cross<ccross@android.com>
> >     Arve Hjønnevåg<arve@android.com>
> >     Peter Oh<poh@broadcom.com>
> >     Greg Hackmann<ghackmann@google.com>
> >     Badhri Jagan Sridharan<Badhri@google.com>
> >I've folded the series up to make it easier to review, and to provide
> >a coherent patch description.
> >
> >Post Gingerbread (Android v2.3), Android dropped USB Mass Storage
> >in favor of Media Transfer Protocal (MTP), which is widely used for
> >transferring media files to digital music players and similar
> >applications. This USB gadget function implements MTP functionalty.
> >
> >Historically this function has been a part of Android composite
> >gadget driver. Android composite driver was Android's solution
> >for dynamic gadget function switching prior to the ConfigFS gadget
> >being merged. There were failed few attempts in past
> >http://marc.info/?l=linux-usb&m=132451695808552  to upstream Android
> >composite driver as well. Now this Android MTP gadget function has been
> >re-implemented so as to be used as a generic ConfigFS function instead.
> >
> >Again, many thanks to Mike, Benoit, Colin, Arve, Peter, Greg and Badhri,
> >as they are the real authors of this work. However, I've folded their
> >patches together and modified it enough that I don't want them to be
> >blamed for any mistakes I've made condensing their patches down.
> >
> >Cc: Mike Lockwood<lockwood@android.com>
> >Cc: Benoit Goby<benoit@android.com>
> >Cc: Colin Cross<ccross@android.com>
> >Cc: Arve Hjønnevåg<arve@android.com>
> >Cc: Peter Oh<poh@broadcom.com>
> >Cc: Greg Hackmann<ghackmann@google.com>
> >Cc: Badhri Jagan Sridharan<Badhri@google.com>
> >Cc: Android Kernel Team<kernel-team@android.com>
> >Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
> >Cc: Jonathan Corbet<corbet@lwn.net>
> >Cc: Felipe Balbi<balbi@ti.com>
> >Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
> >Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
> >Cc: Yegor Yefremov<yegorslists@googlemail.com>
> >Cc: Philippe Reynes<tremyfr@gmail.com>
> >Cc: John Stultz<john.stultz@linaro.org>
> >Cc: Sumit Semwal<sumit.semwal@linaro.org>
> >Signed-off-by: Amit Pundir<amit.pundir@linaro.org>
> 
> In my humble opinion adding such function to Linux kernel doesn't make any
> sense. By design, MTP is a protocol which requires access to userspace
> features esp. file system. It is very important to run MTP daemon with
> suitable user and LSM label and many many other issues which should be
> handled by userspace access policy.
> 
> Moreover this is not a fully functional USB function but only some interface
> which can be used by mtp-responder (mtp-daemon - call it as you like) to
> communicate with host. As we have FunctionFS which allows to implement any
> USB function in as a userspace service. As MTP nature is more related to
> userspace I think that porting MTP daemon to use this is a right way to go.
> This should be much more reasonable than adding new function which also
> requires daemon for proper working. So why add another interface while we
> can use a generic one?

Isn't there already a userspace MTP daemon that uses the existing
functionfs for usb gadgets?  I thought I remember seeing that
somewhere...

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207150 — Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2015-08-13 22:30 +0200
SubjectRe: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function
Message-ID<pX7ip-5FI-1@gated-at.bofh.it>
In reply to#1207140

On 08/13/2015 09:57 PM, Greg Kroah-Hartman wrote:
> On Thu, Aug 13, 2015 at 09:34:46PM +0200, Krzysztof Opasiak wrote:
>> Hello,
>>
>> On 08/13/2015 09:12 PM, Amit Pundir wrote:
>>> his MTP function is based on years of work originally done in the
>>> Android kernel tree by:
>>>      Mike Lockwood<lockwood@android.com>
>>>      Benoit Goby<benoit@android.com>
>>>      Colin Cross<ccross@android.com>
>>>      Arve Hjønnevåg<arve@android.com>
>>>      Peter Oh<poh@broadcom.com>
>>>      Greg Hackmann<ghackmann@google.com>
>>>      Badhri Jagan Sridharan<Badhri@google.com>
>>> I've folded the series up to make it easier to review, and to provide
>>> a coherent patch description.
>>>
>>> Post Gingerbread (Android v2.3), Android dropped USB Mass Storage
>>> in favor of Media Transfer Protocal (MTP), which is widely used for
>>> transferring media files to digital music players and similar
>>> applications. This USB gadget function implements MTP functionalty.
>>>
>>> Historically this function has been a part of Android composite
>>> gadget driver. Android composite driver was Android's solution
>>> for dynamic gadget function switching prior to the ConfigFS gadget
>>> being merged. There were failed few attempts in past
>>> http://marc.info/?l=linux-usb&m=132451695808552  to upstream Android
>>> composite driver as well. Now this Android MTP gadget function has been
>>> re-implemented so as to be used as a generic ConfigFS function instead.
>>>
>>> Again, many thanks to Mike, Benoit, Colin, Arve, Peter, Greg and Badhri,
>>> as they are the real authors of this work. However, I've folded their
>>> patches together and modified it enough that I don't want them to be
>>> blamed for any mistakes I've made condensing their patches down.
>>>
>>> Cc: Mike Lockwood<lockwood@android.com>
>>> Cc: Benoit Goby<benoit@android.com>
>>> Cc: Colin Cross<ccross@android.com>
>>> Cc: Arve Hjønnevåg<arve@android.com>
>>> Cc: Peter Oh<poh@broadcom.com>
>>> Cc: Greg Hackmann<ghackmann@google.com>
>>> Cc: Badhri Jagan Sridharan<Badhri@google.com>
>>> Cc: Android Kernel Team<kernel-team@android.com>
>>> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
>>> Cc: Jonathan Corbet<corbet@lwn.net>
>>> Cc: Felipe Balbi<balbi@ti.com>
>>> Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
>>> Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
>>> Cc: Yegor Yefremov<yegorslists@googlemail.com>
>>> Cc: Philippe Reynes<tremyfr@gmail.com>
>>> Cc: John Stultz<john.stultz@linaro.org>
>>> Cc: Sumit Semwal<sumit.semwal@linaro.org>
>>> Signed-off-by: Amit Pundir<amit.pundir@linaro.org>
>>
>> In my humble opinion adding such function to Linux kernel doesn't make any
>> sense. By design, MTP is a protocol which requires access to userspace
>> features esp. file system. It is very important to run MTP daemon with
>> suitable user and LSM label and many many other issues which should be
>> handled by userspace access policy.
>>
>> Moreover this is not a fully functional USB function but only some interface
>> which can be used by mtp-responder (mtp-daemon - call it as you like) to
>> communicate with host. As we have FunctionFS which allows to implement any
>> USB function in as a userspace service. As MTP nature is more related to
>> userspace I think that porting MTP daemon to use this is a right way to go.
>> This should be much more reasonable than adding new function which also
>> requires daemon for proper working. So why add another interface while we
>> can use a generic one?
>
> Isn't there already a userspace MTP daemon that uses the existing
> functionfs for usb gadgets?  I thought I remember seeing that
> somewhere...
>

I know for sure that ADB and SDB has been ported to use functionfs. I 
can even see ADB with ffs backend working on my nexus 9 with 3.10 kernel.

I've seen such mtp-responder implementation but that time it has not 
been published to open source. I don't know what is the current state...

Best regards,

-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207159 — Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function

FromKrzysztof Opasiak <k.opasiak@samsung.com>
Date2015-08-13 22:50 +0200
SubjectRe: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function
Message-ID<pX7BM-62s-23@gated-at.bofh.it>
In reply to#1207140

On 08/13/2015 09:57 PM, Greg Kroah-Hartman wrote:
> On Thu, Aug 13, 2015 at 09:34:46PM +0200, Krzysztof Opasiak wrote:
>> Hello,
>>
>> On 08/13/2015 09:12 PM, Amit Pundir wrote:
>>> his MTP function is based on years of work originally done in the
>>> Android kernel tree by:
>>>      Mike Lockwood<lockwood@android.com>
>>>      Benoit Goby<benoit@android.com>
>>>      Colin Cross<ccross@android.com>
>>>      Arve Hjønnevåg<arve@android.com>
>>>      Peter Oh<poh@broadcom.com>
>>>      Greg Hackmann<ghackmann@google.com>
>>>      Badhri Jagan Sridharan<Badhri@google.com>
>>> I've folded the series up to make it easier to review, and to provide
>>> a coherent patch description.
>>>
>>> Post Gingerbread (Android v2.3), Android dropped USB Mass Storage
>>> in favor of Media Transfer Protocal (MTP), which is widely used for
>>> transferring media files to digital music players and similar
>>> applications. This USB gadget function implements MTP functionalty.
>>>
>>> Historically this function has been a part of Android composite
>>> gadget driver. Android composite driver was Android's solution
>>> for dynamic gadget function switching prior to the ConfigFS gadget
>>> being merged. There were failed few attempts in past
>>> http://marc.info/?l=linux-usb&m=132451695808552  to upstream Android
>>> composite driver as well. Now this Android MTP gadget function has been
>>> re-implemented so as to be used as a generic ConfigFS function instead.
>>>
>>> Again, many thanks to Mike, Benoit, Colin, Arve, Peter, Greg and Badhri,
>>> as they are the real authors of this work. However, I've folded their
>>> patches together and modified it enough that I don't want them to be
>>> blamed for any mistakes I've made condensing their patches down.
>>>
>>> Cc: Mike Lockwood<lockwood@android.com>
>>> Cc: Benoit Goby<benoit@android.com>
>>> Cc: Colin Cross<ccross@android.com>
>>> Cc: Arve Hjønnevåg<arve@android.com>
>>> Cc: Peter Oh<poh@broadcom.com>
>>> Cc: Greg Hackmann<ghackmann@google.com>
>>> Cc: Badhri Jagan Sridharan<Badhri@google.com>
>>> Cc: Android Kernel Team<kernel-team@android.com>
>>> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
>>> Cc: Jonathan Corbet<corbet@lwn.net>
>>> Cc: Felipe Balbi<balbi@ti.com>
>>> Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
>>> Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
>>> Cc: Yegor Yefremov<yegorslists@googlemail.com>
>>> Cc: Philippe Reynes<tremyfr@gmail.com>
>>> Cc: John Stultz<john.stultz@linaro.org>
>>> Cc: Sumit Semwal<sumit.semwal@linaro.org>
>>> Signed-off-by: Amit Pundir<amit.pundir@linaro.org>
>>
>> In my humble opinion adding such function to Linux kernel doesn't make any
>> sense. By design, MTP is a protocol which requires access to userspace
>> features esp. file system. It is very important to run MTP daemon with
>> suitable user and LSM label and many many other issues which should be
>> handled by userspace access policy.
>>
>> Moreover this is not a fully functional USB function but only some interface
>> which can be used by mtp-responder (mtp-daemon - call it as you like) to
>> communicate with host. As we have FunctionFS which allows to implement any
>> USB function in as a userspace service. As MTP nature is more related to
>> userspace I think that porting MTP daemon to use this is a right way to go.
>> This should be much more reasonable than adding new function which also
>> requires daemon for proper working. So why add another interface while we
>> can use a generic one?
>
> Isn't there already a userspace MTP daemon that uses the existing
> functionfs for usb gadgets?  I thought I remember seeing that
> somewhere...
>

I've found some interesting link[2] which may mean that Sailfish OS guys 
has some mtp implementation with functionfs backend:

<<<<< cite

- /dev/mtp
mtp functionfs rw,relatime

 >>>>> cite

Started digging and got it!

This looks like mtp with ffs backend:

https://github.com/nemomobile/buteo-mtp

Didn't tested, even didn't try to compile, no guarantee;)

Footnotes:
1 - 
http://reviewjolla.blogspot.com/2014/06/techspecs-android-on-jolla-phone.html

Best regards,

-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1207454 — Re: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function

FromAmit Pundir <amit.pundir@linaro.org>
Date2015-08-14 12:00 +0200
SubjectRe: [RFC][PATCH 1/2] usb: gadget: configfs: add MTP function
Message-ID<pXjWi-6VE-1@gated-at.bofh.it>
In reply to#1207159
On 14 August 2015 at 02:11, Krzysztof Opasiak <k.opasiak@samsung.com> wrote:
>
>
> On 08/13/2015 09:57 PM, Greg Kroah-Hartman wrote:
>>
>> On Thu, Aug 13, 2015 at 09:34:46PM +0200, Krzysztof Opasiak wrote:
>>>
>>> Hello,
>>>
>>> On 08/13/2015 09:12 PM, Amit Pundir wrote:
>>>>
>>>> his MTP function is based on years of work originally done in the
>>>> Android kernel tree by:
>>>>      Mike Lockwood<lockwood@android.com>
>>>>      Benoit Goby<benoit@android.com>
>>>>      Colin Cross<ccross@android.com>
>>>>      Arve Hjønnevåg<arve@android.com>
>>>>      Peter Oh<poh@broadcom.com>
>>>>      Greg Hackmann<ghackmann@google.com>
>>>>      Badhri Jagan Sridharan<Badhri@google.com>
>>>> I've folded the series up to make it easier to review, and to provide
>>>> a coherent patch description.
>>>>
>>>> Post Gingerbread (Android v2.3), Android dropped USB Mass Storage
>>>> in favor of Media Transfer Protocal (MTP), which is widely used for
>>>> transferring media files to digital music players and similar
>>>> applications. This USB gadget function implements MTP functionalty.
>>>>
>>>> Historically this function has been a part of Android composite
>>>> gadget driver. Android composite driver was Android's solution
>>>> for dynamic gadget function switching prior to the ConfigFS gadget
>>>> being merged. There were failed few attempts in past
>>>> http://marc.info/?l=linux-usb&m=132451695808552  to upstream Android
>>>> composite driver as well. Now this Android MTP gadget function has been
>>>> re-implemented so as to be used as a generic ConfigFS function instead.
>>>>
>>>> Again, many thanks to Mike, Benoit, Colin, Arve, Peter, Greg and Badhri,
>>>> as they are the real authors of this work. However, I've folded their
>>>> patches together and modified it enough that I don't want them to be
>>>> blamed for any mistakes I've made condensing their patches down.
>>>>
>>>> Cc: Mike Lockwood<lockwood@android.com>
>>>> Cc: Benoit Goby<benoit@android.com>
>>>> Cc: Colin Cross<ccross@android.com>
>>>> Cc: Arve Hjønnevåg<arve@android.com>
>>>> Cc: Peter Oh<poh@broadcom.com>
>>>> Cc: Greg Hackmann<ghackmann@google.com>
>>>> Cc: Badhri Jagan Sridharan<Badhri@google.com>
>>>> Cc: Android Kernel Team<kernel-team@android.com>
>>>> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
>>>> Cc: Jonathan Corbet<corbet@lwn.net>
>>>> Cc: Felipe Balbi<balbi@ti.com>
>>>> Cc: Andrzej Pietrasiewicz<andrzej.p@samsung.com>
>>>> Cc: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
>>>> Cc: Yegor Yefremov<yegorslists@googlemail.com>
>>>> Cc: Philippe Reynes<tremyfr@gmail.com>
>>>> Cc: John Stultz<john.stultz@linaro.org>
>>>> Cc: Sumit Semwal<sumit.semwal@linaro.org>
>>>> Signed-off-by: Amit Pundir<amit.pundir@linaro.org>
>>>
>>>
>>> In my humble opinion adding such function to Linux kernel doesn't make
>>> any
>>> sense. By design, MTP is a protocol which requires access to userspace
>>> features esp. file system. It is very important to run MTP daemon with
>>> suitable user and LSM label and many many other issues which should be
>>> handled by userspace access policy.
>>>
>>> Moreover this is not a fully functional USB function but only some
>>> interface
>>> which can be used by mtp-responder (mtp-daemon - call it as you like) to
>>> communicate with host. As we have FunctionFS which allows to implement
>>> any
>>> USB function in as a userspace service. As MTP nature is more related to
>>> userspace I think that porting MTP daemon to use this is a right way to
>>> go.
>>> This should be much more reasonable than adding new function which also
>>> requires daemon for proper working. So why add another interface while we
>>> can use a generic one?

Fairly valid point. I did see MTP mentioned in FunctionFS context in
Documentation/usb/functionfs.txt but I could not find an open
userpsace MTP daemon implementation based on F_FS to try.

>>
>>
>> Isn't there already a userspace MTP daemon that uses the existing
>> functionfs for usb gadgets?  I thought I remember seeing that
>> somewhere...
>>
>
> I've found some interesting link[2] which may mean that Sailfish OS guys has
> some mtp implementation with functionfs backend:
>
> <<<<< cite
>
> - /dev/mtp
> mtp functionfs rw,relatime
>
>>>>>> cite
>
> Started digging and got it!
>
> This looks like mtp with ffs backend:
>
> https://github.com/nemomobile/buteo-mtp

Thanks for the pointer. This "buteo-mtp" looks interesting.

Regards,
Amit Pundir

>
> Didn't tested, even didn't try to compile, no guarantee;)
>
> Footnotes:
> 1 -
> http://reviewjolla.blogspot.com/2014/06/techspecs-android-on-jolla-phone.html
>
>
> Best regards,
>
> --
> Krzysztof Opasiak
> Samsung R&D Institute Poland
> Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web