sh: maple: Update the maple bus driver to support block reads and writes
Subsystems (4)
PATCH 1/1 sh: maple: Update the maple bus driver to support block reads and writes
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Changes in the bus driver necessitate some changes in the two maple bus input drivers that are currently in mainline.
(Maple is SEGA's proprietary serial bus for the Dreamcast. It is capable of comm speeds of up to 2Mbs.)
As well as supporting block reads and writes this code clean up removes some poor handling of locks, uses an atomic status variable to serialise access to devices and more robusly handles the general performance problems of the bus.
---
drivers/input/joystick/maplecontrol.c +2 -2
@@ -3,7 +3,7 @@* Based on drivers/usb/iforce.c * * Copyright Yaegashi Takeshi, 2001 -* Adrian McMenamin, 2008 +* Adrian McMenamin, 2008 - 2009 */ #include <linux/kernel.h>
@@ -29,7 +29,7 @@ static void dc_pad_callback(struct mapleq *mq)struct maple_device *mapledev = mq->dev;struct dc_pad *pad =maple_get_drvdata (mapledev);struct input_dev *dev = pad->dev; -unsigned char *res = mq->recvbuf; +unsigned char *res = mq->recvbuf->buf; buttons = ~le16_to_cpup ((__le16 *)(res +8 ));
drivers/input/keyboard/maple_keyb.c +22 -15
@@ -1,8 +1,8 @@/* * SEGA Dreamcast keyboard driver * Based on drivers/usb/usbkbd.c -* Copyright YAEGASHI Takeshi, 2001 -* Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008 +* Copyright (c) YAEGASHI Takeshi, 2001 +* Porting to 2.6 Copyright (c) Adrian McMenamin, 2007 - 2009 * * 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
@@ -33,7 +33,7 @@ static DEFINE_MUTEX(maple_keyb_mutex);#define NR_SCANCODES 256 -MODULE_AUTHOR ("YAEGASHI Takeshi, Adrian McMenamin" ); +MODULE_AUTHOR ("Adrian McMenamin <[email protected]" );MODULE_DESCRIPTION ("SEGA Dreamcast keyboard driver" );MODULE_LICENSE ("GPL" );
@@ -115,7 +115,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)input_event (dev,EV_MSC ,MSC_SCAN , code);input_report_key (dev, keycode,0 ); }else -printk (KERN_DEBUG "maple_keyb: " +dev_dbg (&dev->dev,"Unknown key (scancode %#x) released." , code); }
@@ -127,7 +127,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)input_event (dev,EV_MSC ,MSC_SCAN , code);input_report_key (dev, keycode,1 ); }else -printk (KERN_DEBUG "maple_keyb: " +dev_dbg (&dev->dev,"Unknown key (scancode %#x) pressed." , code); }
@@ -140,7 +140,7 @@ static void dc_kbd_callback(struct mapleq *mq) {struct maple_device *mapledev = mq->dev;struct dc_kbd *kbd =maple_get_drvdata (mapledev); -unsigned long *buf = mq->recvbuf; +unsigned long *buf = (unsigned long *)(mq->recvbuf->buf);/* * We should always get the lock because the only
@@ -159,22 +159,27 @@ static void dc_kbd_callback(struct mapleq *mq)static int probe_maple_kbd (struct device *dev) { -struct maple_device *mdev =to_maple_dev (dev); -struct maple_driver *mdrv =to_maple_driver (dev->driver); +struct maple_device *mdev; +struct maple_driver *mdrv;int i, error;struct dc_kbd *kbd;struct input_dev *idev; -if (!(mdev->function &MAPLE_FUNC_KEYBOARD )) -return -EINVAL ; + mdev =to_maple_dev (dev); + mdrv =to_maple_driver (dev->driver); kbd =kzalloc (sizeof (struct dc_kbd ),GFP_KERNEL ); - idev =input_allocate_device (); -if (!kbd || !idev) { +if (!kbd) { error = -ENOMEM ; goto fail; } + idev =input_allocate_device (); +if (!idev) { + error = -ENOMEM ; + goto fail_idev_alloc; + } + kbd->dev = idev;memcpy (kbd->keycode, dc_kbd_keycode,sizeof (kbd->keycode));
@@ -195,7 +200,7 @@ static int probe_maple_kbd(struct device *dev) error =input_register_device (idev);if (error) - goto fail; + goto fail_register;/* Maple polling is locked to VBLANK - which may be just 50/s */ maple_getcond_callback(mdev, dc_kbd_callback, HZ/50,
@@ -207,10 +212,12 @@ static int probe_maple_kbd(struct device *dev)return error; -fail: +fail_register: +maple_set_drvdata (mdev,NULL );input_free_device (idev); +fail_idev_alloc:kfree (kbd); -maple_set_drvdata (mdev,NULL ); +fail:return error; }
drivers/mtd/maps/Kconfig +11 -1
@@ -551,5 +551,15 @@ config MTD_PLATRAM This selection automatically selects the map_ram driver. -endmenu +config MTD_VMU + tristate "Map driver for Dreamcast VMU" + depends on MAPLE + help + This driver enables access to the Dreamcast Visual Memory Unit (VMU). + + Most Dreamcast users will want to say Y here. + To build this as a module select M here, the module will be called + vmu-flash. + +endmenu
drivers/sh/maple/maple.c +235 -228
859 lines not on this page · raw message
include/linux/maple.h +41 -21
92 lines not on this page · raw message
Quoted 15 lines · Adrian McMenamin
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Changes in the bus driver necessitate some changes in the two maple bus input drivers that are currently in mainline.
Quoted 8 lines
(Maple is SEGA's proprietary serial bus for the Dreamcast. It is capable of comm speeds of up to 2Mbs.)
As well as supporting block reads and writes this code clean up removes some poor handling of locks, uses an atomic status variable to serialise access to devices and more robusly handles the general performance problems of the bus.
Apologies, some of the VMU patch slipped into that. Here is a completely clean version.
---
drivers/input/joystick/maplecontrol.c +2 -2
@@ -3,7 +3,7 @@* Based on drivers/usb/iforce.c * * Copyright Yaegashi Takeshi, 2001 -* Adrian McMenamin, 2008 +* Adrian McMenamin, 2008 - 2009 */ #include <linux/kernel.h>
@@ -29,7 +29,7 @@ static void dc_pad_callback(struct mapleq *mq)struct maple_device *mapledev = mq->dev;struct dc_pad *pad =maple_get_drvdata (mapledev);struct input_dev *dev = pad->dev; -unsigned char *res = mq->recvbuf; +unsigned char *res = mq->recvbuf->buf; buttons = ~le16_to_cpup ((__le16 *)(res +8 ));
drivers/input/keyboard/maple_keyb.c +22 -15
@@ -1,8 +1,8 @@/* * SEGA Dreamcast keyboard driver * Based on drivers/usb/usbkbd.c -* Copyright YAEGASHI Takeshi, 2001 -* Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008 +* Copyright (c) YAEGASHI Takeshi, 2001 +* Porting to 2.6 Copyright (c) Adrian McMenamin, 2007 - 2009 * * 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
@@ -33,7 +33,7 @@ static DEFINE_MUTEX(maple_keyb_mutex);#define NR_SCANCODES 256 -MODULE_AUTHOR ("YAEGASHI Takeshi, Adrian McMenamin" ); +MODULE_AUTHOR ("Adrian McMenamin <[email protected]" );MODULE_DESCRIPTION ("SEGA Dreamcast keyboard driver" );MODULE_LICENSE ("GPL" );
@@ -115,7 +115,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)input_event (dev,EV_MSC ,MSC_SCAN , code);input_report_key (dev, keycode,0 ); }else -printk (KERN_DEBUG "maple_keyb: " +dev_dbg (&dev->dev,"Unknown key (scancode %#x) released." , code); }
@@ -127,7 +127,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)input_event (dev,EV_MSC ,MSC_SCAN , code);input_report_key (dev, keycode,1 ); }else -printk (KERN_DEBUG "maple_keyb: " +dev_dbg (&dev->dev,"Unknown key (scancode %#x) pressed." , code); }
@@ -140,7 +140,7 @@ static void dc_kbd_callback(struct mapleq *mq) {struct maple_device *mapledev = mq->dev;struct dc_kbd *kbd =maple_get_drvdata (mapledev); -unsigned long *buf = mq->recvbuf; +unsigned long *buf = (unsigned long *)(mq->recvbuf->buf);/* * We should always get the lock because the only
@@ -159,22 +159,27 @@ static void dc_kbd_callback(struct mapleq *mq)static int probe_maple_kbd (struct device *dev) { -struct maple_device *mdev =to_maple_dev (dev); -struct maple_driver *mdrv =to_maple_driver (dev->driver); +struct maple_device *mdev; +struct maple_driver *mdrv;int i, error;struct dc_kbd *kbd;struct input_dev *idev; -if (!(mdev->function &MAPLE_FUNC_KEYBOARD )) -return -EINVAL ; + mdev =to_maple_dev (dev); + mdrv =to_maple_driver (dev->driver); kbd =kzalloc (sizeof (struct dc_kbd ),GFP_KERNEL ); - idev =input_allocate_device (); -if (!kbd || !idev) { +if (!kbd) { error = -ENOMEM ; goto fail; } + idev =input_allocate_device (); +if (!idev) { + error = -ENOMEM ; + goto fail_idev_alloc; + } + kbd->dev = idev;memcpy (kbd->keycode, dc_kbd_keycode,sizeof (kbd->keycode));
@@ -195,7 +200,7 @@ static int probe_maple_kbd(struct device *dev) error =input_register_device (idev);if (error) - goto fail; + goto fail_register;/* Maple polling is locked to VBLANK - which may be just 50/s */ maple_getcond_callback(mdev, dc_kbd_callback, HZ/50,
@@ -207,10 +212,12 @@ static int probe_maple_kbd(struct device *dev)return error; -fail: +fail_register: +maple_set_drvdata (mdev,NULL );input_free_device (idev); +fail_idev_alloc:kfree (kbd); -maple_set_drvdata (mdev,NULL ); +fail:return error; }
drivers/sh/maple/maple.c +235 -227
855 lines not on this page · raw message
include/linux/maple.h +41 -21
92 lines not on this page · raw message
PATCH 1/1 mtd: sh: maple: Support the Dreamcast visual memory unit as a flash mapping
This patch adds support for the Sega Dreamcast visual memory unit as a flash mapping. It requires changes in the maple bus driver (posted separately) to support block reads and writes.
The VMU is a 'smart' flash device, with a built-in 8-bit controller - for instance there is an erase before a write but it is hidden from the user. But the device's overall behaviour means it works well with the mtd layer and it is appropriate to add it as an mtd mapping.
---
drivers/mtd/maps/Kconfig +11 -1
@@ -551,5 +551,15 @@ config MTD_PLATRAM This selection automatically selects the map_ram driver. -endmenu +config MTD_VMU + tristate "Map driver for Dreamcast VMU" + depends on MAPLE + help + This driver enables access to the Dreamcast Visual Memory Unit (VMU). + + Most Dreamcast users will want to say Y here. + To build this as a module select M here, the module will be called + vmu-flash. + +endmenu
drivers/mtd/maps/Makefile +1 -0
@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o +obj-$(CONFIG_MTD_VMU) += vmu-flash.o
drivers/mtd/maps/vmu-flash.c new file +832 -0
832 lines not on this page · raw message
Re: [PATCH] mtd: sh: maple: Support the Dreamcast visual memory unit as a flash mapping
Quoted 10 lines · Adrian McMenamin
This patch adds support for the Sega Dreamcast visual memory unit as a flash mapping. It requires changes in the maple bus driver (posted separately) to support block reads and writes.
The VMU is a 'smart' flash device, with a built-in 8-bit controller - for instance there is an erase before a write but it is hidden from the user. But the device's overall behaviour means it works well with the mtd layer and it is appropriate to add it as an mtd mapping.
Signed-off-by Adrian McMenamin <[email protected]>
If someone from the MTD side wants to Ack this, I can fold it in to my tree on top of the maple patch that it depends on, which I already have queued.
Paul Mundt
AppliedQuoted 24 lines · Adrian McMenamin
Quoted 15 lines · Adrian McMenamin
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Changes in the bus driver necessitate some changes in the two maple bus input drivers that are currently in mainline.
Quoted 8 lines
(Maple is SEGA's proprietary serial bus for the Dreamcast. It is capable of comm speeds of up to 2Mbs.)
As well as supporting block reads and writes this code clean up removes some poor handling of locks, uses an atomic status variable to serialise access to devices and more robusly handles the general performance problems of the bus.
Quoted 4 lines
Apologies, some of the VMU patch slipped into that. Here is a completely clean version.
Signed-off-by Adrian McMenamin <[email protected]>
Applied, thanks.
PATCH 1/1 mtd: sh: maple: Support the Dreamcast visual memory unit as a flash mapping
In reply to Adrian McMenamin(David, I am posting this again as I haven't seen any comment from you on it - apologies if I have missed any. Paul has accepted the maple bus patches needed to make it work and these are now in linux-next. I have removed copy recipients not directly interested in this now it is separated out from the maple bus patch.)
This patch adds support for the Sega Dreamcast visual memory unit as a flash mapping. It requires changes in the maple bus driver (posted separately) to support block reads and writes.
The VMU is a 'smart' flash device, with a built-in 8-bit controller - for instance there is an erase before a write but it is hidden from the user. But the device's overall behaviour means it works well with the mtd layer and it is appropriate to add it as an mtd mapping.
---
drivers/mtd/maps/Kconfig +11 -1
@@ -551,5 +551,15 @@ config MTD_PLATRAM This selection automatically selects the map_ram driver. -endmenu +config MTD_VMU + tristate "Map driver for Dreamcast VMU" + depends on MAPLE + help + This driver enables access to the Dreamcast Visual Memory Unit (VMU). + + Most Dreamcast users will want to say Y here. + To build this as a module select M here, the module will be called + vmu-flash. + +endmenu
drivers/mtd/maps/Makefile +1 -0
@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o +obj-$(CONFIG_MTD_VMU) += vmu-flash.o
drivers/mtd/maps/vmu-flash.c new file +832 -0
832 lines not on this page · raw message
Quoted 11 lines · Adrian McMenamin
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Looks good to me, but shouldn't this go through the sh maintainers instead? This is their area, right?
thanks,
greg k-h
2009/2/14 Greg KH <[email protected]>:
Quoted 8 lines · Adrian McMenamin
Quoted 7 lines
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
Quoted 7 lines
Quoted 4 lines
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Looks good to me, but shouldn't this go through the sh maintainers instead? This is their area, right?
As it's a change to a bus I thought you were the maintainer?
Quoted 14 lines · Adrian McMenamin
2009/2/14 Greg KH <[email protected]>:
Quoted 13 lines · Adrian McMenamin
Quoted 11 lines
Greg,
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that).
I have posted versions of this before but am here following the patch grouping suggested and have also tested this code and unlike earlier versions it shows no signs of suffering from race conditions - so I hope you will be happy to queue it for inclusion.
Quoted 5 lines
Quoted 2 lines
Looks good to me, but shouldn't this go through the sh maintainers instead? This is their area, right?
As it's a change to a bus I thought you were the maintainer?
Nope, just the driver core.
thanks,
greg k-h