Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1958869pxa; Thu, 6 Aug 2020 22:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCv6Z/UY7ZvdS65c5hG+MmmQ/6PRwEDwT3kamN+8UM/NlFCkJmve6sYMRDWJTZO7nFm1Ea X-Received: by 2002:a17:906:e115:: with SMTP id gj21mr7429369ejb.505.1596777662720; Thu, 06 Aug 2020 22:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596777662; cv=none; d=google.com; s=arc-20160816; b=f5Q2XzbI/CKxxFLrHXNYO/+Sawjg/r78Pm6luOGbwA4aqEriawVy/Iuomt/C9cDLg6 QgXu69xEKxuNgcOE5FSwGNOxJH2U31OCSSGvY9hxoHLhkLC/Fmr4JsU/TDX7WXsRy7ev AttCC2i0NHue7RqGs/Tb2ZHFTQfs2PYBk1uIMUVsZzwQgwr7cva5Jpncy//rNz6wyu8O RMMqxa4CXKZzOyJNYM9yICq3HL9KwFQk53uZTHEwy2KNHnQO3f8ufL6P1WBvL1NbdzW3 AmbupB78u3C8sbGMyqbewDU+mieb4toUg7+iTqIE2YJZJw+goQw1/NK70LABK9IDS4xH STIQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=LKoQxM83Uc+FXvx6t5Ymg1IK53B/gKt39Gp0pbNTE/w=; b=G1eLI+EGWpLfr8ZqTP1MdMU3LWYQVwKtjutmIEAiFPAeMLrF29lWM4Gw3K9HGBNp78 k/9BODLhtK6dJeEG9hMjUp6WwJeMGzrJUrm10JWOj6cG6qY9jak5WFfhjr0y4qph170D DdNyvWK6ANkFSXULkQ7SQE1TD0EHPt9VVLFRWHk05DIeP1Ht47JBeMYQKskh362vCqFb WdnaHMo+P4LxqxyuYKc7E8xCR+9MTCZ95W3cgPCWup2akyKrWRLlReD57WRyorBG5O8x U6ZoxEE3p3GDFhrm5zaJlrrF5W9tPXj6UPWLvsGVTALMU2ZdJwsPmFalmbkSZYRbfkts R34A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VyAVOpNi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec15si4714931ejb.236.2020.08.06.22.20.38; Thu, 06 Aug 2020 22:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VyAVOpNi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726045AbgHGFTh (ORCPT + 99 others); Fri, 7 Aug 2020 01:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGFTg (ORCPT ); Fri, 7 Aug 2020 01:19:36 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA0FC061574 for ; Thu, 6 Aug 2020 22:19:36 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u128so387840pfb.6 for ; Thu, 06 Aug 2020 22:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LKoQxM83Uc+FXvx6t5Ymg1IK53B/gKt39Gp0pbNTE/w=; b=VyAVOpNiqddmfKMBU5li60da/RuApY8f29CHkpTimPilQ86j/gYbLdXJ1JoEKt6vpD d2y9EUvtPB6CzlyDFnlal3mfMmer+GsWBqAAIygnmP1BPWq0yKdn9T5KLNJws9XbR+VJ GgtQ18JNlytDCtEX7K8cs1KdMErJEwTQy/v1E= 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:mime-version :content-transfer-encoding; bh=LKoQxM83Uc+FXvx6t5Ymg1IK53B/gKt39Gp0pbNTE/w=; b=dKZubFXHNi+D3dPpU+3rr97ZNlK3N3ZoJv2pROKV4ty6EgsaNPRude0muCSbZMqnBm 7mMhpD5gykuF0rLk5F16c788csidWj3iyaBbZhQISkLxALwyk4q7V9wCxvyw+JheYOIN YHGhdoQ4AXqPhBUHrPj1Js9PG9TFgo5pQScs2mp900Qj5MI7rF9eYTqwecPT6/tMwxUL B/gRBD91UcFVpGpMJF8IgAhDfNBKzXwlaAby7INBYuyPSpVDj4qrjLEdJKD47/deIWAP bbRjBIWiHlC95BnL85hZIkUe7Wq3bfngN7TfQ80lDuGRrNLgeKRM8PewGt8UIU9ZZaqq 0Gsw== X-Gm-Message-State: AOAM531C9XxNfMpnBGlLMJVbrQ0dfMx5ZGwPg4Ykejn9LHqBgCSq3f1l zqri/QL7TUlZBsrpIYHwk9w5Hg== X-Received: by 2002:a65:4b85:: with SMTP id t5mr10043682pgq.36.1596777575437; Thu, 06 Aug 2020 22:19:35 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id r15sm11381147pfq.189.2020.08.06.22.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 22:19:34 -0700 (PDT) From: Douglas Anderson To: Greg Kroah-Hartman Cc: Akash Asthana , kgdb-bugreport@lists.sourceforge.net, Mukesh Savaliya , Douglas Anderson , Andy Gross , Bjorn Andersson , Evan Green , Jiri Slaby , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] serial: qcom_geni_serial: Fix recent kdb hang Date: Thu, 6 Aug 2020 22:19:08 -0700 Message-Id: <20200806221904.1.I4455ff86f0ef5281c2a0cd0a4712db614548a5ca@changeid> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit e42d6c3ec0c7 ("serial: qcom_geni_serial: Make kgdb work even if UART isn't console") worked pretty well and I've been doing a lot of debugging with it. However, recently I typed "dmesg" in kdb and then held the space key down to scroll through the pagination. My device hung. This was repeatable and I found that it was introduced with the aforementioned commit. It turns out that there are some strange boundary cases in geni where in some weird situations it will signal RX_LAST but then will put 0 in RX_LAST_BYTE. This means that the entire last FIFO entry is valid. This weird corner case is handled in qcom_geni_serial_handle_rx() where you can see that we only honor RX_LAST_BYTE if RX_LAST is set _and_ RX_LAST_BYTE is non-zero. If either of these is not true we use BYTES_PER_FIFO_WORD (4) for the size of the last FIFO word. Let's fix kgdb. While at it, also use the proper #define for 4. Fixes: e42d6c3ec0c7 ("serial: qcom_geni_serial: Make kgdb work even if UART isn't console") Signed-off-by: Douglas Anderson --- drivers/tty/serial/qcom_geni_serial.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 07b7b6b05b8b..e27077656939 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -361,11 +361,16 @@ static int qcom_geni_serial_get_char(struct uart_port *uport) return NO_POLL_CHAR; if (word_cnt == 1 && (status & RX_LAST)) + /* + * NOTE: If RX_LAST_BYTE_VALID is 0 it needs to be + * treated as if it was BYTES_PER_FIFO_WORD. + */ private_data->poll_cached_bytes_cnt = (status & RX_LAST_BYTE_VALID_MSK) >> RX_LAST_BYTE_VALID_SHFT; - else - private_data->poll_cached_bytes_cnt = 4; + + if (private_data->poll_cached_bytes_cnt == 0) + private_data->poll_cached_bytes_cnt = BYTES_PER_FIFO_WORD; private_data->poll_cached_bytes = readl(uport->membase + SE_GENI_RX_FIFOn); -- 2.28.0.236.gb10cc79966-goog