Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5086934yba; Wed, 8 May 2019 07:41:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJdHpkvcQWMC/Oz5pMoTFEKc4q99gjcjeEWfo0yXbR6fanVG9T2UC/5GQE912LILPFgB5p X-Received: by 2002:a65:5886:: with SMTP id d6mr47258749pgu.295.1557326511340; Wed, 08 May 2019 07:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557326511; cv=none; d=google.com; s=arc-20160816; b=BtsitarkY26XSEI5KeqGg3IvP8AVVEpGB/LaXzPsPkLJjAwYZR2EVjm4HR7WdiSZBl SEZQeMifJYhBflMuNW1kjkdD1Q/x1MUjZWyYPTQGaKrhxdHNYcn81D7y1Zn+HrNzBp9H b3MNTwVqpQ/4idACjDTunZzeiRc95E7Qn53YmE1GVFQP+zlwE/178ekI3AM7Jd+orQfO 73NsH4oXCa0WLXaqL+V9fiGfQvkd+lXvjXfM5OxcBSvnfbddRzXlevZFQvurUDNV8Vpy voPnzQo+pLRmO56Gv3dKRBJ6E/nZelXwJbOHIRwWCPQ1DrocB64uN7ThrQijmT73L2n+ WOvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=Jve98AO7qhRp0srSsDF4W+d6aNJW4pm2sPWZgNgiUJo=; b=U5Sh6jYtr9eF54YOEohPXEN15HIU+PSxRh6sdV202macwylIXU7lhZff22hEsFsm/f 3BHBIQIO4xMijQEKt5wDWZ86GDTmkamwIy3cl5TEO3A4/5jUsdWxNwEy7+2GnYFG2UrQ 7mtCCHsrP6nIvwSIXBB6/+0gWuIByg/eS0DScnk6kfSXQoUff7fdcTD6SoBSt58WBVVH Ebk1rBwYIW7z6/OD0Qed32yBsbmLkr6MsRxb2BNV4/2gYkOhyO9vGVU22AemtD/Pb+GX B424c1RQmVQgDaelGTcb45HfFAszb77/92KraKVnfKWETbn1HTaIiItnrNx5I8iOt0fa vvkQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si1674752pgv.146.2019.05.08.07.41.34; Wed, 08 May 2019 07:41:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbfEHMo1 (ORCPT + 99 others); Wed, 8 May 2019 08:44:27 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43470 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbfEHMo0 (ORCPT ); Wed, 8 May 2019 08:44:26 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 29F3D283978 From: Andrzej Pietrasiewicz Subject: Re: [REGRESSION] usb: gadget: f_fs: Allow scatter-gather buffers To: John Stultz , Felipe Balbi Cc: "Yang, Fei" , Bjorn Andersson , Chen Yu , lkml , Linux USB List , Amit Pundir , Marek Szyprowski , "kernel@collabora.com" References: Message-ID: <3b57eb64-4c25-4582-7b0d-59143060b5a5@collabora.com> Date: Wed, 8 May 2019 14:44:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, W dniu 08.05.2019 o 04:18, John Stultz pisze: > Since commit 772a7a724f69 ("usb: gadget: f_fs: Allow scatter-gather > buffers"), I've been seeing trouble with adb transfers in Android on > HiKey960, HiKey and now Dragonboard 845c. > > Sometimes things crash, but often the transfers just stop w/o any > obvious error messages. > > > Andrzej: Do you have any ideas or suggestions on this? I'm happy to > test or run any debug patches, if it would help narrow the issue down. > Can you please try the below patch? One more thing to consider is "functionfs read size 512 > requested size 24, splitting request into multiple reads." in your original report, but let's try this first: From f2b8f27cfa42cafe1f56d8abbe2c76fa0072e368 Mon Sep 17 00:00:00 2001 From: Andrzej Pietrasiewicz Date: Wed, 8 May 2019 13:52:40 +0200 Subject: [PATCH] usb: gadget: Zero ffs_io_data In some cases the "Allocate & copy" block in ffs_epfile_io() is not executed. Consequently, in such a case ffs_alloc_buffer() is never called and struct ffs_io_data is not initialized properly. This in turn leads to problems when ffs_free_buffer() is called at the end of ffs_epfile_io(). This patch uses kzalloc() instead of kmalloc() in the aio case and memset() in non-aio case to properly initialize struct ffs_io_data. Signed-off-by: Andrzej Pietrasiewicz --- drivers/usb/gadget/function/f_fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 47be961f1bf3..41d57ae8bc15 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1182,11 +1182,12 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from) ENTER(); if (!is_sync_kiocb(kiocb)) { - p = kmalloc(sizeof(io_data), GFP_KERNEL); + p = kzalloc(sizeof(io_data), GFP_KERNEL); if (unlikely(!p)) return -ENOMEM; p->aio = true; } else { + memset(p, 0, sizeof(*p)); p->aio = false; } @@ -1218,11 +1219,12 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to) ENTER(); if (!is_sync_kiocb(kiocb)) { - p = kmalloc(sizeof(io_data), GFP_KERNEL); + p = kzalloc(sizeof(io_data), GFP_KERNEL); if (unlikely(!p)) return -ENOMEM; p->aio = true; } else { + memset(p, 0, sizeof(*p)); p->aio = false; } -- 2.17.1