linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sherry Sun <sherry.sun@nxp.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "sudeep.dutt@intel.com" <sudeep.dutt@intel.com>,
	"ashutosh.dixit@intel.com" <ashutosh.dixit@intel.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"kishon@ti.com" <kishon@ti.com>,
	"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: RE: [PATCH V3 1/4] misc: vop: change the way of allocating vring and device page
Date: Mon, 26 Oct 2020 02:54:43 +0000	[thread overview]
Message-ID: <VI1PR04MB4960119E6D56CF64E8FD2E4492190@VI1PR04MB4960.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20201023092524.GA29066@infradead.org>

Hi Christoph,

> 
> >  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.

Okay, will fix them.
> 
> > +		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.

Will change to use dma_mmap_coherent in V4.

Best regards
Sherry 

  reply	other threads:[~2020-10-26  2:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22  5:06 [PATCH V3 0/4] Change vring space from nomal memory to dma coherent memory Sherry Sun
2020-10-22  5:06 ` [PATCH V3 1/4] misc: vop: change the way of allocating vring and device page Sherry Sun
2020-10-22  7:58   ` kernel test robot
2020-10-23  9:25   ` Christoph Hellwig
2020-10-26  2:54     ` Sherry Sun [this message]
2020-10-22  5:06 ` [PATCH V3 2/4] misc: vop: do not allocate and reassign the used ring Sherry Sun
2020-10-22  8:53   ` kernel test robot
2020-10-23  9:26   ` Christoph Hellwig
2020-10-26  3:04     ` Sherry Sun
2020-10-27  6:28       ` gregkh
2020-10-22  5:06 ` [PATCH V3 3/4] misc: vop: simply return the saved dma address instead of virt_to_phys Sherry Sun
2020-10-22  5:06 ` [PATCH V3 4/4] misc: vop: mapping kernel memory to user space as noncached Sherry Sun
2020-10-23  9:28   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR04MB4960119E6D56CF64E8FD2E4492190@VI1PR04MB4960.eurprd04.prod.outlook.com \
    --to=sherry.sun@nxp.com \
    --cc=arnd@arndb.de \
    --cc=ashutosh.dixit@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=kishon@ti.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=sudeep.dutt@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).