linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Grant Likely" <grant.likely@secretlab.ca>
To: "Kumar Gala" <galak@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org, domen.puncer@telargo.com
Subject: Re: [PATCH v2 4/7] bestcomm: core bestcomm support for Freescale MPC5200
Date: Mon, 15 Oct 2007 08:20:06 -0600	[thread overview]
Message-ID: <fa686aa40710150720x6c0ab76hf45d434740d5718f@mail.gmail.com> (raw)
In-Reply-To: <C2B03958-38CC-4B5C-96C1-E8B5366C4D49@kernel.crashing.org>

On 10/15/07, Kumar Gala <galak@kernel.crashing.org> wrote:
> (Comments just on SRAM code)
>
> I think this should be made generic and be utility functionality to
> rheap.
>
> CPM, CPM2, QE, L2 SRAM, etc can all use this.  I'd rather we didn't
> have 3 ways to do the exact same functionality.  (cpm_dpalloc,
> cpm_dpfree, qe_muram_alloc, qe_muram_free)

Fair enough; but not in this patch set.  This series is working
support for bestcomm.  To go to the more generic level of being used
by multiple parts should be done in a separate series.

>
> see other comments inline.
>
> > +
> > diff --git a/arch/powerpc/sysdev/bestcomm/sram.c b/arch/powerpc/
> > sysdev/bestcomm/sram.c
> > new file mode 100644
> > index 0000000..b3f2ed1
> > --- /dev/null
> > +++ b/arch/powerpc/sysdev/bestcomm/sram.c
> > @@ -0,0 +1,177 @@
> > +/*
> > + * Simple memory allocator for on-board SRAM
> > + *
> > + *
> > + * Maintainer : Sylvain Munaut <tnt@246tNt.com>
> > + *
> > + * Copyright (C) 2005 Sylvain Munaut <tnt@246tNt.com>
> > + *
> > + * This file is licensed under the terms of the GNU General Public
> > License
> > + * version 2. This program is licensed "as is" without any
> > warranty of any
> > + * kind, whether express or implied.
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/slab.h>
> > +#include <linux/spinlock.h>
> > +#include <linux/string.h>
> > +#include <linux/ioport.h>
> > +#include <linux/of.h>
> > +
> > +#include <asm/io.h>
> > +#include <asm/mmu.h>
> > +
> > +#include "sram.h"
> > +
> > +
> > +/* Struct keeping our 'state' */
> > +struct bcom_sram *bcom_sram = NULL;
>
> shouldn't be global, so we can support more than one SRAM.

Again; I agree, but I'm not going to make that change in this series.

