From fbbd2018bb479b55dafe1695db2b2bcf42f7942c Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Tue, 21 May 2013 16:00:04 +0200 Subject: [PATCH] usb: Storage support for ARM --- dde_linux/Makefile | 2 +- dde_linux/run/usb_storage.run | 2 +- dde_linux/src/lib/usb/dummies.c | 6 ---- dde_linux/src/lib/usb/include/lx_emul.h | 5 ++- dde_linux/src/lib/usb/include/nic/component.h | 2 +- dde_linux/src/lib/usb/include/platform.h | 9 ++++-- .../src/lib/usb/include/signal/dispatch.h | 6 ++-- .../src/lib/usb/include/storage/component.h | 2 +- dde_linux/src/lib/usb/storage/scsi.c | 32 ++++++++++++------- 9 files changed, 38 insertions(+), 28 deletions(-) diff --git a/dde_linux/Makefile b/dde_linux/Makefile index 6f3dc2761..5a1c17a4a 100644 --- a/dde_linux/Makefile +++ b/dde_linux/Makefile @@ -114,7 +114,7 @@ help: $(ECHO) "cleanall - remove contib sources and downloaded archives" $(ECHO) -prepare: $(CONTRIB_DIR)/.prepared +prepare: clean $(CONTRIB_DIR)/.prepared $(CONTRIB_DIR)/.prepared: Makefile $(CONTRIB_DIR)/.prepared: $(DOWNLOAD_DIR)/$(LINUX_TBZ2) diff --git a/dde_linux/run/usb_storage.run b/dde_linux/run/usb_storage.run index f7cdff65a..bd41e6006 100644 --- a/dde_linux/run/usb_storage.run +++ b/dde_linux/run/usb_storage.run @@ -88,7 +88,7 @@ install_config $config # generic modules set boot_modules { - core init timer usb_drv pci_drv test-block + core init timer usb_drv test-block } lappend_if [have_spec acpi] boot_modules acpi_drv diff --git a/dde_linux/src/lib/usb/dummies.c b/dde_linux/src/lib/usb/dummies.c index 0d2662bdd..2133bb4e7 100644 --- a/dde_linux/src/lib/usb/dummies.c +++ b/dde_linux/src/lib/usb/dummies.c @@ -796,12 +796,6 @@ int scsi_get_resid(struct scsi_cmnd *cmd) { TRACE; return 0; } void scsi_report_bus_reset(struct Scsi_Host *shost, int channel) { TRACE; } void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target) { TRACE; } -void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, - struct scsi_eh_save *ses, unsigned char *cmnd, - int cmnd_size, unsigned sense_bytes) { TRACE; } - -void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, - struct scsi_eh_save *ses) { TRACE; } int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, diff --git a/dde_linux/src/lib/usb/include/lx_emul.h b/dde_linux/src/lib/usb/include/lx_emul.h index 63a37dad5..43879309e 100644 --- a/dde_linux/src/lib/usb/include/lx_emul.h +++ b/dde_linux/src/lib/usb/include/lx_emul.h @@ -2660,7 +2660,10 @@ unsigned int queue_max_hw_sectors(struct request_queue *q); ** scsi/scsi_eh.h ** *******************/ -struct scsi_eh_save { }; +struct scsi_eh_save +{ + unsigned char cmd_len; +}; struct scsi_sense_hdr { diff --git a/dde_linux/src/lib/usb/include/nic/component.h b/dde_linux/src/lib/usb/include/nic/component.h index 2fa5898ce..5f3934dd2 100644 --- a/dde_linux/src/lib/usb/include/nic/component.h +++ b/dde_linux/src/lib/usb/include/nic/component.h @@ -268,7 +268,7 @@ namespace Nic { /** * Root component, handling new session requests */ - class Root : public Packet_root + class Root : public Packet_root { public: diff --git a/dde_linux/src/lib/usb/include/platform.h b/dde_linux/src/lib/usb/include/platform.h index 9733a6f31..13a3571e2 100644 --- a/dde_linux/src/lib/usb/include/platform.h +++ b/dde_linux/src/lib/usb/include/platform.h @@ -63,19 +63,22 @@ struct Services } try { - config()->xml_node().attribute("uhci").has_value("yes"); + if (!config()->xml_node().attribute("uhci").has_value("yes")) + throw -1; uhci = true; PINF("Enabled UHCI (USB 1.0/1.1) support"); } catch (...) { } try { - config()->xml_node().attribute("ehci").has_value("yes"); + if (!config()->xml_node().attribute("ehci").has_value("yes")) + throw -1; ehci = true; PINF("Enabled EHCI (USB 2.0) support"); } catch (...) { } try { - config()->xml_node().attribute("xhci").has_value("yes"); + if (!config()->xml_node().attribute("xhci").has_value("yes")) + throw -1; xhci = true; PINF("Enabled XHCI (USB 3.0) support"); } catch (...) { } diff --git a/dde_linux/src/lib/usb/include/signal/dispatch.h b/dde_linux/src/lib/usb/include/signal/dispatch.h index 273d8c014..48f0ee235 100644 --- a/dde_linux/src/lib/usb/include/signal/dispatch.h +++ b/dde_linux/src/lib/usb/include/signal/dispatch.h @@ -79,7 +79,7 @@ class Packet_session_component : public RPC /** * Root component, handling new session requests */ - template + template class Packet_root : public ROOT_COMPONENT { private: @@ -122,8 +122,8 @@ class Packet_session_component : public RPC } return new (ROOT_COMPONENT::md_alloc()) - SESSION_COMPONENT(env()->ram_session()->alloc(tx_buf_size), - env()->ram_session()->alloc(rx_buf_size), + SESSION_COMPONENT(env()->ram_session()->alloc(tx_buf_size, CACHED), + env()->ram_session()->alloc(rx_buf_size, CACHED), _ep, _sig_rec, _device); } diff --git a/dde_linux/src/lib/usb/include/storage/component.h b/dde_linux/src/lib/usb/include/storage/component.h index c3fd06108..14abd8490 100644 --- a/dde_linux/src/lib/usb/include/storage/component.h +++ b/dde_linux/src/lib/usb/include/storage/component.h @@ -107,7 +107,7 @@ namespace Block { /** * Root component, handling new session requests */ - class Root : public Packet_root + class Root : public Packet_root { public: diff --git a/dde_linux/src/lib/usb/storage/scsi.c b/dde_linux/src/lib/usb/storage/scsi.c index 15aedd2b4..a1af6523e 100644 --- a/dde_linux/src/lib/usb/storage/scsi.c +++ b/dde_linux/src/lib/usb/storage/scsi.c @@ -65,17 +65,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *t, int priv_size) host->max_id = 8; host->hostt = t; -// rval = scsi_setup_command_freelist(shost); -// if (rval) -// goto fail_kfree; - -// shost->ehandler = kthread_run(scsi_error_handler, shost, -// "scsi_eh_%d", shost->host_no); -// if (IS_ERR(shost->ehandler)) { -// rval = PTR_ERR(shost->ehandler); -// goto fail_destroy_freelist; -// } - return host; } @@ -136,6 +125,7 @@ struct scsi_cmnd *_scsi_alloc_command() cmnd->sdb.table.sgl = (struct scatterlist *)kmalloc(sizeof(struct scatterlist), GFP_KERNEL); cmnd->cmnd = kzalloc(MAX_COMMAND_SIZE, 0); cmnd->sdb.table.sgl->page_link = (unsigned long) kzalloc(sizeof(struct page), 0); + cmnd->sense_buffer = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); return cmnd; } @@ -144,6 +134,7 @@ void _scsi_free_command(struct scsi_cmnd *cmnd) { kfree((void *)cmnd->sdb.table.sgl->page_link); kfree(cmnd->sdb.table.sgl); + kfree(cmnd->sense_buffer); kfree(cmnd->cmnd); kfree(cmnd); } @@ -223,3 +214,22 @@ void scsi_scan_host(struct Scsi_Host *host) unsigned scsi_bufflen(struct scsi_cmnd *cmnd) { return cmnd->sdb.length; } struct scatterlist *scsi_sglist(struct scsi_cmnd *cmnd) { return cmnd->sdb.table.sgl; } unsigned scsi_sg_count(struct scsi_cmnd *cmnd) { return cmnd->sdb.table.nents; } + + +/******************** + ** scsi/scsi_eh.h ** + *******************/ + +void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, + struct scsi_eh_save *ses, unsigned char *cmnd, + int cmnd_size, unsigned sense_bytes) +{ + ses->cmd_len = scmd->cmd_len; +} + + +void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, + struct scsi_eh_save *ses) +{ + scmd->cmd_len = ses->cmd_len; +}