From patchwork Sun Mar 25 10:59:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10306569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D5F960385 for ; Sun, 25 Mar 2018 11:00:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 674F32855C for ; Sun, 25 Mar 2018 11:00:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 580B929332; Sun, 25 Mar 2018 11:00:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D1BF62855C for ; Sun, 25 Mar 2018 11:00:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C0A816E413; Sun, 25 Mar 2018 11:00:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC28A6E40D; Sun, 25 Mar 2018 11:00:03 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id h76so10496160wme.4; Sun, 25 Mar 2018 04:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/8rXrlmJIvmA7Mvmam60QlNM9ZrXQbrB/RkPqcAoqoM=; b=EaXSwtlS369PAWaSmZY0cblZVO5tFWZ8UmvK5iqse2Zem/S6dlV4jmYAT76x6FoCYb XAEKHfuidRrvFr4K7L5T/MMn9dEBD7qTbr0f7TRyrqrcvgMkpqf1scI1y6mIf99H0Ejh a84ChPgrt+vDUlIZrjBcvRTN2dhggu6sSjv8vgyGbCGhmkYz8ibTjeepM4OpxPnRUyOE PPn9OSVembU547cPuLNpZOFFo+TXnBiCuFB+xlM61RP76RkfNnETOiYtR8VAMaTbZAG0 3jsseFDKe+OYpkCOyhoGMpSM5gxEFxWm/a5hFzwO2QJT7Ai88PM7Jzh7vtymqzIyqVVn 31kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/8rXrlmJIvmA7Mvmam60QlNM9ZrXQbrB/RkPqcAoqoM=; b=L19XTho/qRagTmXh7QUn2up5OI3PdAgSR25mLYSizJsfIl9/uXq6V2LwkCbj9Xhi7H NgCwLRT0G9dJKVFvOBbMslLuE8S+mYoIaO1vttDC6DskPdYuvn6aPGLCV9VIf26NQCh3 /wSJe/s7JaqTxXRMVrfL/I47MVybHBJq4+rI0t0MOyWk7/9dR8tBgDVv4JygXvDqhHzs 5wWIYjXh5CFLTA1BYufz1oaqvwKO71hWOOp6xxJSjbkakVM4h78h0tyzBROQJxrPcCOj C26QsDaOU6XFidlN/qe6MU4/W6MtT8vp2U56dvL8k9XWvCvsyuBtD3MQqz00wDuWtBsu 3L3w== X-Gm-Message-State: AElRT7HJzyFfYWabpYZ0MCG0PSmjsakrjaQlp1agZnPsEsKstEj5VqpE KP2TDrIQ6Tuh/nBYmvlu4Ok= X-Google-Smtp-Source: AG47ELvwwBAOxX4kUelnOGu6zCSqT74bNuM36ebp4K+39XIYrLdmVvDEOU9Gs9pReiltBNzjdHLtXw== X-Received: by 10.28.195.67 with SMTP id t64mr9799599wmf.113.1521975602301; Sun, 25 Mar 2018 04:00:02 -0700 (PDT) Received: from baker.fritz.box ([2a02:908:1257:4460:80f2:8bcd:4355:2edc]) by smtp.gmail.com with ESMTPSA id z3sm20492230wme.3.2018.03.25.04.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Mar 2018 04:00:01 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] lib/scatterlist: add sg_set_dma_addr() helper Date: Sun, 25 Mar 2018 12:59:53 +0200 Message-Id: <20180325110000.2238-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use this function to set an sg entry to point to device resources mapped using dma_map_resource(). The page pointer is set to NULL and only the DMA address, length and offset values are valid. Signed-off-by: Christian König --- include/linux/scatterlist.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 22b2131bcdcd..f944ee4e482c 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -149,6 +149,29 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf, sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); } +/** + * sg_set_dma_addr - Set sg entry to point at specified dma address + * @sg: SG entry + * @address: DMA address to set + * @len: Length of data + * @offset: Offset into page + * + * Description: + * Use this function to set an sg entry to point to device resources mapped + * using dma_map_resource(). The page pointer is set to NULL and only the DMA + * address, length and offset values are valid. + * + **/ +static inline void sg_set_dma_addr(struct scatterlist *sg, dma_addr_t address, + unsigned int len, unsigned int offset) +{ + sg_set_page(sg, NULL, len, offset); + sg->dma_address = address; +#ifdef CONFIG_NEED_SG_DMA_LENGTH + sg->dma_length = len; +#endif +} + /* * Loop over each sg element, following the pointer to a new list if necessary */