09 Aug, 2013

1 commit


28 Jun, 2013

1 commit

  • Convert printks to pr_ (excludes printk(KERN_DEBUG...)
    to be more consistent throughout the xen subsystem.

    Add pr_fmt with KBUILD_MODNAME or "xen:" KBUILD_MODNAME
    Coalesce formats and add missing word spaces
    Add missing newlines
    Align arguments and reflow to 80 columns
    Remove DRV_NAME from formats as pr_fmt adds the same content

    This does change some of the prefixes of these messages
    but it also does make them more consistent.

    Signed-off-by: Joe Perches
    Signed-off-by: Konrad Rzeszutek Wilk

    Joe Perches
     

30 Jan, 2013

1 commit

  • Normal boot path on system with iommu support:
    swiotlb buffer will be allocated early at first and then try to initialize
    iommu, if iommu for intel or AMD could setup properly, swiotlb buffer
    will be freed.

    The early allocating is with bootmem, and could panic when we try to use
    kdump with buffer above 4G only, or with memmap to limit mem under 4G.
    for example: memmap=4095M$1M to remove memory under 4G.

    According to Eric, add _nopanic version and no_iotlb_memory to fail
    map single later if swiotlb is still needed.

    -v2: don't pass nopanic, and use -ENOMEM return value according to Eric.
    panic early instead of using swiotlb_full to panic...according to Eric/Konrad.
    -v3: make swiotlb_init to be notpanic, but will affect:
    arm64, ia64, powerpc, tile, unicore32, x86.
    -v4: cleanup swiotlb_init by removing swiotlb_init_with_default_size.

    Suggested-by: Eric W. Biederman
    Signed-off-by: Yinghai Lu
    Link: http://lkml.kernel.org/r/1359058816-7615-36-git-send-email-yinghai@kernel.org
    Reviewed-and-tested-by: Konrad Rzeszutek Wilk
    Cc: Joerg Roedel
    Cc: Ralf Baechle
    Cc: Jeremy Fitzhardinge
    Cc: Kyungmin Park
    Cc: Marek Szyprowski
    Cc: Arnd Bergmann
    Cc: Andrzej Pietrasiewicz
    Cc: linux-mips@linux-mips.org
    Cc: xen-devel@lists.xensource.com
    Cc: virtualization@lists.linux-foundation.org
    Cc: Shuah Khan
    Signed-off-by: H. Peter Anvin

    Yinghai Lu
     

30 Oct, 2012

3 commits

  • This change makes it so that the sync functionality also uses physical
    addresses. This helps to further reduce the use of virt_to_phys and
    phys_to_virt functions.

    In order to clarify things since we now have 2 physical addresses in use
    inside of swiotlb_tbl_sync_single I am renaming phys to orig_addr, and
    dma_addr to tlb_addr. This way is should be clear that orig_addr is
    contained within io_orig_addr and tlb_addr is an address within the
    io_tlb_addr buffer.

    Signed-off-by: Alexander Duyck
    Signed-off-by: Konrad Rzeszutek Wilk

    Alexander Duyck
     
  • This change makes it so that the unmap functionality also uses physical
    addresses. This helps to further reduce the use of virt_to_phys and
    phys_to_virt functions.

    In order to clarify things since we now have 2 physical addresses in use
    inside of swiotlb_tbl_unmap_single I am renaming phys to orig_addr, and
    dma_addr to tlb_addr. This way is should be clear that orig_addr is
    contained within io_orig_addr and tlb_addr is an address within the
    io_tlb_addr buffer.

    Signed-off-by: Alexander Duyck
    Signed-off-by: Konrad Rzeszutek Wilk

    Alexander Duyck
     
  • This change makes it so that swiotlb_tbl_map_single will return a physical
    address instead of a virtual address when called. The advantage to this once
    again is that we are avoiding a number of virt_to_phys and phys_to_virt
    translations by working with everything as a physical address.

    One change I had to make in order to support using physical addresses is that
    I could no longer trust 0 to be a invalid physical address on all platforms.
    So instead I made it so that ~0 is returned on error. This should never be a
    valid return value as it implies that only one byte would be available for
    use.

    In order to clarify things since we now have 2 physical addresses in use
    inside of swiotlb_tbl_map_single I am renaming phys to orig_addr, and
    dma_addr to tlb_addr. This way is should be clear that orig_addr is
    contained within io_orig_addr and tlb_addr is an address within the
    io_tlb_addr buffer.

    Signed-off-by: Alexander Duyck
    Signed-off-by: Konrad Rzeszutek Wilk

    Alexander Duyck
     

23 Sep, 2012

1 commit

  • * stable/late-swiotlb.v3.3:
    xen/swiotlb: Fix compile warnings when using plain integer instead of NULL pointer.
    xen/swiotlb: Remove functions not needed anymore.
    xen/pcifront: Use Xen-SWIOTLB when initting if required.
    xen/swiotlb: For early initialization, return zero on success.
    xen/swiotlb: Use the swiotlb_late_init_with_tbl to init Xen-SWIOTLB late when PV PCI is used.
    xen/swiotlb: Move the error strings to its own function.
    xen/swiotlb: Move the nr_tbl determination in its own function.
    swiotlb: add the late swiotlb initialization function with iotlb memory
    xen/swiotlb: With more than 4GB on 64-bit, disable the native SWIOTLB.
    xen/swiotlb: Simplify the logic.

    Conflicts:
    arch/x86/xen/pci-swiotlb-xen.c

    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     

18 Sep, 2012

3 commits

  • Sparse warns us off:
    drivers/xen/swiotlb-xen.c:506:1: warning: symbol 'xen_swiotlb_map_sg' was not declared. Should it be static?
    drivers/xen/swiotlb-xen.c:534:1: warning: symbol 'xen_swiotlb_unmap_sg' was not declared. Should it be static?

    and it looks like we do not need this function at all.

    Acked-by: Stefano Stabellini
    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     
  • If everything is setup properly we would return -ENOMEM since
    rc by default is set to that value. Lets not do that and return
    a proper return code.

    Note: The reason the early code needs this special treatment
    is that it SWIOTLB library call does not return anything (and
    had it failed it would call panic()) - but our function does.

    Acked-by: Stefano Stabellini
    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     
  • With this patch we provide the functionality to initialize the
    Xen-SWIOTLB late in the bootup cycle - specifically for
    Xen PCI-frontend. We still will work if the user had
    supplied 'iommu=soft' on the Linux command line.

    Note: We cannot depend on after_bootmem to automatically
    determine whether this is early or not. This is because
    when PCI IOMMUs are initialized it is after after_bootmem but
    before a lot of "other" subsystems are initialized.

    CC: FUJITA Tomonori
    [v1: Fix smatch warnings]
    [v2: Added check for xen_swiotlb]
    [v3: Rebased with new xen-swiotlb changes]
    [v4: squashed xen/swiotlb: Depending on after_bootmem is not correct in]
    Reviewed-by: Stefano Stabellini
    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     

17 Sep, 2012

2 commits


12 Sep, 2012

1 commit

  • …/tip into stable/for-linus-3.7

    * 'x86/platform' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (9690 commits)
    x86: Document x86_init.paging.pagetable_init()
    x86: xen: Cleanup and remove x86_init.paging.pagetable_setup_done()
    x86: Move paging_init() call to x86_init.paging.pagetable_init()
    x86: Rename pagetable_setup_start() to pagetable_init()
    x86: Remove base argument from x86_init.paging.pagetable_setup_start
    Linux 3.6-rc5
    HID: tpkbd: work even if the new Lenovo Keyboard driver is not configured
    Remove user-triggerable BUG from mpol_to_str
    xen/pciback: Fix proper FLR steps.
    uml: fix compile error in deliver_alarm()
    dj: memory scribble in logi_dj
    Fix order of arguments to compat_put_time[spec|val]
    xen: Use correct masking in xen_swiotlb_alloc_coherent.
    xen: fix logical error in tlb flushing
    xen/p2m: Fix one-off error in checking the P2M tree directory.
    powerpc: Don't use __put_user() in patch_instruction
    powerpc: Make sure IPI handlers see data written by IPI senders
    powerpc: Restore correct DSCR in context switch
    powerpc: Fix DSCR inheritance in copy_thread()
    powerpc: Keep thread.dscr and thread.dscr_inherit in sync
    ...

    Konrad Rzeszutek Wilk
     

05 Sep, 2012

1 commit

  • When running 32-bit pvops-dom0 and a driver tries to allocate a coherent
    DMA-memory the xen swiotlb-implementation returned memory beyond 4GB.

    The underlaying reason is that if the supplied driver passes in a
    DMA_BIT_MASK(64) ( hwdev->coherent_dma_mask is set to 0xffffffffffffffff)
    our dma_mask will be u64 set to 0xffffffffffffffff even if we set it to
    DMA_BIT_MASK(32) previously. Meaning we do not reset the upper bits.
    By using the dma_alloc_coherent_mask function - it does the proper casting
    and we get 0xfffffffff.

    This caused not working sound on a system with 4 GB and a 64-bit
    compatible sound-card with sets the DMA-mask to 64bit.

    On bare-metal and the forward-ported xen-dom0 patches from OpenSuse a coherent
    DMA-memory is always allocated inside the 32-bit address-range by calling
    dma_alloc_coherent_mask.

    This patch adds the same functionality to xen swiotlb and is a rebase of the
    original patch from Ronny Hegewald which never got upstream b/c the
    underlaying reason was not understood until now.

    The original email with the original patch is in:
    http://old-list-archives.xen.org/archives/html/xen-devel/2010-02/msg00038.html
    the original thread from where the discussion started is in:
    http://old-list-archives.xen.org/archives/html/xen-devel/2010-01/msg00928.html

    Signed-off-by: Ronny Hegewald
    Signed-off-by: Stefano Panella
    Acked-By: David Vrabel
    Signed-off-by: Konrad Rzeszutek Wilk
    CC: stable@vger.kernel.org

    Ronny Hegewald
     

23 Aug, 2012

1 commit

  • Sparse warns us off:
    drivers/xen/swiotlb-xen.c:506:1: warning: symbol 'xen_swiotlb_map_sg' was not declared. Should it be static?
    drivers/xen/swiotlb-xen.c:534:1: warning: symbol 'xen_swiotlb_unmap_sg' was not declared. Should it be static?

    and it looks like we do not need this function at all.

    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     

22 Aug, 2012

1 commit


28 Mar, 2012

1 commit

  • Adapt core x86 and IA64 architecture code for dma_map_ops changes: replace
    alloc/free_coherent with generic alloc/free methods.

    Signed-off-by: Andrzej Pietrasiewicz
    Acked-by: Kyungmin Park
    [removed swiotlb related changes and replaced it with wrappers,
    merged with IA64 patch to avoid inter-patch dependences in intel-iommu code]
    Signed-off-by: Marek Szyprowski
    Reviewed-by: Arnd Bergmann
    Acked-by: Tony Luck

    Andrzej Pietrasiewicz
     

20 Dec, 2011

1 commit


16 Dec, 2011

1 commit

  • This fixes an odd bug found on a Dell PowerEdge 1850/0RC130
    (BIOS A05 01/09/2006) where all of the modules doing pci_set_dma_mask
    would fail with:

    ata_piix 0000:00:1f.1: enabling device (0005 -> 0007)
    ata_piix 0000:00:1f.1: can't derive routing for PCI INT A
    ata_piix 0000:00:1f.1: BMDMA: failed to set dma mask, falling back to PIO

    The issue was the Xen-SWIOTLB was allocated such as that the end of
    buffer was stradling a page (and also above 4GB). The fix was
    spotted by Kalev Leonid which was to piggyback on git commit
    e79f86b2ef9c0a8c47225217c1018b7d3d90101c "swiotlb: Use page alignment
    for early buffer allocation" which:

    We could call free_bootmem_late() if swiotlb is not used, and
    it will shrink to page alignment.

    So alloc them with page alignment at first, to avoid lose two pages

    And doing that fixes the outstanding issue.

    CC: stable@kernel.org
    Suggested-by: "Kalev, Leonid"
    Reported-and-Tested-by: "Taylor, Neal E"
    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     

06 Dec, 2011

1 commit


01 Nov, 2011

1 commit


27 Aug, 2011

4 commits

  • The process to swizzle a Machine Frame Number (MFN) is not always
    necessary. Especially if we know that we actually do not have to do it.
    In this patch we check the MFN against the device's coherent
    DMA mask and if the requested page(s) are contingous. If it all checks
    out we will just return the bus addr without doing the memory
    swizzle.

    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     
  • Fix printk() and panic() args [swap them] to fix build warnings:

    drivers/xen/swiotlb-xen.c:201: warning: format '%s' expects type 'char *', but argument 2 has type 'int'
    drivers/xen/swiotlb-xen.c:201: warning: format '%d' expects type 'int', but argument 3 has type 'char *'
    drivers/xen/swiotlb-xen.c:202: warning: format '%s' expects type 'char *', but argument 2 has type 'int'
    drivers/xen/swiotlb-xen.c:202: warning: format '%d' expects type 'int', but argument 3 has type 'char *'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Konrad Rzeszutek Wilk

    Randy Dunlap
     
  • Propagate the baremetal git commit "swiotlb: fix wrong panic"
    (fba99fa38b023224680308a482e12a0eca87e4e1) in the Xen-SWIOTLB version.
    wherein swiotlb's map_page wrongly calls panic() when it can't find
    a buffer fit for device's dma mask. It should return an error instead.

    Devices with an odd dma mask (i.e. under 4G) like b44 network card hit
    this bug (the system crashes):

    http://marc.info/?l=linux-kernel&m=129648943830106&w=2

    If xen-swiotlb returns an error, b44 driver can use the own bouncing
    mechanism.

    CC: stable@kernel.org
    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     
  • We can fail seting up Xen-SWIOTLB if:
    - The host does not have enough contiguous DMA32 memory available
    (can happen on a machine that has fragmented memory from starting,
    stopping many guests).
    - Not enough low memory (almost never happens).

    We retry allocating and exchanging the swath of contiguous memory
    up to three times. Each time we decrease the amount we need - the
    minimum being of 2MB.

    If we compleltly fail, we will print the reason for failure on the Xen
    console on top of doing it to earlyprintk=xen console.

    Signed-off-by: Konrad Rzeszutek Wilk

    Konrad Rzeszutek Wilk
     

10 Jun, 2011

1 commit


07 Jun, 2011

1 commit

  • By default the io_tlb_nslabs is set to zero, and gets set to
    whatever value is passed in via swiotlb_init_with_tbl function.
    The default value passed in is 64MB. However, if the user provides
    the 'swiotlb=' the default value is ignored and
    the value provided by the user is used... Except when the SWIOTLB
    is used under Xen - there the default value of 64MB is used and
    the Xen-SWIOTLB has no mechanism to get the 'io_tlb_nslabs' filled
    out by setup_io_tlb_npages functions. This patch provides a function
    for the Xen-SWIOTLB to call to see if the io_tlb_nslabs is set
    and if so use that value.

    Signed-off-by: FUJITA Tomonori
    Signed-off-by: Konrad Rzeszutek Wilk

    FUJITA Tomonori
     

10 Apr, 2011

1 commit


27 Jul, 2010

1 commit

  • This patchset:

    PV guests under Xen are running in an non-contiguous memory architecture.

    When PCI pass-through is utilized, this necessitates an IOMMU for
    translating bus (DMA) to virtual and vice-versa and also providing a
    mechanism to have contiguous pages for device drivers operations (say DMA
    operations).

    Specifically, under Xen the Linux idea of pages is an illusion. It
    assumes that pages start at zero and go up to the available memory. To
    help with that, the Linux Xen MMU provides a lookup mechanism to
    translate the page frame numbers (PFN) to machine frame numbers (MFN)
    and vice-versa. The MFN are the "real" frame numbers. Furthermore
    memory is not contiguous. Xen hypervisor stitches memory for guests
    from different pools, which means there is no guarantee that PFN==MFN
    and PFN+1==MFN+1. Lastly with Xen 4.0, pages (in debug mode) are
    allocated in descending order (high to low), meaning the guest might
    never get any MFN's under the 4GB mark.

    Signed-off-by: Konrad Rzeszutek Wilk
    Acked-by: Jeremy Fitzhardinge
    Cc: FUJITA Tomonori
    Cc: Albert Herranz
    Cc: Ian Campbell

    Konrad Rzeszutek Wilk