>
> > +EXPORT_SYMBOL_GPL(bcom_sram);        /* needed for inline functions */
> > +
> > +
> > +/*
> > ======================================================================
> > == */
> > +/* Public
> > API                                                               */
> > +/*
> > ======================================================================
> > == */
> > +/* DO NOT USE in interrupts, if needed in irq handler, we should
> > use the
> > +   _irqsave version of the spin_locks */
> > +
> > +int bcom_sram_init(struct device_node *sram_node, char *owner)
> > +{
> > +     int rv;
> > +     const u32 *regaddr_p;
> > +     u64 regaddr64, size64;
> > +     unsigned int psize;
> > +
> > +     /* Create our state struct */
> > +     if (bcom_sram) {
> > +             printk(KERN_ERR "%s: bcom_sram_init: "
> > +                     "Already initialiwed !\n", owner);
> > +             return -EBUSY;
> > +     }
> > +
> > +     bcom_sram = kmalloc(sizeof(struct bcom_sram), GFP_KERNEL);
>
> should return this handle to the user.

To be done when this driver is changed to support multiple sram regions.

> > diff --git a/arch/powerpc/sysdev/bestcomm/sram.h b/arch/powerpc/
> > sysdev/bestcomm/sram.h
> > new file mode 100644
> > index 0000000..b6d6689
> > --- /dev/null
> > +++ b/arch/powerpc/sysdev/bestcomm/sram.h
> > @@ -0,0 +1,54 @@
> > +/*
> > + * Handling of a sram zone for bestcomm
> > + *
> > + *
> > + * Copyright (C) 2007 Sylvain Munaut <tnt@246tNt.com>
> > + *
> > + * This file is licensed under the terms of the GNU General Public
> > License
> > + * version 2. This program is licensed "as is" without any
> > warranty of any
> > + * kind, whether express or implied.
> > + */
> > +
> > +#ifndef __BESTCOMM_SRAM_H__
> > +#define __BESTCOMM_SRAM_H__
> > +
> > +#include <asm/rheap.h>
> > +#include <asm/mmu.h>
> > +#include <linux/spinlock.h>
> > +
> > +
> > +/* Structure used internally */
> > +     /* The internals are here for the inline functions
> > +      * sake, certainly not for the user to mess with !
> > +      */
> > +struct bcom_sram {
> > +     phys_addr_t              base_phys;
> > +     void                    *base_virt;
>
> __iomem for base_virt?

I'll take a look

>
> > +     unsigned int             size;
> > +     rh_info_t               *rh;
> > +     spinlock_t               lock;
> > +};
> > +
> > +extern struct bcom_sram *bcom_sram;
> > +
> > +
> > +/* Public API */
> > +extern int  bcom_sram_init(struct device_node *sram_node, char
> > *owner);
> > +extern void bcom_sram_cleanup(void);
> > +
> > +extern void* bcom_sram_alloc(int size, int align, phys_addr_t *phys);
> > +extern void  bcom_sram_free(void *ptr);
> > +
> > +static inline phys_addr_t bcom_sram_va2pa(void *va) {
>
> should take bcom_sram handle as a param
>
> > +     return bcom_sram->base_phys +
> > +             (unsigned long)(va - bcom_sram->base_virt);
>
> shouldn't this cast be phys_addr_t?

I don't think so.  ->base_phys is of type phys_addr_t;
(va-bcom_sram->base_virt) is just an offset from ->base_phys.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

  reply	other threads:[~2007-10-15 14:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-14  4:41 [PATCH v2 0/7] 2nd respin of bestcomm patches Grant Likely
2007-10-14  4:41 ` [PATCH v2 1/7] exports rheap symbol to modules Grant Likely
2007-10-14  4:41 ` [PATCH v2 2/7] rheap: Changes config mechanism Grant Likely
2007-10-15 13:43   ` Kumar Gala
2007-10-15 13:55     ` Grant Likely
2007-10-15 14:03       ` Kumar Gala
2007-10-15 14:06         ` Grant Likely
2007-10-15 14:53         ` Timur Tabi
2007-10-15 14:54           ` Kumar Gala
2007-10-15 14:54             ` Timur Tabi
2007-10-15 15:09               ` Grant Likely
2007-10-14  4:42 ` [PATCH v2 3/7] mpc52xx: Update mpc52xx_psc structure with B revision changes Grant Likely
2007-10-14  4:42 ` [PATCH v2 4/7] bestcomm: core bestcomm support for Freescale MPC5200 Grant Likely
2007-10-14 11:33   ` Sven Luther
2007-10-14 20:22     ` Grant Likely
2007-10-14 20:25       ` Sven Luther
2007-10-14 21:23         ` Grant Likely
2007-10-15  6:12           ` Sven Luther
2007-10-15 11:55   ` Matt Sealey
2007-10-15 14:04     ` Grant Likely
2007-10-15 20:53       ` Matt Sealey
2007-10-15 20:55         ` Matt Sealey
2007-10-15 21:06         ` Grant Likely
2007-10-16 13:21       ` tnt
2007-10-15 14:06   ` Kumar Gala
2007-10-15 14:20     ` Grant Likely [this message]
2007-10-15 14:39       ` Matt Sealey
2007-10-14  4:42 ` [PATCH v2 5/7] bestcomm: ATA task support Grant Likely
2007-10-14  4:42 ` [PATCH v2 6/7] bestcomm: FEC " Grant Likely
2007-10-14  4:42 ` [PATCH v2 7/7] bestcomm: GenBD " Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa686aa40710150720x6c0ab76hf45d434740d5718f@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=domen.puncer@telargo.com \
    --cc=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).