* [PATCH 0/3] spufs: mmap fixes and updates
@ 2007-02-13 0:46 Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 1/3] spufs: remove need for struct page for SPEs Benjamin Herrenschmidt
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-13 0:46 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, cbe-oss-dev
This is a new version of the spufs patch removing dependency
on struct page along with a bugfix for some serious bitrot that
happened in spufs mmap facility lately.
The 2 VM patches this depends on have been merged in Linus tree
last night so this should go in now.
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] spufs: remove need for struct page for SPEs
2007-02-13 0:46 [PATCH 0/3] spufs: mmap fixes and updates Benjamin Herrenschmidt
@ 2007-02-13 0:46 ` Benjamin Herrenschmidt
2007-02-13 12:15 ` [Cbe-oss-dev] " Arnd Bergmann
2007-02-13 0:46 ` [PATCH 2/3] powerpc: Remove SPU struct page's for PS3 Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility Benjamin Herrenschmidt
2 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-13 0:46 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, cbe-oss-dev
This patch removes the need for struct page for SPE local store
and registers from spufs. It also makes the locking much more
obvious and no longer relying on the truncate logic black magic
for protecting against races between unmap_mapping_range() and
new pages faulted in. It does so by switching to a nopfn() handler
and using the new vm_insert_pfn() to setup the PTEs itself while
holding a lock on the SPE.
The nice thing is that this patch actually removes a lot more code
than it adds :-)
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/Kconfig | 2
arch/powerpc/platforms/cell/spu_manage.c | 102 ++++++--------------------
arch/powerpc/platforms/cell/spufs/file.c | 121 ++++++++++++++-----------------
3 files changed, 80 insertions(+), 145 deletions(-)
Index: linux-cell/arch/powerpc/platforms/cell/spufs/file.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spufs/file.c 2007-02-13 11:18:57.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/cell/spufs/file.c 2007-02-13 11:22:21.000000000 +1100
@@ -95,14 +95,12 @@ spufs_mem_write(struct file *file, const
return ret;
}
-static struct page *
-spufs_mem_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_mem_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
- struct page *page = NOPAGE_SIGBUS;
-
struct spu_context *ctx = vma->vm_file->private_data;
- unsigned long offset = address - vma->vm_start;
+ unsigned long pfn, offset = address - vma->vm_start;
+
offset += vma->vm_pgoff << PAGE_SHIFT;
spu_acquire(ctx);
@@ -110,24 +108,22 @@ spufs_mem_mmap_nopage(struct vm_area_str
if (ctx->state == SPU_STATE_SAVED) {
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
& ~_PAGE_NO_CACHE);
- page = vmalloc_to_page(ctx->csa.lscsa->ls + offset);
+ pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset);
} else {
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
- | _PAGE_NO_CACHE);
- page = pfn_to_page((ctx->spu->local_store_phys + offset)
- >> PAGE_SHIFT);
+ | _PAGE_NO_CACHE);
+ pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
}
- spu_release(ctx);
+ vm_insert_pfn(vma, address, pfn);
- if (type)
- *type = VM_FAULT_MINOR;
+ spu_release(ctx);
- page_cache_get(page);
- return page;
+ return NOPFN_REFAULT;
}
+
static struct vm_operations_struct spufs_mem_mmap_vmops = {
- .nopage = spufs_mem_mmap_nopage,
+ .nopfn = spufs_mem_mmap_nopfn,
};
static int
@@ -136,7 +132,7 @@ spufs_mem_mmap(struct file *file, struct
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE);
@@ -152,49 +148,42 @@ static const struct file_operations spuf
.mmap = spufs_mem_mmap,
};
-static struct page *spufs_ps_nopage(struct vm_area_struct *vma,
+static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
unsigned long address,
- int *type, unsigned long ps_offs,
+ unsigned long ps_offs,
unsigned long ps_size)
{
- struct page *page = NOPAGE_SIGBUS;
- int fault_type = VM_FAULT_SIGBUS;
struct spu_context *ctx = vma->vm_file->private_data;
- unsigned long offset = address - vma->vm_start;
- unsigned long area;
+ unsigned long area, offset = address - vma->vm_start;
int ret;
offset += vma->vm_pgoff << PAGE_SHIFT;
if (offset >= ps_size)
- goto out;
+ return NOPFN_SIGBUS;
+ /* error here usually means a signal.. we might want to test
+ * the error code more precisely though
+ */
ret = spu_acquire_runnable(ctx);
if (ret)
- goto out;
+ return NOPFN_REFAULT;
area = ctx->spu->problem_phys + ps_offs;
- page = pfn_to_page((area + offset) >> PAGE_SHIFT);
- fault_type = VM_FAULT_MINOR;
- page_cache_get(page);
-
+ vm_insert_pfn(vma, address, (area + offset) >> PAGE_SHIFT);
spu_release(ctx);
- out:
- if (type)
- *type = fault_type;
-
- return page;
+ return NOPFN_REFAULT;
}
#if SPUFS_MMAP_4K
-static struct page *spufs_cntl_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_cntl_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
- return spufs_ps_nopage(vma, address, type, 0x4000, 0x1000);
+ return spufs_ps_nopfn(vma, address, 0x4000, 0x1000);
}
static struct vm_operations_struct spufs_cntl_mmap_vmops = {
- .nopage = spufs_cntl_mmap_nopage,
+ .nopfn = spufs_cntl_mmap_nopfn,
};
/*
@@ -205,7 +194,7 @@ static int spufs_cntl_mmap(struct file *
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
@@ -791,23 +780,23 @@ static ssize_t spufs_signal1_write(struc
return 4;
}
-static struct page *spufs_signal1_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_signal1_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
#if PAGE_SIZE == 0x1000
- return spufs_ps_nopage(vma, address, type, 0x14000, 0x1000);
+ return spufs_ps_nopfn(vma, address, 0x14000, 0x1000);
#elif PAGE_SIZE == 0x10000
/* For 64k pages, both signal1 and signal2 can be used to mmap the whole
* signal 1 and 2 area
*/
- return spufs_ps_nopage(vma, address, type, 0x10000, 0x10000);
+ return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
#else
#error unsupported page size
#endif
}
static struct vm_operations_struct spufs_signal1_mmap_vmops = {
- .nopage = spufs_signal1_mmap_nopage,
+ .nopfn = spufs_signal1_mmap_nopfn,
};
static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
@@ -815,7 +804,7 @@ static int spufs_signal1_mmap(struct fil
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
@@ -899,23 +888,23 @@ static ssize_t spufs_signal2_write(struc
}
#if SPUFS_MMAP_4K
-static struct page *spufs_signal2_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_signal2_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
#if PAGE_SIZE == 0x1000
- return spufs_ps_nopage(vma, address, type, 0x1c000, 0x1000);
+ return spufs_ps_nopfn(vma, address, 0x1c000, 0x1000);
#elif PAGE_SIZE == 0x10000
/* For 64k pages, both signal1 and signal2 can be used to mmap the whole
* signal 1 and 2 area
*/
- return spufs_ps_nopage(vma, address, type, 0x10000, 0x10000);
+ return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
#else
#error unsupported page size
#endif
}
static struct vm_operations_struct spufs_signal2_mmap_vmops = {
- .nopage = spufs_signal2_mmap_nopage,
+ .nopfn = spufs_signal2_mmap_nopfn,
};
static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
@@ -923,7 +912,7 @@ static int spufs_signal2_mmap(struct fil
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
@@ -1000,14 +989,14 @@ DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_ty
spufs_signal2_type_set, "%llu");
#if SPUFS_MMAP_4K
-static struct page *spufs_mss_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
- return spufs_ps_nopage(vma, address, type, 0x0000, 0x1000);
+ return spufs_ps_nopfn(vma, address, 0x0000, 0x1000);
}
static struct vm_operations_struct spufs_mss_mmap_vmops = {
- .nopage = spufs_mss_mmap_nopage,
+ .nopfn = spufs_mss_mmap_nopfn,
};
/*
@@ -1018,7 +1007,7 @@ static int spufs_mss_mmap(struct file *f
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
@@ -1042,14 +1031,14 @@ static const struct file_operations spuf
.mmap = spufs_mss_mmap,
};
-static struct page *spufs_psmap_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_psmap_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
- return spufs_ps_nopage(vma, address, type, 0x0000, 0x20000);
+ return spufs_ps_nopfn(vma, address, 0x0000, 0x20000);
}
static struct vm_operations_struct spufs_psmap_mmap_vmops = {
- .nopage = spufs_psmap_mmap_nopage,
+ .nopfn = spufs_psmap_mmap_nopfn,
};
/*
@@ -1060,7 +1049,7 @@ static int spufs_psmap_mmap(struct file
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
@@ -1083,14 +1072,14 @@ static const struct file_operations spuf
#if SPUFS_MMAP_4K
-static struct page *spufs_mfc_mmap_nopage(struct vm_area_struct *vma,
- unsigned long address, int *type)
+static unsigned long spufs_mfc_mmap_nopfn(struct vm_area_struct *vma,
+ unsigned long address)
{
- return spufs_ps_nopage(vma, address, type, 0x3000, 0x1000);
+ return spufs_ps_nopfn(vma, address, 0x3000, 0x1000);
}
static struct vm_operations_struct spufs_mfc_mmap_vmops = {
- .nopage = spufs_mfc_mmap_nopage,
+ .nopfn = spufs_mfc_mmap_nopfn,
};
/*
@@ -1101,7 +1090,7 @@ static int spufs_mfc_mmap(struct file *f
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma->vm_flags |= VM_IO;
+ vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
| _PAGE_NO_CACHE | _PAGE_GUARDED);
Index: linux-cell/arch/powerpc/Kconfig
===================================================================
--- linux-cell.orig/arch/powerpc/Kconfig 2007-02-13 11:21:21.000000000 +1100
+++ linux-cell/arch/powerpc/Kconfig 2007-02-13 11:22:21.000000000 +1100
@@ -880,7 +880,7 @@ config ARCH_SPARSEMEM_ENABLE
config ARCH_SPARSEMEM_DEFAULT
def_bool y
- depends on (SMP && PPC_PSERIES) || PPC_CELL
+ depends on (SMP && PPC_PSERIES) || PPC_PS3
config ARCH_POPULATES_NODE_MAP
def_bool y
Index: linux-cell/arch/powerpc/platforms/cell/spu_manage.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spu_manage.c 2007-02-13 11:25:59.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/cell/spu_manage.c 2007-02-13 11:29:56.000000000 +1100
@@ -59,63 +59,6 @@ static u64 __init find_spu_unit_number(s
return 0;
}
-static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
- const char *prop)
-{
- const struct address_prop {
- unsigned long address;
- unsigned int len;
- } __attribute__((packed)) *p;
- int proplen;
-
- unsigned long start_pfn, nr_pages;
- struct pglist_data *pgdata;
- struct zone *zone;
- int ret;
-
- p = get_property(spe, prop, &proplen);
- WARN_ON(proplen != sizeof (*p));
-
- start_pfn = p->address >> PAGE_SHIFT;
- nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
- pgdata = NODE_DATA(spu->node);
- zone = pgdata->node_zones;
-
- ret = __add_pages(zone, start_pfn, nr_pages);
-
- return ret;
-}
-
-static void __iomem * __init map_spe_prop(struct spu *spu,
- struct device_node *n, const char *name)
-{
- const struct address_prop {
- unsigned long address;
- unsigned int len;
- } __attribute__((packed)) *prop;
-
- const void *p;
- int proplen;
- void __iomem *ret = NULL;
- int err = 0;
-
- p = get_property(n, name, &proplen);
- if (proplen != sizeof (struct address_prop))
- return NULL;
-
- prop = p;
-
- err = cell_spuprop_present(spu, n, name);
- if (err && (err != -EEXIST))
- goto out;
-
- ret = ioremap(prop->address, prop->len);
-
- out:
- return ret;
-}
-
static void spu_unmap(struct spu *spu)
{
if (!firmware_has_feature(FW_FEATURE_LPAR))
@@ -157,6 +100,23 @@ static int __init spu_map_interrupts_old
return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
}
+static void __iomem * __init spu_map_prop_old(struct spu *spu,
+ struct device_node *n,
+ const char *name)
+{
+ const struct address_prop {
+ unsigned long address;
+ unsigned int len;
+ } __attribute__((packed)) *prop;
+ int proplen;
+
+ prop = get_property(n, name, &proplen);
+ if (prop == NULL || proplen != sizeof (struct address_prop))
+ return NULL;
+
+ return ioremap(prop->address, prop->len);
+}
+
static int __init spu_map_device_old(struct spu *spu)
{
struct device_node *node = spu->devnode;
@@ -175,7 +135,7 @@ static int __init spu_map_device_old(str
/* we use local store as ram, not io memory */
spu->local_store = (void __force *)
- map_spe_prop(spu, node, "local-store");
+ spu_map_prop_old(spu, node, "local-store");
if (!spu->local_store)
goto out;
@@ -184,16 +144,16 @@ static int __init spu_map_device_old(str
goto out_unmap;
spu->problem_phys = *(unsigned long *)prop;
- spu->problem = map_spe_prop(spu, node, "problem");
+ spu->problem = spu_map_prop_old(spu, node, "problem");
if (!spu->problem)
goto out_unmap;
- spu->priv2 = map_spe_prop(spu, node, "priv2");
+ spu->priv2 = spu_map_prop_old(spu, node, "priv2");
if (!spu->priv2)
goto out_unmap;
if (!firmware_has_feature(FW_FEATURE_LPAR)) {
- spu->priv1 = map_spe_prop(spu, node, "priv1");
+ spu->priv1 = spu_map_prop_old(spu, node, "priv1");
if (!spu->priv1)
goto out_unmap;
}
@@ -245,34 +205,20 @@ static int spu_map_resource(struct spu *
void __iomem** virt, unsigned long *phys)
{
struct device_node *np = spu->devnode;
- unsigned long start_pfn, nr_pages;
- struct pglist_data *pgdata;
- struct zone *zone;
struct resource resource = { };
unsigned long len;
int ret;
ret = of_address_to_resource(np, nr, &resource);
if (ret)
- goto out;
-
+ return ret;
if (phys)
*phys = resource.start;
len = resource.end - resource.start + 1;
*virt = ioremap(resource.start, len);
if (!*virt)
- ret = -EINVAL;
-
- start_pfn = resource.start >> PAGE_SHIFT;
- nr_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
- pgdata = NODE_DATA(spu->node);
- zone = pgdata->node_zones;
-
- ret = __add_pages(zone, start_pfn, nr_pages);
-
-out:
- return ret;
+ return -EINVAL;
+ return 0;
}
static int __init spu_map_device(struct spu *spu)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] powerpc: Remove SPU struct page's for PS3
2007-02-13 0:46 [PATCH 0/3] spufs: mmap fixes and updates Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 1/3] spufs: remove need for struct page for SPEs Benjamin Herrenschmidt
@ 2007-02-13 0:46 ` Benjamin Herrenschmidt
2007-02-13 12:16 ` [Cbe-oss-dev] " Arnd Bergmann
2007-02-13 0:46 ` [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility Benjamin Herrenschmidt
2 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-13 0:46 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, cbe-oss-dev
Struct page are no longer needed for SPUs, so let's not create them
on PS3 anymore.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/ps3/spu.c | 42 +--------------------------------------
1 file changed, 2 insertions(+), 40 deletions(-)
Index: linux-cell/arch/powerpc/platforms/ps3/spu.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/ps3/spu.c 2007-02-13 11:34:38.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/ps3/spu.c 2007-02-13 11:37:07.000000000 +1100
@@ -170,31 +170,6 @@ static int __init construct_spu(struct s
return result;
}
-static int __init add_spu_pages(unsigned long start_addr, unsigned long size)
-{
- int result;
- unsigned long start_pfn;
- unsigned long nr_pages;
- struct pglist_data *pgdata;
- struct zone *zone;
-
- BUG_ON(!mem_init_done);
-
- start_pfn = start_addr >> PAGE_SHIFT;
- nr_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
- pgdata = NODE_DATA(0);
- zone = pgdata->node_zones;
-
- result = __add_pages(zone, start_pfn, nr_pages);
-
- if (result)
- pr_debug("%s:%d: __add_pages failed: (%d)\n",
- __func__, __LINE__, result);
-
- return result;
-}
-
static void spu_unmap(struct spu *spu)
{
iounmap(spu->priv2);
@@ -206,19 +181,6 @@ static void spu_unmap(struct spu *spu)
static int __init setup_areas(struct spu *spu)
{
struct table {char* name; unsigned long addr; unsigned long size;};
- int result;
-
- /* setup pages */
-
- result = add_spu_pages(spu->local_store_phys, LS_SIZE);
- if (result)
- goto fail_add;
-
- result = add_spu_pages(spu->problem_phys, sizeof(struct spu_problem));
- if (result)
- goto fail_add;
-
- /* ioremap */
spu_pdata(spu)->shadow = __ioremap(
spu_pdata(spu)->shadow_addr, sizeof(struct spe_shadow),
@@ -260,8 +222,8 @@ static int __init setup_areas(struct spu
fail_ioremap:
spu_unmap(spu);
-fail_add:
- return result;
+
+ return -ENOMEM;
}
static int __init setup_interrupts(struct spu *spu)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility
2007-02-13 0:46 [PATCH 0/3] spufs: mmap fixes and updates Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 1/3] spufs: remove need for struct page for SPEs Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 2/3] powerpc: Remove SPU struct page's for PS3 Benjamin Herrenschmidt
@ 2007-02-13 0:46 ` Benjamin Herrenschmidt
2007-02-13 12:16 ` [Cbe-oss-dev] " Arnd Bergmann
2 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-13 0:46 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, cbe-oss-dev
It looks like we've had some serious bitrot there mostly due to tracking
of address_space's of mmap'ed files getting out of sync with the actual
mmap code. The mfc, mss and psmap were not tracked properly and thus
not invalidated on context switches (oops !)
I also removed the various file->f_mapping = inode->i_mapping;
assignments that were done in the other open() routines since that
is already done for us by __dentry_open.
One improvement we might want to do later is to assign the various
ctx-> fields at mmap time instead of file open/close time so that we
don't call unmap_mapping_range() on thing that have not been mmap'ed
Finally, I added some smp_wmb's after assigning the ctx-> fields to make
sure they are visible to other CPUs. I don't think this is really
necessary as I suspect locking in the fs layer will make that happen
anyway but better safe than sorry.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/cell/spufs/context.c | 12 ++++++++----
arch/powerpc/platforms/cell/spufs/file.c | 16 ++++++++++++----
arch/powerpc/platforms/cell/spufs/spufs.h | 2 ++
3 files changed, 22 insertions(+), 8 deletions(-)
Index: linux-cell/arch/powerpc/platforms/cell/spufs/context.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spufs/context.c 2007-02-09 15:47:28.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/cell/spufs/context.c 2007-02-09 15:48:27.000000000 +1100
@@ -111,13 +111,17 @@ void spu_unmap_mappings(struct spu_conte
if (ctx->local_store)
unmap_mapping_range(ctx->local_store, 0, LS_SIZE, 1);
if (ctx->mfc)
- unmap_mapping_range(ctx->mfc, 0, 0x4000, 1);
+ unmap_mapping_range(ctx->mfc, 0, 0x1000, 1);
if (ctx->cntl)
- unmap_mapping_range(ctx->cntl, 0, 0x4000, 1);
+ unmap_mapping_range(ctx->cntl, 0, 0x1000, 1);
if (ctx->signal1)
- unmap_mapping_range(ctx->signal1, 0, 0x4000, 1);
+ unmap_mapping_range(ctx->signal1, 0, PAGE_SIZE, 1);
if (ctx->signal2)
- unmap_mapping_range(ctx->signal2, 0, 0x4000, 1);
+ unmap_mapping_range(ctx->signal2, 0, PAGE_SIZE, 1);
+ if (ctx->mss)
+ unmap_mapping_range(ctx->mss, 0, 0x1000, 1);
+ if (ctx->psmap)
+ unmap_mapping_range(ctx->psmap, 0, 0x20000, 1);
}
int spu_acquire_exclusive(struct spu_context *ctx)
Index: linux-cell/arch/powerpc/platforms/cell/spufs/file.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spufs/file.c 2007-02-09 15:47:28.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/cell/spufs/file.c 2007-02-09 16:29:33.000000000 +1100
@@ -45,8 +45,8 @@ spufs_mem_open(struct inode *inode, stru
struct spufs_inode_info *i = SPUFS_I(inode);
struct spu_context *ctx = i->i_ctx;
file->private_data = ctx;
- file->f_mapping = inode->i_mapping;
ctx->local_store = inode->i_mapping;
+ smp_wmb();
return 0;
}
@@ -232,8 +232,8 @@ static int spufs_cntl_open(struct inode
struct spu_context *ctx = i->i_ctx;
file->private_data = ctx;
- file->f_mapping = inode->i_mapping;
ctx->cntl = inode->i_mapping;
+ smp_wmb();
return simple_attr_open(inode, file, spufs_cntl_get,
spufs_cntl_set, "0x%08lx");
}
@@ -717,8 +717,8 @@ static int spufs_signal1_open(struct ino
struct spufs_inode_info *i = SPUFS_I(inode);
struct spu_context *ctx = i->i_ctx;
file->private_data = ctx;
- file->f_mapping = inode->i_mapping;
ctx->signal1 = inode->i_mapping;
+ smp_wmb();
return nonseekable_open(inode, file);
}
@@ -824,8 +824,8 @@ static int spufs_signal2_open(struct ino
struct spufs_inode_info *i = SPUFS_I(inode);
struct spu_context *ctx = i->i_ctx;
file->private_data = ctx;
- file->f_mapping = inode->i_mapping;
ctx->signal2 = inode->i_mapping;
+ smp_wmb();
return nonseekable_open(inode, file);
}
@@ -1021,8 +1021,11 @@ static int spufs_mss_mmap(struct file *f
static int spufs_mss_open(struct inode *inode, struct file *file)
{
struct spufs_inode_info *i = SPUFS_I(inode);
+ struct spu_context *ctx = i->i_ctx;
file->private_data = i->i_ctx;
+ ctx->mss = inode->i_mapping;
+ smp_wmb();
return nonseekable_open(inode, file);
}
@@ -1060,8 +1063,11 @@ static int spufs_psmap_mmap(struct file
static int spufs_psmap_open(struct inode *inode, struct file *file)
{
struct spufs_inode_info *i = SPUFS_I(inode);
+ struct spu_context *ctx = i->i_ctx;
file->private_data = i->i_ctx;
+ ctx->psmap = inode->i_mapping;
+ smp_wmb();
return nonseekable_open(inode, file);
}
@@ -1114,6 +1120,8 @@ static int spufs_mfc_open(struct inode *
return -EBUSY;
file->private_data = ctx;
+ ctx->mfc = inode->i_mapping;
+ smp_wmb();
return nonseekable_open(inode, file);
}
Index: linux-cell/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spufs/spufs.h 2007-02-09 15:47:28.000000000 +1100
+++ linux-cell/arch/powerpc/platforms/cell/spufs/spufs.h 2007-02-09 15:48:15.000000000 +1100
@@ -51,6 +51,8 @@ struct spu_context {
struct address_space *cntl; /* 'control' area mappings. */
struct address_space *signal1; /* 'signal1' area mappings. */
struct address_space *signal2; /* 'signal2' area mappings. */
+ struct address_space *mss; /* 'mss' area mappings. */
+ struct address_space *psmap; /* 'psmap' area mappings. */
u64 object_id; /* user space pointer for oprofile */
enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 1/3] spufs: remove need for struct page for SPEs
2007-02-13 0:46 ` [PATCH 1/3] spufs: remove need for struct page for SPEs Benjamin Herrenschmidt
@ 2007-02-13 12:15 ` Arnd Bergmann
0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2007-02-13 12:15 UTC (permalink / raw)
To: cbe-oss-dev; +Cc: Paul Mackerras, linuxppc-dev
On Tuesday 13 February 2007 01:46, Benjamin Herrenschmidt wrote:
> This patch removes the need for struct page for SPE local store
> and registers from spufs. It also makes the locking much more
> obvious and no longer relying on the truncate logic black magic
> for protecting against races between unmap_mapping_range() and
> new pages faulted in. It does so by switching to a nopfn() handler
> and using the new vm_insert_pfn() to setup the PTEs itself while
> holding a lock on the SPE.
>
> The nice thing is that this patch actually removes a lot more code
> than it adds :-)
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 2/3] powerpc: Remove SPU struct page's for PS3
2007-02-13 0:46 ` [PATCH 2/3] powerpc: Remove SPU struct page's for PS3 Benjamin Herrenschmidt
@ 2007-02-13 12:16 ` Arnd Bergmann
0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2007-02-13 12:16 UTC (permalink / raw)
To: cbe-oss-dev; +Cc: Paul Mackerras, linuxppc-dev
On Tuesday 13 February 2007 01:46, Benjamin Herrenschmidt wrote:
> Struct page are no longer needed for SPUs, so let's not create them
> on PS3 anymore.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility
2007-02-13 0:46 ` [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility Benjamin Herrenschmidt
@ 2007-02-13 12:16 ` Arnd Bergmann
0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2007-02-13 12:16 UTC (permalink / raw)
To: cbe-oss-dev; +Cc: Paul Mackerras, linuxppc-dev
On Tuesday 13 February 2007 01:46, Benjamin Herrenschmidt wrote:
> It looks like we've had some serious bitrot there mostly due to tracking
> of address_space's of mmap'ed files getting out of sync with the actual
> mmap code. The mfc, mss and psmap were not tracked properly and thus
> not invalidated on context switches (oops !)
>
> I also removed the various file->f_mapping = inode->i_mapping;
> assignments that were done in the other open() routines since that
> is already done for us by __dentry_open.
>
> One improvement we might want to do later is to assign the various
> ctx-> fields at mmap time instead of file open/close time so that we
> don't call unmap_mapping_range() on thing that have not been mmap'ed
>
> Finally, I added some smp_wmb's after assigning the ctx-> fields to make
> sure they are visible to other CPUs. I don't think this is really
> necessary as I suspect locking in the fs layer will make that happen
> anyway but better safe than sorry.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-02-13 12:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-13 0:46 [PATCH 0/3] spufs: mmap fixes and updates Benjamin Herrenschmidt
2007-02-13 0:46 ` [PATCH 1/3] spufs: remove need for struct page for SPEs Benjamin Herrenschmidt
2007-02-13 12:15 ` [Cbe-oss-dev] " Arnd Bergmann
2007-02-13 0:46 ` [PATCH 2/3] powerpc: Remove SPU struct page's for PS3 Benjamin Herrenschmidt
2007-02-13 12:16 ` [Cbe-oss-dev] " Arnd Bergmann
2007-02-13 0:46 ` [PATCH 3/3] spufs: Fix bitrot of the SPU mmap facility Benjamin Herrenschmidt
2007-02-13 12:16 ` [Cbe-oss-dev] " Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).