Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp858868pxb; Fri, 22 Apr 2022 12:48:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzErJzqaBC5EFlEKDG06eGrhTxTwIHQEnYmxz7rOY1mQppTNH5WdpLoJxHlJlW7HoIyJ4ti X-Received: by 2002:a63:df0f:0:b0:3aa:436f:8784 with SMTP id u15-20020a63df0f000000b003aa436f8784mr5258717pgg.514.1650656927085; Fri, 22 Apr 2022 12:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650656927; cv=none; d=google.com; s=arc-20160816; b=b0RK02YQpYvbwmRcMuvvwKs1/+RM9UqdqRd27DFxxZWlb6a3dVy7ttcOj5Fz/omQrR eUZZDh4Jsi09D0GeePl+xknNMjcAPRVtboh5qZAZo5vYh9UZFGubv2Y8ZGYhUhkakEwS 4mml8hW5fS2BcjqnZ85Rs/uVXG3HVKBrGUySHEL7wCpZ8vLa7srloUNKVY+GWzWGhDsp H/ytogVijvX0F8tpNIX79Sv1GNF33Of73XiveXvh4ojRZ6qQU2vwJ7RoBeBGmG9ZAd50 PEnyqH7pW3KgroBdhx89b8mAzL30Gw4xe0pXVZceZ952UVyDZnDcZfZmhslc3zS/3U2M LXpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iJzr6qxKhUCJVpWoaD5qEOjsPT5SF4o7wU409r6zRH8=; b=MNJ8NGPklosz39h/BZc3Pv0GHOQHDObqmNa8RpqL+tN/RRm2sDYSwSdLgUEGOjNbcb z90f0GAmf5e3aGsRRTbmUbmC4iq/CJ/gk1QISnTLy0nWVXExl/Fdgco37fbcP6XDnLEa 4k3UYieGMuq+xhNLLHeBxfiW+cBm5bceMe+4OaUpptLEfatY5ruF8hm6jUBtCNTRFLOf 6gOJtcLYdWQ6mTQc7CU61G2Rg8flhEGVYwk8qtRDhpheBS3M/RXfcS9HUV3oRCx+gtGt TncxXZueP3CGmgWczveZLMjHpPRD4beJEq8hKS9RqNKRuj/GSsW8tWqAtNj8HgG+L9lm 3ymg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="f/9iyE+z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 14-20020a63104e000000b003aa38af0e3fsi8709864pgq.234.2022.04.22.12.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:48:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="f/9iyE+z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 864AE212392; Fri, 22 Apr 2022 11:50:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444911AbiDVHj5 (ORCPT + 99 others); Fri, 22 Apr 2022 03:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238383AbiDVHjz (ORCPT ); Fri, 22 Apr 2022 03:39:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9EC5133A; Fri, 22 Apr 2022 00:37:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E136BB82ABF; Fri, 22 Apr 2022 07:37:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D39C385A0; Fri, 22 Apr 2022 07:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650613019; bh=/UjuOtx9fL0nf2WxyJQGshyyvuSlNPOux43de6wbbNY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f/9iyE+zfp6xwVYLA485y+zz3vvb9m50NtEtqvvOHdtmk1Nk/oLzPt5Tu1nAaO7xD zPD+jz0GmkAb+Lh1EpAapRE0hegNBpuNBiLIVk2dimikjwyGoovqOxUaQgPO0UsTON fWf0GM8AEFXXoMW77Y8pvYmMwEJC67FjKMBXKK84= Date: Fri, 22 Apr 2022 09:36:56 +0200 From: Greg KH To: Hongyu Xie Cc: johan@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hongyu Xie , stable@vger.kernel.org, "sheng . huang" , wangqi@kylinos.cn, xiongxin@kylinos.cn Subject: Re: [RESEND PATCH -next] USB: serial: pl2303: implement reset_resume member Message-ID: References: <20220419065408.2461091-1-xy521521@gmail.com> <99546b13-44f1-3dbf-aeb4-86c76ce74626@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99546b13-44f1-3dbf-aeb4-86c76ce74626@gmail.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 22, 2022 at 02:42:41PM +0800, Hongyu Xie wrote: > > Hi greg > On 2022/4/22 13:07, Greg KH wrote: > > On Fri, Apr 22, 2022 at 10:35:59AM +0800, Hongyu Xie wrote: > > > > > > Hi greg, > > > On 2022/4/22 00:45, Greg KH wrote: > > > > On Tue, Apr 19, 2022 at 02:54:08PM +0800, Hongyu Xie wrote: > > > > > From: Hongyu Xie > > > > > > > > > > pl2303.c doesn't have reset_resume for hibernation. > > > > > So needs_binding will be set to 1 duiring hibernation. > > > > > usb_forced_unbind_intf will be called, and the port minor > > > > > will be released (x in ttyUSBx). > > > > > > > > Please use the full 72 columns that you are allowed in a changelog text. > > > > > > > > > > > > > It works fine if you have only one USB-to-serial device. > > > > > Assume you have 2 USB-to-serial device, nameing A and B. > > > > > A gets a smaller minor(ttyUSB0), B gets a bigger one. > > > > > And start to hibernate. When your PC is in hibernation, > > > > > unplug device A. Then wake up your PC by pressing the > > > > > power button. After waking up the whole system, device > > > > > B gets ttyUSB0. This will casuse a problem if you were > > > > > using those to ports(like opened two minicom process) > > > > > before hibernation. > > > > > So member reset_resume is needed in usb_serial_driver > > > > > pl2303_device. > > > > > > > > If you want persistent device naming, use the symlinks that udev creates > > > > for your for all your serial devices. Never rely on the number of a USB > > > > to serial device. > > > Let me put it this way. Assume you need to record messages output from two > > > machines using 2 USB-to-serial devices(naming A and B, and A is on > > > USB1-port3, B is on USB1-port4) opened by two minicom process. > > > The setting for A in minicom would be like: > > > "A - Serial Device : /dev/ttyUSB0" > > > The setting for B in minicom would be like: > > > "A - Serial Device : /dev/ttyUSB1" > > > Then start to hibernate on your computer. When your PC is in > > > hibernation, unplug A. After waking up your computer, "/dev/ttyUSB0" > > > would be released first, then allocated to B. The minicom process used > > > to record outputs from A is now recording B's outputs. The minicom > > > process used to record outputs from B is now recording nothing, because > > > "/dev/ttyUSB1" is not exist anymore. That's the problem I've been > > > talking about. And I don't think using symlinks will solve this problem. > > > > Yes, symlinks will solve the issue, that is what they are there for. > > Look in /dev/serial/ for a persistent name for them that allows you to > > uniquely open the correct device if they can be described. Using > > /dev/ttyUSBX is almost never the correct thing to do. > Thanks for letting me know this. This patch is useless. It's not useless, I'm just saying that you should not be relying on ttyUSBX nodes to ever be persistent. > I still have one > more question though, since using /dev/ttyUSBX is almost never the correct > thing to do, what is /dev/ttyUSBx used for then? That is the name that the kernel gives them, as it has to pick something. Same for all kernel device names, the persistence rules live in userspace, not in the kernel. Now if this is a valid feature or not for the driver that's a totally different question that I will let Johan review. I was just pointing out a way for you to resolve your issue today without any kernel changes needed at all. thanks, greg k-h