Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2399860imu; Thu, 24 Jan 2019 12:06:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mH4D+Q1Uq4oC3tGbLTx9Dz0v0PAVlYw4s3fnVjbxQ+g20JhL/GigwLC/Ihm5ULC0npwjR X-Received: by 2002:a63:e80e:: with SMTP id s14mr7216823pgh.30.1548360393801; Thu, 24 Jan 2019 12:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360393; cv=none; d=google.com; s=arc-20160816; b=XHsQbOxWYaB4RdWyK4/8QRjm6J/Ob7YURdE57g76cyoP6Lkz4M3XeJYFEgCG6cK0il AS5Etkq73gcm4iJ7QfM7aqxXZMi2o5HUqe/ydL6zYD6TSzwgKUIijiRo7iF2x2z5wUqM InqHkkuuPGofd0ds4VpZkoJckjr2Jpmmppu4XsdCUtE+gGAa0dhgKQKariQoRclXncTr nYTgmahT7yZHXWRugP02P5i5IDutVD9oObCS7cwzBhdEtJoMnOnEyfs7hqQc/oYtnAfO Dp+lENdduxxV44rRotWAywb50tHxJtdFZuOpwxeBXo+PwE8nxYTUVZM5muSYBzAqskEz I6sw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GaNOYo+rGDCdpyldTR9lX5gX34yT79wEzq98zpUkez0=; b=GpM7I+pG52WoM1Fc7ALYRmp58dvXqAQM8Xp1PvkSuR/TBjQSuTjZtvat5VXM3KmIkd cdGZdxn2xMJO3iStkQqI/nrWzZrM5VM4uZe8SSXJNzxXSb6wqdkQRY4iBgqoU8fjKm69 k7sDkupkbGF39iWLvWi1CbjzHnsvg5+JrG5x9T87IvEUq9ti/Bo052a3HORxssnW6VVV djzg8p27YIqx4+hTajmljzYAWdKoLs5+3NT5bP1YN9JUCWlXNYhoSQc5AR9Q/k5yq+MB 9nJ9WRUOaCI1TpRwrjl7XXX8QiNth62Jwi5q6pnni4VDuDOrk/3Wnuz2N27NIFXUj5cY +l9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ble6kXSt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z123si14408719pfc.97.2019.01.24.12.06.17; Thu, 24 Jan 2019 12:06:33 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ble6kXSt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731618AbfAXTb1 (ORCPT + 99 others); Thu, 24 Jan 2019 14:31:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:59140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731599AbfAXTbW (ORCPT ); Thu, 24 Jan 2019 14:31:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80C6B218E2; Thu, 24 Jan 2019 19:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358282; bh=9dDhT9r6HEB0KxcHsPIzfRpuVjw4Y9jsCO5JCoxXsRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ble6kXStVKUxeZj/8xvwS9Kyx8ViC3pTNMEH5H4sn1/1dEGyOL5DnB67p2zqPl8Xc cSCOUDKy6aBQw2uOVZJolF7w0S4yxLnOSl60M+/5DTFzSf7jAeQc7juuSVJbQFSgTx yOeA/fREbzivzAIgQuzqEK/LD6E3OFG8jG2B9jmI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kazuya Mizuguchi , Yoshihiro Shimoda , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 18/63] usb: gadget: udc: renesas_usb3: add a safety connection way for forced_b_device Date: Thu, 24 Jan 2019 20:20:07 +0100 Message-Id: <20190124190157.199035379@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190155.176570028@linuxfoundation.org> References: <20190124190155.176570028@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit ceb94bc52c437463f0903e61060a94a2226fb672 ] This patch adds a safety connection way for "forced_b_device" with "workaround_for_vbus" like below: < Example for R-Car E3 Ebisu > # modprobe # echo 1 > /sys/kernel/debug/ee020000.usb/b_device (connect a usb cable to host side.) # echo 2 > /sys/kernel/debug/ee020000.usb/b_device Previous code should have connected a usb cable before the "b_device" is set to 1 on the Ebisu board. However, if xHCI driver on the board is probed, it causes some troubles: - Conflicts USB VBUS/signals between the board and another host. - "Cannot enable. Maybe the USB cable is bad?" might happen on both the board and another host with a usb hub. - Cannot enumerate a usb gadget correctly because an interruption of VBUS change happens unexpectedly. Reported-by: Kazuya Mizuguchi Signed-off-by: Yoshihiro Shimoda Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/renesas_usb3.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index ade0723787e5..e5355ede2c46 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -352,6 +352,7 @@ struct renesas_usb3 { bool extcon_host; /* check id and set EXTCON_USB_HOST */ bool extcon_usb; /* check vbus and set EXTCON_USB */ bool forced_b_device; + bool start_to_connect; }; #define gadget_to_renesas_usb3(_gadget) \ @@ -470,7 +471,8 @@ static void usb3_init_axi_bridge(struct renesas_usb3 *usb3) static void usb3_init_epc_registers(struct renesas_usb3 *usb3) { usb3_write(usb3, ~0, USB3_USB_INT_STA_1); - usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); + if (!usb3->workaround_for_vbus) + usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); } static bool usb3_wakeup_usb2_phy(struct renesas_usb3 *usb3) @@ -676,8 +678,7 @@ static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev) usb3_set_mode(usb3, host); usb3_vbus_out(usb3, a_dev); /* for A-Peripheral or forced B-device mode */ - if ((!host && a_dev) || - (usb3->workaround_for_vbus && usb3->forced_b_device)) + if ((!host && a_dev) || usb3->start_to_connect) usb3_connect(usb3); spin_unlock_irqrestore(&usb3->lock, flags); } @@ -2369,7 +2370,11 @@ static ssize_t renesas_usb3_b_device_write(struct file *file, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) return -EFAULT; - if (!strncmp(buf, "1", 1)) + usb3->start_to_connect = false; + if (usb3->workaround_for_vbus && usb3->forced_b_device && + !strncmp(buf, "2", 1)) + usb3->start_to_connect = true; + else if (!strncmp(buf, "1", 1)) usb3->forced_b_device = true; else usb3->forced_b_device = false; @@ -2377,7 +2382,7 @@ static ssize_t renesas_usb3_b_device_write(struct file *file, if (usb3->workaround_for_vbus) usb3_disconnect(usb3); - /* Let this driver call usb3_connect() anyway */ + /* Let this driver call usb3_connect() if needed */ usb3_check_id(usb3); return count; -- 2.19.1