From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1c5USZ-0005rS-9U for mharc-grub-devel@gnu.org; Sat, 12 Nov 2016 04:18:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5USX-0005rJ-14 for grub-devel@gnu.org; Sat, 12 Nov 2016 04:18:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5UST-0003kX-Rw for grub-devel@gnu.org; Sat, 12 Nov 2016 04:18:49 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:33968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c5UST-0003jO-Jb for grub-devel@gnu.org; Sat, 12 Nov 2016 04:18:45 -0500 Received: by mail-lf0-x243.google.com with SMTP id o141so2802314lff.1 for ; Sat, 12 Nov 2016 01:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=V23vnJtNULrfSeQC+Fls6VUYa8W0N/KkDOYRv5Ii3Rc=; b=lH1Cx+NPYqh52V6cRY5Z4f+ckpO+GjTsSjC9a3mqBX2kzEeKY9+2CEtYkXjcaQ3cLF Ku/bhm9XhDKcAK2kltiyAfKsRK+H82Conuq0rPHla8PHFmMEd9VLqwyreUkIT4pyEicG /FCj4KZDYToWSCDQmj39JtWSVWGuJtInVxhuLon0G7x6EqHbiCQ1KVV5RVIoNcq5gAol WIGf5ZdGw5nKJM7TLIiA6Lw81pJEzfGYypmZ8FVQfl39N06Jhh3Lr6gu9vRYOaKXgAoG eK8S1RhmaYUquNb1OW6alkO4SX0JcrH61UR79DLFXt7nMnXTAe2yU9+jPw4ThjO1wpN9 bVyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=V23vnJtNULrfSeQC+Fls6VUYa8W0N/KkDOYRv5Ii3Rc=; b=Ss6pF5pFUfLfe1+2/WQ+8Zu5perd2Cu3JAHsC5CqYPyYcWvPmlXLofxqrjHZ//z+Is lx8QEctla35yOMNn48gm2u57OXiQIYCsZtBh+VFDAxoFgY+/fv60jqgmivwOhNbX/cJ8 HiCVA5aCOGhSuoae+Th72ykWdhZ1R/nZAZIMOJtUbsC0dq1UbE7CU7zkT3LK8zqfUfiq AIEebtY/VXRYrSIYBHGbpEb31vN7nJS0aQBRQRj1Ju0QB29lzwq8Va1PRmdh0PRFUawh Hl8H6/bo38jY/Is+pm7/TZUhiAu6+eZNX2JN9s9htQtrwE3UBBqUWhDu1rKhzQz52U6o lJqw== X-Gm-Message-State: ABUngvdMmMWU1KDqqssXDsG7Wdpw6SkfQhjC3+/6l4RA4iJ40A9TloFZWqzB8l1WBOOaBg== X-Received: by 10.25.160.21 with SMTP id j21mr3738305lfe.166.1478942324074; Sat, 12 Nov 2016 01:18:44 -0800 (PST) Received: from [192.168.1.44] (ppp109-252-90-55.pppoe.spdop.ru. [109.252.90.55]) by smtp.gmail.com with ESMTPSA id 137sm2571934lfz.2.2016.11.12.01.18.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Nov 2016 01:18:43 -0800 (PST) Subject: Re: [PATCH 2/2] serial: Poll USB devices if usbX serial port is missing To: The development of GNU GRUB References: <1478785539-2919-1-git-send-email-joonas.lahtinen@linux.intel.com> <1478785539-2919-2-git-send-email-joonas.lahtinen@linux.intel.com> Cc: Joonas Lahtinen From: Andrei Borzenkov Message-ID: <7b9507a2-8bd4-2da7-8a04-333377e42bec@gmail.com> Date: Sat, 12 Nov 2016 12:18:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1478785539-2919-2-git-send-email-joonas.lahtinen@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::243 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2016 09:18:50 -0000 10.11.2016 16:45, Joonas Lahtinen пишет: > If usbX serial port is missing, try to poll USB devices. This makes them > appear at least on Intel NUC devices DN2820FYKH and DCCP847DYE. > > This fixes cases where you try to configure usbX serial at the beginning > of a script, like: > > serial usb0 --speed=115200 --word=8 --parity=none --stop=1 > terminal_output --append serial_usb0 > terminal_input --append serial_usb0 > > Without this patch the above would fail with: > > serial port `usb0' isn't found > > Strangely, adding 'usb' command before the serial initialization > made it work, and even moving the terminal_output and input command > to be before. This is due to the terminal_output command detecting > "serial_usb" and running USB polling if the output is missing. 'usb' > command from usbtest module always polls USB devices. > > As it is the logical thing to configure the serial port before adding > it as an output or input, this patch makes things works as expected. > Most online resources mentioning GRUB and USB serial adapters also do > mention the above order, so there must be quite many struggling with > this problem on platforms where USB needs to be polled in order for > the detection to happen. > > Signed-off-by: Joonas Lahtinen > --- > grub-core/term/serial.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c > index db80b3b..1f856a2 100644 > --- a/grub-core/term/serial.c > +++ b/grub-core/term/serial.c > @@ -191,6 +191,7 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) > struct grub_serial_port *port; > struct grub_serial_config config; > grub_err_t err; > + int again; > > if (state[OPTION_UNIT].set) > { > @@ -212,7 +213,25 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) > if (!name) > name = "com0"; > > - port = grub_serial_find (name); > + again = 0; > + while(1) > + { > + port = grub_serial_find (name); > + > + if (port || again) > + break; > + > + if (grub_memcmp (name, "usb", sizeof ("usb") - 1) == 0) > + { > + grub_usb_poll_devices(1); This creates hard dependency of serial module to usb. Please use grub_term_poll_usb as terminal module does. > + again = 1; > + } > + else > + { > + break; > + } > + } > + > if (!port) > return grub_error (GRUB_ERR_BAD_ARGUMENT, > N_("serial port `%s' isn't found"), >