Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp502284lqp; Thu, 4 Apr 2024 23:15:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVK/PSDRrbt2GXhpDMLaTQM9g+NBUWgwFjnvPPKRjx9SjVwmPzDlz6kS1vYOisG3Rx+3EW7FNNJt4y6P6bORJzJHdV1AKCha/fs5ksamg== X-Google-Smtp-Source: AGHT+IHkLPwgstmjEPlMeONLsfN5Q3s1LkzdifWvecIB9M+0h8BD1doKdVWCYVM962FZUz2hYHAF X-Received: by 2002:a05:6a00:2341:b0:6ea:9b37:c288 with SMTP id j1-20020a056a00234100b006ea9b37c288mr882976pfj.15.1712297736990; Thu, 04 Apr 2024 23:15:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712297736; cv=pass; d=google.com; s=arc-20160816; b=E2xHZE15gPh9+eQAnUtu1i4RXMHcQfCUnpPsfTvw6OA990tmMvBzAZZ6Blsu9xuHXJ JzUadw6rrViZmjD1w9SrAKnMqagJTPPOFXQfdHwF2IoQma5cLJFXoVi2Le76lJUn2sc2 z8MNHcEypAvoLRLUP2XdGuY9W3Trj3RXMCoaHB59u3a0xHe58D9oErhMFx0gb7bMAElL afwWChiwEeYwbuOinOxKMHzFhvyRwUnIS8J8QoMgWVZMhcBSuW7jWFZ07kfCRlPPTzF6 ts1ujYCa3wiiQC+J1FBnpfw6YIJRrmEmo32vxYQEe2RujSWwIivMROgoqZFL8Pcsud6F 0oUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=94y/q4qwp22LxS25UKwXWYJg1nZ4hUkXL4Nh/QmmBRo=; fh=QJ8vJz0JL6c8fqQRAKc0NXCP+/F+4NYQGSVBSghPQr8=; b=eBL740HrQdM0xAoJphEkYHibVgzhRNchkOaFIGsrbhMinrg0Ttufq/YYldPRlIDFnf Hl4QRgP3RkFglLdtt1Hqi5SxzqtOScc5fhcUf+NZrQMK3feDMZTLysgz5T8UHCXBVja0 QPeIEyOos1N0Ry1bV++zAsdQtqnBPJX1mNaGvyk3Bnfpv5jns5tmbNsi0ZdgOg/KDR/M hpLSdOoqq78kylAGCPAThja3Znb/tqtq8unFgIs3JbtjMx/BuIW2W2vBoKcIfEr7VzwV gi2LAxtb2Fvaf5UcZ1n5jCgxz49jPYlBlWnv96qtZsq3w8vVy46Ks1Y5nzb7wsa7cK3b YiYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ekMXKAld; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ff19-20020a056a002f5300b006e732c05716si760866pfb.355.2024.04.04.23.15.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 23:15:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ekMXKAld; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A5793B22F80 for ; Fri, 5 Apr 2024 06:11:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E8022575B; Fri, 5 Apr 2024 06:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ekMXKAld" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D68249FA; Fri, 5 Apr 2024 06:09:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297353; cv=none; b=lNmPFJCkBSR5X8ni21vcphERah9aJbGPkAsRQ2Hl+TUEm5Oxw59izKXCrjcSXjJRqUy12R5N5/PESxS0zGSD4x6X+J9i5zTOOKY3SLvTcrXO9DXBm2wLp7R2ebIaAaAShQqGb7myF0/R2i/vHaGz5h/dHVCEITlzy1C0weGbCXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297353; c=relaxed/simple; bh=KVsipsYsYMv/yG54CaStidUVpSv0BOqzJ7Q6MUmF5/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NVQS7sJ2DzmYcJfzI+JAotXc/ZImN3mpc7k/c5xq62y+QsuGMcbMZwGvaorJwK7VPA/aiE0LYxw+3T1+uTLiLVm32C3bfI+E5bc7CvxzamqsKNjVqTuYP3gvOU+4miSUmqwpISFByDl7KKBQu/RIBOZplpgpJGOZ9asc5408BAM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ekMXKAld; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABEA9C43601; Fri, 5 Apr 2024 06:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712297352; bh=KVsipsYsYMv/yG54CaStidUVpSv0BOqzJ7Q6MUmF5/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekMXKAldDk5A0/hhar1jOHHOX2Q5+uattPl9QYCAt6X9v1wnsFeNGA1JosAZ/es0X Tiv9Q7/ymF1zFeZK9G2HdhWRr/TJV+uklFxWM84Wfg7IhH7YNmqv6izFsp7pLjCcaS Rs2fYi35XmLWrR1l31E9Q+PVEjdJxhqzlrYUjIhJywMzefdHXaGf188SisQHImiei7 1amEhnFN4i+aa5BPaH5qv4CFUSnoJtveexr2aIp1C/ugP6OBhcgDT8WjJLJcBNVQRM 36p6EhJNL1HkZOoKC5fkGjeH4CVtZY3jbuW3dHjT+F4rCvlZ3j8F4+LyXnd088JGIW eOUjnglwhNl3A== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/15] tty: atmel_serial: use single DMA mapping for TX Date: Fri, 5 Apr 2024 08:08:24 +0200 Message-ID: <20240405060826.2521-14-jirislaby@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405060826.2521-1-jirislaby@kernel.org> References: <20240405060826.2521-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit dma_map_single() provides much easier interface for simple mappings as used for TX in atmel_serial. So switch to that, removing all the s-g unnecessary handling. Note that it is not easy (maybe impossible) to use kfifo_dma_* API for atmel's serial purposes. It handles DMA very specially. Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Genoud Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: linux-arm-kernel@lists.infradead.org --- drivers/tty/serial/atmel_serial.c | 35 +++++++++++++------------------ 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 5bb5e4303754..69ec80ffc97b 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -132,7 +132,7 @@ struct atmel_uart_port { struct dma_async_tx_descriptor *desc_rx; dma_cookie_t cookie_tx; dma_cookie_t cookie_rx; - struct scatterlist sg_tx; + dma_addr_t tx_phys; struct scatterlist sg_rx; struct tasklet_struct tasklet_rx; struct tasklet_struct tasklet_tx; @@ -904,8 +904,8 @@ static void atmel_release_tx_dma(struct uart_port *port) if (chan) { dmaengine_terminate_all(chan); dma_release_channel(chan); - dma_unmap_sg(port->dev, &atmel_port->sg_tx, 1, - DMA_TO_DEVICE); + dma_unmap_single(port->dev, atmel_port->tx_phys, + UART_XMIT_SIZE, DMA_TO_DEVICE); } atmel_port->desc_tx = NULL; @@ -922,7 +922,7 @@ static void atmel_tx_dma(struct uart_port *port) struct tty_port *tport = &port->state->port; struct dma_chan *chan = atmel_port->chan_tx; struct dma_async_tx_descriptor *desc; - struct scatterlist sgl[2], *sg, *sg_tx = &atmel_port->sg_tx; + struct scatterlist sgl[2], *sg; unsigned int tx_len, tail, part1_len, part2_len, sg_len; dma_addr_t phys_addr; @@ -955,7 +955,7 @@ static void atmel_tx_dma(struct uart_port *port) sg_init_table(sgl, 2); sg_len = 0; - phys_addr = sg_dma_address(sg_tx) + tail; + phys_addr = atmel_port->tx_phys + tail; if (part1_len) { sg = &sgl[sg_len++]; sg_dma_address(sg) = phys_addr; @@ -987,7 +987,8 @@ static void atmel_tx_dma(struct uart_port *port) return; } - dma_sync_sg_for_device(port->dev, sg_tx, 1, DMA_TO_DEVICE); + dma_sync_single_for_device(port->dev, atmel_port->tx_phys, + UART_XMIT_SIZE, DMA_TO_DEVICE); atmel_port->desc_tx = desc; desc->callback = atmel_complete_tx_dma; @@ -1014,7 +1015,7 @@ static int atmel_prepare_tx_dma(struct uart_port *port) dma_cap_mask_t mask; struct dma_slave_config config; struct dma_chan *chan; - int ret, nent; + int ret; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -1029,26 +1030,18 @@ static int atmel_prepare_tx_dma(struct uart_port *port) dma_chan_name(atmel_port->chan_tx)); spin_lock_init(&atmel_port->lock_tx); - sg_init_table(&atmel_port->sg_tx, 1); /* UART circular tx buffer is an aligned page. */ BUG_ON(!PAGE_ALIGNED(tport->xmit_buf)); - sg_set_page(&atmel_port->sg_tx, - virt_to_page(tport->xmit_buf), - UART_XMIT_SIZE, - offset_in_page(tport->xmit_buf)); - nent = dma_map_sg(port->dev, - &atmel_port->sg_tx, - 1, - DMA_TO_DEVICE); + atmel_port->tx_phys = dma_map_single(port->dev, tport->xmit_buf, + UART_XMIT_SIZE, DMA_TO_DEVICE); - if (!nent) { + if (dma_mapping_error(port->dev, atmel_port->tx_phys)) { dev_dbg(port->dev, "need to release resource of dma\n"); goto chan_err; } else { - dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, - sg_dma_len(&atmel_port->sg_tx), - tport->xmit_buf, - &sg_dma_address(&atmel_port->sg_tx)); + dev_dbg(port->dev, "%s: mapped %lu@%p to %pad\n", __func__, + UART_XMIT_SIZE, tport->xmit_buf, + &atmel_port->tx_phys); } /* Configure the slave DMA */ -- 2.44.0