* [PATCH 2/5] arcmsr: Support Hibernation
@ 2012-11-15 7:24 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2012-11-15 7:24 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: patch2 --]
[-- Type: application/octet-stream, Size: 6901 bytes --]
diff -uprN a//drivers/scsi/arcmsr/arcmsr.h b//drivers/scsi/arcmsr/arcmsr.h
--- a//drivers/scsi/arcmsr/arcmsr.h 2012-10-12 16:28:42.175958900 +0800
+++ b//drivers/scsi/arcmsr/arcmsr.h 2012-10-12 16:29:10.215958628 +0800
@@ -63,7 +63,8 @@ struct device_attribute;
#define ARCMSR_DEFAULT_SG_ENTRIES 38
#define ARCMSR_MAX_HBB_POSTQUEUE 264
#define ARCMSR_MAX_XFER_LEN 0x26000
-#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMST_NUM_MSIX_VECTORS 4
#ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_1880 0x1880
#endif
@@ -511,6 +512,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *host;
unsigned long vir2phy_offset;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_t outbound_int_enable;
uint32_t cdb_phyaddr_hi32;
@@ -547,6 +549,8 @@ struct AdapterControlBlock
/* iop init */
#define ACB_F_ABORT 0x0200
#define ACB_F_FIRMWARE_TRAP 0x0400
+ #define ACB_F_MSI_ENABLED 0x1000
+ #define ACB_F_MSIX_ENABLED 0x2000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_head ccb_free_list;
diff -uprN a//drivers/scsi/arcmsr/arcmsr_hba.c b//drivers/scsi/arcmsr/arcmsr_hba.c
--- a//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-12 16:28:42.175958900 +0800
+++ b//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-12 16:29:10.239958629 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -662,6 +673,134 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+ free_irq(pdev->irq, acb);
+ pci_disable_msi(pdev);
+ } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
+ pci_disable_msix(pdev);
+ } else {
+ free_irq(pdev->irq, acb);
+ }
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error \n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ printk(KERN_WARNING
+ "scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+ if (!pci_enable_msix(pdev, entries,
+ ARCMST_NUM_MSIX_VECTORS)) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+ i++) {
+ entries[i].entry = i;
+ if (request_irq(entries[i].vector,
+ arcmsr_do_interrupt, 0,
+ "arcmsr", acb)) {
+ for (j = 0 ; j < i ; j++)
+ free_irq(entries[i].vector,
+ acb);
+ goto controller_stop;
+ }
+ acb->entries[i] = entries[i];
+ }
+ acb->acb_flags |= ACB_F_MSIX_ENABLED;
+ } else {
+ printk("arcmsr%d: MSI-X"
+ "failed to enable\n", acb->host->host_no);
+ if (request_irq(pdev->irq,
+ arcmsr_do_interrupt, IRQF_SHARED,
+ "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ } else {
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+ controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 2/5] arcmsr: Support Hibernation
@ 2013-02-08 6:07 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2013-02-08 6:07 UTC (permalink / raw)
To: 'NickCheng', linux-scsi; +Cc: linux-kernel, jejb
Please ignore the last mails with checkpatch file.
Thanks,
-----Original Message-----
From: NickCheng [mailto:nick.cheng@areca.com.tw]
Sent: Friday, February 08, 2013 2:03 PM
To: 'linux-scsi@vger.kernel.org'
Cc: 'linux-kernel@vger.kernel.org'; 'jejb@kernel.org'; 黃清隆
Subject: [PATCH 2/5] arcmsr: Support Hibernation
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2013-02-08 6:03 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2013-02-08 6:03 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb, ???
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: patch2 --]
[-- Type: application/octet-stream, Size: 6882 bytes --]
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-08 13:55:04.814477574 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-08 13:55:18.557754617 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -553,10 +564,10 @@ arcmsr_message_isr_bh_fn(struct work_str
psdev =
scsi_device_lookup(acb->host,
0, target, lun);
- if (psdev != NULL) {
- scsi_remove_device(psdev);
- scsi_device_put(psdev);
- }
+ if (psdev != NULL) {
+ scsi_remove_device(psdev);
+ scsi_device_put(psdev);
+ }
}
temp >>= 1;
diff >>= 1;
@@ -663,6 +674,85 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ free_irq(pdev->irq, acb);
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error\n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ pr_warn("scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
@@ -680,8 +770,7 @@ static int arcmsr_probe(struct pci_dev *
if (error) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (error) {
- printk(KERN_WARNING
- "scsi%d: No suitable DMA mask available\n",
+ pr_warn("scsi%d: No suitable DMA mask available\n",
host->host_no);
goto scsi_host_release;
}
@@ -960,12 +1049,12 @@ arcmsr_report_ccb_state(struct AdapterCo
default:
pr_notice("arcmsr%d: scsi id = %d lun = %d"
- "isr get command error done, but got unknown"
- "DeviceStatus = 0x%x\n"
- , acb->host->host_no
- , id
- , lun
- , ccb->arcmsr_cdb.DeviceStatus);
+ "isr get command error done, but got unknown"
+ "DeviceStatus = 0x%x\n"
+ , acb->host->host_no
+ , id
+ , lun
+ , ccb->arcmsr_cdb.DeviceStatus);
acb->devstate[id][lun] = ARECA_RAID_GONE;
ccb->pcmd->result = DID_NO_CONNECT << 16;
arcmsr_ccb_complete(ccb);
@@ -996,7 +1085,7 @@ struct CommandControlBlock *pCCB, bool e
pr_notice("arcmsr%d: isr get an illegal ccb command"
"done acb = '0x%p'"
"ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x"
- " ccboutstandingcount = %d\n"
+ "ccboutstandingcount = %d\n"
, acb->host->host_no
, acb
, pCCB
@@ -1023,6 +1112,7 @@ arcmsr_done4abort_postqueue(struct Adapt
uint32_t outbound_intstatus;
outbound_intstatus = readl(®->outbound_intstatus) &
acb->outbound_int_enable;
+ /*clear and abort all outbound posted Q*/
writel(outbound_intstatus, ®->outbound_intstatus);
while (((flag_ccb = readl(®->outbound_queueport))
!= 0xFFFFFFFF)
@@ -2262,8 +2352,8 @@ arcmsr_hbaA_get_config(struct AdapterCon
®->inbound_msgaddr0);
if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
pr_notice("arcmsr%d: wait 'get adapter firmware"
- "miscellaneous data' timeout\n",
- acb->host->host_no);
+ "miscellaneous data' timeout\n",
+ acb->host->host_no);
return false;
}
count = 8;
@@ -3368,8 +3458,8 @@ arcmsr_abort(struct scsi_cmnd *cmd)
int rtn = FAILED;
pr_notice("arcmsr%d: abort device command of"
"scsi id = %d lun = %d\n",
- acb->host->host_no,
- cmd->device->id, cmd->device->lun);
+ acb->host->host_no,
+ cmd->device->id, cmd->device->lun);
acb->acb_flags |= ACB_F_ABORT;
acb->num_aborts++;
/*
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2013-02-08 6:02 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2013-02-08 6:02 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb, ???
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: checkpatch2 --]
[-- Type: application/octet-stream, Size: 2202 bytes --]
WARNING: Too many leading tabs - consider code refactoring
#70: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:567:
+ if (psdev != NULL) {
WARNING: line over 80 characters
#71: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:568:
+ scsi_remove_device(psdev);
WARNING: line over 80 characters
#72: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:569:
+ scsi_device_put(psdev);
WARNING: braces {} are not necessary for single statement blocks
#96: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:692:
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
WARNING: printk() should include KERN_ facility level
#127: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:723:
+ printk("%s: pci_enable_device error\n", __func__);
WARNING: Too many leading tabs - consider code refactoring
#150: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:746:
+ for (j = 0 ; j < i ; j++)
WARNING: line over 80 characters
#151: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:747:
+ free_irq(entries[i].vector,
WARNING: printk() should include KERN_ facility level
#159: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:755:
+ printk("arcmsr%d: MSI-X"
WARNING: quoted string split across lines
#160: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:756:
+ printk("arcmsr%d: MSI-X"
+ "failed to enable\n", acb->host->host_no);
WARNING: braces {} are not necessary for single statement blocks
#168: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:764:
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
WARNING: quoted string split across lines
#231: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:1100:
pr_notice("arcmsr%d: scsi id = %d lun = %d"
+ "isr get command error done, but got unknown"
WARNING: quoted string split across lines
#263: FILE: drivers/scsi/arcmsr/arcmsr_hba.c:2403:
pr_notice("arcmsr%d: wait 'get adapter firmware"
+ "miscellaneous data' timeout\n",
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 12 warnings, 259 lines checked
../patch2 has style problems, please review.
If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2013-02-06 8:36 NickCheng
2013-02-07 17:31 ` Tomas Henzl
0 siblings, 1 reply; 11+ messages in thread
From: NickCheng @ 2013-02-06 8:36 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb, 黃清隆
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: patch2 --]
[-- Type: application/octet-stream, Size: 9507 bytes --]
diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h 2013-02-06 16:27:33.655790583 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h 2013-02-06 16:27:59.615397282 +0800
@@ -64,6 +64,7 @@ struct device_attribute;
#define ARCMSR_MAX_HBB_POSTQUEUE 264
#define ARCMSR_MAX_XFER_LEN 0x26000
#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMST_NUM_MSIX_VECTORS 4
#ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_1880 0x1880
#endif
@@ -510,6 +511,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *host;
unsigned long vir2phy_offset;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_t outbound_int_enable;
uint32_t cdb_phyaddr_hi32;
@@ -546,6 +548,8 @@ struct AdapterControlBlock
/* iop init */
#define ACB_F_ABORT 0x0200
#define ACB_F_FIRMWARE_TRAP 0x0400
+ #define ACB_F_MSI_ENABLED 0x1000
+ #define ACB_F_MSIX_ENABLED 0x2000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_head ccb_free_list;
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-06 16:27:34.139804136 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-06 16:27:59.960413119 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -553,10 +564,10 @@ arcmsr_message_isr_bh_fn(struct work_str
psdev =
scsi_device_lookup(acb->host,
0, target, lun);
- if (psdev != NULL) {
- scsi_remove_device(psdev);
- scsi_device_put(psdev);
- }
+ if (psdev != NULL) {
+ scsi_remove_device(psdev);
+ scsi_device_put(psdev);
+ }
}
temp >>= 1;
diff >>= 1;
@@ -663,6 +674,133 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+ free_irq(pdev->irq, acb);
+ pci_disable_msi(pdev);
+ } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
+ pci_disable_msix(pdev);
+ } else {
+ free_irq(pdev->irq, acb);
+ }
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error\n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ pr_warn("scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+ if (!pci_enable_msix(pdev, entries,
+ ARCMST_NUM_MSIX_VECTORS)) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+ i++) {
+ entries[i].entry = i;
+ if (request_irq(entries[i].vector,
+ arcmsr_do_interrupt, 0,
+ "arcmsr", acb)) {
+ for (j = 0 ; j < i ; j++)
+ free_irq(entries[i].vector,
+ acb);
+ goto controller_stop;
+ }
+ acb->entries[i] = entries[i];
+ }
+ acb->acb_flags |= ACB_F_MSIX_ENABLED;
+ } else {
+ printk("arcmsr%d: MSI-X"
+ "failed to enable\n", acb->host->host_no);
+ if (request_irq(pdev->irq,
+ arcmsr_do_interrupt, IRQF_SHARED,
+ "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ } else {
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
@@ -680,8 +818,7 @@ static int arcmsr_probe(struct pci_dev *
if (error) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (error) {
- printk(KERN_WARNING
- "scsi%d: No suitable DMA mask available\n",
+ pr_warn("scsi%d: No suitable DMA mask available\n",
host->host_no);
goto scsi_host_release;
}
@@ -960,12 +1097,12 @@ arcmsr_report_ccb_state(struct AdapterCo
default:
pr_notice("arcmsr%d: scsi id = %d lun = %d"
- "isr get command error done, but got unknown"
- "DeviceStatus = 0x%x\n"
- , acb->host->host_no
- , id
- , lun
- , ccb->arcmsr_cdb.DeviceStatus);
+ "isr get command error done, but got unknown"
+ "DeviceStatus = 0x%x\n"
+ , acb->host->host_no
+ , id
+ , lun
+ , ccb->arcmsr_cdb.DeviceStatus);
acb->devstate[id][lun] = ARECA_RAID_GONE;
ccb->pcmd->result = DID_NO_CONNECT << 16;
arcmsr_ccb_complete(ccb);
@@ -996,7 +1133,7 @@ struct CommandControlBlock *pCCB, bool e
pr_notice("arcmsr%d: isr get an illegal ccb command"
"done acb = '0x%p'"
"ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x"
- " ccboutstandingcount = %d\n"
+ "ccboutstandingcount = %d\n"
, acb->host->host_no
, acb
, pCCB
@@ -1023,6 +1160,7 @@ arcmsr_done4abort_postqueue(struct Adapt
uint32_t outbound_intstatus;
outbound_intstatus = readl(®->outbound_intstatus) &
acb->outbound_int_enable;
+ /*clear and abort all outbound posted Q*/
writel(outbound_intstatus, ®->outbound_intstatus);
while (((flag_ccb = readl(®->outbound_queueport))
!= 0xFFFFFFFF)
@@ -2262,8 +2400,8 @@ arcmsr_hbaA_get_config(struct AdapterCon
®->inbound_msgaddr0);
if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
pr_notice("arcmsr%d: wait 'get adapter firmware"
- "miscellaneous data' timeout\n",
- acb->host->host_no);
+ "miscellaneous data' timeout\n",
+ acb->host->host_no);
return false;
}
count = 8;
@@ -3368,8 +3506,8 @@ arcmsr_abort(struct scsi_cmnd *cmd)
int rtn = FAILED;
pr_notice("arcmsr%d: abort device command of"
"scsi id = %d lun = %d\n",
- acb->host->host_no,
- cmd->device->id, cmd->device->lun);
+ acb->host->host_no,
+ cmd->device->id, cmd->device->lun);
acb->acb_flags |= ACB_F_ABORT;
acb->num_aborts++;
/*
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] arcmsr: Support Hibernation
2013-02-06 8:36 NickCheng
@ 2013-02-07 17:31 ` Tomas Henzl
0 siblings, 0 replies; 11+ messages in thread
From: Tomas Henzl @ 2013-02-07 17:31 UTC (permalink / raw)
To: NickCheng; +Cc: linux-scsi, linux-kernel, jejb, 黃清隆
On 02/06/2013 09:36 AM, NickCheng wrote:
> From: Nick Cheng <nick.cheng@areca.com.tw>
>
> Support hibernation for whole series of RAID controllers
> Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
> ---
Hi Nick,
this patch (2/5) already uses msi-x in the PM part, while the "Support MSI and MSI-X"
is added in the patch 3/5. You should switch the order - the support for msi-x should precede
the use of it in "Support Hibernation".
Tomas
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2012-12-04 11:59 NickCheng
2012-12-17 10:48 ` James Bottomley
0 siblings, 1 reply; 11+ messages in thread
From: NickCheng @ 2012-12-04 11:59 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: patch2 --]
[-- Type: application/octet-stream, Size: 9516 bytes --]
diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h 2012-12-04 19:15:13.579086738 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h 2012-12-04 19:15:26.143086617 +0800
@@ -64,6 +64,7 @@ struct device_attribute;
#define ARCMSR_MAX_HBB_POSTQUEUE 264
#define ARCMSR_MAX_XFER_LEN 0x26000
#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMST_NUM_MSIX_VECTORS 4
#ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_1880 0x1880
#endif
@@ -510,6 +511,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *host;
unsigned long vir2phy_offset;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_t outbound_int_enable;
uint32_t cdb_phyaddr_hi32;
@@ -546,6 +548,8 @@ struct AdapterControlBlock
/* iop init */
#define ACB_F_ABORT 0x0200
#define ACB_F_FIRMWARE_TRAP 0x0400
+ #define ACB_F_MSI_ENABLED 0x1000
+ #define ACB_F_MSIX_ENABLED 0x2000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_head ccb_free_list;
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2012-12-04 19:15:13.579086738 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2012-12-04 19:15:26.147086633 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -553,10 +564,10 @@ arcmsr_message_isr_bh_fn(struct work_str
psdev =
scsi_device_lookup(acb->host,
0, target, lun);
- if (psdev != NULL) {
- scsi_remove_device(psdev);
- scsi_device_put(psdev);
- }
+ if (psdev != NULL) {
+ scsi_remove_device(psdev);
+ scsi_device_put(psdev);
+ }
}
temp >>= 1;
diff >>= 1;
@@ -663,6 +674,133 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+ free_irq(pdev->irq, acb);
+ pci_disable_msi(pdev);
+ } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
+ pci_disable_msix(pdev);
+ } else {
+ free_irq(pdev->irq, acb);
+ }
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error\n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ pr_warn("scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+ if (!pci_enable_msix(pdev, entries,
+ ARCMST_NUM_MSIX_VECTORS)) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+ i++) {
+ entries[i].entry = i;
+ if (request_irq(entries[i].vector,
+ arcmsr_do_interrupt, 0,
+ "arcmsr", acb)) {
+ for (j = 0 ; j < i ; j++)
+ free_irq(entries[i].vector,
+ acb);
+ goto controller_stop;
+ }
+ acb->entries[i] = entries[i];
+ }
+ acb->acb_flags |= ACB_F_MSIX_ENABLED;
+ } else {
+ printk("arcmsr%d: MSI-X "
+ "failed to enable\n", acb->host->host_no);
+ if (request_irq(pdev->irq,
+ arcmsr_do_interrupt, IRQF_SHARED,
+ "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ } else {
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
@@ -680,8 +818,7 @@ static int arcmsr_probe(struct pci_dev *
if (error) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (error) {
- printk(KERN_WARNING
- "scsi%d: No suitable DMA mask available\n",
+ pr_warn("scsi%d: No suitable DMA mask available\n",
host->host_no);
goto scsi_host_release;
}
@@ -960,12 +1097,12 @@ arcmsr_report_ccb_state(struct AdapterCo
default:
pr_notice("arcmsr%d: scsi id = %d lun = %d "
- "isr get command error done, but got unknown "
- "DeviceStatus = 0x%x\n"
- , acb->host->host_no
- , id
- , lun
- , ccb->arcmsr_cdb.DeviceStatus);
+ "isr get command error done, but got unknown "
+ "DeviceStatus = 0x%x\n"
+ , acb->host->host_no
+ , id
+ , lun
+ , ccb->arcmsr_cdb.DeviceStatus);
acb->devstate[id][lun] = ARECA_RAID_GONE;
ccb->pcmd->result = DID_NO_CONNECT << 16;
arcmsr_ccb_complete(ccb);
@@ -996,7 +1133,7 @@ struct CommandControlBlock *pCCB, bool e
pr_notice("arcmsr%d: isr get an illegal ccb command "
"done acb = '0x%p' "
"ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x "
- " ccboutstandingcount = %d\n"
+ "ccboutstandingcount = %d\n"
, acb->host->host_no
, acb
, pCCB
@@ -1023,6 +1160,7 @@ arcmsr_done4abort_postqueue(struct Adapt
uint32_t outbound_intstatus;
outbound_intstatus = readl(®->outbound_intstatus) &
acb->outbound_int_enable;
+ /*clear and abort all outbound posted Q*/
writel(outbound_intstatus, ®->outbound_intstatus);
while (((flag_ccb = readl(®->outbound_queueport))
!= 0xFFFFFFFF)
@@ -2262,8 +2400,8 @@ arcmsr_hbaA_get_config(struct AdapterCon
®->inbound_msgaddr0);
if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
pr_notice("arcmsr%d: wait 'get adapter firmware "
- "miscellaneous data' timeout\n",
- acb->host->host_no);
+ "miscellaneous data' timeout\n",
+ acb->host->host_no);
return false;
}
count = 8;
@@ -3368,8 +3506,8 @@ arcmsr_abort(struct scsi_cmnd *cmd)
int rtn = FAILED;
pr_notice("arcmsr%d: abort device command of "
"scsi id = %d lun = %d\n",
- acb->host->host_no,
- cmd->device->id, cmd->device->lun);
+ acb->host->host_no,
+ cmd->device->id, cmd->device->lun);
acb->acb_flags |= ACB_F_ABORT;
acb->num_aborts++;
/*
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] arcmsr: Support Hibernation
2012-12-04 11:59 NickCheng
@ 2012-12-17 10:48 ` James Bottomley
0 siblings, 0 replies; 11+ messages in thread
From: James Bottomley @ 2012-12-17 10:48 UTC (permalink / raw)
To: NickCheng; +Cc: linux-scsi, linux-kernel, jejb
On Tue, 2012-12-04 at 19:59 +0800, NickCheng wrote:
> From: Nick Cheng <nick.cheng@areca.com.tw>
>
> Support hibernation for whole series of RAID controllers
This doesn't compile:
CC [M] drivers/scsi/arcmsr/arcmsr_hba.o
drivers/scsi/arcmsr/arcmsr_hba.c: In function ‘arcmsr_iop_message_xfer’:
drivers/scsi/arcmsr/arcmsr_hba.c:1871:36: error: ‘KM_IRQ0’ undeclared (first use in this function)
drivers/scsi/arcmsr/arcmsr_hba.c:1871:36: note: each undeclared identifier is reported only once for each function it appears in
drivers/scsi/arcmsr/arcmsr_hba.c:1871:2: error: too many arguments to function ‘kmap_atomic’
In file included from include/linux/pagemap.h:10:0,
from include/linux/blkdev.h:13,
from include/scsi/scsi_cmnd.h:5,
from drivers/scsi/arcmsr/arcmsr_hba.c:67:
include/linux/highmem.h:66:21: note: declared here
drivers/scsi/arcmsr/arcmsr_hba.c:2127:44: error: macro "kunmap_atomic" passed 2 arguments, but takes just 1
drivers/scsi/arcmsr/arcmsr_hba.c:2127:2: error: ‘kunmap_atomic’ undeclared (first use in this function)
drivers/scsi/arcmsr/arcmsr_hba.c: In function ‘arcmsr_handle_virtual_command’:
drivers/scsi/arcmsr/arcmsr_hba.c:2180:37: error: ‘KM_IRQ0’ undeclared (first use in this function)
drivers/scsi/arcmsr/arcmsr_hba.c:2180:3: error: too many arguments to function ‘kmap_atomic’
In file included from include/linux/pagemap.h:10:0,
from include/linux/blkdev.h:13,
from include/scsi/scsi_cmnd.h:5,
from drivers/scsi/arcmsr/arcmsr_hba.c:67:
include/linux/highmem.h:66:21: note: declared here
drivers/scsi/arcmsr/arcmsr_hba.c:2184:45: error: macro "kunmap_atomic" passed 2 arguments, but takes just 1
drivers/scsi/arcmsr/arcmsr_hba.c:2184:3: error: ‘kunmap_atomic’ undeclared (first use in this function)
make[3]: *** [drivers/scsi/arcmsr/arcmsr_hba.o] Error 1
And that's because you're using an ancient form of kmap_atomic() which
was deprecated by
commit 3e4d3af501cccdc8a8cca41bdbe57d54ad7e7e73
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Tue Oct 26 14:21:51 2010 -0700
mm: stack based kmap_atomic()
And actually made unsupported a year ago. What are you compile testing
this against?
James
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2012-11-16 11:55 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2012-11-16 11:55 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
[-- Attachment #2: patch2 --]
[-- Type: application/octet-stream, Size: 9558 bytes --]
diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h 2012-11-16 12:32:43.466705952 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h 2012-11-16 13:49:11.742661469 +0800
@@ -64,6 +64,7 @@ struct device_attribute;
#define ARCMSR_MAX_HBB_POSTQUEUE 264
#define ARCMSR_MAX_XFER_LEN 0x26000
#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMST_NUM_MSIX_VECTORS 4
#ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_1880 0x1880
#endif
@@ -510,6 +511,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *host;
unsigned long vir2phy_offset;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_t outbound_int_enable;
uint32_t cdb_phyaddr_hi32;
@@ -546,6 +548,8 @@ struct AdapterControlBlock
/* iop init */
#define ACB_F_ABORT 0x0200
#define ACB_F_FIRMWARE_TRAP 0x0400
+ #define ACB_F_MSI_ENABLED 0x1000
+ #define ACB_F_MSIX_ENABLED 0x2000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_head ccb_free_list;
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2012-11-16 12:32:43.466705952 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2012-11-16 13:49:11.742661469 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -553,10 +564,10 @@ arcmsr_message_isr_bh_fn(struct work_str
psdev =
scsi_device_lookup(acb->host,
0, target, lun);
- if (psdev != NULL) {
- scsi_remove_device(psdev);
- scsi_device_put(psdev);
- }
+ if (psdev != NULL) {
+ scsi_remove_device(psdev);
+ scsi_device_put(psdev);
+ }
}
temp >>= 1;
diff >>= 1;
@@ -663,6 +674,133 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+ free_irq(pdev->irq, acb);
+ pci_disable_msi(pdev);
+ } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
+ pci_disable_msix(pdev);
+ } else {
+ free_irq(pdev->irq, acb);
+ }
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error \n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ pr_warn("scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+ if (!pci_enable_msix(pdev, entries,
+ ARCMST_NUM_MSIX_VECTORS)) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+ i++) {
+ entries[i].entry = i;
+ if (request_irq(entries[i].vector,
+ arcmsr_do_interrupt, 0,
+ "arcmsr", acb)) {
+ for (j = 0 ; j < i ; j++)
+ free_irq(entries[i].vector,
+ acb);
+ goto controller_stop;
+ }
+ acb->entries[i] = entries[i];
+ }
+ acb->acb_flags |= ACB_F_MSIX_ENABLED;
+ } else {
+ printk("arcmsr%d: MSI-X"
+ "failed to enable\n", acb->host->host_no);
+ if (request_irq(pdev->irq,
+ arcmsr_do_interrupt, IRQF_SHARED,
+ "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ } else {
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+ controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
@@ -680,8 +818,7 @@ static int arcmsr_probe(struct pci_dev *
if (error) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (error) {
- printk(KERN_WARNING
- "scsi%d: No suitable DMA mask available\n",
+ pr_warn("scsi%d: No suitable DMA mask available\n",
host->host_no);
goto scsi_host_release;
}
@@ -994,15 +1131,15 @@ struct CommandControlBlock *pCCB, bool e
return;
}
pr_notice("arcmsr%d: isr get an illegal ccb command"
- "done acb = '0x%p'"
- "ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x"
+ "done acb = '0x%p'"
+ "ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x"
" ccboutstandingcount = %d\n"
- , acb->host->host_no
- , acb
- , pCCB
- , pCCB->acb
- , pCCB->startdone
- , atomic_read(&acb->ccboutstandingcount));
+ , acb->host->host_no
+ , acb
+ , pCCB
+ , pCCB->acb
+ , pCCB->startdone
+ , atomic_read(&acb->ccboutstandingcount));
return;
}
arcmsr_report_ccb_state(acb, pCCB, error);
@@ -1023,6 +1160,7 @@ arcmsr_done4abort_postqueue(struct Adapt
uint32_t outbound_intstatus;
outbound_intstatus = readl(®->outbound_intstatus) &
acb->outbound_int_enable;
+ /*clear and abort all outbound posted Q*/
writel(outbound_intstatus, ®->outbound_intstatus);
while (((flag_ccb = readl(®->outbound_queueport))
!= 0xFFFFFFFF)
@@ -2262,8 +2400,8 @@ arcmsr_hbaA_get_config(struct AdapterCon
®->inbound_msgaddr0);
if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
pr_notice("arcmsr%d: wait 'get adapter firmware"
- "miscellaneous data' timeout\n",
- acb->host->host_no);
+ "miscellaneous data' timeout\n",
+ acb->host->host_no);
return false;
}
count = 8;
@@ -2532,7 +2670,7 @@ arcmsr_hbaA_polling_ccbdone(struct Adapt
continue;
}
pr_notice("arcmsr%d: polling get an illegal"
- "ccb command done ccb = '0x%p'"
+ "ccb command done ccb = '0x%p'"
"ccboutstandingcount = %d\n"
, acb->host->host_no
, ccb
@@ -3369,8 +3507,8 @@ arcmsr_abort(struct scsi_cmnd *cmd)
int rtn = FAILED;
pr_notice("arcmsr%d: abort device command of"
"scsi id = %d lun = %d\n",
- acb->host->host_no,
- cmd->device->id, cmd->device->lun);
+ acb->host->host_no,
+ cmd->device->id, cmd->device->lun);
acb->acb_flags |= ACB_F_ABORT;
acb->num_aborts++;
/*
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2012-10-12 9:06 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2012-10-12 9:06 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
diff -uprN a//drivers/scsi/arcmsr/arcmsr.h b//drivers/scsi/arcmsr/arcmsr.h
--- a//drivers/scsi/arcmsr/arcmsr.h 2012-10-12 16:28:42.175958900 +0800
+++ b//drivers/scsi/arcmsr/arcmsr.h 2012-10-12 16:29:10.215958628 +0800
@@ -63,7 +63,8 @@ struct device_attribute;
#define ARCMSR_DEFAULT_SG_ENTRIES 38
#define ARCMSR_MAX_HBB_POSTQUEUE 264
#define ARCMSR_MAX_XFER_LEN 0x26000
-#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMSR_CDB_SG_PAGE_LENGTH 256
+#define ARCMST_NUM_MSIX_VECTORS 4
#ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_1880 0x1880
#endif
@@ -511,6 +512,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *host;
unsigned long vir2phy_offset;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_t outbound_int_enable;
uint32_t cdb_phyaddr_hi32;
@@ -547,6 +549,8 @@ struct AdapterControlBlock
/* iop init */
#define ACB_F_ABORT 0x0200
#define ACB_F_FIRMWARE_TRAP 0x0400
+ #define ACB_F_MSI_ENABLED 0x1000
+ #define ACB_F_MSIX_ENABLED 0x2000
struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_head ccb_free_list;
diff -uprN a//drivers/scsi/arcmsr/arcmsr_hba.c b//drivers/scsi/arcmsr/arcmsr_hba.c
--- a//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-12 16:28:42.175958900 +0800
+++ b//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-12 16:29:10.239958629 +0800
@@ -89,11 +89,18 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+#ifdef CONFIG_PM
+ static int arcmsr_suspend(struct pci_dev *pdev,
+ pm_message_t state);
+ static int arcmsr_resume(struct pci_dev *pdev);
+#endif
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+ u32 orig_mask);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
@@ -166,6 +173,10 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ #ifdef CONFIG_PM
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
+ #endif
.shutdown = arcmsr_shutdown,
};
/*
@@ -662,6 +673,134 @@ arcmsr_message_isr_bh_fn(struct work_str
}
}
+#ifdef CONFIG_PM
+ static int
+ arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+ {
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+ free_irq(pdev->irq, acb);
+ pci_disable_msi(pdev);
+ } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+ free_irq(acb->entries[i].vector, acb);
+ }
+ pci_disable_msix(pdev);
+ } else {
+ free_irq(pdev->irq, acb);
+ }
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+ }
+
+ static int
+ arcmsr_resume(struct pci_dev *pdev)
+ {
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb =
+ (struct AdapterControlBlock *)host->hostdata;
+ struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error \n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ printk(KERN_WARNING
+ "scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+ if (!pci_enable_msix(pdev, entries,
+ ARCMST_NUM_MSIX_VECTORS)) {
+ for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+ i++) {
+ entries[i].entry = i;
+ if (request_irq(entries[i].vector,
+ arcmsr_do_interrupt, 0,
+ "arcmsr", acb)) {
+ for (j = 0 ; j < i ; j++)
+ free_irq(entries[i].vector,
+ acb);
+ goto controller_stop;
+ }
+ acb->entries[i] = entries[i];
+ }
+ acb->acb_flags |= ACB_F_MSIX_ENABLED;
+ } else {
+ printk("arcmsr%d: MSI-X"
+ "failed to enable\n", acb->host->host_no);
+ if (request_irq(pdev->irq,
+ arcmsr_do_interrupt, IRQF_SHARED,
+ "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+ if (!pci_enable_msi(pdev)) {
+ acb->acb_flags |= ACB_F_MSI_ENABLED;
+ }
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ } else {
+ if (request_irq(pdev->irq, arcmsr_do_interrupt,
+ IRQF_SHARED, "arcmsr", acb)) {
+ goto controller_stop;
+ }
+ }
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies +
+ msecs_to_jiffies(6 * HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function =
+ &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+ controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+ }
+#endif
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct Scsi_Host *host;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/5] arcmsr: Support Hibernation
@ 2012-10-03 12:39 NickCheng
0 siblings, 0 replies; 11+ messages in thread
From: NickCheng @ 2012-10-03 12:39 UTC (permalink / raw)
To: linux-scsi; +Cc: linux-kernel, jejb
From: Nick Cheng <nick.cheng@areca.com.tw>
Support hibernation for whole series of RAID controllers
Signed-off-by: Nick Cheng <nick.cheng@areca.com.tw>
---
diff -uprN -X linux-vanilla/Documentation/dontdiff
linux-vanilla//drivers/scsi/arcmsr/arcmsr_hba.c
linux-development//drivers/scsi/arcmsr/arcmsr_hba.c
--- linux-vanilla//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-03
19:08:33.338634210 +0800
+++ linux-development//drivers/scsi/arcmsr/arcmsr_hba.c 2012-10-03
18:50:32.694644708 +0800
@@ -42,7 +42,7 @@
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************
***
** For history of changes, see Documentation/scsi/ChangeLog.arcmsr
-** Firmware Specification, see Documentation/scsi/arcmsr_spec.txt
+** Firmware Specification, see Documentation/scsi/arcmsr_spec.txt
****************************************************************************
***
*/
#include <linux/module.h>
@@ -90,6 +90,8 @@ static int arcmsr_bios_param(struct scsi
static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd
*cmd);
static int arcmsr_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
+static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state);
+static int arcmsr_resume(struct pci_dev *pdev);
static void arcmsr_remove(struct pci_dev *pdev);
static void arcmsr_shutdown(struct pci_dev *pdev);
static void arcmsr_iop_init(struct AdapterControlBlock *acb);
@@ -167,6 +169,8 @@ static struct pci_driver arcmsr_pci_driv
.id_table = arcmsr_device_id_table,
.probe = arcmsr_probe,
.remove = arcmsr_remove,
+ .suspend = arcmsr_suspend,
+ .resume = arcmsr_resume,
.shutdown = arcmsr_shutdown,
};
/*
@@ -603,6 +607,80 @@ static void arcmsr_message_isr_bh_fn(str
}
}
+static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+ int i;
+ uint32_t intmask_org;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb = (struct AdapterControlBlock
*)host->hostdata;
+
+ intmask_org = arcmsr_disable_outbound_ints(acb);
+ del_timer_sync(&acb->eternal_timer);
+ flush_scheduled_work();
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ arcmsr_enable_outbound_ints(acb, intmask_org);
+ pci_set_drvdata(pdev, host);
+ pci_save_state(pdev);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ return 0;
+}
+
+static int arcmsr_resume(struct pci_dev *pdev)
+{
+ int error, i, j;
+ struct Scsi_Host *host = pci_get_drvdata(pdev);
+ struct AdapterControlBlock *acb = (struct AdapterControlBlock
*)host->hostdata;
+
+ pci_set_power_state(pdev, PCI_D0);
+ pci_enable_wake(pdev, PCI_D0, 0);
+ pci_restore_state(pdev);
+ if (pci_enable_device(pdev)) {
+ printk("%s: pci_enable_device error \n", __func__);
+ return -ENODEV;
+ }
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (error) {
+ error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (error) {
+ printk(KERN_WARNING
+ "scsi%d: No suitable DMA mask available\n",
+ host->host_no);
+ goto controller_unregister;
+ }
+ }
+ pci_set_master(pdev);
+ arcmsr_iop_init(acb);
+ if (request_irq(pdev->irq, arcmsr_do_interrupt, IRQF_SHARED,
"arcmsr", acb)) {
+ printk("arcmsr%d: request_irq =%d failed!\n",
acb->host->host_no, pdev->irq);
+ goto controller_stop;
+ }
+ timer_init:
+ INIT_WORK(&acb->arcmsr_do_message_isr_bh,
+ arcmsr_message_isr_bh_fn);
+ atomic_set(&acb->rq_map_token, 16);
+ atomic_set(&acb->ante_token_value, 16);
+ acb->fw_flag = FW_NORMAL;
+ init_timer(&acb->eternal_timer);
+ acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 *
HZ);
+ acb->eternal_timer.data = (unsigned long) acb;
+ acb->eternal_timer.function = &arcmsr_request_device_map;
+ add_timer(&acb->eternal_timer);
+ return 0;
+ controller_stop:
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ controller_unregister:
+ scsi_remove_host(host);
+ arcmsr_free_ccb_pool(acb);
+ arcmsr_unmap_pciregion(acb);
+ pci_release_regions(pdev);
+ scsi_host_put(host);
+ pci_disable_device(pdev);
+ return -ENODEV;
+}
+
static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id
*id)
{
struct Scsi_Host *host;
@@ -1539,14 +1617,7 @@ static void arcmsr_hbaC_postqueue_isr(st
throttling++;
}
}
-/*
-***************************************************************************
*******
-** Handle a message interrupt
-**
-** The only message interrupt we expect is in response to a query for the
current adapter config.
-** We want this in order to compare the drivemap so that we can detect
newly-attached drives.
-***************************************************************************
*******
-*/
+
static void arcmsr_hbaA_message_isr(struct AdapterControlBlock *acb)
{
struct MessageUnit_A *reg = acb->pmuA;
@@ -1562,15 +1633,7 @@ static void arcmsr_hbaB_message_isr(stru
writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN, reg->iop2drv_doorbell);
schedule_work(&acb->arcmsr_do_message_isr_bh);
}
-/*
-***************************************************************************
*******
-** Handle a message interrupt
-**
-** The only message interrupt we expect is in response to a query for the
-** current adapter config.
-** We want this in order to compare the drivemap so that we can detect
newly-attached drives.
-***************************************************************************
*******
-*/
+
static void arcmsr_hbaC_message_isr(struct AdapterControlBlock *acb)
{
struct MessageUnit_C *reg = acb->pmuC;
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-02-08 6:08 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-15 7:24 [PATCH 2/5] arcmsr: Support Hibernation NickCheng
-- strict thread matches above, loose matches on Subject: below --
2013-02-08 6:07 NickCheng
2013-02-08 6:03 NickCheng
2013-02-08 6:02 NickCheng
2013-02-06 8:36 NickCheng
2013-02-07 17:31 ` Tomas Henzl
2012-12-04 11:59 NickCheng
2012-12-17 10:48 ` James Bottomley
2012-11-16 11:55 NickCheng
2012-10-12 9:06 NickCheng
2012-10-03 12:39 NickCheng
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).