mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Kelvin.Cao@microchip.com
Cc: hch@infradead.org, dmaengine@vger.kernel.org, vkoul@kernel.org,
	George.Ge@microchip.com, linux-kernel@vger.kernel.org,
	logang@deltatee.com
Subject: Re: [PATCH v2 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver
Date: Thu, 13 Apr 2023 22:57:29 -0700	[thread overview]
Message-ID: <ZDjrSVVv8LZDEfQY@infradead.org> (raw)
In-Reply-To: <c86fe78f384295d5694b1534efa1f5b070c8123c.camel@microchip.com>

On Thu, Apr 13, 2023 at 11:22:14PM +0000, Kelvin.Cao@microchip.com wrote:
> On Mon, 2023-04-10 at 18:42 +0200, Christoph Hellwig wrote:
> > 
> > > +     writew((__force u16)cpu_to_le16(SWITCHTEC_DMA_SQ_SIZE),
> > > +            &swdma_chan->mmio_chan_fw->sq_size);
> > > +     writew((__force u16)cpu_to_le16(SWITCHTEC_DMA_CQ_SIZE),
> > > +            &swdma_chan->mmio_chan_fw->cq_size);
> > 
> > This looks broken to me, writew always expects cpu endian arguments
> > and byte swaps on big endian systems.
> 
> Do you mean writew assumes the peripherals be little-endian, and will
> do the swap when host is bit-endian?

Yes.  All the standard mmio accessors ({read,write}{b,w,l,q}) do that.

> > But I find the whole pcim_iomap_table concept very confusing to the
> > reader of the driver, and given that it doesn't really use many
> > devm or pcim routines I'd suggest removing them all and sticking to
> > one well understood way of manging resource lifetimes.
> 
> I didn't get it. Do you have specific suggestion?


 - instead of pcim_enable_device call pci_enable_device, and then
   just call pci_disable_device in ->remove and on error
 - instead of pcim_iomap_regions, call pci_request_mem_regions on
   probe, and pci_release_mem_regions on release / fail, and then
   do an ioremap(pci_resource_start(pdev, 1) for the actual bar
   (and iounmap on release/fail) instead of pcim_iomap_table.

> > dma_set_mask_and_coherent for a smaller mask will never succeed when
> > trying to set it to a larger one failed.  So you can remove the
> > second
> > call here.
> 
> By default the kernel assumes the device can address 32-bit address
> space,

Yes.

> I wonder why it wouldn't allow 32-bit mask when it failes 64-
> bit?

The kernel never fails setting a 64-bit DMA mask, it only fails setting
too small masks.

  reply	other threads:[~2023-04-14  5:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 18:06 [PATCH v2 0/1] Switchtec Switch DMA Engine Driver Kelvin Cao
2023-04-03 18:06 ` [PATCH v2 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver Kelvin Cao
2023-04-03 20:26   ` Christophe JAILLET
2023-04-03 21:13     ` Kelvin.Cao
2023-04-10 16:42   ` Christoph Hellwig
2023-04-11 15:47     ` Logan Gunthorpe
2023-04-13 19:00       ` Kelvin.Cao
2023-04-13 22:40     ` Kelvin.Cao
2023-04-14  5:50       ` Christoph Hellwig
2023-04-14 23:08         ` Kelvin.Cao
2023-04-13 23:22     ` Kelvin.Cao
2023-04-14  5:57       ` Christoph Hellwig [this message]
2023-04-03 18:06 ` [PATCH v2 0/1] Switchtec Switch DMA Engine Driver Kelvin Cao
2023-04-03 18:06 ` [PATCH v2 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver Kelvin Cao

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=ZDjrSVVv8LZDEfQY@infradead.org \
    --to=hch@infradead.org \
    --cc=George.Ge@microchip.com \
    --cc=Kelvin.Cao@microchip.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=vkoul@kernel.org \
    /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

all inboxes | Powered by JetHome®