Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5548162pxb; Wed, 26 Jan 2022 14:43:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3NyK/qjQU9LLzNjKQ3ne8nxCnGAzGMlhpiU5miMNpENAy09OJ9Bn1rOTHW+uTRGXIJWIT X-Received: by 2002:a05:6402:190d:: with SMTP id e13mr1153736edz.38.1643237037277; Wed, 26 Jan 2022 14:43:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643237037; cv=none; d=google.com; s=arc-20160816; b=q/FV1jcAzrb85icTeDaLq/7NM5M3WqG71ZJ+Fdrp4RvjLntDzKDjpfeuUO5lU24It7 x0VRs99zS//86RQdCcvJmb4x3yHLXwk/GPGZoUn0sQspOm/hNuwM9o9Qpf7U0kxWUBOn mxLF7lnYyg61ol7NQeDsi//jtmL4/Jj0/XmHSjHrYjy09oKSqbAThKH4qYcK8OyI2j77 STPdFsDz4H5+9gGcm0+EqXsEDE17viKSM0wqUc+5C9aSjMqG1BtPhDpmlz8fWmqfA8fI 9jNYxl3RbHXSAgL2MTsMkqmlICFRRbEPNE+3H89mOHqp2k8a0YIhzkxTG6cq9oDBXhoo E4dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=svVcHi5JSpOvpblxB4CzFcNbmkdRXarhhuosFn3oXZw=; b=zV3ycilWiMDzqOEMP+l907qHbVBIlU70RHkqvVV4atLUPg3zNE3jcpCuapZZEYlK7p 9pGxJiaoHIXr632TuQZw8IBjMIC4EgkGJwz3ogjS23aXS9rlOkfDM02GaQQhmyQ34HrU oKailVyW3fNQAYNNJLpU1uXr8ldXU6GdOm0g8rYpEoJtmaovLe3G1Fkz4sm+LbxKnDpy 86dvWCSEdlUAeVSWt2PzmHLYLIlPibEE/CO3i9zEZ98MXUSLBXc3ZaSLDauDJR5jhwtH 7mu837aItwwF92admG7AK66IWAfr72TOOEVX5D5V8SHx1UBox5sw6H3xx5vW5atvryUy EIgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FqpofSRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si334780edt.243.2022.01.26.14.43.30; Wed, 26 Jan 2022 14:43:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FqpofSRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231262AbiAZUgm (ORCPT + 99 others); Wed, 26 Jan 2022 15:36:42 -0500 Received: from mga01.intel.com ([192.55.52.88]:9982 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbiAZUge (ORCPT ); Wed, 26 Jan 2022 15:36:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643229394; x=1674765394; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IrlXjlrSWxXOy2UwGYcFGyJqa/q0NhSjnDXBLVc54aM=; b=FqpofSRbgvaR6lMfozaw2Cl3YmTpyQoogo2Tjh4B2IIk0Q7jiUQS7CgT BTiUBCIDogOC9z2N0VmjOwM/GzDRrpilbyVdV0orqlUrKZ8782oJE179V uu1IovWSYNWYcMClPD7LEuHZWeRTWDwzkYO4FcPNq9vTPEqkAzAOG9P9H 1faxjSWQgiVk6wCWUAUQtoljkp/gvVlRDwuCVZ/StkMGvFh7oYCRvYJgp 3c9mb/rm3FdLGTAEzhyKveBPz8TMiUFeePuMRl4jtEtgS8Og78pgJXTWS E2u8uDoIDprkByqGv/jTdS6Uamz9XG6kA7oIcT5kgXtIPGODgULJpr9NU w==; X-IronPort-AV: E=McAfee;i="6200,9189,10239"; a="271098470" X-IronPort-AV: E=Sophos;i="5.88,319,1635231600"; d="scan'208";a="271098470" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 12:36:26 -0800 X-IronPort-AV: E=Sophos;i="5.88,319,1635231600"; d="scan'208";a="581221519" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.202]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 12:36:23 -0800 From: Lucas De Marchi To: intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, Matt Roper , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/19] dma-buf-map: Add wrapper over memset Date: Wed, 26 Jan 2022 12:36:52 -0800 Message-Id: <20220126203702.1784589-10-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220126203702.1784589-1-lucas.demarchi@intel.com> References: <20220126203702.1784589-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like memcpy_toio(), there is also need to write a direct value to a memory block. Add dma_buf_map_memset() to abstract memset() vs memset_io() Cc: Matt Roper Cc: Sumit Semwal Cc: Christian König Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Lucas De Marchi --- include/linux/dma-buf-map.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h index 3514a859f628..c9fb04264cd0 100644 --- a/include/linux/dma-buf-map.h +++ b/include/linux/dma-buf-map.h @@ -317,6 +317,23 @@ static inline void dma_buf_map_memcpy_to(struct dma_buf_map *dst, const void *sr memcpy(dst->vaddr, src, len); } +/** + * dma_buf_map_memset - Memset into dma-buf mapping + * @dst: The dma-buf mapping structure + * @value: The value to set + * @len: The number of bytes to set in dst + * + * Set value in dma-buf mapping. Depending on the buffer's location, the helper + * picks the correct method of accessing the memory. + */ +static inline void dma_buf_map_memset(struct dma_buf_map *dst, int value, size_t len) +{ + if (dst->is_iomem) + memset_io(dst->vaddr_iomem, value, len); + else + memset(dst->vaddr, value, len); +} + /** * dma_buf_map_incr - Increments the address stored in a dma-buf mapping * @map: The dma-buf mapping structure -- 2.35.0