From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: rubini@gnudd.com, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH] x86/PCI: sta2x11: use default DMA address translation ops
Date: Fri, 18 Oct 2019 10:51:58 +0200 [thread overview]
Message-ID: <c0fe3d2189130449a2de64b5a0ed4b3325a7602e.camel@suse.de> (raw)
In-Reply-To: <20191017224120.GA68948@google.com>
[-- Attachment #1: Type: text/plain, Size: 3263 bytes --]
Hi Bjorn,
thanks for having a look at it.
On Thu, 2019-10-17 at 17:41 -0500, Bjorn Helgaas wrote:
> Hi Nicolas,
>
> I'm hoping Christoph will chime in and one of the x86 guys will merge
> this, since I'm not a DMA expert. Trivial comments/questions below.
>
> On Wed, Oct 16, 2019 at 06:51:37PM +0200, Nicolas Saenz Julienne wrote:
> > The devices found behind this PCIe chip have unusual DMA mapping
> > constraints as there is an AMBA interconnect placed in between them and
> > the different PCI endpoints. The offset between physical memory
> > addresses and AMBA's view is provided by reading a PCI config register,
> > which is saved and used whenever DMA mapping is needed.
> >
> > It turns out that this DMA setup can be represented by properly setting
> > 'dma_pfn_offset', 'dma_bus_mask' and 'dma_mask' during the PCI device
> > enable fixup. And ultimately allows us to get rid of this device's
> > custom DMA functions.
> >
> > Aside from the code deletion and DMA setup, sta2x11_pdev_to_mapping() is
> > moved to avoid warnings whenever CONFIG_PM is not enabled.
> >
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > - pci_read_config_dword(pdev, AHB_BASE(0), &map->amba_base);
> > +
> > + pci_read_config_dword(pdev, AHB_BASE(0), &amba_base);
> > + dev->dma_pfn_offset = PFN_DOWN(-amba_base);
> > + dev->bus_dma_mask = amba_base + STA2X11_AMBA_SIZE - 1;
>
> I think of a mask as typically being one less than a power of two, but
> that's not the case here, e.g., STA2X11_AMBA_SIZE - 1 == 0x1fffffff
> (512MB-1), so if amba_size is 1G, the mask will be 0x5fffffff.
>
> Just double-checking to be sure that's what you intend.
Yes I'm aware of it.
I know it's counter-intuitive name wise but dma-direct uses it more like a top
address than a mask (see for example 'dma_capable()' in dma-direct.h). There is
at least another driver using 'dev->bus_dma_mask' as such (see
arch/powerpc/sysdev/fsl_pci.c).
That said, I agree it something Christoph should ratify for this to get merged.
> > + pci_set_consistent_dma_mask(pdev, amba_base + STA2X11_AMBA_SIZE - 1);
> > + pci_set_dma_mask(pdev, amba_base + STA2X11_AMBA_SIZE - 1);
>
> Maybe add a local variable instead of repeating the "amba_base + ..."
> expression three times?
Noted.
> > /* Configure AHB mapping */
> > pci_write_config_dword(pdev, AHB_PEXLBASE(0), 0);
> > @@ -252,14 +156,25 @@ static void sta2x11_map_ep(struct pci_dev *pdev)
> > pci_write_config_dword(pdev, AHB_CRW(i), 0);
> >
> > dev_info(&pdev->dev,
> > - "sta2x11: Map EP %i: AMBA address %#8x-%#8x\n",
> > - sta2x11_pdev_to_ep(pdev), map->amba_base,
> > - map->amba_base + STA2X11_AMBA_SIZE - 1);
> > + "sta2x11: Map EP %i: AMBA address %#8x-%#8llx\n",
> > + sta2x11_pdev_to_ep(pdev), amba_base, dev->bus_dma_mask);
>
> This would read better as
>
> amba_base, amba_base + STA2X11_AMBA_SIZE - 1
>
> I know that's the same dev->bus_dma_mask, but a "mask" is not the
> obvious name for the end of a range.
Ok.
I just got a notification from my mail server that it failed to deliver the
mail to Christoph, it seems I misspelled it.
I'll fix all this and send a v2.
Regards,
Nicolas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-10-18 8:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 16:51 Nicolas Saenz Julienne
2019-10-17 22:41 ` Bjorn Helgaas
2019-10-18 8:51 ` Nicolas Saenz Julienne [this message]
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=c0fe3d2189130449a2de64b5a0ed4b3325a7602e.camel@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=bp@alien8.de \
--cc=helgaas@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rubini@gnudd.com \
--cc=tglx@linutronix.de \
--cc=x86@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®