From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbcESCyT (ORCPT ); Wed, 18 May 2016 22:54:19 -0400 Received: from mga14.intel.com ([192.55.52.115]:7843 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751420AbcESCyS (ORCPT ); Wed, 18 May 2016 22:54:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,332,1459839600"; d="scan'208";a="106574969" From: "Du, Changbin" To: Michal Nazarewicz , Felipe Balbi , Alan Stern CC: Al Viro , "gregkh@linuxfoundation.org" , "rui.silva@linaro.org" , "k.opasiak@samsung.com" , "lars@metafoo.de" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] usb: gadget: f_fs: report error if excess data received Thread-Topic: [PATCH] usb: gadget: f_fs: report error if excess data received Thread-Index: AQHRq3BkOTyP65TD/EyOGR5aoZlhp5+zC1+AgAGg+eD//6xsgIAAiP0A//+GGYCAAIkPQP//j6UAABFEzND//4Z3AP//dChAgACe5AD//nhXAIACyeWAgACETwCABJ1TAIAAAugAgAACeYCAAGJkAP/++X8wAHG06AAAAQrhgAAHH5uA//6h6bA= Date: Thu, 19 May 2016 02:54:14 +0000 Message-ID: <0C18FE92A7765D4EB9EE5D38D86A563A05D30D7A@SHSMSX103.ccr.corp.intel.com> References: <87eg92p3cn.fsf@linux.intel.com> <87bn46p2gk.fsf@linux.intel.com> <0C18FE92A7765D4EB9EE5D38D86A563A05D30546@SHSMSX103.ccr.corp.intel.com> <878tz7zn7y.fsf@linux.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2QyOGUwZmMtZjcyZC00MWY1LThiZWQtM2Y2MmI2ODM1Njg0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ijd5R29IZlpWWWw2VjREdEJpdGdMekxhbm9PTm5BVGk2dERtcWJ0cFkrSW89In0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u4J2sZYP031709 > On Wed, May 18 2016, Felipe Balbi wrote: > > we've been through this before. This needs to be done at the gadget > > layer. Gadget driver can over-allocate ahead of time if > > gadget->quirk_ep_out_aligned_size is true, then we avoid memcpy() at > > the UDC driver level. > > Right, all right, so let’s look at it from a regular USB function point > of view. If a USB function allocates a request which is not aligned, > UDC will align the buffer and *drop* excess data. Seeing how ugly > Do you mean UDC driver align the buffer? I searched the code, currently only DWC3 needs buffer size to be aligned to MaxPacketSize on ep out. And the align is done in f_fs driver. > f_fs’s code is becoming, I’m now leaning to letting to f_fs do the same > thing: if user space makes an unaligned read, f_fs aligns the buffer and > then drops excess data. > > Any arguments for f_fs to not drop the data apply to UDC, so they should > behave identically. > I'd prefer fail the request at all, and it is better done in HW. Because per the USB Spec that device can return NAK if a function was unable to accept data >>From the host. the DWC3 has not been design as this, if software fail the transfer, it is a little weird for host. So, now we have 3 choices: 1) buffer the excess data 2) fail the transfer 3) drop the excess data, then print an warning message Which one do you prefer? > -- > Best regards > ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ > «If at first you don’t succeed, give up skydiving» Best Regards, Du, Changbin