[PATCH 1/7] frv: use generic pci_enable_resources() - Kernel

This is a discussion on [PATCH 1/7] frv: use generic pci_enable_resources() - Kernel ; From: Bjorn Helgaas Use the generic pci_enable_resources() instead of the arch-specific code. Unlike this arch-specific code, the generic version: - checks PCI_NUM_RESOURCES (11), not 6, resources - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set - skips ROM resources ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: [PATCH 1/7] frv: use generic pci_enable_resources()

  1. [PATCH 1/7] frv: use generic pci_enable_resources()

    From: Bjorn Helgaas

    Use the generic pci_enable_resources() instead of the arch-specific code.

    Unlike this arch-specific code, the generic version:
    - checks PCI_NUM_RESOURCES (11), not 6, resources
    - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
    - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
    - checks for resource collisions with "!r->parent"

    Signed-off-by: Bjorn Helgaas
    Signed-off-by: David Howells
    ---

    arch/frv/mb93090-mb00/pci-frv.c | 32 --------------------------------
    arch/frv/mb93090-mb00/pci-frv.h | 1 -
    arch/frv/mb93090-mb00/pci-vdk.c | 2 +-
    3 files changed, 1 insertions(+), 34 deletions(-)


    diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
    index edae117..43d6753 100644
    --- a/arch/frv/mb93090-mb00/pci-frv.c
    +++ b/arch/frv/mb93090-mb00/pci-frv.c
    @@ -201,38 +201,6 @@ void __init pcibios_resource_survey(void)
    pcibios_assign_resources();
    }

    -int pcibios_enable_resources(struct pci_dev *dev, int mask)
    -{
    - u16 cmd, old_cmd;
    - int idx;
    - struct resource *r;
    -
    - pci_read_config_word(dev, PCI_COMMAND, &cmd);
    - old_cmd = cmd;
    - for(idx=0; idx<6; idx++) {
    - /* Only set up the requested stuff */
    - if (!(mask & (1< - continue;
    -
    - r = &dev->resource[idx];
    - if (!r->start && r->end) {
    - printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
    - return -EINVAL;
    - }
    - if (r->flags & IORESOURCE_IO)
    - cmd |= PCI_COMMAND_IO;
    - if (r->flags & IORESOURCE_MEM)
    - cmd |= PCI_COMMAND_MEMORY;
    - }
    - if (dev->resource[PCI_ROM_RESOURCE].start)
    - cmd |= PCI_COMMAND_MEMORY;
    - if (cmd != old_cmd) {
    - printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
    - pci_write_config_word(dev, PCI_COMMAND, cmd);
    - }
    - return 0;
    -}
    -
    /*
    * If we set up a device for bus mastering, we need to check the latency
    * timer as certain crappy BIOSes forget to set it properly.
    diff --git a/arch/frv/mb93090-mb00/pci-frv.h b/arch/frv/mb93090-mb00/pci-frv.h
    index 0c7bf39..f3fe559 100644
    --- a/arch/frv/mb93090-mb00/pci-frv.h
    +++ b/arch/frv/mb93090-mb00/pci-frv.h
    @@ -29,7 +29,6 @@ extern unsigned int __nongpreldata pci_probe;
    extern unsigned int pcibios_max_latency;

    void pcibios_resource_survey(void);
    -int pcibios_enable_resources(struct pci_dev *, int);

    /* pci-vdk.c */

    diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
    index f003cfa..0f41c3a 100644
    --- a/arch/frv/mb93090-mb00/pci-vdk.c
    +++ b/arch/frv/mb93090-mb00/pci-vdk.c
    @@ -412,7 +412,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
    {
    int err;

    - if ((err = pcibios_enable_resources(dev, mask)) < 0)
    + if ((err = pci_enable_resources(dev, mask)) < 0)
    return err;
    if (!dev->msi_enabled)
    pcibios_enable_irq(dev);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 2/7] FRV: Provide dma_map_page() for NOMMU and fix comments

    Provide dma_map_page() for the NOMMU-mode FRV arch.

    Also do some fixing on the comments attached to the various DMA functions for
    both MMU and NOMMU mode FRV code.

    Signed-off-by: David Howells
    ---

    arch/frv/mb93090-mb00/pci-dma-nommu.c | 23 ++++++++++++++++++++---
    arch/frv/mb93090-mb00/pci-dma.c | 11 +++++++++--
    2 files changed, 29 insertions(+), 5 deletions(-)


    diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c b/arch/frv/mb93090-mb00/pci-dma-nommu.c
    index 64ee58d..52ff9ae 100644
    --- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
    +++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
    @@ -111,7 +111,7 @@ EXPORT_SYMBOL(dma_free_coherent);
    * The 32-bit bus address to use is returned.
    *
    * Once the device is given the dma address, the device owns this memory
    - * until either pci_unmap_single or pci_dma_sync_single is performed.
    + * until either dma_unmap_single or pci_dma_sync_single is performed.
    */
    dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
    enum dma_data_direction direction)
    @@ -129,7 +129,7 @@ EXPORT_SYMBOL(dma_map_single);
    /*
    * Map a set of buffers described by scatterlist in streaming
    * mode for DMA. This is the scather-gather version of the
    - * above pci_map_single interface. Here the scatter gather list
    + * above dma_map_single interface. Here the scatter gather list
    * elements are each tagged with the appropriate dma address
    * and length. They are obtained via sg_dma_{address,length}(SG).
    *
    @@ -139,7 +139,7 @@ EXPORT_SYMBOL(dma_map_single);
    * The routine returns the number of addr/length pairs actually
    * used, at most nents.
    *
    - * Device ownership issues as mentioned above for pci_map_single are
    + * Device ownership issues as mentioned above for dma_map_single are
    * the same here.
    */
    int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
    @@ -158,3 +158,20 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
    }

    EXPORT_SYMBOL(dma_map_sg);
    +
    +/*
    + * Map a single page of the indicated size for DMA in streaming mode.
    + * The 32-bit bus address to use is returned.
    + *
    + * Device ownership issues as mentioned above for dma_map_single are
    + * the same here.
    + */
    +dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
    + size_t size, enum dma_data_direction direction)
    +{
    + BUG_ON(direction == DMA_NONE);
    + flush_dcache_page(page);
    + return (dma_addr_t) page_to_phys(page) + offset;
    +}
    +
    +EXPORT_SYMBOL(dma_map_page);
    diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
    index 662f7b1..3ddedeb 100644
    --- a/arch/frv/mb93090-mb00/pci-dma.c
    +++ b/arch/frv/mb93090-mb00/pci-dma.c
    @@ -61,7 +61,7 @@ EXPORT_SYMBOL(dma_map_single);
    /*
    * Map a set of buffers described by scatterlist in streaming
    * mode for DMA. This is the scather-gather version of the
    - * above pci_map_single interface. Here the scatter gather list
    + * above dma_map_single interface. Here the scatter gather list
    * elements are each tagged with the appropriate dma address
    * and length. They are obtained via sg_dma_{address,length}(SG).
    *
    @@ -71,7 +71,7 @@ EXPORT_SYMBOL(dma_map_single);
    * The routine returns the number of addr/length pairs actually
    * used, at most nents.
    *
    - * Device ownership issues as mentioned above for pci_map_single are
    + * Device ownership issues as mentioned above for dma_map_single are
    * the same here.
    */
    int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
    @@ -105,6 +105,13 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,

    EXPORT_SYMBOL(dma_map_sg);

    +/*
    + * Map a single page of the indicated size for DMA in streaming mode.
    + * The 32-bit bus address to use is returned.
    + *
    + * Device ownership issues as mentioned above for dma_map_single are
    + * the same here.
    + */
    dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset,
    size_t size, enum dma_data_direction direction)
    {

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 6/7] binfmt_elf_fdpic: Convert initial stack alignment to arch_align_stack()

    From: Paul Mundt

    binfmt_elf_fdpic seems to have grabbed a hard-coded hack from an ancient
    version of binfmt_elf in order to try and fix up initial stack alignment
    on multi-threaded x86, which while in addition to being unused, was also
    pushed down beyond the first set of operations on the stack pointer,
    negating the entire purpose.

    These days, we have an architecture independent arch_align_stack(), so we
    switch to using that instead. Move the initial alignment up before the
    initial stores while we're at it.

    Signed-off-by: Paul Mundt
    Signed-off-by: David Howells
    ---

    fs/binfmt_elf_fdpic.c | 25 ++++++++-----------------
    1 files changed, 8 insertions(+), 17 deletions(-)


    diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
    index 0955d03..f8c1469 100644
    --- a/fs/binfmt_elf_fdpic.c
    +++ b/fs/binfmt_elf_fdpic.c
    @@ -466,7 +466,8 @@ error_kill:
    #endif

    /*
    - * present useful information to the program
    + * present useful information to the program by shovelling it onto the new
    + * process's stack
    */
    static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    struct mm_struct *mm,
    @@ -482,9 +483,13 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    int loop;
    int nr; /* reset for each csp adjustment */

    - /* we're going to shovel a whole load of stuff onto the stack */
    #ifdef CONFIG_MMU
    - sp = bprm->p;
    + /* In some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
    + * by the processes running on the same package. One thing we can do is
    + * to shuffle the initial stack for them, so we give the architecture
    + * an opportunity to do so here.
    + */
    + sp = arch_align_stack(bprm->p);
    #else
    sp = mm->start_stack;

    @@ -527,20 +532,6 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    return -EFAULT;
    }

    -#if defined(__i386__) && defined(CONFIG_SMP)
    - /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
    - * by the processes running on the same package. One thing we can do is
    - * to shuffle the initial stack for them.
    - *
    - * the conditionals here are unneeded, but kept in to make the code
    - * behaviour the same as pre change unless we have hyperthreaded
    - * processors. This keeps Mr Marcelo Person happier but should be
    - * removed for 2.5
    - */
    - if (smp_num_siblings > 1)
    - sp = sp - ((current->pid % 64) << 7);
    -#endif
    -
    sp &= ~7UL;

    /* stack the load map(s) */

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 5/7] binfmt_elf_fdpic: Support auxvec base platform string.

    From: Paul Mundt

    Commit 483fad1c3fa1060d7e6710e84a065ad514571739 introduces
    AT_BASE_PLATFORM, but only implements it for binfmt_elf. Given that
    AT_VECTOR_SIZE_BASE is unconditionally enlarged for us, and it's only
    optionally added in for the platforms that set ELF_BASE_PLATFORM, wire
    it up for binfmt_elf_fdpic, too.

    Signed-off-by: Paul Mundt
    Signed-off-by: David Howells
    ---

    fs/binfmt_elf_fdpic.c | 50 ++++++++++++++++++++++++++++++++++++++++++-------
    1 files changed, 43 insertions(+), 7 deletions(-)


    diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
    index 80c1f95..0955d03 100644
    --- a/fs/binfmt_elf_fdpic.c
    +++ b/fs/binfmt_elf_fdpic.c
    @@ -455,6 +455,16 @@ error_kill:
    }

    /************************************************** ***************************/
    +
    +#ifndef ELF_BASE_PLATFORM
    +/*
    + * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
    + * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
    + * will be copied to the user stack in the same manner as AT_PLATFORM.
    + */
    +#define ELF_BASE_PLATFORM NULL
    +#endif
    +
    /*
    * present useful information to the program
    */
    @@ -466,8 +476,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    unsigned long sp, csp, nitems;
    elf_caddr_t __user *argv, *envp;
    size_t platform_len = 0, len;
    - char *k_platform;
    - char __user *u_platform, *p;
    + char *k_platform, *k_base_platform;
    + char __user *u_platform, *u_base_platform, *p;
    long hwcap;
    int loop;
    int nr; /* reset for each csp adjustment */
    @@ -483,11 +493,14 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    return -EFAULT;
    #endif

    - /* get hold of platform and hardware capabilities masks for the machine
    - * we are running on. In some cases (Sparc), this info is impossible
    - * to get, in others (i386) it is merely difficult.
    - */
    hwcap = ELF_HWCAP;
    +
    + /*
    + * If this architecture has a platform capability string, copy it
    + * to userspace. In some cases (Sparc), this info is impossible
    + * for userspace to get any other way, in others (i386) it is
    + * merely difficult.
    + */
    k_platform = ELF_PLATFORM;
    u_platform = NULL;

    @@ -499,6 +512,21 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    return -EFAULT;
    }

    + /*
    + * If this architecture has a "base" platform capability
    + * string, copy it to userspace.
    + */
    + k_base_platform = ELF_BASE_PLATFORM;
    + u_base_platform = NULL;
    +
    + if (k_base_platform) {
    + platform_len = strlen(k_base_platform) + 1;
    + sp -= platform_len;
    + u_base_platform = (char __user *) sp;
    + if (__copy_to_user(u_base_platform, k_base_platform, platform_len) != 0)
    + return -EFAULT;
    + }
    +
    #if defined(__i386__) && defined(CONFIG_SMP)
    /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
    * by the processes running on the same package. One thing we can do is
    @@ -543,7 +571,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    /* force 16 byte _final_ alignment here for generality */
    #define DLINFO_ITEMS 13

    - nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
    + nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + \
    + (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;

    csp = sp;
    sp -= nitems * 2 * sizeof(unsigned long);
    @@ -575,6 +604,13 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    (elf_addr_t) (unsigned long) u_platform);
    }

    + if (k_base_platform) {
    + nr = 0;
    + csp -= 2 * sizeof(unsigned long);
    + NEW_AUX_ENT(AT_BASE_PLATFORM,
    + (elf_addr_t) (unsigned long) u_base_platform);
    + }
    +
    nr = 0;
    csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
    NEW_AUX_ENT(AT_HWCAP, hwcap);

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 3/7] FRV: Switch unaligned access to the packed-struct implementation

    From: Harvey Harrison

    Switch unaligned access to the packed-struct implementation for BE accesses as
    this reduces the size of the kernel a little. LE still uses the byte shift.

    Signed-off-by: Harvey Harrison
    Signed-off-by: David Howells
    ---

    include/asm-frv/unaligned.h | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)


    diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h
    index 839a2fb..6c61c05 100644
    --- a/include/asm-frv/unaligned.h
    +++ b/include/asm-frv/unaligned.h
    @@ -13,7 +13,7 @@
    #define _ASM_UNALIGNED_H

    #include
    -#include
    +#include
    #include

    #define get_unaligned __get_unaligned_be

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 7/7] binfmt_elf_fdpic: Wire up AT_EXECFD, AT_EXECFN, AT_SECURE.

    From: Paul Mundt

    These auxvec entries are the only ones left unhandled out of the current
    base implementation. This syncs up binfmt_elf_fdpic with linux/auxvec.h
    and current binfmt_elf.

    Signed-off-by: Paul Mundt
    Signed-off-by: David Howells
    ---

    fs/binfmt_elf_fdpic.c | 14 +++++++++++++-
    1 files changed, 13 insertions(+), 1 deletions(-)


    diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
    index f8c1469..b42a8db 100644
    --- a/fs/binfmt_elf_fdpic.c
    +++ b/fs/binfmt_elf_fdpic.c
    @@ -25,6 +25,7 @@
    #include
    #include
    #include
    +#include
    #include
    #include
    #include
    @@ -560,11 +561,14 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    }

    /* force 16 byte _final_ alignment here for generality */
    -#define DLINFO_ITEMS 13
    +#define DLINFO_ITEMS 15

    nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + \
    (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;

    + if (bprm->interp_flags & BINPRM_FLAGS_EXECFD)
    + nitems++;
    +
    csp = sp;
    sp -= nitems * 2 * sizeof(unsigned long);
    sp -= (bprm->envc + 1) * sizeof(char *); /* envv[] */
    @@ -602,6 +606,12 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    (elf_addr_t) (unsigned long) u_base_platform);
    }

    + if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
    + nr = 0;
    + csp -= 2 * sizeof(unsigned long);
    + NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
    + }
    +
    nr = 0;
    csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
    NEW_AUX_ENT(AT_HWCAP, hwcap);
    @@ -617,6 +627,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
    NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid);
    NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid);
    NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid);
    + NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
    + NEW_AUX_ENT(AT_EXECFN, bprm->exec);

    #ifdef ARCH_DLINFO
    nr = 0;

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread