From patchwork Fri Oct 25 07:33:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 177678 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3286020ill; Fri, 25 Oct 2019 00:33:47 -0700 (PDT) X-Received: by 2002:a1c:3b42:: with SMTP id i63mr1926165wma.37.1571988827860; Fri, 25 Oct 2019 00:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571988827; cv=none; d=google.com; s=arc-20160816; b=zeBd6AI46qrYqNwM0STL2w9vhHAgWRCEZlRgW+PNE3cH9sxn/iJzG2kkIIP8PTt/J5 rh+rJGCOyEHsc27xNNtjzyUwAfsm34lMGkFNqFKwIN07mNfZ4Kc5SsWDXK2HkqkAjmd5 yqG8P5tI5r8hurF12CWBZbd+JS1bNY6G0KgTr5CZCUeCR5Jr2siqFyVtKBnhIZjksEGH 7uOgIGy6erzgEI5NbasuWIQ5/QT0wF/FrG8YCpmj546ZUa3HD1q4YCaHGWCn29Ge+Gl9 v8vtMHW5VH9/Tnj1PgVOOhap1TwkHXrl1rlrG0dX7hRhLrDJpSL3WLKlPvTdUksrBkXt RLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VxRxdqK8wDgtRtqhN/4fmGim8qsHy1Sh2vs1pQm0S1s=; b=m+qBJ1PilPCaurIW9MUJSa8xrVS8Vr4iIkqbddQSXb+7rY12FphtPj8ABT/88ms/bh NwPlUrmQp9P4JIlAeA/2A45rCO6Qan7rzsBUIq52lmErS+jzcwBgPXAvDvjnNYKdyGl1 5nu/81e9MTpWy4HonV4DkpKo+b2luYW6lquXAktIwFGb7mg1TnNisoG4ecKjO371YarA PW5x8nQt3cyi2NEFK3KHEZq6SmZaTquDUCTNR01CvGoZQIlgO1RotINcgCJakXWnU/qH ZnHhlF01lOzHNRb4rRxHrZrJc3ryw4PMYdnOnrlRflN3+ntPHJBTGiswabQF8k9ETpKI AIlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F5JEpHMe; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l14sor738815wru.29.2019.10.25.00.33.47 for (Google Transport Security); Fri, 25 Oct 2019 00:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F5JEpHMe; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VxRxdqK8wDgtRtqhN/4fmGim8qsHy1Sh2vs1pQm0S1s=; b=F5JEpHMej8YX8/tXiqp25sBGpi1nHuIwrK/ACEWIlTPQozJML/KptQdG5HGN4mB0mN Dmj9dtiWrZYX+yR4JK3i5Lrw7hKeW+ZMJhTepWlCKmhVeVGbDNAPXVaKRs49ut5Lchs0 pGD2ZDoyvmprP9o6AMdzq9FkIlo5jzFVLmfO6O0XiN/zFuzIo43Ms3rH2k8+GWNv37wk Aq9mXXxRAIzdsuXmoGscnLJrlSDOetxBr+G4c3kWFlddhFxWqp7ShmIBashpCE7vlqNI JqRXHfCVpcFEjLwlJbT8XxvWOLUMeeWwrzIKjnAHNEPWE1XG74iy+9G1Ok8qTXMOQYad KaDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VxRxdqK8wDgtRtqhN/4fmGim8qsHy1Sh2vs1pQm0S1s=; b=EGeyOcH19hnamNDBYT3wQ/66ccebo+qhqvSylOvOIUANtuCEIG9n/uGgssCtPCSkh5 1Sc2IdHL12kRsP3BaYHrOS5uR7JfN/hhU5ZoUVDxcOefr12r00IUiodBJMjLLmiaP/7F tXfcmpZY+4Bcemwtlc+8CzlMMfo48LdEnB/lrmETUdkT9+Z4m8OhRDUhvGJaqcnSgVpr 46YwCG30LIYwo6K9GtjLQRjRIOmZ9BGq02gW1IQWg0M5brdO6/ppWfcdcPc9qxjIQ4Xg UlUiGtv0WGUPDXGQvV+3iIVYzXd667paZTEWyonrDSmjb1PZIJ4kcmMYtbrBUEDY/nvf fkNQ== X-Gm-Message-State: APjAAAUWFEZYrsN4vaW0SdDxqxvVyI/wBsmFm4Q5oojPbqu4fJEdnfos xcEI2NvT2vTFDrI8bFu7hDm1kRuq X-Google-Smtp-Source: APXvYqwDI5MATscItj7Zxy/MypGFHIa/wSL6G9jo3i0hphS69xVNL/iB2urgVUDMDDWBUq8S5GQmGQ== X-Received: by 2002:a05:6000:118f:: with SMTP id g15mr1440429wrx.242.1571988827402; Fri, 25 Oct 2019 00:33:47 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id a11sm1586602wmh.40.2019.10.25.00.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 00:33:46 -0700 (PDT) From: Daniel Thompson To: Douglas Anderson , Jason Wessel Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v4 4/5] kdb: Improve handling of characters from different input sources Date: Fri, 25 Oct 2019 08:33:27 +0100 Message-Id: <20191025073328.643-5-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191025073328.643-1-daniel.thompson@linaro.org> References: <20191025073328.643-1-daniel.thompson@linaro.org> MIME-Version: 1.0 Currently if an escape timer is interrupted by a character from a different input source then the new character is discarded and the function returns '\e' (which will be discarded by the level above). It is hard to see why this would ever be the desired behaviour. Fix this to return the new character rather than the '\e'. This is a bigger refactor than might be expected because the new character needs to go through escape sequence detection. Signed-off-by: Daniel Thompson Reviewed-by: Douglas Anderson --- kernel/debug/kdb/kdb_io.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) -- 2.21.0 diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 9b6933d585b5..f794c0ca4557 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -127,10 +127,10 @@ char kdb_getchar(void) { #define ESCAPE_UDELAY 1000 #define ESCAPE_DELAY (2*1000000/ESCAPE_UDELAY) /* 2 seconds worth of udelays */ - char escape_data[5]; /* longest vt100 escape sequence is 4 bytes */ - char *ped = escape_data; + char buf[4]; /* longest vt100 escape sequence is 4 bytes */ + char *pbuf = buf; int escape_delay = 0; - get_char_func *f, *f_escape = NULL; + get_char_func *f, *f_prev = NULL; int key; for (f = &kdb_poll_funcs[0]; ; ++f) { @@ -150,26 +150,26 @@ char kdb_getchar(void) continue; } - if (escape_delay == 0 && key == '\e') { + /* + * When the first character is received (or we get a change + * input source) we set ourselves up to handle an escape + * sequences (just in case). + */ + if (f_prev != f) { + f_prev = f; + pbuf = buf; escape_delay = ESCAPE_DELAY; - ped = escape_data; - f_escape = f; - } - if (escape_delay) { - if (f_escape != f) - return '\e'; - - *ped++ = key; - key = kdb_handle_escape(escape_data, ped - escape_data); - if (key < 0) - return '\e'; - if (key == 0) - continue; } - break; /* A key to process */ + *pbuf++ = key; + key = kdb_handle_escape(buf, pbuf - buf); + if (key < 0) /* no escape sequence; return first character */ + return buf[0]; + if (key > 0) + return key; } - return key; + + unreachable(); } /*