* Re: [POWERPC] 8xx: fix swap
From: Segher Boessenkool @ 2008-03-06 16:12 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Paul Mackerras, LKML
In-Reply-To: <7E836D6E-867B-4A35-9B3D-CD1D52E7F2DC@kernel.crashing.org>
> do we need similar fixes to arch/ppc ?
Do we care?
arch/ppc needs many fixes, when you have implemented all of that, you
get a clone of arch/powerpc ;-)
Segher
^ permalink raw reply
* Re: [POWERPC] 8xx: fix swap
From: Scott Wood @ 2008-03-06 16:05 UTC (permalink / raw)
To: Kumar Gala; +Cc: Paul Mackerras, LKML, linuxppc-dev
In-Reply-To: <7E836D6E-867B-4A35-9B3D-CD1D52E7F2DC@kernel.crashing.org>
On Thu, Mar 06, 2008 at 09:56:58AM -0600, Kumar Gala wrote:
> On Mar 6, 2008, at 4:53 AM, Vitaly Bordug wrote:
> > arch/powerpc/kernel/head_8xx.S | 30 ++++++++++++++++++++++++++
> > +++-
> > include/asm-powerpc/pgtable-ppc32.h | 8 --------
> > 2 files changed, 29 insertions(+), 9 deletions(-)
>
> do we need similar fixes to arch/ppc ?
Yes, a patch was posted a while ago.
-Scott
^ permalink raw reply
* Performance in Booting Linux w/ Device Tree via U-Boot out of JFFS2 on NAND
From: Grant Erickson @ 2008-03-06 17:30 UTC (permalink / raw)
To: linuxppc-embedded@ozlabs.org
I am continuing some experiments in booting Linux w/ a flattened device tree
via u-boot (1.3.2-rc3) from JFFS2 on NAND on an AMCC "Haleakala" board and
am curious if anyone has come up with some quantitative performance
characterizations of the various options (in all cases, u-boot lives on NOR
flash). The options I am evaluating are:
1) Put uImage and haleakala.dtb in their own "raw" NAND slices and boot with
u-boot nand commands:
static struct mtd_partition nand_parts[] = {
{
.name = "kernel",
.offset = 0,
.size = 0x0400000
},
{
.name = "fdt",
.offset = 0x0400000,
.size = 0x0010000
},
{
.name = "root",
.offset = 0x0410000,
.size = 0x3BF0000
}
};
=> nand read.i 200000 0 400000
=> nand read.i 400000 400000 10000
=> setenv bootargs ${bootargs} console=ttyS0,${baudrate}
=> setenv bootargs ${bootargs} root=/dev/mtdblock9 rootfstype=jffs2
=> bootm 200000 - 400000
Qualitative performance: Nearly instantaneous.
As expected, in this case the qualitative, subjective time to seeing "Linux
version 2.6.25-rc3-00951-g6514352-dirty ..." is nearly instantaneous.
2) Put uImage and haleakala.dtb as files in /boot in the ~12 MB JFFS2 root
file system image in the ~60 MB "root" NAND slice and boot with u-boot
fsload commands:
=> fsload 200000 boot/uImage
=> fsload 400000 boot/haleakala.dtb
=> setenv bootargs ${bootargs} console=ttyS0,${baudrate}
=> setenv bootargs ${bootargs} root=/dev/mtdblock9 rootfstype=jffs2
=> bootm 200000 - 400000
2a) With CFG_JFFS2_SORT_FRAGMENTS enabled.
Qualitative performance: Takes the better part of 30-35 minutes.
As expected with the in-documentation warnings about
CFG_JFFS2_SORT_FRAGMENTS and looking at the code in
u-boot/fs/jffs2/jffs2_nand_1pass.c, the qualitative, subjective time to
seeing the Linux version banner is slow, slow and slow.
2b) With CFG_JFFS2_SORT_FRAGMENTS disabled.
Qualitative performance: Takes about 30 seconds to two minutes.
3) This is a hybrid approach that I am setting up right now and is where I
am curious if anyone has done plots of fsload time on JFFS2 + NAND relative
to file system size.
Here, we use a separate 4 MB "/boot" JFFS2 file system for uImage and
haleakala.dtb files and a 60 MB "/" JFFS2 file system for the root file
system.
static struct mtd_partition nand_parts[] = {
{
.name = "boot",
.offset = 0,
.size = 0x0400000
},
{
.name = "root",
.offset = 0x0400000,
.size = 0x3C00000
}
};
=> fsload 200000 uImage
=> fsload 400000 haleakala.dtb
=> setenv bootargs ${bootargs} console=ttyS0,${baudrate}
=> setenv bootargs ${bootargs} root=/dev/mtdblock9 rootfstype=jffs2
=> bootm 200000 - 400000
3a) With CFG_JFFS2_SORT_FRAGMENTS enabled.
Shouldn't be necessary since the /boot file system would only ever be
accessed read-only and updated by nandwrite, not individual file updates.
3b) With CFG_JFFS2_SORT_FRAGMENTS disabled.
Qualitative performance: TBD <= 2b
Thanks,
Grant Erickson
^ permalink raw reply
* Re: How to boot kernel in JTAG mode
From: David Baird @ 2008-03-06 17:40 UTC (permalink / raw)
To: learn linux; +Cc: Heydeck, linuxppc-embedded
In-Reply-To: <56ef64000803060220r61a9cd87ibf1e92af95fad04a@mail.gmail.com>
On Thu, Mar 6, 2008 at 3:20 AM, learn linux <learn.mips.linux@gmail.com> wrote:
> Hi,
> I am new to this linux and jtag. I want to set up the my board in
> jtag mode so that I could boot the kernel in jtag mode and try to debug the
> kernel.
> I need a general information how to set it up.
Can you give more details? What board? What processor?
^ permalink raw reply
* [PATCH 0/5] 2.6.25-rc3-mm1 hotplug memory remove updates
From: Badari Pulavarty @ 2008-03-06 18:54 UTC (permalink / raw)
To: lkml, linuxppc-dev, paulus; +Cc: Yasunori Goto, Andrew Morton, pbadari
Hi Andrew & Paul,
Here are the updates for hotplug memory remove. Most changes are
PPC specific, but I would like these to be included in next -mm
for easy testing and review, before including in Paul's tree.
eHEA driver folks are verifying if the exported interface
walk_memory_resource() is good enough for their needs. And also,
we are verifying the code on x86_64. Once that is done, we may
be able to cleanup some of the code (make remove_memory() arch
generic).
We still have an issue with not being able to free up the allocations
that came from bootmem. Yasunori Goto wants to clean up that code.
[PATCH 1/5] generic __remove_pages() support
[PATCH 2/5] [PPC] htab_remove_mapping() error handling
[PATCH 3/5] [PPC] hotplug memory notifications for ppc
[PATCH 4/5] [PPC] update lmb for hotplug memory add/remove
[PATCH 5/5] [PPC] provide walk_memory_resource() for ppc
Testing: All the patches are tested on p-series LPAR configuration,
writing to /sysfs & /proc, through DLPAR tools and through HMC.
Testing on x86_64 needs more work.
Thanks,
Badari
^ permalink raw reply
* [PATCH 1/5] generic __remove_pages() support
From: Badari Pulavarty @ 2008-03-06 18:55 UTC (permalink / raw)
To: lkml; +Cc: linuxppc-dev, Andrew Morton, paulus, Yasunori Goto
In-Reply-To: <1204829673.7939.59.camel@dyn9047017100.beaverton.ibm.com>
Generic helper function to remove section mappings and sysfs entries
for the section of the memory we are removing. offline_pages() correctly
adjusted zone and marked the pages reserved.
Issue: If mem_map, usemap allocation could come from different places -
kmalloc, vmalloc, alloc_pages or bootmem. There is no easy way
to find and free up bootmem allocations.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
include/linux/memory_hotplug.h | 4 +++
mm/memory_hotplug.c | 44 +++++++++++++++++++++++++++++++++++++++++
mm/sparse.c | 43 +++++++++++++++++++++++++++++++++++++---
3 files changed, 88 insertions(+), 3 deletions(-)
Index: linux-2.6.25-rc2/mm/memory_hotplug.c
===================================================================
--- linux-2.6.25-rc2.orig/mm/memory_hotplug.c 2008-02-27 12:58:17.000000000 -0800
+++ linux-2.6.25-rc2/mm/memory_hotplug.c 2008-02-27 16:06:50.000000000 -0800
@@ -102,6 +102,21 @@ static int __add_section(struct zone *zo
return register_new_memory(__pfn_to_section(phys_start_pfn));
}
+static int __remove_section(struct zone *zone, struct mem_section *ms)
+{
+ int ret = -EINVAL;
+
+ if (!valid_section(ms))
+ return ret;
+
+ ret = unregister_memory_section(ms);
+ if (ret)
+ return ret;
+
+ sparse_remove_one_section(zone, ms);
+ return 0;
+}
+
/*
* Reasonably generic function for adding memory. It is
* expected that archs that support memory hotplug will
@@ -135,6 +150,35 @@ int __add_pages(struct zone *zone, unsig
}
EXPORT_SYMBOL_GPL(__add_pages);
+int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
+ unsigned long nr_pages)
+{
+ unsigned long i, ret = 0;
+ int sections_to_remove;
+ unsigned long flags;
+ struct pglist_data *pgdat = zone->zone_pgdat;
+
+ /*
+ * We can only remove entire sections
+ */
+ BUG_ON(phys_start_pfn & ~PAGE_SECTION_MASK);
+ BUG_ON(nr_pages % PAGES_PER_SECTION);
+
+ release_mem_region(phys_start_pfn << PAGE_SHIFT, nr_pages * PAGE_SIZE);
+
+ sections_to_remove = nr_pages / PAGES_PER_SECTION;
+ for (i = 0; i < sections_to_remove; i++) {
+ unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
+ pgdat_resize_lock(pgdat, &flags);
+ ret = __remove_section(zone, __pfn_to_section(pfn));
+ pgdat_resize_unlock(pgdat, &flags);
+ if (ret)
+ break;
+ }
+ return ret;
+}
+EXPORT_SYMBOL_GPL(__remove_pages);
+
static void grow_zone_span(struct zone *zone,
unsigned long start_pfn, unsigned long end_pfn)
{
Index: linux-2.6.25-rc2/mm/sparse.c
===================================================================
--- linux-2.6.25-rc2.orig/mm/sparse.c 2008-02-15 12:57:20.000000000 -0800
+++ linux-2.6.25-rc2/mm/sparse.c 2008-02-27 13:02:51.000000000 -0800
@@ -198,12 +198,13 @@ static unsigned long sparse_encode_mem_m
}
/*
- * We need this if we ever free the mem_maps. While not implemented yet,
- * this function is included for parity with its sibling.
+ * Decode mem_map from the coded memmap
*/
-static __attribute((unused))
+static
struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum)
{
+ /* mask off the extra low bits of information */
+ coded_mem_map &= SECTION_MAP_MASK;
return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum);
}
@@ -363,6 +364,26 @@ static void __kfree_section_memmap(struc
}
#endif /* CONFIG_SPARSEMEM_VMEMMAP */
+static void free_section_usemap(struct page *memmap, unsigned long *usemap)
+{
+ if (!usemap)
+ return;
+
+ /*
+ * Check to see if allocation came from hot-plug-add
+ */
+ if (PageSlab(virt_to_page(usemap))) {
+ kfree(usemap);
+ if (memmap)
+ __kfree_section_memmap(memmap, PAGES_PER_SECTION);
+ return;
+ }
+
+ /*
+ * Allocations came from bootmem - how do I free up ?
+ */
+}
+
/*
* returns the number of sections whose mem_maps were properly
* set. If this is <=0, then that means that the passed-in
@@ -415,4 +436,20 @@ out:
}
return ret;
}
+
+void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
+{
+ struct page *memmap = NULL;
+ unsigned long *usemap = NULL;
+
+ if (ms->section_mem_map) {
+ usemap = ms->pageblock_flags;
+ memmap = sparse_decode_mem_map(ms->section_mem_map,
+ __section_nr(ms));
+ ms->section_mem_map = 0;
+ ms->pageblock_flags = NULL;
+ }
+
+ free_section_usemap(memmap, usemap);
+}
#endif
Index: linux-2.6.25-rc2/include/linux/memory_hotplug.h
===================================================================
--- linux-2.6.25-rc2.orig/include/linux/memory_hotplug.h 2008-02-27 12:58:17.000000000 -0800
+++ linux-2.6.25-rc2/include/linux/memory_hotplug.h 2008-02-27 13:00:04.000000000 -0800
@@ -8,6 +8,7 @@
struct page;
struct zone;
struct pglist_data;
+struct mem_section;
#ifdef CONFIG_MEMORY_HOTPLUG
/*
@@ -64,6 +65,8 @@ extern int offline_pages(unsigned long,
/* reasonably generic interface to expand the physical pages in a zone */
extern int __add_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
+extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
+ unsigned long nr_pages);
/*
* Walk thorugh all memory which is registered as resource.
@@ -188,5 +191,6 @@ extern int arch_add_memory(int nid, u64
extern int remove_memory(u64 start, u64 size);
extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
int nr_pages);
+extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms);
#endif /* __LINUX_MEMORY_HOTPLUG_H */
^ permalink raw reply
* [PATCH 2/5] [PPC] htab_remove_mapping() error handling
From: Badari Pulavarty @ 2008-03-06 18:56 UTC (permalink / raw)
To: lkml; +Cc: linuxppc-dev, Andrew Morton, paulus, Yasunori Goto
In-Reply-To: <1204829673.7939.59.camel@dyn9047017100.beaverton.ibm.com>
If the sub-arch doesn't support hpte_removebolted(), gracefully
return failure rather than success.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
arch/powerpc/mm/hash_utils_64.c | 14 +++++++++-----
include/asm-powerpc/sparsemem.h | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
Index: linux-2.6.25-rc3/arch/powerpc/mm/hash_utils_64.c
===================================================================
--- linux-2.6.25-rc3.orig/arch/powerpc/mm/hash_utils_64.c 2008-03-05 10:14:28.000000000 -0800
+++ linux-2.6.25-rc3/arch/powerpc/mm/hash_utils_64.c 2008-03-05 10:18:55.000000000 -0800
@@ -192,7 +192,7 @@ int htab_bolt_mapping(unsigned long vsta
return ret < 0 ? ret : 0;
}
-static void htab_remove_mapping(unsigned long vstart, unsigned long vend,
+static int htab_remove_mapping(unsigned long vstart, unsigned long vend,
int psize, int ssize)
{
unsigned long vaddr;
@@ -202,12 +202,15 @@ static void htab_remove_mapping(unsigned
step = 1 << shift;
if (!ppc_md.hpte_removebolted) {
- printk("Sub-arch doesn't implement hpte_removebolted\n");
- return;
+ printk(KERN_WARNING "Sub-arch doesn't implement "
+ "hpte_removebolted\n");
+ return -EINVAL;
}
for (vaddr = vstart; vaddr < vend; vaddr += step)
ppc_md.hpte_removebolted(vaddr, psize, ssize);
+
+ return 0;
}
static int __init htab_dt_scan_seg_sizes(unsigned long node,
@@ -449,9 +452,10 @@ void create_section_mapping(unsigned lon
mmu_linear_psize, mmu_kernel_ssize));
}
-void remove_section_mapping(unsigned long start, unsigned long end)
+int remove_section_mapping(unsigned long start, unsigned long end)
{
- htab_remove_mapping(start, end, mmu_linear_psize, mmu_kernel_ssize);
+ return htab_remove_mapping(start, end, mmu_linear_psize,
+ mmu_kernel_ssize);
}
#endif /* CONFIG_MEMORY_HOTPLUG */
Index: linux-2.6.25-rc3/include/asm-powerpc/sparsemem.h
===================================================================
--- linux-2.6.25-rc3.orig/include/asm-powerpc/sparsemem.h 2008-03-05 10:14:31.000000000 -0800
+++ linux-2.6.25-rc3/include/asm-powerpc/sparsemem.h 2008-03-05 10:19:09.000000000 -0800
@@ -15,7 +15,7 @@
#ifdef CONFIG_MEMORY_HOTPLUG
extern void create_section_mapping(unsigned long start, unsigned long end);
-extern void remove_section_mapping(unsigned long start, unsigned long end);
+extern int remove_section_mapping(unsigned long start, unsigned long end);
#ifdef CONFIG_NUMA
extern int hot_add_scn_to_nid(unsigned long scn_addr);
#else
^ permalink raw reply
* [PATCH 3/5] [PPC] hotplug memory notifications for ppc
From: Badari Pulavarty @ 2008-03-06 18:57 UTC (permalink / raw)
To: lkml; +Cc: linuxppc-dev, Andrew Morton, paulus, Yasunori Goto
In-Reply-To: <1204829673.7939.59.camel@dyn9047017100.beaverton.ibm.com>
Hotplug memory notifier for ppc64. This gets invoked by writing
the device-node that needs to be removed to /proc/ppc64/ofdt.
We need to adjust the sections and remove sysfs entries by
calling __remove_pages(). Then call arch specific code to
get rid of htab mappings for the section of memory.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Reviewed-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/pseries/Makefile | 1
arch/powerpc/platforms/pseries/hotplug-memory.c | 98 ++++++++++++++++++++++++
2 files changed, 99 insertions(+)
Index: linux-2.6.25-rc2/arch/powerpc/platforms/pseries/hotplug-memory.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.25-rc2/arch/powerpc/platforms/pseries/hotplug-memory.c 2008-02-29 09:25:14.000000000 -0800
@@ -0,0 +1,98 @@
+/*
+ * pseries Memory Hotplug infrastructure.
+ *
+ * Copyright (C) 2008 Badari Pulavarty, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/of.h>
+#include <asm/firmware.h>
+#include <asm/machdep.h>
+#include <asm/pSeries_reconfig.h>
+
+static int pseries_remove_memory(struct device_node *np)
+{
+ const char *type;
+ const unsigned int *my_index;
+ const unsigned int *regs;
+ u64 start_pfn, start;
+ struct zone *zone;
+ int ret = -EINVAL;
+
+ /*
+ * Check to see if we are actually removing memory
+ */
+ type = of_get_property(np, "device_type", NULL);
+ if (type == NULL || strcmp(type, "memory") != 0)
+ return 0;
+
+ /*
+ * Find the memory index and size of the removing section
+ */
+ my_index = of_get_property(np, "ibm,my-drc-index", NULL);
+ if (!my_index)
+ return ret;
+
+ regs = of_get_property(np, "reg", NULL);
+ if (!regs)
+ return ret;
+
+ start_pfn = section_nr_to_pfn(*my_index & 0xffff);
+ zone = page_zone(pfn_to_page(start_pfn));
+
+ /*
+ * Remove section mappings and sysfs entries for the
+ * section of the memory we are removing.
+ *
+ * NOTE: Ideally, this should be done in generic code like
+ * remove_memory(). But remove_memory() gets called by writing
+ * to sysfs "state" file and we can't remove sysfs entries
+ * while writing to it. So we have to defer it to here.
+ */
+ ret = __remove_pages(zone, start_pfn, regs[3] >> PAGE_SHIFT);
+ if (ret)
+ return ret;
+
+ /*
+ * Remove htab bolted mappings for this section of memory
+ */
+ start = (unsigned long)__va(start_pfn << PAGE_SHIFT);
+ ret = remove_section_mapping(start, start + regs[3]);
+ return ret;
+}
+
+static int pseries_memory_notifier(struct notifier_block *nb,
+ unsigned long action, void *node)
+{
+ int err = NOTIFY_OK;
+
+ switch (action) {
+ case PSERIES_RECONFIG_ADD:
+ break;
+ case PSERIES_RECONFIG_REMOVE:
+ if (pseries_remove_memory(node))
+ err = NOTIFY_BAD;
+ break;
+ default:
+ err = NOTIFY_DONE;
+ break;
+ }
+ return err;
+}
+
+static struct notifier_block pseries_mem_nb = {
+ .notifier_call = pseries_memory_notifier,
+};
+
+static int __init pseries_memory_hotplug_init(void)
+{
+ if (firmware_has_feature(FW_FEATURE_LPAR))
+ pSeries_reconfig_notifier_register(&pseries_mem_nb);
+
+ return 0;
+}
+machine_device_initcall(pseries, pseries_memory_hotplug_init);
Index: linux-2.6.25-rc2/arch/powerpc/platforms/pseries/Makefile
===================================================================
--- linux-2.6.25-rc2.orig/arch/powerpc/platforms/pseries/Makefile 2008-02-28 08:15:53.000000000 -0800
+++ linux-2.6.25-rc2/arch/powerpc/platforms/pseries/Makefile 2008-02-28 08:17:57.000000000 -0800
@@ -14,6 +14,7 @@ obj-$(CONFIG_PCI) += pci.o pci_dlpar.o
obj-$(CONFIG_PCI_MSI) += msi.o
obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
+obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o
obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
obj-$(CONFIG_HVCS) += hvcserver.o
^ permalink raw reply
* [PATCH 4/5] [PPC] update lmb for hotplug memory add/remove
From: Badari Pulavarty @ 2008-03-06 18:58 UTC (permalink / raw)
To: lkml; +Cc: linuxppc-dev, Andrew Morton, paulus, Yasunori Goto
In-Reply-To: <1204829673.7939.59.camel@dyn9047017100.beaverton.ibm.com>
ppc kernel maintains information about logical memory blocks in
lmb.memory structure at the boot time. Its not updated for
hotplug memory add/remove. hotplug memory notifier for memory
add/remove now updates lmb.memory.
This information is useful for eHEA driver to find out the memory
layout and holes.
NOTE: Calls to lmb_add() and lmb_remove() needs to be serialized by
the caller. In this case blocking_notifier_chain(pSeries_reconfig_chain)
does that.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
arch/powerpc/platforms/pseries/hotplug-memory.c | 43 +++++++++++++++
include/linux/lmb.h | 3 -
lib/lmb.c | 66 ++++++++++++++++++++----
3 files changed, 102 insertions(+), 10 deletions(-)
Index: linux-2.6.25-rc3/lib/lmb.c
===================================================================
--- linux-2.6.25-rc3.orig/lib/lmb.c 2008-03-05 10:44:29.000000000 -0800
+++ linux-2.6.25-rc3/lib/lmb.c 2008-03-05 10:44:56.000000000 -0800
@@ -54,14 +54,13 @@ void lmb_dump_all(void)
#endif /* DEBUG */
}
-static unsigned long __init lmb_addrs_overlap(u64 base1,
- u64 size1, u64 base2, u64 size2)
+static unsigned long lmb_addrs_overlap(u64 base1, u64 size1, u64 base2,
+ u64 size2)
{
return ((base1 < (base2+size2)) && (base2 < (base1+size1)));
}
-static long __init lmb_addrs_adjacent(u64 base1, u64 size1,
- u64 base2, u64 size2)
+static long lmb_addrs_adjacent(u64 base1, u64 size1, u64 base2, u64 size2)
{
if (base2 == base1 + size1)
return 1;
@@ -71,7 +70,7 @@ static long __init lmb_addrs_adjacent(u6
return 0;
}
-static long __init lmb_regions_adjacent(struct lmb_region *rgn,
+static long lmb_regions_adjacent(struct lmb_region *rgn,
unsigned long r1, unsigned long r2)
{
u64 base1 = rgn->region[r1].base;
@@ -82,7 +81,7 @@ static long __init lmb_regions_adjacent(
return lmb_addrs_adjacent(base1, size1, base2, size2);
}
-static void __init lmb_remove_region(struct lmb_region *rgn, unsigned long r)
+static void lmb_remove_region(struct lmb_region *rgn, unsigned long r)
{
unsigned long i;
@@ -94,7 +93,7 @@ static void __init lmb_remove_region(str
}
/* Assumption: base addr of region 1 < base addr of region 2 */
-static void __init lmb_coalesce_regions(struct lmb_region *rgn,
+static void lmb_coalesce_regions(struct lmb_region *rgn,
unsigned long r1, unsigned long r2)
{
rgn->region[r1].size += rgn->region[r2].size;
@@ -129,7 +128,7 @@ void __init lmb_analyze(void)
}
/* This routine called with relocation disabled. */
-static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
+static long lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
{
unsigned long coalesced = 0;
long adjacent, i;
@@ -195,7 +194,7 @@ static long __init lmb_add_region(struct
}
/* This routine may be called with relocation disabled. */
-long __init lmb_add(u64 base, u64 size)
+long lmb_add(u64 base, u64 size)
{
struct lmb_region *_rgn = &(lmb.memory);
@@ -207,6 +206,55 @@ long __init lmb_add(u64 base, u64 size)
}
+long lmb_remove(u64 base, u64 size)
+{
+ struct lmb_region *rgn = &(lmb.memory);
+ u64 rgnbegin, rgnend;
+ u64 end = base + size;
+ int i;
+
+ rgnbegin = rgnend = 0; /* supress gcc warnings */
+
+ /* Find the region where (base, size) belongs to */
+ for (i=0; i < rgn->cnt; i++) {
+ rgnbegin = rgn->region[i].base;
+ rgnend = rgnbegin + rgn->region[i].size;
+
+ if ((rgnbegin <= base) && (end <= rgnend))
+ break;
+ }
+
+ /* Didn't find the region */
+ if (i == rgn->cnt)
+ return -1;
+
+ /* Check to see if we are removing entire region */
+ if ((rgnbegin == base) && (rgnend == end)) {
+ lmb_remove_region(rgn, i);
+ return 0;
+ }
+
+ /* Check to see if region is matching at the front */
+ if (rgnbegin == base) {
+ rgn->region[i].base = end;
+ rgn->region[i].size -= size;
+ return 0;
+ }
+
+ /* Check to see if the region is matching at the end */
+ if (rgnend == end) {
+ rgn->region[i].size -= size;
+ return 0;
+ }
+
+ /*
+ * We need to split the entry - adjust the current one to the
+ * beginging of the hole and add the region after hole.
+ */
+ rgn->region[i].size = base - rgn->region[i].base;
+ return lmb_add_region(rgn, end, rgnend - end);
+}
+
long __init lmb_reserve(u64 base, u64 size)
{
struct lmb_region *_rgn = &(lmb.reserved);
Index: linux-2.6.25-rc3/arch/powerpc/platforms/pseries/hotplug-memory.c
===================================================================
--- linux-2.6.25-rc3.orig/arch/powerpc/platforms/pseries/hotplug-memory.c 2008-03-05 10:44:51.000000000 -0800
+++ linux-2.6.25-rc3/arch/powerpc/platforms/pseries/hotplug-memory.c 2008-03-05 10:45:06.000000000 -0800
@@ -10,6 +10,7 @@
*/
#include <linux/of.h>
+#include <linux/lmb.h>
#include <asm/firmware.h>
#include <asm/machdep.h>
#include <asm/pSeries_reconfig.h>
@@ -58,6 +59,11 @@ static int pseries_remove_memory(struct
return ret;
/*
+ * Update memory regions for memory remove
+ */
+ lmb_remove(start_pfn << PAGE_SHIFT, regs[3]);
+
+ /*
* Remove htab bolted mappings for this section of memory
*/
start = (unsigned long)__va(start_pfn << PAGE_SHIFT);
@@ -65,6 +71,41 @@ static int pseries_remove_memory(struct
return ret;
}
+static int pseries_add_memory(struct device_node *np)
+{
+ const char *type;
+ const unsigned int *my_index;
+ const unsigned int *regs;
+ u64 start_pfn;
+ int ret = -EINVAL;
+
+ /*
+ * Check to see if we are actually adding memory
+ */
+ type = of_get_property(np, "device_type", NULL);
+ if (type == NULL || strcmp(type, "memory") != 0)
+ return 0;
+
+ /*
+ * Find the memory index and size of the removing section
+ */
+ my_index = of_get_property(np, "ibm,my-drc-index", NULL);
+ if (!my_index)
+ return ret;
+
+ regs = of_get_property(np, "reg", NULL);
+ if (!regs)
+ return ret;
+
+ start_pfn = section_nr_to_pfn(*my_index & 0xffff);
+
+ /*
+ * Update memory region to represent the memory add
+ */
+ lmb_add(start_pfn << PAGE_SHIFT, regs[3]);
+ return 0;
+}
+
static int pseries_memory_notifier(struct notifier_block *nb,
unsigned long action, void *node)
{
@@ -72,6 +113,8 @@ static int pseries_memory_notifier(struc
switch (action) {
case PSERIES_RECONFIG_ADD:
+ if (pseries_add_memory(node))
+ err = NOTIFY_BAD;
break;
case PSERIES_RECONFIG_REMOVE:
if (pseries_remove_memory(node))
Index: linux-2.6.25-rc3/include/linux/lmb.h
===================================================================
--- linux-2.6.25-rc3.orig/include/linux/lmb.h 2008-03-05 10:44:29.000000000 -0800
+++ linux-2.6.25-rc3/include/linux/lmb.h 2008-03-05 10:44:56.000000000 -0800
@@ -40,7 +40,8 @@ extern struct lmb lmb;
extern void __init lmb_init(void);
extern void __init lmb_analyze(void);
-extern long __init lmb_add(u64 base, u64 size);
+extern long lmb_add(u64 base, u64 size);
+extern long lmb_remove(u64 base, u64 size);
extern long __init lmb_reserve(u64 base, u64 size);
extern u64 __init lmb_alloc(u64 size, u64 align);
extern u64 __init lmb_alloc_base(u64 size,
^ permalink raw reply
* [PATCH 5/5] [PPC] provide walk_memory_resource() for ppc
From: Badari Pulavarty @ 2008-03-06 18:59 UTC (permalink / raw)
To: lkml; +Cc: linuxppc-dev, Andrew Morton, paulus, Yasunori Goto
In-Reply-To: <1204829673.7939.59.camel@dyn9047017100.beaverton.ibm.com>
Provide walk_memory_resource() for ppc64. PPC maintains
logic memory region mapping in lmb.memory structures. Walk
through these structures and do the callbacks for the
contiguous chunks.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
arch/powerpc/mm/mem.c | 30 +++++++++++++++++++++++-------
include/linux/lmb.h | 1 +
lib/lmb.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 7 deletions(-)
Index: linux-2.6.25-rc3/lib/lmb.c
===================================================================
--- linux-2.6.25-rc3.orig/lib/lmb.c 2008-03-05 10:28:55.000000000 -0800
+++ linux-2.6.25-rc3/lib/lmb.c 2008-03-05 10:34:01.000000000 -0800
@@ -416,3 +416,36 @@ int __init lmb_is_reserved(u64 addr)
}
return 0;
}
+
+/*
+ * Given a <base, len>, find which memory regions belong to this range.
+ * Adjust the request and return a contiguous chunk.
+ */
+int lmb_find(struct lmb_property *res)
+{
+ int i;
+ u64 rstart, rend;
+
+ rstart = res->base;
+ rend = rstart + res->size - 1;
+
+ for (i = 0; i < lmb.memory.cnt; i++) {
+ u64 start = lmb.memory.region[i].base;
+ u64 end = start + lmb.memory.region[i].size - 1;
+
+ if (start > rend)
+ return -1;
+
+ if ((end >= rstart) && (start < rend)) {
+ /* adjust the request */
+ if (rstart < start)
+ rstart = start;
+ if (rend > end)
+ rend = end;
+ res->base = rstart;
+ res->size = rend - rstart + 1;
+ return 0;
+ }
+ }
+ return -1;
+}
Index: linux-2.6.25-rc3/arch/powerpc/mm/mem.c
===================================================================
--- linux-2.6.25-rc3.orig/arch/powerpc/mm/mem.c 2008-03-05 10:14:28.000000000 -0800
+++ linux-2.6.25-rc3/arch/powerpc/mm/mem.c 2008-03-05 10:32:16.000000000 -0800
@@ -148,19 +148,35 @@ out:
/*
* walk_memory_resource() needs to make sure there is no holes in a given
- * memory range. On PPC64, since this range comes from /sysfs, the range
- * is guaranteed to be valid, non-overlapping and can not contain any
- * holes. By the time we get here (memory add or remove), /proc/device-tree
- * is updated and correct. Only reason we need to check against device-tree
- * would be if we allow user-land to specify a memory range through a
- * system call/ioctl etc. instead of doing offline/online through /sysfs.
+ * memory range. PPC64 does not maintain the memory layout in /proc/iomem.
+ * Instead it maintains it in lmb.memory structures. Walk through the
+ * memory regions, find holes and callback for contiguous regions.
*/
int
walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
int (*func)(unsigned long, unsigned long, void *))
{
- return (*func)(start_pfn, nr_pages, arg);
+ struct lmb_property res;
+ unsigned long pfn, len;
+ u64 end;
+ int ret = -1;
+
+ res.base = (u64) start_pfn << PAGE_SHIFT;
+ res.size = (u64) nr_pages << PAGE_SHIFT;
+
+ end = res.base + res.size - 1;
+ while ((res.base < end) && (lmb_find(&res) >= 0)) {
+ pfn = (unsigned long)(res.base >> PAGE_SHIFT);
+ len = (unsigned long)(res.size >> PAGE_SHIFT);
+ ret = (*func)(pfn, len, arg);
+ if (ret)
+ break;
+ res.base += (res.size + 1);
+ res.size = (end - res.base + 1);
+ }
+ return ret;
}
+EXPORT_SYMBOL_GPL(walk_memory_resource);
#endif /* CONFIG_MEMORY_HOTPLUG */
Index: linux-2.6.25-rc3/include/linux/lmb.h
===================================================================
--- linux-2.6.25-rc3.orig/include/linux/lmb.h 2008-03-05 10:30:06.000000000 -0800
+++ linux-2.6.25-rc3/include/linux/lmb.h 2008-03-05 10:33:12.000000000 -0800
@@ -52,6 +52,7 @@ extern u64 __init lmb_phys_mem_size(void
extern u64 __init lmb_end_of_DRAM(void);
extern void __init lmb_enforce_memory_limit(u64 memory_limit);
extern int __init lmb_is_reserved(u64 addr);
+extern int lmb_find(struct lmb_property *res);
extern void lmb_dump_all(void);
^ permalink raw reply
* Problems in fixup_device function
From: John Linn @ 2008-03-06 19:21 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 593 bytes --]
I've added some code to virtex_device_fixup and am seeing some strange
side affects. I've added code to read from an iic device and populate
the mac address including ioremap. The code works fine, but the side
affects are not fine.
Anyone have any experience here?
I see the loops_per_jiffy getting hosed like there is some bad code, but
I can't track it down. It moves around badly, like it can come and go
with printk additions or deletions.
I don't know enough about the stack and Linux to know if there could be
a problem there.
Thanks,
John
[-- Attachment #2: Type: text/html, Size: 8016 bytes --]
^ permalink raw reply
* Re: [PATCH 1/5] generic __remove_pages() support
From: Badari Pulavarty @ 2008-03-06 19:29 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linuxppc-dev, Andrew Morton, paulus, lkml, Yasunori Goto
In-Reply-To: <20080306110847.11d7cb26.randy.dunlap@oracle.com>
On Thu, 2008-03-06 at 11:08 -0800, Randy Dunlap wrote:
> On Thu, 06 Mar 2008 10:55:34 -0800 Badari Pulavarty wrote:
>
> > Generic helper function to remove section mappings and sysfs entries
> > for the section of the memory we are removing. offline_pages() correctly
> > adjusted zone and marked the pages reserved.
>
> Such generic (exported, non-static) interfaces could use some
> (kernel-)docs, please.
Sure. Will do.
> > Issue: If mem_map, usemap allocation could come from different places -
> > kmalloc, vmalloc, alloc_pages or bootmem. There is no easy way
> > to find and free up bootmem allocations.
> >
> > Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
> >
> > ---
> > include/linux/memory_hotplug.h | 4 +++
> > mm/memory_hotplug.c | 44 +++++++++++++++++++++++++++++++++++++++++
> > mm/sparse.c | 43 +++++++++++++++++++++++++++++++++++++---
> > 3 files changed, 88 insertions(+), 3 deletions(-)
>
> > Index: linux-2.6.25-rc2/include/linux/memory_hotplug.h
> > ===================================================================
> > --- linux-2.6.25-rc2.orig/include/linux/memory_hotplug.h 2008-02-27 12:58:17.000000000 -0800
> > +++ linux-2.6.25-rc2/include/linux/memory_hotplug.h 2008-02-27 13:00:04.000000000 -0800
> > @@ -64,6 +65,8 @@ extern int offline_pages(unsigned long,
> > /* reasonably generic interface to expand the physical pages in a zone */
> > extern int __add_pages(struct zone *zone, unsigned long start_pfn,
> > unsigned long nr_pages);
> > +extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
> > + unsigned long nr_pages);
> >
> > /*
> > * Walk thorugh all memory which is registered as resource.
>
> through :)
I will fix that.
Thanks,
Badari
^ permalink raw reply
* Re: Problems in fixup_device function
From: Grant Likely @ 2008-03-06 19:38 UTC (permalink / raw)
To: John Linn; +Cc: linuxppc-embedded
In-Reply-To: <20080306192149.4A0A9708064@mail119-dub.bigfish.com>
On Thu, Mar 6, 2008 at 12:21 PM, John Linn <John.Linn@xilinx.com> wrote:
>
>
>
>
> I've added some code to virtex_device_fixup and am seeing some strange side
> affects. I've added code to read from an iic device and populate the mac
> address including ioremap. The code works fine, but the side affects are
> not fine.
Specifically, what are you trying to do? Are you modifying the data
in the platform device?
Cheers,
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply
* RE: Problems in fixup_device function
From: John Linn @ 2008-03-06 19:40 UTC (permalink / raw)
To: Grant Likely; +Cc: linuxppc-embedded
In-Reply-To: <fa686aa40803061138s8ed3d6r53cff6324fdf99f2@mail.gmail.com>
I am loading the mac address into the data of the platform device.
-- John
-----Original Message-----
From: glikely@secretlab.ca [mailto:glikely@secretlab.ca] On Behalf Of
Grant Likely
Sent: Thursday, March 06, 2008 12:39 PM
To: John Linn
Cc: linuxppc-embedded@ozlabs.org
Subject: Re: Problems in fixup_device function
On Thu, Mar 6, 2008 at 12:21 PM, John Linn <John.Linn@xilinx.com> wrote:
>
>
>
>
> I've added some code to virtex_device_fixup and am seeing some strange
side
> affects. I've added code to read from an iic device and populate the
mac
> address including ioremap. The code works fine, but the side affects
are
> not fine.
Specifically, what are you trying to do? Are you modifying the data
in the platform device?
Cheers,
g.
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply
* Re: [PATCH 1/2] firewire: endianess fix
From: Gabriel Paubert @ 2008-03-06 20:23 UTC (permalink / raw)
To: Stefan Richter
Cc: Kristian Hoegsberg, linux-kernel, linuxppc-dev, sparclinux,
Jarod Wilson, linux1394-devel, Sam Ravnborg, Harvey Harrison
In-Reply-To: <47CF2C08.5000609@s5r6.in-berlin.de>
On Thu, Mar 06, 2008 at 12:26:00AM +0100, Stefan Richter wrote:
> Gabriel Paubert wrote:
> >>>I have a Pismo which I use on a virtually
> >>>daily basis (and about to remove the last remnants of MacOS on it).
> >>>However I have disabled Firewire because it would not sleep and wake
> >>>up properly.
> ...
> >For now I have only tested the new stack with a 6 year old 1.8" disk
> >and everything works, including suspend to RAM. The kernel is 2.6.25-rc4
> >plus additional pull from linux1394-2.6.git: 2.6.25-rc4-00032-g8d36ba4.
>
> That's great. Thanks for testing.
The old stack also works. I forgot to mention that with the new
stack (not with the old) there is a message when going to sleep:
firewire_ohci: pci_set_power_state failed with -5
but it is harmless, and if I understand correctly due to the
fact that the power management on this chip is not implemented
through capability fields in the PCI configuration space.
Gabriel
^ permalink raw reply
* Re: [PATCH 1/5] generic __remove_pages() support
From: Randy Dunlap @ 2008-03-06 19:08 UTC (permalink / raw)
To: Badari Pulavarty; +Cc: linuxppc-dev, Andrew Morton, paulus, lkml, Yasunori Goto
In-Reply-To: <1204829734.7939.61.camel@dyn9047017100.beaverton.ibm.com>
On Thu, 06 Mar 2008 10:55:34 -0800 Badari Pulavarty wrote:
> Generic helper function to remove section mappings and sysfs entries
> for the section of the memory we are removing. offline_pages() correctly
> adjusted zone and marked the pages reserved.
Such generic (exported, non-static) interfaces could use some
(kernel-)docs, please.
> Issue: If mem_map, usemap allocation could come from different places -
> kmalloc, vmalloc, alloc_pages or bootmem. There is no easy way
> to find and free up bootmem allocations.
>
> Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
>
> ---
> include/linux/memory_hotplug.h | 4 +++
> mm/memory_hotplug.c | 44 +++++++++++++++++++++++++++++++++++++++++
> mm/sparse.c | 43 +++++++++++++++++++++++++++++++++++++---
> 3 files changed, 88 insertions(+), 3 deletions(-)
> Index: linux-2.6.25-rc2/include/linux/memory_hotplug.h
> ===================================================================
> --- linux-2.6.25-rc2.orig/include/linux/memory_hotplug.h 2008-02-27 12:58:17.000000000 -0800
> +++ linux-2.6.25-rc2/include/linux/memory_hotplug.h 2008-02-27 13:00:04.000000000 -0800
> @@ -64,6 +65,8 @@ extern int offline_pages(unsigned long,
> /* reasonably generic interface to expand the physical pages in a zone */
> extern int __add_pages(struct zone *zone, unsigned long start_pfn,
> unsigned long nr_pages);
> +extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
> + unsigned long nr_pages);
>
> /*
> * Walk thorugh all memory which is registered as resource.
through :)
---
~Randy
^ permalink raw reply
* Re: Xilinx Temac link detect
From: khollan @ 2008-03-06 20:44 UTC (permalink / raw)
To: linuxppc-embedded
In-Reply-To: <15616042.post@talk.nabble.com>
I figure I could write a C program to talk to the ioctl in the TEMAC driver
and read the PHY register. Does anyone have example code for talking to
network ioctl's?
Thanks
Kevin
--
View this message in context: http://www.nabble.com/Xilinx-Temac-link-detect-tp15616042p15883376.html
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
^ permalink raw reply
* Re: [PATCH 1/5] generic __remove_pages() support
From: Dave Hansen @ 2008-03-06 20:54 UTC (permalink / raw)
To: Badari Pulavarty; +Cc: linuxppc-dev, Andrew Morton, paulus, lkml, Yasunori Goto
In-Reply-To: <1204829734.7939.61.camel@dyn9047017100.beaverton.ibm.com>
On Thu, 2008-03-06 at 10:55 -0800, Badari Pulavarty wrote:
> + if (memmap)
> + __kfree_section_memmap(memmap, PAGES_PER_SECTION);
> + return;
> + }
> +
> + /*
> + * Allocations came from bootmem - how do I free up ?
> + */
> +
Shouldn't we figure this one out before merging?
I think we at least need a printk() there.
-- Dave
^ permalink raw reply
* Re: [PATCH 1/5] generic __remove_pages() support
From: Badari Pulavarty @ 2008-03-06 21:42 UTC (permalink / raw)
To: Dave Hansen; +Cc: linuxppc-dev, Andrew Morton, paulus, lkml, Yasunori Goto
In-Reply-To: <1204836859.4772.32.camel@nimitz.home.sr71.net>
On Thu, 2008-03-06 at 12:54 -0800, Dave Hansen wrote:
> On Thu, 2008-03-06 at 10:55 -0800, Badari Pulavarty wrote:
> > + if (memmap)
> > + __kfree_section_memmap(memmap, PAGES_PER_SECTION);
> > + return;
> > + }
> > +
> > + /*
> > + * Allocations came from bootmem - how do I free up ?
> > + */
> > +
>
> Shouldn't we figure this one out before merging?
>
> I think we at least need a printk() there.
I can add a printk(). I am hoping Yasunori Goto has something to
handle this, before we really merge into mainline.
Thanks,
Badari
^ permalink raw reply
* Please pull pasemi.git for-2.6.26 branch
From: Olof Johansson @ 2008-03-06 21:44 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev, pasemi-linux
Hi Paul,
Please pull from 'for-2.6.26' branch of
master.kernel.org:/pub/scm/linux/kernel/git/olof/pasemi.git for-2.6.26
to receive the following updates. They have all been posted to the list
previously, and had only minor updates to remove a couple of compiler
warnings:
arch/powerpc/platforms/pasemi/dma_lib.c | 144 ++++++++++++++
drivers/net/Makefile | 3
drivers/net/pasemi_mac.c | 324 ++++++++++++++++++++++++++------
drivers/net/pasemi_mac.h | 35 +++
drivers/net/pasemi_mac_ethtool.c | 159 +++++++++++++++
include/asm-powerpc/pasemi_dma.h | 77 +++++++
6 files changed, 681 insertions(+), 61 deletions(-)
Olof Johansson (6):
pasemi_mac: Move RX/TX section enablement to dma_lib
[POWERPC] pasemi: Add flag management functions to dma_lib
[POWERPC] pasemi: Add function engine management functions to dma_lib
pasemi_mac: jumbo frame support
pasemi_mac: Enable GSO by default
pasemi_mac: basic ethtool support
^ permalink raw reply
* Re: Please pull pasemi.git for-2.6.26 branch
From: Paul Mackerras @ 2008-03-06 22:15 UTC (permalink / raw)
To: Olof Johansson; +Cc: linuxppc-dev, pasemi-linux
In-Reply-To: <20080306214406.GA2631@lixom.net>
Olof Johansson writes:
> Please pull from 'for-2.6.26' branch of
>
> master.kernel.org:/pub/scm/linux/kernel/git/olof/pasemi.git for-2.6.26
>
> to receive the following updates. They have all been posted to the list
> previously, and had only minor updates to remove a couple of compiler
> warnings:
>
> arch/powerpc/platforms/pasemi/dma_lib.c | 144 ++++++++++++++
> drivers/net/Makefile | 3
> drivers/net/pasemi_mac.c | 324 ++++++++++++++++++++++++++------
> drivers/net/pasemi_mac.h | 35 +++
> drivers/net/pasemi_mac_ethtool.c | 159 +++++++++++++++
> include/asm-powerpc/pasemi_dma.h | 77 +++++++
> 6 files changed, 681 insertions(+), 61 deletions(-)
Is Jeff Garzik OK with those pasemi_mac_* updates going via my tree?
Paul.
^ permalink raw reply
* RE: Xilinx Temac link detect
From: John Linn @ 2008-03-06 22:14 UTC (permalink / raw)
To: khollan, linuxppc-embedded
In-Reply-To: <15883376.post@talk.nabble.com>
Hi Kevin,
I couldn't find any example laying around, so I took a shot at it based
on other non-network examples we had. I've not personally done it so
bear that in mind.
I have not tried to compile any of this, just stole parts for places and
pasted in.
Hope it helps,
John
#include <ioctl.h>
/*
* FD of the IIC device opened.
*/
int Fdtemac;
struct mii_ioctl_data ioctl_data;=09
/*
* Open the device.
*/
Fdtemac =3D open("/dev/TBD", O_RDWR);
if(Fdtemac < 0)
{
printf("Cannot open the temac device\n");
return -1;
}
/* setup the inputs to the ioctl call */
ioctl_data.phy_num =3D TBD;
ioctl_data.reg_num =3D TBD;
=09
/*
* Read the phy register
*/
Register =3D ioctl(Fdtemac, SIOCGMIIREG, &ioctl_data);
if(Status < 0)
{
/* failure */
return 0;
}
/* results should be in ioctl_data.val_out I think
}
>From the temac linux adapter, a snippet showing the the ioctl function.
xenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct mii_ioctl_data *data =3D (struct mii_ioctl_data *)
&rq->ifr_data;
case SIOCGMIIREG: /* Read GMII PHY register. */
ret =3D XTemac_PhyRead(&lp->Emac, data->phy_id,
data->reg_num, &data->val_out);
}
from linux/mii.h
/* This structure is used in all SIOCxMIIxxx ioctl calls */
struct mii_ioctl_data {
__u16 phy_id;
__u16 reg_num;
__u16 val_in;
__u16 val_out;
};
from linux/if.h
struct ifreq=20
{
#define IFHWADDRLEN 6
union
{
char ifrn_name[IFNAMSIZ]; /* if name, e.g.
"en0" */
} ifr_ifrn;
=09
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_ivalue;
int ifru_mtu;
struct ifmap ifru_map;
char ifru_slave[IFNAMSIZ]; /* Just fits the size */
char ifru_newname[IFNAMSIZ];
void __user * ifru_data;
struct if_settings ifru_settings;
} ifr_ifru;
};
-----Original Message-----
From: linuxppc-embedded-bounces+john.linn=3Dxilinx.com@ozlabs.org
[mailto:linuxppc-embedded-bounces+john.linn=3Dxilinx.com@ozlabs.org] On
Behalf Of khollan
Sent: Thursday, March 06, 2008 1:44 PM
To: linuxppc-embedded@ozlabs.org
Subject: Re: Xilinx Temac link detect
I figure I could write a C program to talk to the ioctl in the TEMAC
driver
and read the PHY register. Does anyone have example code for talking to
network ioctl's?
Thanks
Kevin
--=20
View this message in context:
http://www.nabble.com/Xilinx-Temac-link-detect-tp15616042p15883376.html
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
^ permalink raw reply
* Re: Please pull pasemi.git for-2.6.26 branch
From: Olof Johansson @ 2008-03-06 22:32 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, pasemi-linux, jgarzik
In-Reply-To: <18384.27914.34609.721913@cargo.ozlabs.ibm.com>
On Fri, Mar 07, 2008 at 09:15:38AM +1100, Paul Mackerras wrote:
> Olof Johansson writes:
>
> > Please pull from 'for-2.6.26' branch of
> >
> > master.kernel.org:/pub/scm/linux/kernel/git/olof/pasemi.git for-2.6.26
> >
> > to receive the following updates. They have all been posted to the list
> > previously, and had only minor updates to remove a couple of compiler
> > warnings:
> >
> > arch/powerpc/platforms/pasemi/dma_lib.c | 144 ++++++++++++++
> > drivers/net/Makefile | 3
> > drivers/net/pasemi_mac.c | 324 ++++++++++++++++++++++++++------
> > drivers/net/pasemi_mac.h | 35 +++
> > drivers/net/pasemi_mac_ethtool.c | 159 +++++++++++++++
> > include/asm-powerpc/pasemi_dma.h | 77 +++++++
> > 6 files changed, 681 insertions(+), 61 deletions(-)
>
> Is Jeff Garzik OK with those pasemi_mac_* updates going via my tree?
Yes, he explicitly asked for it last week:
http://ozlabs.org/pipermail/linuxppc-dev/2008-February/052227.html
-Olof
^ permalink raw reply
* Re: [PATCH 1/5] generic __remove_pages() support
From: Badari Pulavarty @ 2008-03-06 23:37 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linuxppc-dev, Andrew Morton, paulus, lkml, Yasunori Goto
In-Reply-To: <20080306110847.11d7cb26.randy.dunlap@oracle.com>
Here is the latest version, addressing Randy and Dave's comments.
Thanks,
Badari
Generic helper function to remove section mappings and sysfs entries
for the section of the memory we are removing. offline_pages() correctly
adjusted zone and marked the pages reserved.
Issue: If mem_map, usemap allocation could come from different places -
kmalloc, vmalloc, alloc_pages or bootmem. There is no easy way
to find and free up bootmem allocations.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
include/linux/memory_hotplug.h | 6 +++-
mm/memory_hotplug.c | 55 +++++++++++++++++++++++++++++++++++++++++
mm/sparse.c | 45 +++++++++++++++++++++++++++++++--
3 files changed, 102 insertions(+), 4 deletions(-)
Index: linux-2.6.25-rc3.save/mm/memory_hotplug.c
===================================================================
--- linux-2.6.25-rc3.save.orig/mm/memory_hotplug.c 2008-03-05 10:44:30.000000000 -0800
+++ linux-2.6.25-rc3.save/mm/memory_hotplug.c 2008-03-06 15:08:45.000000000 -0800
@@ -102,6 +102,21 @@ static int __add_section(struct zone *zo
return register_new_memory(__pfn_to_section(phys_start_pfn));
}
+static int __remove_section(struct zone *zone, struct mem_section *ms)
+{
+ int ret = -EINVAL;
+
+ if (!valid_section(ms))
+ return ret;
+
+ ret = unregister_memory_section(ms);
+ if (ret)
+ return ret;
+
+ sparse_remove_one_section(zone, ms);
+ return 0;
+}
+
/*
* Reasonably generic function for adding memory. It is
* expected that archs that support memory hotplug will
@@ -135,6 +150,46 @@ int __add_pages(struct zone *zone, unsig
}
EXPORT_SYMBOL_GPL(__add_pages);
+/**
+ * __remove_pages() - remove sections of pages from a zone
+ * @zone: zone from which pages need to be removed
+ * @phys_start_pfn: starting pageframe (must be aligned to start of a section)
+ * @nr_pages: number of pages to remove (must be multiple of section size)
+ *
+ * Generic helper function to remove section mappings and sysfs entries
+ * for the section of the memory we are removing. Caller needs to make
+ * sure that pages are marked reserved and zones are adjust properly by
+ * calling offline_pages().
+ */
+int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
+ unsigned long nr_pages)
+{
+ unsigned long i, ret = 0;
+ int sections_to_remove;
+ unsigned long flags;
+ struct pglist_data *pgdat = zone->zone_pgdat;
+
+ /*
+ * We can only remove entire sections
+ */
+ BUG_ON(phys_start_pfn & ~PAGE_SECTION_MASK);
+ BUG_ON(nr_pages % PAGES_PER_SECTION);
+
+ release_mem_region(phys_start_pfn << PAGE_SHIFT, nr_pages * PAGE_SIZE);
+
+ sections_to_remove = nr_pages / PAGES_PER_SECTION;
+ for (i = 0; i < sections_to_remove; i++) {
+ unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
+ pgdat_resize_lock(pgdat, &flags);
+ ret = __remove_section(zone, __pfn_to_section(pfn));
+ pgdat_resize_unlock(pgdat, &flags);
+ if (ret)
+ break;
+ }
+ return ret;
+}
+EXPORT_SYMBOL_GPL(__remove_pages);
+
static void grow_zone_span(struct zone *zone,
unsigned long start_pfn, unsigned long end_pfn)
{
Index: linux-2.6.25-rc3.save/mm/sparse.c
===================================================================
--- linux-2.6.25-rc3.save.orig/mm/sparse.c 2008-03-05 10:44:30.000000000 -0800
+++ linux-2.6.25-rc3.save/mm/sparse.c 2008-03-06 15:15:18.000000000 -0800
@@ -198,12 +198,13 @@ static unsigned long sparse_encode_mem_m
}
/*
- * We need this if we ever free the mem_maps. While not implemented yet,
- * this function is included for parity with its sibling.
+ * Decode mem_map from the coded memmap
*/
-static __attribute((unused))
+static
struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum)
{
+ /* mask off the extra low bits of information */
+ coded_mem_map &= SECTION_MAP_MASK;
return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum);
}
@@ -363,6 +364,28 @@ static void __kfree_section_memmap(struc
}
#endif /* CONFIG_SPARSEMEM_VMEMMAP */
+static void free_section_usemap(struct page *memmap, unsigned long *usemap)
+{
+ if (!usemap)
+ return;
+
+ /*
+ * Check to see if allocation came from hot-plug-add
+ */
+ if (PageSlab(virt_to_page(usemap))) {
+ kfree(usemap);
+ if (memmap)
+ __kfree_section_memmap(memmap, PAGES_PER_SECTION);
+ return;
+ }
+
+ /*
+ * TODO: Allocations came from bootmem - how do I free up ?
+ */
+ printk(KERN_WARNING "Not freeing up allocations from bootmem "
+ "- leaking memory\n");
+}
+
/*
* returns the number of sections whose mem_maps were properly
* set. If this is <=0, then that means that the passed-in
@@ -415,4 +438,20 @@ out:
}
return ret;
}
+
+void sparse_remove_one_section(struct zone *zone, struct mem_section *ms)
+{
+ struct page *memmap = NULL;
+ unsigned long *usemap = NULL;
+
+ if (ms->section_mem_map) {
+ usemap = ms->pageblock_flags;
+ memmap = sparse_decode_mem_map(ms->section_mem_map,
+ __section_nr(ms));
+ ms->section_mem_map = 0;
+ ms->pageblock_flags = NULL;
+ }
+
+ free_section_usemap(memmap, usemap);
+}
#endif
Index: linux-2.6.25-rc3.save/include/linux/memory_hotplug.h
===================================================================
--- linux-2.6.25-rc3.save.orig/include/linux/memory_hotplug.h 2008-03-05 10:44:30.000000000 -0800
+++ linux-2.6.25-rc3.save/include/linux/memory_hotplug.h 2008-03-06 15:02:13.000000000 -0800
@@ -8,6 +8,7 @@
struct page;
struct zone;
struct pglist_data;
+struct mem_section;
#ifdef CONFIG_MEMORY_HOTPLUG
/*
@@ -64,9 +65,11 @@ extern int offline_pages(unsigned long,
/* reasonably generic interface to expand the physical pages in a zone */
extern int __add_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
+extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
+ unsigned long nr_pages);
/*
- * Walk thorugh all memory which is registered as resource.
+ * Walk through all memory which is registered as resource.
* arg is (start_pfn, nr_pages, private_arg_pointer)
*/
extern int walk_memory_resource(unsigned long start_pfn,
@@ -188,5 +191,6 @@ extern int arch_add_memory(int nid, u64
extern int remove_memory(u64 start, u64 size);
extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
int nr_pages);
+extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms);
#endif /* __LINUX_MEMORY_HOTPLUG_H */
^ permalink raw reply
* [PATCH] pasemi_dma: Driver for PA Semi PWRficient on-chip DMA engine
From: Olof Johansson @ 2008-03-06 23:39 UTC (permalink / raw)
To: dan.j.williams, shannon.nelson
Cc: linuxppc-dev, pasemi-linux, linux-kernel, hskinnemoen
pasemi_dma: Driver for PA Semi PWRficient on-chip DMA engine
First cut at a dma copy offload driver for PA Semi PWRficient. It uses the
platform-specific functions to allocate channels, etc.
Signed-off-by: Olof Johansson <olof@lixom.net>
---
This has some dependencies on other patches currently queued up in the
powerpc git trees for 2.6.26. I'd appreciate reviews and acked-bys, but
it might be easiest to just merge it up the powerpc path due to the
dependencies.
-Olof
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 27340a7..bbeaf10 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -54,6 +54,13 @@ config FSL_DMA_SELFTEST
Enable the self test for each DMA channel. A self test will be
performed after the channel probed to ensure the DMA works well.
+config PASEMI_DMA
+ tristate "PA Semi DMA Engine support"
+ depends on PPC_PASEMI
+ select DMA_ENGINE
+ help
+ Enable support for the DMA Engine on PA Semi PWRficient SoCs
+
config DMA_ENGINE
bool
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index c8036d9..6729959 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
ioatdma-objs := ioat.o ioat_dma.o ioat_dca.o
obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
obj-$(CONFIG_FSL_DMA) += fsldma.o
+obj-$(CONFIG_PASEMI_DMA) += pasemi_dma.o
diff --git a/drivers/dma/pasemi_dma.c b/drivers/dma/pasemi_dma.c
new file mode 100644
index 0000000..844ab11
--- /dev/null
+++ b/drivers/dma/pasemi_dma.c
@@ -0,0 +1,478 @@
+/*
+ * Driver for the PA Semi PWRficient DMA Engine (copy parts)
+ * Copyright (c) 2007,2008 Olof Johansson, PA Semi, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/dmaengine.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/pasemi_dma.h>
+
+#define MAX_CH 16
+#define MAX_XFER 0x40000
+#define RING_SZ 8192
+
+struct pasemi_dma_desc {
+ u64 src;
+ u64 dest;
+ dma_addr_t src_dma;
+ dma_addr_t dest_dma;
+ size_t len;
+ struct list_head node;
+ int tx_cnt;
+ struct dma_async_tx_descriptor async_tx;
+ struct pasemi_dma_chan *chan;
+};
+
+struct pasemi_dma_chan {
+ struct pasemi_dmachan chan;
+ spinlock_t ring_lock; /* Protects the ring only */
+ spinlock_t desc_lock; /* Protects the descriptor list */
+ struct pasemi_dma *dma_dev;
+ struct pasemi_dma_desc *ring_info[RING_SZ]; /* softc */
+ unsigned int next_to_fill;
+ unsigned int next_to_clean;
+ struct dma_chan common;
+ struct list_head free_desc;
+ int desc_count;
+ int in_use;
+};
+
+struct pasemi_dma {
+ struct pci_dev *pdev;
+ struct dma_device common;
+ struct pasemi_dma_chan *chans[MAX_CH];
+};
+
+static unsigned int channels = 4;
+module_param(channels, uint, S_IRUGO);
+MODULE_PARM_DESC(channels, "Number of channels for copy (default: 2)");
+
+#define to_pasemi_dma_chan(chan) container_of(chan, struct pasemi_dma_chan, \
+ common)
+#define to_pasemi_dma_desc(lh) container_of(lh, struct pasemi_dma_desc, node)
+#define tx_to_desc_sw(tx) container_of(tx, struct pasemi_dma_desc, async_tx)
+
+static void pasemi_dma_clean(struct pasemi_dma_chan *chan)
+{
+ int old, new, i;
+ unsigned long flags;
+ struct pasemi_dma_desc *desc;
+ spin_lock_irqsave(&chan->desc_lock, flags);
+
+ old = chan->next_to_clean;
+
+ new = *chan->chan.status & PAS_STATUS_PCNT_M;
+ new <<= 2;
+ new &= (RING_SZ-1);
+
+ if (old > new)
+ new += RING_SZ;
+
+ for (i = old; i < new; i += 4) {
+ if (unlikely(chan->chan.ring_virt[i & (RING_SZ-1)] & XCT_COPY_O))
+ break;
+ desc = chan->ring_info[i & (RING_SZ-1)];
+ list_add_tail(&desc->node, &chan->free_desc);
+ }
+
+ chan->next_to_clean = i & (RING_SZ-1);
+
+ spin_unlock_irqrestore(&chan->desc_lock, flags);
+}
+
+static int pasemi_dma_intr(int irq, void *data)
+{
+ struct pasemi_dma_chan *chan = data;
+ unsigned int cmdsta;
+
+ cmdsta = pasemi_read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chan.chno));
+
+ return IRQ_HANDLED;
+}
+
+static int pasemi_dma_alloc_chan_resources(struct dma_chan *chan)
+{
+ struct pasemi_dma_chan *ch = to_pasemi_dma_chan(chan);
+ u32 val;
+ unsigned int cfg;
+ int ret, chno;
+
+ if (ch->in_use)
+ return RING_SZ;
+
+ spin_lock_init(&ch->ring_lock);
+ spin_lock_init(&ch->desc_lock);
+
+ chno = ch->chan.chno;
+
+ ret = pasemi_dma_alloc_ring(&ch->chan, RING_SZ);
+ if (ret) {
+ printk(KERN_INFO "pasemi_dma: Failed to allocate descriptor ring: %d\n", ret);
+ return ret;
+ }
+
+ ch->in_use = 1;
+
+ /* We can really set CNTTH to anything, since we never
+ * re-enable it after the first interrupt at the moment.
+ */
+ pasemi_write_iob_reg(PAS_IOB_DMA_TXCH_CFG(chno),
+ PAS_IOB_DMA_TXCH_CFG_CNTTH(0));
+
+ pasemi_write_iob_reg(PAS_IOB_DMA_TXCH_RESET(chno), 0x30);
+
+ pasemi_write_dma_reg(PAS_DMA_TXCHAN_BASEL(chno),
+ PAS_DMA_TXCHAN_BASEL_BRBL(ch->chan.ring_dma));
+
+ val = PAS_DMA_TXCHAN_BASEU_BRBH(ch->chan.ring_dma >> 32);
+ val |= PAS_DMA_TXCHAN_BASEU_SIZ(ch->chan.ring_size >> 3);
+
+ pasemi_write_dma_reg(PAS_DMA_TXCHAN_BASEU(chno), val);
+
+ cfg = PAS_DMA_TXCHAN_CFG_TY_COPY |
+ PAS_DMA_TXCHAN_CFG_UP |
+ PAS_DMA_TXCHAN_CFG_LPDQ |
+ PAS_DMA_TXCHAN_CFG_LPSQ |
+ PAS_DMA_TXCHAN_CFG_WT(4);
+
+ pasemi_write_dma_reg(PAS_DMA_TXCHAN_CFG(chno), cfg);
+
+ pasemi_dma_start_chan(&ch->chan, PAS_DMA_TXCHAN_TCMDSTA_SZ |
+ PAS_DMA_TXCHAN_TCMDSTA_DB |
+ PAS_DMA_TXCHAN_TCMDSTA_DE |
+ PAS_DMA_TXCHAN_TCMDSTA_DA);
+
+ ch->next_to_fill = 0;
+ ch->next_to_clean = 0;
+ ch->desc_count = 0;
+
+ return ch->chan.ring_size/4;
+}
+
+static void pasemi_dma_free_chan_resources(struct dma_chan *chan)
+{
+ struct pasemi_dma_chan *ch = to_pasemi_dma_chan(chan);
+
+ if (ch->in_use)
+ pasemi_dma_free_ring(&ch->chan);
+
+ ch->in_use = 0;
+
+ return;
+}
+
+static enum dma_status pasemi_dma_is_complete(struct dma_chan *chan,
+ dma_cookie_t cookie,
+ dma_cookie_t *done,
+ dma_cookie_t *used)
+{
+ struct pasemi_dma_chan *ch = to_pasemi_dma_chan(chan);
+ dma_cookie_t clean, fill;
+ int tries = 1;
+ enum dma_status ret;
+
+ pasemi_dma_clean(ch);
+
+ do {
+ clean = (ch->next_to_clean - 4) & (RING_SZ-1);
+ fill = (ch->next_to_fill - 1) & (RING_SZ-1) ;
+
+ if (done)
+ *done = clean;
+ if (used)
+ *used = fill;
+
+ ret = dma_async_is_complete(cookie, clean, fill);
+ } while (ret != DMA_SUCCESS && --tries);
+
+ return ret;
+}
+
+
+static void pasemi_dma_issue_pending(struct dma_chan *chan)
+{
+ return;
+}
+
+static void pasemi_dma_dependency_added(struct dma_chan *chan)
+{
+ return;
+}
+
+
+static dma_cookie_t
+pasemi_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+ struct pasemi_dma_desc *desc = tx_to_desc_sw(tx);
+ struct pasemi_dma_chan *chan = desc->chan;
+ unsigned long flags;
+ u64 xct[4], *ring;
+ int idx, len;
+
+ len = desc->len;
+ if (unlikely(!len)) {
+ xct[0] = XCT_COPY_DTY_PREF;
+ len = 1;
+ } else
+ xct[0] = 0;
+
+ xct[0] |= XCT_COPY_O | XCT_COPY_LLEN(len);
+ xct[1] = XCT_PTR_LEN(len) | XCT_PTR_ADDR(desc->dest) | XCT_PTR_T;
+ xct[2] = XCT_PTR_LEN(len) | XCT_PTR_ADDR(desc->src);
+ xct[3] = 0;
+
+ spin_lock_irqsave(&chan->ring_lock, flags);
+
+ idx = chan->next_to_fill;
+
+ ring = chan->chan.ring_virt;
+
+ /* This is where we copy stuff to the ring */
+
+ ring[idx & (RING_SZ-1)] = xct[0];
+ ring[(idx+1) & (RING_SZ-1)] = xct[1];
+ ring[(idx+2) & (RING_SZ-1)] = xct[2];
+ ring[(idx+3) & (RING_SZ-1)] = xct[3];
+
+ chan->next_to_fill = (chan->next_to_fill + 4) & (RING_SZ-1);
+
+ chan->ring_info[idx] = desc;
+
+ pasemi_write_dma_reg(PAS_DMA_TXCHAN_INCR(chan->chan.chno), 2);
+
+ spin_unlock_irqrestore(&chan->ring_lock, flags);
+ return idx;
+}
+
+static struct pasemi_dma_desc *
+pasemi_dma_alloc_descriptor(struct pasemi_dma_chan *ch, gfp_t flags)
+{
+ struct pasemi_dma_desc *desc;
+ struct pasemi_dma *dev;
+
+ dev = ch->dma_dev;
+
+ desc = kzalloc(sizeof(*desc), flags);
+ if (unlikely(!desc))
+ return NULL;
+
+ dma_async_tx_descriptor_init(&desc->async_tx, &ch->common);
+ desc->async_tx.tx_submit = pasemi_tx_submit;
+ desc->chan = ch;
+ INIT_LIST_HEAD(&desc->async_tx.tx_list);
+
+ return desc;
+}
+
+static struct dma_async_tx_descriptor *
+pasemi_dma_prep_memcpy(struct dma_chan *chan, dma_addr_t dma_dest,
+ dma_addr_t dma_src, size_t len, unsigned long flags)
+{
+ struct pasemi_dma_chan *ch = to_pasemi_dma_chan(chan);
+ struct pasemi_dma_desc *desc;
+ int retries = 0;
+
+ if (len >= MAX_XFER) {
+ if (printk_ratelimit())
+ printk(KERN_WARNING "pasemi_dma: Copy request too long (%ld > %d)\n",
+ len, MAX_XFER);
+ return NULL;
+ }
+
+retry:
+
+ spin_lock_bh(&ch->desc_lock);
+
+ if (!list_empty(&ch->free_desc)) {
+ desc = list_entry(ch->free_desc.next, struct pasemi_dma_desc,
+ node);
+ list_del(&desc->node);
+ } else {
+ if (ch->desc_count >= (RING_SZ/2)) {
+ spin_unlock_bh(&ch->desc_lock);
+ if (!retries++) {
+ pasemi_dma_clean(ch);
+ goto retry;
+ }
+ return NULL;
+ }
+ ch->desc_count++;
+ /* try to get another desc */
+ spin_unlock_bh(&ch->desc_lock);
+ desc = pasemi_dma_alloc_descriptor(ch, GFP_KERNEL);
+ spin_lock_bh(&ch->desc_lock);
+ /* will this ever happen? */
+ BUG_ON(!desc);
+ }
+ spin_unlock_bh(&ch->desc_lock);
+
+ desc->len = len;
+ desc->dest = dma_dest;
+ desc->src = dma_src;
+
+ return &desc->async_tx;
+}
+
+static int enumerate_dma_channels(struct pasemi_dma *device)
+{
+ int i, ret;
+ struct pasemi_dma_chan *ch;
+
+ device->common.chancnt = channels;
+
+ for (i = 0; i < device->common.chancnt; i++) {
+ ch = pasemi_dma_alloc_chan(TXCHAN, sizeof(*ch),
+ offsetof(struct pasemi_dma_chan,
+ chan));
+ ch->dma_dev = device;
+ ch->common.device = &device->common;
+ ret = request_irq(ch->chan.irq, &pasemi_dma_intr, IRQF_DISABLED,
+ "pasemi_dma", ch);
+ if (ret) {
+ printk(KERN_INFO "pasemi_dma: request of irq %d failed: %d\n",
+ ch->chan.irq, ret);
+ return ret;
+ }
+ INIT_LIST_HEAD(&ch->free_desc);
+ list_add_tail(&ch->common.device_node,
+ &device->common.channels);
+ }
+ return device->common.chancnt;
+}
+
+static int __devinit pasemi_dma_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int err;
+ struct pasemi_dma *device;
+ struct dma_device *dma_dev;
+
+ err = pci_enable_device(pdev);
+ if (err)
+ goto err_enable_device;
+
+ device = kzalloc(sizeof(*device), GFP_KERNEL);
+ if (!device) {
+ err = -ENOMEM;
+ goto err_kzalloc;
+ }
+
+ device->pdev = pdev;
+ pci_set_drvdata(pdev, device);
+
+ dma_dev = &device->common;
+
+ INIT_LIST_HEAD(&dma_dev->channels);
+ enumerate_dma_channels(device);
+
+ dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
+ dma_dev->device_alloc_chan_resources = pasemi_dma_alloc_chan_resources;
+ dma_dev->device_free_chan_resources = pasemi_dma_free_chan_resources;
+ dma_dev->device_prep_dma_memcpy = pasemi_dma_prep_memcpy;
+ dma_dev->device_is_tx_complete = pasemi_dma_is_complete;
+ dma_dev->device_issue_pending = pasemi_dma_issue_pending;
+ dma_dev->device_dependency_added = pasemi_dma_dependency_added;
+ dma_dev->dev = &pdev->dev;
+
+ printk(KERN_INFO "PA Semi DMA Engine found, using %d channels for copy\n",
+ dma_dev->chancnt);
+
+ err = dma_async_device_register(dma_dev);
+
+ return err;
+
+err_kzalloc:
+ pci_disable_device(pdev);
+err_enable_device:
+
+ printk(KERN_ERR "PA Semi DMA Engine initialization failed\n");
+
+ return err;
+}
+
+static void pasemi_dma_shutdown(struct pci_dev *pdev)
+{
+ struct pasemi_dma *device;
+ device = pci_get_drvdata(pdev);
+
+ dma_async_device_unregister(&device->common);
+}
+
+static void __devexit pasemi_dma_remove(struct pci_dev *pdev)
+{
+ struct pasemi_dma *device;
+ struct dma_chan *chan, *_chan;
+ struct pasemi_dma_chan *pasemi_ch;
+
+ device = pci_get_drvdata(pdev);
+ dma_async_device_unregister(&device->common);
+
+ list_for_each_entry_safe(chan, _chan, &device->common.channels,
+ device_node) {
+ pasemi_ch = to_pasemi_dma_chan(chan);
+ free_irq(pasemi_ch->chan.irq, pasemi_ch);
+ list_del(&chan->device_node);
+ pasemi_dma_free_chan(&pasemi_ch->chan);
+ }
+
+ pci_disable_device(pdev);
+ kfree(device);
+}
+
+static struct pci_device_id pasemi_dma_pci_tbl[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa007) },
+ { }
+};
+MODULE_DEVICE_TABLE(pci, pasemi_dma_pci_tbl);
+
+static struct pci_driver pasemi_dma_pci_driver = {
+ .name = "pasemi_dma",
+ .id_table = pasemi_dma_pci_tbl,
+ .probe = pasemi_dma_probe,
+ .shutdown = pasemi_dma_shutdown,
+ .remove = __devexit_p(pasemi_dma_remove),
+};
+
+
+static int __init pasemi_dma_init_module(void)
+{
+ int err;
+
+ err = pasemi_dma_init();
+ if (err)
+ return err;
+
+ return pci_register_driver(&pasemi_dma_pci_driver);
+}
+
+module_init(pasemi_dma_init_module);
+
+static void __exit pasemi_dma_exit_module(void)
+{
+ pci_unregister_driver(&pasemi_dma_pci_driver);
+}
+
+module_exit(pasemi_dma_exit_module);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Olof Johansson <olof@lixom.net>");
+MODULE_DESCRIPTION("PA Semi PWRficient DMA Engine driver");
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox