mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 00:34:20 +08:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
250 lines
5.4 KiB
C
250 lines
5.4 KiB
C
/* jazz_esp.c: ESP front-end for MIPS JAZZ systems.
|
|
*
|
|
* Copyright (C) 2007 Thomas Bogendörfer (tsbogend@alpha.frankende)
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/types.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <asm/irq.h>
|
|
#include <asm/io.h>
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/jazz.h>
|
|
#include <asm/jazzdma.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include "esp_scsi.h"
|
|
|
|
#define DRV_MODULE_NAME "jazz_esp"
|
|
#define PFX DRV_MODULE_NAME ": "
|
|
#define DRV_VERSION "1.000"
|
|
#define DRV_MODULE_RELDATE "May 19, 2007"
|
|
|
|
static void jazz_esp_write8(struct esp *esp, u8 val, unsigned long reg)
|
|
{
|
|
*(volatile u8 *)(esp->regs + reg) = val;
|
|
}
|
|
|
|
static u8 jazz_esp_read8(struct esp *esp, unsigned long reg)
|
|
{
|
|
return *(volatile u8 *)(esp->regs + reg);
|
|
}
|
|
|
|
static dma_addr_t jazz_esp_map_single(struct esp *esp, void *buf,
|
|
size_t sz, int dir)
|
|
{
|
|
return dma_map_single(esp->dev, buf, sz, dir);
|
|
}
|
|
|
|
static int jazz_esp_map_sg(struct esp *esp, struct scatterlist *sg,
|
|
int num_sg, int dir)
|
|
{
|
|
return dma_map_sg(esp->dev, sg, num_sg, dir);
|
|
}
|
|
|
|
static void jazz_esp_unmap_single(struct esp *esp, dma_addr_t addr,
|
|
size_t sz, int dir)
|
|
{
|
|
dma_unmap_single(esp->dev, addr, sz, dir);
|
|
}
|
|
|
|
static void jazz_esp_unmap_sg(struct esp *esp, struct scatterlist *sg,
|
|
int num_sg, int dir)
|
|
{
|
|
dma_unmap_sg(esp->dev, sg, num_sg, dir);
|
|
}
|
|
|
|
static int jazz_esp_irq_pending(struct esp *esp)
|
|
{
|
|
if (jazz_esp_read8(esp, ESP_STATUS) & ESP_STAT_INTR)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
static void jazz_esp_reset_dma(struct esp *esp)
|
|
{
|
|
vdma_disable ((int)esp->dma_regs);
|
|
}
|
|
|
|
static void jazz_esp_dma_drain(struct esp *esp)
|
|
{
|
|
/* nothing to do */
|
|
}
|
|
|
|
static void jazz_esp_dma_invalidate(struct esp *esp)
|
|
{
|
|
vdma_disable ((int)esp->dma_regs);
|
|
}
|
|
|
|
static void jazz_esp_send_dma_cmd(struct esp *esp, u32 addr, u32 esp_count,
|
|
u32 dma_count, int write, u8 cmd)
|
|
{
|
|
BUG_ON(!(cmd & ESP_CMD_DMA));
|
|
|
|
jazz_esp_write8(esp, (esp_count >> 0) & 0xff, ESP_TCLOW);
|
|
jazz_esp_write8(esp, (esp_count >> 8) & 0xff, ESP_TCMED);
|
|
vdma_disable ((int)esp->dma_regs);
|
|
if (write)
|
|
vdma_set_mode ((int)esp->dma_regs, DMA_MODE_READ);
|
|
else
|
|
vdma_set_mode ((int)esp->dma_regs, DMA_MODE_WRITE);
|
|
|
|
vdma_set_addr ((int)esp->dma_regs, addr);
|
|
vdma_set_count ((int)esp->dma_regs, dma_count);
|
|
vdma_enable ((int)esp->dma_regs);
|
|
|
|
scsi_esp_cmd(esp, cmd);
|
|
}
|
|
|
|
static int jazz_esp_dma_error(struct esp *esp)
|
|
{
|
|
u32 enable = vdma_get_enable((int)esp->dma_regs);
|
|
|
|
if (enable & (R4030_MEM_INTR|R4030_ADDR_INTR))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct esp_driver_ops jazz_esp_ops = {
|
|
.esp_write8 = jazz_esp_write8,
|
|
.esp_read8 = jazz_esp_read8,
|
|
.map_single = jazz_esp_map_single,
|
|
.map_sg = jazz_esp_map_sg,
|
|
.unmap_single = jazz_esp_unmap_single,
|
|
.unmap_sg = jazz_esp_unmap_sg,
|
|
.irq_pending = jazz_esp_irq_pending,
|
|
.reset_dma = jazz_esp_reset_dma,
|
|
.dma_drain = jazz_esp_dma_drain,
|
|
.dma_invalidate = jazz_esp_dma_invalidate,
|
|
.send_dma_cmd = jazz_esp_send_dma_cmd,
|
|
.dma_error = jazz_esp_dma_error,
|
|
};
|
|
|
|
static int __devinit esp_jazz_probe(struct platform_device *dev)
|
|
{
|
|
struct scsi_host_template *tpnt = &scsi_esp_template;
|
|
struct Scsi_Host *host;
|
|
struct esp *esp;
|
|
struct resource *res;
|
|
int err;
|
|
|
|
host = scsi_host_alloc(tpnt, sizeof(struct esp));
|
|
|
|
err = -ENOMEM;
|
|
if (!host)
|
|
goto fail;
|
|
|
|
host->max_id = 8;
|
|
esp = shost_priv(host);
|
|
|
|
esp->host = host;
|
|
esp->dev = dev;
|
|
esp->ops = &jazz_esp_ops;
|
|
|
|
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
|
if (!res)
|
|
goto fail_unlink;
|
|
|
|
esp->regs = (void __iomem *)res->start;
|
|
if (!esp->regs)
|
|
goto fail_unlink;
|
|
|
|
res = platform_get_resource(dev, IORESOURCE_MEM, 1);
|
|
if (!res)
|
|
goto fail_unlink;
|
|
|
|
esp->dma_regs = (void __iomem *)res->start;
|
|
|
|
esp->command_block = dma_alloc_coherent(esp->dev, 16,
|
|
&esp->command_block_dma,
|
|
GFP_KERNEL);
|
|
if (!esp->command_block)
|
|
goto fail_unmap_regs;
|
|
|
|
host->irq = platform_get_irq(dev, 0);
|
|
err = request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp);
|
|
if (err < 0)
|
|
goto fail_unmap_command_block;
|
|
|
|
esp->scsi_id = 7;
|
|
esp->host->this_id = esp->scsi_id;
|
|
esp->scsi_id_mask = (1 << esp->scsi_id);
|
|
esp->cfreq = 40000000;
|
|
|
|
dev_set_drvdata(&dev->dev, esp);
|
|
|
|
err = scsi_esp_register(esp, &dev->dev);
|
|
if (err)
|
|
goto fail_free_irq;
|
|
|
|
return 0;
|
|
|
|
fail_free_irq:
|
|
free_irq(host->irq, esp);
|
|
fail_unmap_command_block:
|
|
dma_free_coherent(esp->dev, 16,
|
|
esp->command_block,
|
|
esp->command_block_dma);
|
|
fail_unmap_regs:
|
|
fail_unlink:
|
|
scsi_host_put(host);
|
|
fail:
|
|
return err;
|
|
}
|
|
|
|
static int __devexit esp_jazz_remove(struct platform_device *dev)
|
|
{
|
|
struct esp *esp = dev_get_drvdata(&dev->dev);
|
|
unsigned int irq = esp->host->irq;
|
|
|
|
scsi_esp_unregister(esp);
|
|
|
|
free_irq(irq, esp);
|
|
dma_free_coherent(esp->dev, 16,
|
|
esp->command_block,
|
|
esp->command_block_dma);
|
|
|
|
scsi_host_put(esp->host);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* work with hotplug and coldplug */
|
|
MODULE_ALIAS("platform:jazz_esp");
|
|
|
|
static struct platform_driver esp_jazz_driver = {
|
|
.probe = esp_jazz_probe,
|
|
.remove = __devexit_p(esp_jazz_remove),
|
|
.driver = {
|
|
.name = "jazz_esp",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
};
|
|
|
|
static int __init jazz_esp_init(void)
|
|
{
|
|
return platform_driver_register(&esp_jazz_driver);
|
|
}
|
|
|
|
static void __exit jazz_esp_exit(void)
|
|
{
|
|
platform_driver_unregister(&esp_jazz_driver);
|
|
}
|
|
|
|
MODULE_DESCRIPTION("JAZZ ESP SCSI driver");
|
|
MODULE_AUTHOR("Thomas Bogendoerfer (tsbogend@alpha.franken.de)");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
module_init(jazz_esp_init);
|
|
module_exit(jazz_esp_exit);
|