linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC/PATCH 3/7] Powerpc MSI ops layer
       [not found] <20060928215339.D911C67BFA@ozlabs.org>
@ 2006-10-03 21:54 ` Jake Moilanen
  2006-10-24  1:51   ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Jake Moilanen @ 2006-10-03 21:54 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel, Benjamin Herrenschmidt, linuxppc-dev,
	Eric W. Biederman

On Fri, 2006-09-29 at 07:53 +1000, Michael Ellerman wrote:
> Powerpc MSI ops layer.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> ---
> 
>  arch/powerpc/kernel/msi.c        |  347 +++++++++++++++++++++++++++++++++++++++
>  include/asm-powerpc/machdep.h    |    6 
>  include/asm-powerpc/msi.h        |  175 +++++++++++++++++++
>  include/asm-powerpc/pci-bridge.h |    4 
>  4 files changed, 532 insertions(+)
> 
> Index: to-merge/arch/powerpc/kernel/msi.c
> ===================================================================
> --- /dev/null
> +++ to-merge/arch/powerpc/kernel/msi.c
> @@ -0,0 +1,347 @@
> +/*
> + * Copyright 2006 (C), Michael Ellerman, 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.
> + */
> +
> +#undef DEBUG
> +
> +#include <linux/kernel.h>
> +#include <linux/slab.h>
> +#include <asm/msi.h>
> +#include <asm/machdep.h>
> +
> +static struct ppc_msi_ops *get_msi_ops(struct pci_dev *pdev)
> +{
> +	if (ppc_md.get_msi_ops)
> +		return ppc_md.get_msi_ops(pdev);
> +	return NULL;
> +}
> +
> +/* Activated by pci=nomsi on the command line. */
> +static int no_msi;
> +
> +void pci_no_msi(void)
> +{
> +	no_msi = 1;
> +}
> +
> +
> +/* msi_info helpers */
> +
> +static struct pci_dn *get_pdn(struct pci_dev *pdev)
> +{
> +	struct device_node *dn;
> +	struct pci_dn *pdn;
> +
> +	dn = pci_device_to_OF_node(pdev);
> +	if (!dn) {
> +		pr_debug("get_pdn: no dn found for %s\n", pci_name(pdev));
> +		return NULL;
> +	}
> +
> +	pdn = PCI_DN(dn);
> +	if (!pdn) {
> +		pr_debug("get_pdn: no pci_dn found for %s\n", pci_name(pdev));
> +		return NULL;
> +	}
> +
> +	return pdn;
> +}
> +
> +static int alloc_msi_info(struct pci_dev *pdev, int num,
> +			struct msix_entry *entries, int type)
> +{
> +	struct msi_info *info;
> +	unsigned int entries_size;
> +	struct pci_dn *pdn;
> +
> +	entries_size = sizeof(struct msix_entry) * num;
> +
> +	info = kzalloc(sizeof(struct msi_info) + entries_size, GFP_KERNEL);

Shouldn't you do a second kzalloc for info->entries, and not just add on
the size to the end?

> +	if (!info) {
> +		pr_debug("alloc_msi_info: kzalloc failed for %s\n",
> +				pci_name(pdev));
> +		return -ENOMEM;
> +	}
> +
> +	info->type = type;
> +	info->num = num;
> +	memcpy(info->entries, entries, entries_size);
> +
> +	pdn = get_pdn(pdev);
> +	if (!pdn || pdn->msi_info)	/* don't leak info structs */
> +		BUG();
> +
> +	pdn->msi_info = info;
> +
> +	return 0;
> +}
> +


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 3/7] Powerpc MSI ops layer
  2006-10-03 21:54 ` [RFC/PATCH 3/7] Powerpc MSI ops layer Jake Moilanen
@ 2006-10-24  1:51   ` Michael Ellerman
  2006-10-24 13:44     ` Jake Moilanen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2006-10-24  1:51 UTC (permalink / raw)
  To: Jake Moilanen
  Cc: linux-kernel, Benjamin Herrenschmidt, linuxppc-dev,
	Eric W. Biederman

