Received: by 10.192.165.148 with SMTP id m20csp92802imm; Fri, 4 May 2018 07:12:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZotlqKNGr4N0y/Jl8Bo+hS/F/GE8WFLmjN6dCk1FkFZmzipToq/ospIkvtG0auHcP5pH43O X-Received: by 2002:a17:902:b582:: with SMTP id a2-v6mr568275pls.371.1525443125254; Fri, 04 May 2018 07:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525443125; cv=none; d=google.com; s=arc-20160816; b=S3d1lfEKavubDEgB5vlCD9ArnhnfsMLAGSGrqCmjiMnVg1qCOx96RM9lnFXFNS6XqF W7nmmQxbsU+QJN0bdKD9L/6stMaJgIhG7eFHDXty7Ar2rnFtYzc+sJYv1fuFqeQC7AHd UchSYvgaAy+P4IuJVcN0OfsezHa7/UPQgg/yp+XcVRuyZCaGVyvJdZ0EQPJHrnxEI9C8 uQeKQGLYF6mFPV6gNcRUCyCoVlgtfHcV69tljvlW/Aic2fxeK2mpSYYif8RqnD7mQf2i X/8z+vTg/PMmQoj62r0gCxgmrLFkFfczdMzAsuhrMjGraVrGfnc2aPf3/+UqjXQ2mlYA srMw== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=SKmLnxKjvSvSLNR6VCZLnsPUAjq/6rFHIjrJ7EVmjVA=; b=A+ic8ICdJKCqVIm4jmxYng0nWq5ISMtPIhFBtdAPjdsJQuvDBYND+dwe2fg0+LIN0B Wmn2S3FPKiHGXdB/OT25SbeLOesNNHSb1mtstCik40cZqoBizH6NQFOSdXpu0I4uXECm brH+TLseJorhxrcdn/A294y1WvBvRK+ywWr4uzmusLmt/8SdOWbBrzHABnewiuyMmZNd JZVh5wOZPNs+hWoJ6XVSWTuAIw0C1pMDnFtd2XfLADw+DP1nyuPbWPyVhZaSkK2H6c2J SJl8vISVmRI69j7Yqdz/8MIdP/rctPA8RDobWyXDe9n3EFQ9BUNDlkyIiBRnXb60WdnH mluA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XS4Yxk+S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r74si16057867pfe.168.2018.05.04.07.11.51; Fri, 04 May 2018 07:12:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XS4Yxk+S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751423AbeEDOKZ (ORCPT + 99 others); Fri, 4 May 2018 10:10:25 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:41988 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751189AbeEDOKW (ORCPT ); Fri, 4 May 2018 10:10:22 -0400 Received: by mail-ot0-f193.google.com with SMTP id l13-v6so24610067otk.9; Fri, 04 May 2018 07:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SKmLnxKjvSvSLNR6VCZLnsPUAjq/6rFHIjrJ7EVmjVA=; b=XS4Yxk+SNP34IUxBqXYd9PHbnjeSgnsKJsxdQ8NNcgpfmy8qn3WmSh6BjVklGHXNtV lvPF263QsI9GfNq7TLW0yIF1A130M0Kw7mKQzWUS32Z9mMbCjs+Uq/KL2ikFv+/y6wdX 27e+Uy3caRz50GX5W2cUZ7HfPMBl3nKmA2zgVZf4sLqwkbVXgQRXkx1eSNwabyvyERu3 C6Dwan2xKtAbxzcCrrqOgm1TLrB2Z8/MwOFpAmZtXaEjATgDY9Z98zOU2FPhUUUMjYOi WNBch++5gqJMZYwvCOuPvbY3zBmgOKNulOdlhkGEbC4xS2cXCx8T1e3DtshR5idn7KcA tSYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SKmLnxKjvSvSLNR6VCZLnsPUAjq/6rFHIjrJ7EVmjVA=; b=K2RLK9Q8gxNhCn7Qsb038gPIRnFwlZeS286U/pFe93zAVPcQBwYAXSMu5kt//6A6bk HcLGDSNDPihD7QQwtkVO8H1GWr+2QkyfAIGjBaH+fx+AoUT20KPIdRykvqY0DlHBdT5M ZssE65pkl9zpQWQh0HMR9Pui3bkps0dtSj8WhQt1jgc8nZIrz7Qget0xJKzsi5YQukng q97ni2q2SrxKnBAy1aa8yBcROQRieiZvLEBQp86sYCa4aiK2akOROxYrLThnBijt8fAd /qYhMOe7cUvfovBZepavXRTBzGrDvFtMME2687k6ki4jk/z4ghv9KpsF/f7Sy7Usc6cX e3PA== X-Gm-Message-State: ALQs6tDAUHom+G+hlt2XiptyPYjo2UE1kGE58FNiLJM5dYvIiDoNa9OH iPFeeFtqhRiYR6p4c8Frm57eUCGGhFM4UYRZokw= X-Received: by 2002:a9d:ef:: with SMTP id 44-v6mr18737004otk.164.1525443021393; Fri, 04 May 2018 07:10:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:118b:0:0:0:0:0 with HTTP; Fri, 4 May 2018 07:10:20 -0700 (PDT) In-Reply-To: References: <20180503183408.GA12152@kroah.com> From: Muni Sekhar Date: Fri, 4 May 2018 19:40:20 +0530 Message-ID: Subject: Re: serial: start_tx & buffer handling To: =?UTF-8?Q?lo=C3=AFc_tourlonias?= Cc: Greg KH , linux-kernel@vger.kernel.org, linux-serial , kernelnewbies Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 4, 2018 at 5:44 PM, lo=C3=AFc tourlonias wrote: > Hi > > On Fri, May 4, 2018 at 6:31 AM, Muni Sekhar wr= ote: >>> >>> On Fri, May 4, 2018 at 12:04 AM, Greg KH wrote: >>> > On Thu, May 03, 2018 at 08:08:48PM +0530, Muni Sekhar wrote: >>> >> Hi All, >>> >> >>> >> I=E2=80=99m trying to understand how user mode buffer is written to = low level >>> >> serial hardware registers. >>> >> >>> >> For this I read the kernel code and I came to know that from user mo= de >>> >> write() API lands into kernel=E2=80=99s tty_write() ("drivers/tty/tt= y_io.c") >>> >> and then it calls a uart_write() ("drivers/tty/serial/serial_core.c"= ). >>> >> >>> >> In uart_write(), the buffer is copied to circ_buf and then it calls >>> >> low level serial hardware driver=E2=80=99s start_tx() (struct uart_o= ps >>> >> .start_tx). But here I could not find how the buffer kept in circ_bu= f >>> >> is copied to serial port=E2=80=99s TX_FIFO registers? >>> >> >>> >> Can someone take a moment to explain me on this? >>> > >>> > It all depends on which specific UART driver you are looking at, they >>> > all do it a bit different depending on the hardware. >>> > >>> > Which one are you looking at? Look at what the start_tx callback doe= s >>> > for that specific driver, that should give you a hint as to how data >>> > starts flowing. Usually an interrupt is enabled that is used to flus= h >>> > the buffer out to the hardware. >>> > >>> >>> I=E2=80=99m looking for any existing sample code which does DMA transfe= rs of >>> UART transmitted data. I looked at the bcm63xx_uart.c, it looks it >>> does not handle DMA transfers. Even copying the Tx buffer (from >>> circ_buf) to UART_FIFO_REG happening in ISR. > > > You can have a look at atmel_serial kernel module (built for ARM). > https://elixir.bootlin.com/linux/latest/source/drivers/tty/serial/atmel_= serial.c > > The dma buffer is linked to uart circular buffer in prepare_tx() functio= n > called from uart_startup(). It's released in release_tx() function calle= d > from uart_shutdown(). DMA buffer is managed in schedule_tx() function ca= lled > from a tasklet triggered by the ISR. Thanks a lot for this information. > > HTH > >>> >>> >>> > thanks, >>> > >>> > greg k-h >>> >>> >>> >>> -- >>> Thanks, >>> Sekhar >>> >>> _______________________________________________ >>> Kernelnewbies mailing list >>> Kernelnewbies@kernelnewbies.org >>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> >> --=20 Thanks, Sekhar