Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp352726pxu; Fri, 23 Oct 2020 02:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBOHzpM8bXxZSohAK72/aJnX01ExcKpnrviaROP+au2VGdQO6OLeIoJ7MOdtZHxXsTFjsm X-Received: by 2002:a17:906:1c8f:: with SMTP id g15mr1027243ejh.179.1603445401437; Fri, 23 Oct 2020 02:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603445401; cv=none; d=google.com; s=arc-20160816; b=v7xkJVKjo3gSJh15yLlAKtOUhHTsDImTut7sGWajLIoLGZ6UV5dvg6Sb/9Xh5fwcRM M+j4aoGvqwOMrVrmt+oHeWK1I9PGRcYi5bgeV2CkL0z/z7ULkwI+UyqsGTvHWjWUspv7 qIXZY5msKnxsA5SB8Gk5uMIBJlhNOa5zUr577W7i+k7F6tkp97zqb5oA89Xxbfr/VBcT 6MOnvhCcA9/UMeyYSVe142ss7gaGi11mvEdxW6TYJmiTxXwWWi4x8qHaz7T0iQiJpE3j IgZevOOKqJT0u2QKw/Vu2ie2y5AjJ7QnR5yKXgwMrUHYy0xJIc8pM6L+l8C/u/LwnAE5 6VKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bO9d4/8VddxQSew19V0MnlbQL7WrSOvaPC7e14MIGxc=; b=HIjsDVn/uxjJQ3xOwK/uA+Pc9NU+OpddJ2CCGz7+ojDsDV7cow6lACQPhi+91YRSaw KcVlLbAnz41+aQQfbCRjWnNZKWY7O2BV/JIdVZBjAdtNPqa3pLNR1GQvd2qTUisRgS1S cJgSJmO28Em1PB3QBxSGRPndJfd/Ex4njRxBzyDV5PF5VmuFvAtb21fTQZyCb0hiIXrF kzdTcQoZCHiij6Q71OukpYHV5CmoEZhr1RQxMmF2rjdOlbRjdGVKwLr50WnGUXzvogHb pASbhvlKRrPLxwib8FXgVbYAlnjzPjPTG0srGl5taH3wJl33MMTy2wOo+AIkD0Phghed BVSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bMs3H12C; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx20si482721ejb.701.2020.10.23.02.29.39; Fri, 23 Oct 2020 02:30:01 -0700 (PDT) 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=@infradead.org header.s=casper.20170209 header.b=bMs3H12C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S461425AbgJWJZe (ORCPT + 99 others); Fri, 23 Oct 2020 05:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S461101AbgJWJZc (ORCPT ); Fri, 23 Oct 2020 05:25:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398D1C0613CE; Fri, 23 Oct 2020 02:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bO9d4/8VddxQSew19V0MnlbQL7WrSOvaPC7e14MIGxc=; b=bMs3H12C0UD+AXbZSWgF2V+FVn H1GG0oimFk7AUhal9+QFfWnCEIThL0YThVnEKz+E3S3p5+vMAlZsdcogYCE3IaqSvXXCfzwDPYvct fjwVAb60LJehSk3xEe+okJz/qEUbqh846voXjVtSRiOlR9Qd74IxR7fnIFgUupCdfb1I+X9MRw0Rd 3Rvgv8+v7QfPVUKqXE4NEw6CWWEfHX759MwJTy4dhk0gva5Vr7psMOaX/iD8+v6DZa2g8X0ZM0BFs wuj4jsgC/Trq0Cch7iqX7OIpZokrA+XiWUXM3gcCF/xq6YWijJbGIkPUfRplGdVseXUI1LmDnDz9s 2fe089zw==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVtK8-0007vB-4p; Fri, 23 Oct 2020 09:25:24 +0000 Date: Fri, 23 Oct 2020 10:25:24 +0100 From: Christoph Hellwig To: Sherry Sun Cc: hch@infradead.org, sudeep.dutt@intel.com, ashutosh.dixit@intel.com, arnd@arndb.de, gregkh@linuxfoundation.org, kishon@ti.com, lorenzo.pieralisi@arm.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-imx@nxp.com Subject: Re: [PATCH V3 1/4] misc: vop: change the way of allocating vring and device page Message-ID: <20201023092524.GA29066@infradead.org> References: <20201022050638.29641-1-sherry.sun@nxp.com> <20201022050638.29641-2-sherry.sun@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201022050638.29641-2-sherry.sun@nxp.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > static int mic_dp_init(struct mic_device *mdev) > { > - mdev->dp = kzalloc(MIC_DP_SIZE, GFP_KERNEL); > + mdev->dp = dma_alloc_coherent(&mdev->pdev->dev, MIC_DP_SIZE, > + &mdev->dp_dma_addr, GFP_KERNEL); > if (!mdev->dp) > return -ENOMEM; > > - mdev->dp_dma_addr = mic_map_single(mdev, > - mdev->dp, MIC_DP_SIZE); > - if (mic_map_error(mdev->dp_dma_addr)) { > - kfree(mdev->dp); > - dev_err(&mdev->pdev->dev, "%s %d err %d\n", > - __func__, __LINE__, -ENOMEM); > - return -ENOMEM; > - } > mdev->ops->write_spad(mdev, MIC_DPLO_SPAD, mdev->dp_dma_addr); > mdev->ops->write_spad(mdev, MIC_DPHI_SPAD, mdev->dp_dma_addr >> 32); > return 0; > @@ -68,8 +62,7 @@ static int mic_dp_init(struct mic_device *mdev) > /* Uninitialize the device page */ > static void mic_dp_uninit(struct mic_device *mdev) > { > - mic_unmap_single(mdev, mdev->dp_dma_addr, MIC_DP_SIZE); > - kfree(mdev->dp); > + dma_free_coherent(&mdev->pdev->dev, MIC_DP_SIZE, mdev->dp, mdev->dp_dma_addr); > } This adds an over 80 char line. Also please just kill mic_dp_init and mic_dp_uninit and inline those into the callers. > + vvr->buf = dma_alloc_coherent(vop_dev(vdev), VOP_INT_DMA_BUF_SIZE, > + &vvr->buf_da, GFP_KERNEL); Another overly long line. > @@ -1068,7 +1049,7 @@ vop_query_offset(struct vop_vdev *vdev, unsigned long offset, > struct vop_vringh *vvr = &vdev->vvr[i]; > > if (offset == start) { > - *pa = virt_to_phys(vvr->vring.va); > + *pa = vqconfig[i].address; vqconfig[i].address is a __le64, so this needs an endian swap. But more importantly the caller of vop_query_offset, vop_mmap, uses remap_pfn_range and pa. You cannot mix remap_pfn_range with DMA coherent allocations, it can only be mmaped using dma_mmap_coherent.