[-- Attachment #1: Type: text/plain, Size: 3115 bytes --]

On Tue, 2006-10-03 at 16:54 -0500, Jake Moilanen wrote:
> On Fri, 2006-09-29 at 07:53 +1000, Michael Ellerman wrote:
> > Powerpc MSI ops layer.
> > 
> > Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> > ---
> > 
> >  arch/powerpc/kernel/msi.c        |  347 +++++++++++++++++++++++++++++++++++++++
> >  include/asm-powerpc/machdep.h    |    6 
> >  include/asm-powerpc/msi.h        |  175 +++++++++++++++++++
> >  include/asm-powerpc/pci-bridge.h |    4 
> >  4 files changed, 532 insertions(+)
> > 
> > Index: to-merge/arch/powerpc/kernel/msi.c
> > ===================================================================
> > --- /dev/null
> > +++ to-merge/arch/powerpc/kernel/msi.c
> > @@ -0,0 +1,347 @@
> > +/*
> > + * Copyright 2006 (C), Michael Ellerman, 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.
> > + */
> > +
> > +#undef DEBUG
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/slab.h>
> > +#include <asm/msi.h>
> > +#include <asm/machdep.h>
> > +
> > +static struct ppc_msi_ops *get_msi_ops(struct pci_dev *pdev)
> > +{
> > +	if (ppc_md.get_msi_ops)
> > +		return ppc_md.get_msi_ops(pdev);
> > +	return NULL;
> > +}
> > +
> > +/* Activated by pci=nomsi on the command line. */
> > +static int no_msi;
> > +
> > +void pci_no_msi(void)
> > +{
> > +	no_msi = 1;
> > +}
> > +
> > +
> > +/* msi_info helpers */
> > +
> > +static struct pci_dn *get_pdn(struct pci_dev *pdev)
> > +{
> > +	struct device_node *dn;
> > +	struct pci_dn *pdn;
> > +
> > +	dn = pci_device_to_OF_node(pdev);
> > +	if (!dn) {
> > +		pr_debug("get_pdn: no dn found for %s\n", pci_name(pdev));
> > +		return NULL;
> > +	}
> > +
> > +	pdn = PCI_DN(dn);
> > +	if (!pdn) {
> > +		pr_debug("get_pdn: no pci_dn found for %s\n", pci_name(pdev));
> > +		return NULL;
> > +	}
> > +
> > +	return pdn;
> > +}
> > +
> > +static int alloc_msi_info(struct pci_dev *pdev, int num,
> > +			struct msix_entry *entries, int type)
> > +{
> > +	struct msi_info *info;
> > +	unsigned int entries_size;
> > +	struct pci_dn *pdn;
> > +
> > +	entries_size = sizeof(struct msix_entry) * num;
> > +
> > +	info = kzalloc(sizeof(struct msi_info) + entries_size, GFP_KERNEL);
> 
> Shouldn't you do a second kzalloc for info->entries, and not just add on
> the size to the end?

We could, but I don't see why it's better. It's a little sneaky to tack
the entries on the end but I don't see a problem with it?

There is a bug in there that I don't set the entries pointer before
doing the memcpy, but I've fixed that - or is that what you meant ? :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 3/7] Powerpc MSI ops layer
  2006-10-24  1:51   ` Michael Ellerman
@ 2006-10-24 13:44     ` Jake Moilanen
  0 siblings, 0 replies; 3+ messages in thread
From: Jake Moilanen @ 2006-10-24 13:44 UTC (permalink / raw)
  To: michael
  Cc: linux-kernel, Benjamin Herrenschmidt, linuxppc-dev,
	Eric W. Biederman

On Tue, 2006-10-24 at 11:51 +1000, Michael Ellerman wrote:
> On Tue, 2006-10-03 at 16:54 -0500, Jake Moilanen wrote:
> > On Fri, 2006-09-29 at 07:53 +1000, Michael Ellerman wrote:
> > > Powerpc MSI ops layer.
> > > 
> > > Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> > > ---
> > > 
> > >  arch/powerpc/kernel/msi.c        |  347 +++++++++++++++++++++++++++++++++++++++
> > >  include/asm-powerpc/machdep.h    |    6 
> > >  include/asm-powerpc/msi.h        |  175 +++++++++++++++++++
> > >  include/asm-powerpc/pci-bridge.h |    4 
> > >  4 files changed, 532 insertions(+)
> > > 
> > > Index: to-merge/arch/powerpc/kernel/msi.c
> > > ===================================================================
> > > --- /dev/null
> > > +++ to-merge/arch/powerpc/kernel/msi.c
> > > @@ -0,0 +1,347 @@
> > > +/*
> > > + * Copyright 2006 (C), Michael Ellerman, 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.
> > > + */
> > > +
> > > +#undef DEBUG
> > > +
> > > +#include <linux/kernel.h>
> > > +#include <linux/slab.h>
> > > +#include <asm/msi.h>
> > > +#include <asm/machdep.h>
> > > +
> > > +static struct ppc_msi_ops *get_msi_ops(struct pci_dev *pdev)
> > > +{
> > > +	if (ppc_md.get_msi_ops)
> > > +		return ppc_md.get_msi_ops(pdev);
> > > +	return NULL;
> > > +}
> > > +
> > > +/* Activated by pci=nomsi on the command line. */
> > > +static int no_msi;
> > > +
> > > +void pci_no_msi(void)
> > > +{
> > > +	no_msi = 1;
> > > +}
> > > +
> > > +
> > > +/* msi_info helpers */
> > > +
> > > +static struct pci_dn *get_pdn(struct pci_dev *pdev)
> > > +{
> > > +	struct device_node *dn;
> > > +	struct pci_dn *pdn;
> > > +
> > > +	dn = pci_device_to_OF_node(pdev);
> > > +	if (!dn) {
> > > +		pr_debug("get_pdn: no dn found for %s\n", pci_name(pdev));
> > > +		return NULL;
> > > +	}
> > > +
> > > +	pdn = PCI_DN(dn);
> > > +	if (!pdn) {
> > > +		pr_debug("get_pdn: no pci_dn found for %s\n", pci_name(pdev));
> > > +		return NULL;
> > > +	}
> > > +
> > > +	return pdn;
> > > +}
> > > +
> > > +static int alloc_msi_info(struct pci_dev *pdev, int num,
> > > +			struct msix_entry *entries, int type)
> > > +{
> > > +	struct msi_info *info;
> > > +	unsigned int entries_size;
> > > +	struct pci_dn *pdn;
> > > +
> > > +	entries_size = sizeof(struct msix_entry) * num;
> > > +
> > > +	info = kzalloc(sizeof(struct msi_info) + entries_size, GFP_KERNEL);
> > 
> > Shouldn't you do a second kzalloc for info->entries, and not just add on
> > the size to the end?
> 
> We could, but I don't see why it's better. It's a little sneaky to tack
> the entries on the end but I don't see a problem with it?
> 
> There is a bug in there that I don't set the entries pointer before
> doing the memcpy, but I've fixed that - or is that what you meant ? :)

Yeah...I was just pointing out there was a bug.  :)




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-24 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20060928215339.D911C67BFA@ozlabs.org>
2006-10-03 21:54 ` [RFC/PATCH 3/7] Powerpc MSI ops layer Jake Moilanen
2006-10-24  1:51   ` Michael Ellerman
2006-10-24 13:44     ` Jake Moilanen

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).