All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: Yong Zhi <yong.zhi@intel.com>
Cc: Sakari Ailus <sakari.ailus@iki.fi>,
	linux-media@vger.kernel.org,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	"Zheng, Jian Xu" <jian.xu.zheng@intel.com>,
	"Mani, Rajmohan" <rajmohan.mani@intel.com>,
	hyungwoo.yang@intel.com
Subject: Re: [PATCH 3/3] [media] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Date: Thu, 25 May 2017 23:57:35 +0900	[thread overview]
Message-ID: <CAAFQd5AseYifg_saO9YqGP1b++CrYqJAdjU0jg+g0XJvzi74Sw@mail.gmail.com> (raw)
In-Reply-To: <CAAFQd5Df=wyZcXxU7qOPouCDOQ7HT1XFo5Oh9Tj3uPcT3eDuSg@mail.gmail.com>

Hi Yong,

On Wed, May 10, 2017 at 12:27 AM, Tomasz Figa <tfiga@chromium.org> wrote:
> On Tue, May 2, 2017 at 9:00 PM, Sakari Ailus <sakari.ailus@iki.fi> wrote:
>> Hi Yong,
>>
>> Thanks for the patches! Some comments below.
>>
>> On Sat, Apr 29, 2017 at 06:34:36PM -0500, Yong Zhi wrote:
>>> +
>>> +/**************** FBPT operations ****************/
>>> +
>>> +static void cio2_fbpt_exit_dummy(struct cio2_device *cio2)
>>> +{
>>> +     if (cio2->dummy_lop) {
>>> +             dma_free_noncoherent(&cio2->pci_dev->dev, PAGE_SIZE,
>>> +                             cio2->dummy_lop, cio2->dummy_lop_bus_addr);
>>> +             cio2->dummy_lop = NULL;
>>> +     }
>>> +     if (cio2->dummy_page) {
>>> +             dma_free_noncoherent(&cio2->pci_dev->dev, PAGE_SIZE,
>>> +                             cio2->dummy_page, cio2->dummy_page_bus_addr);
>>> +             cio2->dummy_page = NULL;
>>> +     }
>>> +}
>>> +
>>> +static int cio2_fbpt_init_dummy(struct cio2_device *cio2)
>>> +{
>>> +     unsigned int i;
>>> +
>>> +     cio2->dummy_page = dma_alloc_noncoherent(&cio2->pci_dev->dev, PAGE_SIZE,
>>> +                                     &cio2->dummy_page_bus_addr, GFP_KERNEL);
>>> +     cio2->dummy_lop = dma_alloc_noncoherent(&cio2->pci_dev->dev, PAGE_SIZE,
>>> +                                     &cio2->dummy_lop_bus_addr, GFP_KERNEL);
>>> +     if (!cio2->dummy_page || !cio2->dummy_lop) {
>>> +             cio2_fbpt_exit_dummy(cio2);
>>> +             return -ENOMEM;
>>> +     }
>>> +     /*
>>> +      * List of Pointers(LOP) contains 1024x32b pointers to 4KB page each
>>> +      * Initialize each entry to dummy_page bus base address.
>>> +      */
>>> +     for (i = 0; i < PAGE_SIZE / sizeof(*cio2->dummy_lop); i++)
>>> +             cio2->dummy_lop[i] = cio2->dummy_page_bus_addr >> PAGE_SHIFT;
>>> +
>>> +     dma_sync_single_for_device(&cio2->pci_dev->dev, /* DMA phy addr */
>>> +                     cio2->dummy_lop_bus_addr, PAGE_SIZE, DMA_TO_DEVICE);
>>> +
>>> +     return 0;
>>> +}
>>> +
>>> +static void cio2_fbpt_entry_enable(struct cio2_device *cio2,
>>> +                                struct cio2_fbpt_entry entry[CIO2_MAX_LOPS])
>>> +{
>>> +     dma_wmb();
>>
>> Is there a particular reason to have this?
>>
>> The documentation states that (Documentation/memory-barriers.txt):
>>
>>      These are for use with consistent memory to guarantee the ordering
>>      of writes or reads of shared memory accessible to both the CPU and a
>>      DMA capable device.
>>
>> This is while the device does not do cache coherent DMA.
>
> I think the first question we should ask is why the driver allocates
> non-consistent memory for this kind of structures. Looks like a waste
> of cachelines, given that it seems to be a primarily write-only memory
> (from CPU point of view), with rare read backs of entry[0] to check
> the flags, which can be modified by the device. Moreover, the fact
> that the memory is being cached actually defeats the barrier, as you
> first write entry[1..N], call the barrier, write entry[0] and then
> flush the cache starting from entry[0], which means that the hardware
> sees entry[0] (+/- the size of the cacheline) before further entries.
>
> Other than that, I think the barrier makes sense, as the compiler (or
> even the CPU or buses) could reorder the writes without it, regardless
> of whether the memory is consistent or not. (Of course the cache
> flushing problem above remains if the memory is non-consistent.)

Any updates on this and other comments?

Best regards,
Tomasz

  reply	other threads:[~2017-05-25 14:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-29 23:34 [PATCH 0/3] [media] add IPU3 CIO2 CSI2 driver Yong Zhi
2017-04-29 23:34 ` [PATCH 1/3] [media] videodev2.h, v4l2-ioctl: add IPU3 raw10 color format Yong Zhi
2017-04-29 23:34 ` [PATCH 2/3] [media] doc-rst: add IPU3 raw10 bayer pixel format definitions Yong Zhi
2017-05-08  8:33   ` Hans Verkuil
2017-05-16 12:02   ` Sakari Ailus
2017-04-29 23:34 ` [PATCH 3/3] [media] intel-ipu3: cio2: Add new MIPI-CSI2 driver Yong Zhi
2017-04-30  0:33   ` kbuild test robot
2017-05-02 13:00   ` Sakari Ailus
2017-05-03 10:57     ` Tuukka Toivonen
2017-05-03 20:23       ` Sakari Ailus
2017-05-09 15:27     ` Tomasz Figa
2017-05-25 14:57       ` Tomasz Figa [this message]
2017-05-03  8:58   ` Sakari Ailus
2017-05-03 11:06     ` Tuukka Toivonen
2017-05-03 20:25       ` Sakari Ailus
2017-05-03 20:35   ` Hans Verkuil
2017-05-03 21:00     ` Sakari Ailus
2017-05-08  9:06   ` Hans Verkuil
2017-05-08 12:10     ` Sakari Ailus
2017-05-08 12:32       ` Hans Verkuil
2017-05-08 12:56         ` Sakari Ailus
2017-05-08 13:08           ` Hans Verkuil
2017-05-08 21:32             ` Sakari Ailus
2017-06-01 10:27   ` Sakari Ailus

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=CAAFQd5AseYifg_saO9YqGP1b++CrYqJAdjU0jg+g0XJvzi74Sw@mail.gmail.com \
    --to=tfiga@chromium.org \
    --cc=hyungwoo.yang@intel.com \
    --cc=jian.xu.zheng@intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=rajmohan.mani@intel.com \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yong.zhi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.