From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout1.w1.samsung.com ([210.118.77.11]:62841 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753799AbbIXRK6 (ORCPT ); Thu, 24 Sep 2015 13:10:58 -0400 Subject: Re: [PATCH v3 1/2] usb: gadget: loopback: fix: Don't share qlen and buflen between instances To: balbi@ti.com, Robert Baldyga References: <1442947223-13277-1-git-send-email-k.opasiak@samsung.com> <56041470.70306@samsung.com> <20150924165136.GF14151@saruman.tx.rr.com> Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, andrzej.p@samsung.com, stable@vger.kernel.org From: Krzysztof Opasiak Message-id: <56042E9D.5040408@samsung.com> Date: Thu, 24 Sep 2015 19:10:53 +0200 MIME-version: 1.0 In-reply-to: <20150924165136.GF14151@saruman.tx.rr.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 09/24/2015 06:51 PM, Felipe Balbi wrote: > On Thu, Sep 24, 2015 at 05:19:12PM +0200, Robert Baldyga wrote: >> On 09/22/2015 08:40 PM, Krzysztof Opasiak wrote: >>> Each instance of loopback function may have different qlen >>> and buflen attributes values. When linking function to >>> configuration those values had been assigned to global >>> variables. Linking other instance to config overwrites those >>> values. >>> >>> This commit moves those values to f_loopback structure >>> to avoid overwriting. Now each function has its own instance >>> of those values. >>> >>> Cc: # 3.10+ >>> Signed-off-by: Krzysztof Opasiak >> >> Reviewed-by: Robert Baldyga > > doesn't seem to fit stable IMO. Care to explain why you think we need > to backport this to v3.10+ ? > Let's consider following set of commands: cd $CFS_ROOT/usb_gadget mkdir g1 cd g1 mkdir functions/SourceSink.1 mkdir functions/SourceSink.2 echo 1024 > functions/SourceSink.1/buflen echo 512 > functions/SourceSink.2/buflen mkdir configs/c.1 ln -s functions/SourceSink.1 configs/c.1/ ln -s functions/SourceSink.2 configs/c.1/ echo $UDC > UDC You assume that after executing this script you will get two instances of SourceSink functions and one of them will alloc requests buffers which has 1024 and second one which has only 512. Unfortunately due to using global variables both of them are going to alloc only 512 bytes for each request. The same situation is with qlen. All instances are going to use attributes values from the last one in the system, even if they are in multiple gadgets. In my opinion second patch in this series is much more important as it makes loopback function working again after almost year of being only /dev/null and /dev/zero. But that one should to go only to 3.18. Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics