Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.1830);
	 Mon, 22 Jan 2007 06:35:03 -0800
Received: from ftp.linux-mips.org ([194.74.144.162]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.1830);
	 Mon, 22 Jan 2007 06:35:03 -0800
Received: from localhost.localdomain ([127.0.0.1]:15078 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S28575822AbXAVOdZ convert rfc822-to-quoted-printable (ORCPT
	<rfc822;dan.stein@onstor.com> + 1 other);
	Mon, 22 Jan 2007 14:33:25 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 22 Jan 2007 14:33:02 +0000 (GMT)
Received: from mba.ocn.ne.jp ([210.190.142.172]:44508 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S28575816AbXAVOc5 convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 22 Jan 2007 14:32:57 +0000
Received: from localhost (p7223-ipad301funabasi.chiba.ocn.ne.jp [122.18.1.223])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 2B97EB731; Mon, 22 Jan 2007 23:32:52 +0900 (JST)
Date:	Mon, 22 Jan 2007 23:32:51 +0900 (JST)
Message-Id: <20070122.233251.74752372.anemo@mba.ocn.ne.jp>
To:	Eric.Piel@lifl.fr
Cc:	akpm@osdl.org, ralf@linux-mips.org, linux-kernel@vger.kernel.org,
	linux-mips@linux-mips.org
Subject: Re: [PATCH] Make CARDBUS_MEM_SIZE and CARDBUS_IO_SIZE customizable
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <45B4C2DA.8020906@lifl.fr>
References: <20070119.121910.96686038.nemoto@toshiba-tops.co.jp>
	<20070119.125751.104030382.nemoto@toshiba-tops.co.jp>
	<45B4C2DA.8020906@lifl.fr>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 3.3 on Emacs 21.4 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type:	Text/Plain; charset=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
X-archive-position: 13733
X-ecartis-version: Ecartis v1.0.0
Sender:	linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list:	linux-mips
Return-Path: linux-mips-bounce@linux-mips.org
X-OriginalArrivalTime: 22 Jan 2007 14:35:03.0023 (UTC) FILETIME=[809A47F0:01C73E32]

On Mon, 22 Jan 2007 14:57:46 +0100, =C9ric Piel <Eric.Piel@lifl.fr> wro=
te:
> > +		cbiosize=3Dnn[KMG]	A fixed amount of bus space is
> > +				reserved for CardBus bridges.
> > +				The default value is 256 bytes.
> > +		cbmemsize=3Dnn[KMG]	A fixed amount of bus space is
> > +				reserved for CardBus bridges.
> > +				The default value is 64 megabytes.
> Hi, I've got the feeling that those two parameters don't do the same=20
> things, although they have the same description ;-) Maybe the texts=20
> could be:
> * The fixed amount of bus space which is reserved for the CardBus=20
> bridges IO window.
> * The fixed amount of bus space which is reserved for the CardBus=20
> bridges memory window.

Thanks for your comment.  Updated.


Subject: [PATCH] Make CARDBUS_MEM_SIZE and CARDBUS_IO_SIZE customizable

CARDBUS_MEM_SIZE was increased to 64MB on 2.6.20-rc2, but larger size
might result in allocation failure for the reserving itself on some
platforms (for example typical 32bit MIPS).  Make it (and
CARDBUS_IO_SIZE too) customizable by "pci=3D" option for such platforms=
=2E

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 Documentation/kernel-parameters.txt |    6 ++++++
 drivers/pci/pci.c                   |    6 ++++++
 drivers/pci/setup-bus.c             |   27 +++++++++++++++------------
 include/linux/pci.h                 |    3 +++
 4 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel=
-parameters.txt
index 25d2985..dc39989 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1259,6 +1259,12 @@ and is between 256 and 4096 characters.
 				This sorting is done to get a device
 				order compatible with older (<=3D 2.4) kernels.
 		nobfsort	Don't sort PCI devices into breadth-first order.
+		cbiosize=3Dnn[KMG]	The fixed amount of bus space which is
+				reserved for the CardBus bridges IO window.
+				The default value is 256 bytes.
+		cbmemsize=3Dnn[KMG]	The fixed amount of bus space which is
+				reserved for the CardBus bridges memory window.
+				The default value is 64 megabytes.
=20
 	pcmv=3D		[HW,PCMCIA] BadgePAD 4
=20
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 206c834..639069a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1168,6 +1168,12 @@ static int __devinit pci_setup(char *str
 		if (*str && (str =3D pcibios_setup(str)) && *str) {
 			if (!strcmp(str, "nomsi")) {
 				pci_no_msi();
+			} else if (!strncmp(str, "cbiosize=3D", 9)) {
+				pci_cardbus_io_size =3D
+					memparse(str + 9, &str);
+			} else if (!strncmp(str, "cbmemsize=3D", 10)) {
+				pci_cardbus_mem_size =3D
+					memparse(str + 10, &str);
 			} else {
 				printk(KERN_ERR "PCI: Unknown option `%s'\n",
 						str);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 89f3036..1dfc288 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -40,8 +40,11 @@
  * FIXME: IO should be max 256 bytes.  However, since we may
  * have a P2P bridge below a cardbus bridge, we need 4K.
  */
-#define CARDBUS_IO_SIZE		(256)
-#define CARDBUS_MEM_SIZE	(64*1024*1024)
+#define DEFAULT_CARDBUS_IO_SIZE		(256)
+#define DEFAULT_CARDBUS_MEM_SIZE	(64*1024*1024)
+/* pci=3Dcbmemsize=3DnnM,cbiosize=3Dnn can override this */
+unsigned long pci_cardbus_io_size =3D DEFAULT_CARDBUS_IO_SIZE;
+unsigned long pci_cardbus_mem_size =3D DEFAULT_CARDBUS_MEM_SIZE;
=20
 static void __devinit
 pbus_assign_resources_sorted(struct pci_bus *bus)
@@ -415,12 +418,12 @@ pci_bus_size_cardbus(struct pci_bus *bus
 	 * Reserve some resources for CardBus.  We reserve
 	 * a fixed amount of bus space for CardBus bridges.
 	 */
-	b_res[0].start =3D CARDBUS_IO_SIZE;
-	b_res[0].end =3D b_res[0].start + CARDBUS_IO_SIZE - 1;
+	b_res[0].start =3D pci_cardbus_io_size;
+	b_res[0].end =3D b_res[0].start + pci_cardbus_io_size - 1;
 	b_res[0].flags |=3D IORESOURCE_IO;
=20
-	b_res[1].start =3D CARDBUS_IO_SIZE;
-	b_res[1].end =3D b_res[1].start + CARDBUS_IO_SIZE - 1;
+	b_res[1].start =3D pci_cardbus_io_size;
+	b_res[1].end =3D b_res[1].start + pci_cardbus_io_size - 1;
 	b_res[1].flags |=3D IORESOURCE_IO;
=20
 	/*
@@ -440,16 +443,16 @@ pci_bus_size_cardbus(struct pci_bus *bus
 	 * twice the size.
 	 */
 	if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) {
-		b_res[2].start =3D CARDBUS_MEM_SIZE;
-		b_res[2].end =3D b_res[2].start + CARDBUS_MEM_SIZE - 1;
+		b_res[2].start =3D pci_cardbus_mem_size;
+		b_res[2].end =3D b_res[2].start + pci_cardbus_mem_size - 1;
 		b_res[2].flags |=3D IORESOURCE_MEM | IORESOURCE_PREFETCH;
=20
-		b_res[3].start =3D CARDBUS_MEM_SIZE;
-		b_res[3].end =3D b_res[3].start + CARDBUS_MEM_SIZE - 1;
+		b_res[3].start =3D pci_cardbus_mem_size;
+		b_res[3].end =3D b_res[3].start + pci_cardbus_mem_size - 1;
 		b_res[3].flags |=3D IORESOURCE_MEM;
 	} else {
-		b_res[3].start =3D CARDBUS_MEM_SIZE * 2;
-		b_res[3].end =3D b_res[3].start + CARDBUS_MEM_SIZE * 2 - 1;
+		b_res[3].start =3D pci_cardbus_mem_size * 2;
+		b_res[3].end =3D b_res[3].start + pci_cardbus_mem_size * 2 - 1;
 		b_res[3].flags |=3D IORESOURCE_MEM;
 	}
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index f3c617e..ff04c69 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -837,5 +837,8 @@ extern int pci_pci_problems;
 #define PCIPCI_ALIMAGIK		32	/* Need low latency setting */
 #define PCIAGP_FAIL		64	/* No PCI to AGP DMA */
=20
+extern unsigned long pci_cardbus_io_size;
+extern unsigned long pci_cardbus_mem_size;
+
 #endif /* __KERNEL__ */
 #endif /* LINUX_PCI_H */

