From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 C1A9120C000 for ; Tue, 12 Nov 2024 08:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731400520; cv=none; b=tVsc4R4xncVh+HlQEdYTWPcY/P93F5G2MnPh0LNpOtGzV3IqRo5KHOuhmWIIMUj8u5ttN3ly+EHS26QPYMqplffNDQOUfOIPfhbsDu23DJF8LwCXUzt1oAsxe2ZPgppRYkPfCI2B0KROMi0AJyp/4n0PAURM8HO7FH1P3UQ2gc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731400520; c=relaxed/simple; bh=q1kY2sQYlq+hOddVsv3T5fQZjCOWNt9cci/DeyYLwq0=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=cPjjE0Z6Yex0+l/L3G8RZrmmwsg6tlDQNQR7Fg9e2mXmqT5C2XYKqFZoVt5JbabTyAYhf3o7kflCMVZIAS+ufiIv4OKWb9fYPXiQ6oRXsbvuoSASFWej4VIluNenHX0PbZ8PIpof945t+lT5RaEIJhQ5IBR+L3V4e/l7KBZj+c8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=kEn/K0Rj; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="kEn/K0Rj" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so47189175e9.2 for ; Tue, 12 Nov 2024 00:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1731400517; x=1732005317; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=PL5GeOh28TysV9Lqq7NP7GxRHBqQLXUN1hL7aKNKaMk=; b=kEn/K0RjlE+vo2+wilIXoOGshXRTmUj5jJzpPKaziwXLy3w2vpPI9jRqIfliqu78wX /lbqNpiWnJ29DWxcxBxMd2XNBmqipUIucxkPUhxHzvM58sSX2ytJefViUYzoJwiZknQl d0wB8Oahp9BIlG/SG3uAe3JSf7fvhKlKlg4AHhFyXA/D4gKHztN0fTwoCpRsTDtr0nlN HCBmTd40S6uF3I+kVj2DMtycdJ22GZwWuDDVDp43PGBmbfddimWTbaEvtWXL10jWaqAQ 6hJDTAAC49PPP8JNYV7rMZEtdVY8Amat8VbGKYCscxRW4sRVn7PKRQlv8mVAzeTutznf QV2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731400517; x=1732005317; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PL5GeOh28TysV9Lqq7NP7GxRHBqQLXUN1hL7aKNKaMk=; b=iDGmdV1Rmn6QiIKdI1yta4C1qpKeQrMbOcV8TiGuvROYQQwMQ98oBwwlbdEGnfphiY s4vq1DgUfj0ayAKPd61fgi3JTiVoXSx1RKaylWZiVycKGof+TMY6wthCPMPPxs4SHSWI CzzD1R38ZQfW51Alxhmb+nQnpxEX+EWsDXQ3OlXFP5v6U7qR6Y+o/kF54J3havxJ7rbH JKh37fPG7ZYYTBif6N1NJtikaHp2oIXnkIejcX4YtBY8uTmZYCbpNXc94aOKKerS5bF3 2cc+4ioQ4kRMUOTdAcHja/ZQPD0OVnysqRC21Lp1C01GrQVCWmaufLWvKSyJyS5pvIPM uX3A== X-Forwarded-Encrypted: i=1; AJvYcCVxyQTklnyyMt65bjzLvN3Iff4FBa+yJxaYQAxL1L9HMrsCJYFzqNC6NLwuuV9rr99TnSBLIIim0gMI1yA=@vger.kernel.org X-Gm-Message-State: AOJu0YySeR8vnKbvgyDgofrzxxc+NuOZSS5AJ8URXIXMpi1R+6Eak7wU bn/1R5l4BQt77Qhq1vRO4VSNsjycTwfsTrDkXvBEvTaucFAmCOJjDk6772pCrZ8= X-Google-Smtp-Source: AGHT+IFa1LixkOeiL8eI5oMGEu2ThX65XIYTJoURm9f8rPbRKT4O56MDA08ZH8xosIwK+pODYwTchA== X-Received: by 2002:a05:6000:178d:b0:368:37ac:3f95 with SMTP id ffacd0b85a97d-381f17255b9mr12724481f8f.31.1731400516852; Tue, 12 Nov 2024 00:35:16 -0800 (PST) Received: from [192.168.50.4] ([82.78.167.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed97f544sm14918813f8f.40.2024.11.12.00.35.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Nov 2024 00:35:16 -0800 (PST) Message-ID: Date: Tue, 12 Nov 2024 10:35:13 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/8] serial: sh-sci: Check if TX data was written to device in .tx_empty() Content-Language: en-US From: Claudiu Beznea To: Jiri Slaby , geert+renesas@glider.be, magnus.damm@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, gregkh@linuxfoundation.org, p.zabel@pengutronix.de, g.liakhovetski@gmx.de, lethal@linux-sh.org Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-serial@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org References: <20241108100513.2814957-1-claudiu.beznea.uj@bp.renesas.com> <20241108100513.2814957-3-claudiu.beznea.uj@bp.renesas.com> <530f4a8e-b71a-4db1-a2cc-df1fcfa132ec@kernel.org> <3711546e-a551-4cc9-a378-17aab5b426ef@tuxon.dev> In-Reply-To: <3711546e-a551-4cc9-a378-17aab5b426ef@tuxon.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, Jiri, On 08.11.2024 14:19, Claudiu Beznea wrote: >>> @@ -885,6 +887,7 @@ static void sci_transmit_chars(struct uart_port *port) >>>           } >>>             sci_serial_out(port, SCxTDR, c); >>> +        s->first_time_tx = true; >>>             port->icount.tx++; >>>       } while (--count > 0); >>> @@ -1241,6 +1244,8 @@ static void sci_dma_tx_complete(void *arg) >>>       if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS) >>>           uart_write_wakeup(port); >>>   +    s->first_time_tx = true; >> This is too late IMO. The first in-flight dma won't be accounted in >> sci_tx_empty(). From DMA submit up to now. > If it's in-flight we can't determine it's status anyway with one variable. > We can set this variable later but it wouldn't tell the truth as the TX > might be in progress anyway or may have been finished? > > The hardware might help with this though the TEND bit. According to the HW > manual, the TEND bit has the following meaning: > > 0: Transmission is in the waiting state or in progress. > 1: Transmission is completed. > > But the problem, from my point of view, is that the 0 has double meaning. > > I noticed the tx_empty() is called in kernel multiple times before > declaring TX is empty or not. E.g., uart_suspend_port() call it 3 times, > uart_wait_until_sent() call it in a while () look with a timeout. There is > the uart_ioctl() which calls it though uart_get_lsr_info() only one time > but I presumed the user space might implement the same multiple trials > approach before declaring it empty. > > Because of this I considered it wouldn't be harmful for the scenario you > described "The first in-flight dma won't be accounted in sci_tx_empty()" > as the user may try again later to check the status. For this reason I also > chose to have no extra locking around this variable. > > Please let me know if you consider otherwise. With the above explanation, can you please let me know if you still consider I should change the approach for this patch? Thank you, Claudiu Beznea