Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp130059lqm; Mon, 10 Jun 2024 15:28:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUsrOue49+/hGBM23dNC11tSQQ853y9GdjbD5uTtE8KVSsWRnstTRmXYPewSmldZJ0dQE4xmFCpV5DNW1RnrYz1uNXNLjRcwcmtzu0WlQ== X-Google-Smtp-Source: AGHT+IF5kU/raarx/gty80QMEcr0HPQyPlRZNatzz5ziWMSxLAZNOEGDYIe3r0p61cx3nB9p7Id2 X-Received: by 2002:a05:622a:281:b0:440:21b1:f84a with SMTP id d75a77b69052e-4413abb897emr18984401cf.9.1718058485272; Mon, 10 Jun 2024 15:28:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718058485; cv=pass; d=google.com; s=arc-20160816; b=CsU5N+mR3EyON0t3VXH0uJaWjbjV1mtHKrwUkl77pAhgNWGxxCjJiIIDcxDNYy3AlP LI7c441YM9VIu7upaGBtPPmPDDmsKXj0YyRsrw4EtR3MB6AawH9gnSwkL5U5gaOBPZbm kpVhAGMiUQiqCrOkzAnR/ovTXgYY+Vo6bTOzpAautFcCq3NDF1cqqAKr3G92rzIoUFMF M+xOnCpKj8WQi9ys2o3sZi4idjmSL+iX8C41pPXRa5aiY5HxxjQcwpNEPkPYLTX86YA/ w07i7TmUxqYMwDMuRJRxjAjliqyf77IzrN7oEmOY7HvRLQlvXPc0pZcS4Y/gACujio97 QL+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=t61vhNKu4lfde12Y7MkGP0C3wTMA8CL4vSTRQiLNbi4=; fh=Ag1dgLCSw0g52qNmejeKUU0l4viOidLm03oIcsEPWo8=; b=eY1ApVsUrNTzk47J8NAZedqNgwHqpLKTAxH09IzaSoNLX4Zqf37DioYtb0fvPo5hrB RB4bNHMaWsvugO+Q2AfqdR71r0vhWYnzHsuC7DGgoq6BGkrVYrdgLdr4JuXRciPBlbZJ tJV0yD8n6U86N6tVsBJD561FuyUd1p564qAUKXwEuCPWyEJ83U1z4e82xptZ3JylTHOo sWhBAwa1nkc+LyrBb/WbrX05VxjtXhmwxyLqPugoLfuQCyfFcHZPFtgXq62cfwzu5KHz tPAYL8kupbZYVhr/Z9zN4qyhWflit7/5cFk/cRHLm2volPCZabZHrwPfJ4OGI9AOlbjI V4aQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LU8bIS3v; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-209001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-4404d76aa21si82316731cf.698.2024.06.10.15.28.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 15:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LU8bIS3v; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-209001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E26AE1C22095 for ; Mon, 10 Jun 2024 22:28:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B8821514F6; Mon, 10 Jun 2024 22:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LU8bIS3v" Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9F6614F9CA for ; Mon, 10 Jun 2024 22:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718058402; cv=none; b=dFaomV4f7wuNa9TZvxDwtOMvcbXsir5Cdf73LeAum2yiEe19DfRsNKl791xaGPg5aDjB29s9EdAvyHK8zsgK8NDIlFAKDkfGDa/G38fsSZesT1y6WcpvJAhDB/AV7qsMZlzlS7aVzLyu7pa/Y/5WY+8jNgz3XIE/tPMuHimr3uk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718058402; c=relaxed/simple; bh=jkVV1qC5l78Q3rbJemzf3Lvhx8BH5IjwVLa5ql5PA1o=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=A6vDUs8rbZTUsoCcWDaEDXNbRIScJ910eDaND4d1x9Mp6ZoYBetLmOBsYXo9eiiMo/4qVPMbH/q0MOd1OdyuEsLOxkT8UZ+/gAiHXdNgT+/tBp3I7w7uB5+dd/y1LcCfs+VlJQqv6BXA1NhcmoqWcLip3ux4S+TiUIqW91jLDZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=LU8bIS3v; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-43fb094da40so51719171cf.0 for ; Mon, 10 Jun 2024 15:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718058398; x=1718663198; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=t61vhNKu4lfde12Y7MkGP0C3wTMA8CL4vSTRQiLNbi4=; b=LU8bIS3vBADw8n19ZuMa7gXEVQ7GAb77Hp5ErnEsCevyJBW4wHzD7i4Zt3SBWbGG63 qZiBsqrg+XJZw1KDDAOwM/3JxPbadALuf3soW1LoUwSJURinytJxECtqwCggl11QIhTa pePXZBE90bC26cSXI7RB7G5cQECwFo9nSSRXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718058398; x=1718663198; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t61vhNKu4lfde12Y7MkGP0C3wTMA8CL4vSTRQiLNbi4=; b=gxluEOjaJMPnuBUeIi394iPRzSwhkKvYp1G1uYYR8NY2naokLsC2IblqQAOSIhLnrd Rxzs3215qgQxUo/jaiKwT5OucgaBusQBA/L1nnBSLXZULTSqeJrjiw4wmiHzzBuiGo2J GnCxafTs1w9ZwmSBebxC2jn75NkQw9BPIuQGYue4ChzXYnkQXmQyI4mj09sbpYDqomv0 +U0ARlIGvqXLoc58soSLNBXZLQzDABAW+a4KYDT7yYUCgf3wCmpUDLbeuR/sST/LTlXe m1leSamdOCQNHl5WPV6UqhgAwu1t2QBX6ULvcB1kWkJfUnd/yw/2hPCLldCyjrFXbU35 Q3oQ== X-Forwarded-Encrypted: i=1; AJvYcCWur4MPA76IMGhh6CGFXTokykqs2In3VU9RpNMEdH545LhJeUktFXFKtangJC2DAb8WgSU53LABJcZvgKwMlSugsihJgpKXnAiKWnd8 X-Gm-Message-State: AOJu0YyJjWggkfOPqBQVv7KhkwWNn7EGPj2eZC5P6BjOsAqS5ZTet/xH GCTS5tx6MNefSBFS6Kd4PUv90V/VjOt58r/qF1Tt1/dIxi6rZd2FHfKs5eOKns1rHAFYcK7g8Y0 = X-Received: by 2002:a05:622a:87:b0:440:25e8:15d7 with SMTP id d75a77b69052e-4413ab8e74emr19150101cf.6.1718058398189; Mon, 10 Jun 2024 15:26:38 -0700 (PDT) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com. [209.85.160.173]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44038a684c4sm39952501cf.21.2024.06.10.15.26.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 15:26:36 -0700 (PDT) Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4400cc0dad1so192261cf.0 for ; Mon, 10 Jun 2024 15:26:36 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUceMJfqUrvvBXMvUD+BcgNAsZZQpZMOoHgyhv2D924Fbh4KeoskVkZX3zC6fj8QfgTNqDe9Z8l3F9CzgFysqDR8vJcDAk7hjCsKVmy X-Received: by 2002:a05:622a:5818:b0:440:331b:59f7 with SMTP id d75a77b69052e-441401262famr1308541cf.6.1718058395830; Mon, 10 Jun 2024 15:26:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240604160123.2029413-1-dianders@chromium.org> <20240604090028.v3.6.I0f81a5baa37d368f291c96ee4830abca337e3c87@changeid> <2c5c3d46-5fe2-6678-34ea-647c28f5a4f0@linux.intel.com> In-Reply-To: <2c5c3d46-5fe2-6678-34ea-647c28f5a4f0@linux.intel.com> From: Doug Anderson Date: Mon, 10 Jun 2024 15:26:24 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 6/7] serial: qcom-geni: Fix suspend while active UART xfer To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: Greg Kroah-Hartman , Jiri Slaby , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Andy Shevchenko , linux-arm-msm@vger.kernel.org, Konrad Dybcio , LKML , linux-serial , John Ogness , Yicong Yang , Tony Lindgren , Stephen Boyd , Johan Hovold , Bjorn Andersson , Thomas Gleixner , Vijaya Krishna Nivarthi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Fri, Jun 7, 2024 at 12:43=E2=80=AFAM Ilpo J=C3=A4rvinen wrote: > > > @@ -311,11 +312,14 @@ static bool qcom_geni_serial_poll_bit(struct uart= _port *uport, > > > > static void qcom_geni_serial_setup_tx(struct uart_port *uport, u32 xmi= t_size) > > { > > + struct qcom_geni_serial_port *port =3D to_dev_port(uport); > > u32 m_cmd; > > > > writel(xmit_size, uport->membase + SE_UART_TX_TRANS_LEN); > > m_cmd =3D UART_START_TX << M_OPCODE_SHFT; > > Unrelated to this patch and won't belong to this patch but I noticed it > while reviewing. This could be converted into: > > m_cmd =3D FIELD_PREP(M_OPCODE_MSK, UART_START_TX); > > (and after converting the other use in the header file, the SHFT define > becomes unused). Sure. I'm going to leave that to someone in the future, though. I've already spent more time than I should on this series and, if we're going to do this, we should convert the whole driver (and perhaps all the geni drivers). > > @@ -335,6 +339,64 @@ static void qcom_geni_serial_poll_tx_done(struct u= art_port *uport) > > writel(irq_clear, uport->membase + SE_GENI_M_IRQ_CLEAR); > > } > > > > +static void qcom_geni_serial_drain_tx_fifo(struct uart_port *uport) > > +{ > > + struct qcom_geni_serial_port *port =3D to_dev_port(uport); > > + > > + /* > > + * If the main sequencer is inactive it means that the TX command= has > > + * been completed and all bytes have been sent. Nothing to do in = that > > + * case. > > + */ > > + if (!qcom_geni_serial_main_active(uport)) > > + return; > > + > > + /* > > + * Wait until the FIFO has been drained. We've already taken byte= s out > > + * of the higher level queue in qcom_geni_serial_send_chunk_fifo(= ) so > > + * if we don't drain the FIFO but send the "cancel" below they se= em to > > + * get lost. > > + */ > > + qcom_geni_serial_poll_bitfield(uport, SE_GENI_M_GP_LENGTH, GENMAS= K(31, 0), > > That GENMASK(31, 0) is a field in a register (even if it covers the > entire register)? It should be named with a define instead of creating th= e > field mask here in an online fashion. Sure. Done. > > + port->tx_total - port->tx_remainin= g); > > + > > + /* > > + * If clearing the FIFO made us inactive then we're done--no need= for > > + * a cancel. > > + */ > > + if (!qcom_geni_serial_main_active(uport)) > > + return; > > + > > + /* > > + * Cancel the current command. After this the main sequencer will > > + * stop reporting that it's active and we'll have to start a new > > + * transfer command. > > + * > > + * If we skip doing this cancel and then continue with a system > > + * suspend while there's an active command in the main sequencer > > + * then after resume time we won't get any more interrupts on the > > + * main sequencer until we send the cancel. > > + */ > > + geni_se_cancel_m_cmd(&port->se); > > + if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, > > + M_CMD_CANCEL_EN, true)) { > > + /* The cancel failed; try an abort as a fallback. */ > > + geni_se_abort_m_cmd(&port->se); > > + qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, > > + M_CMD_ABORT_EN, true); > > Misaligned. Done.