* [PATCH v2 3/17] arcmsr: Add code to support system hibernation
@ 2014-08-08 12:05 Ching Huang
2014-08-08 14:23 ` Tomas Henzl
0 siblings, 1 reply; 5+ messages in thread
From: Ching Huang @ 2014-08-08 12:05 UTC (permalink / raw)
To: hch, jbottomley, dan.carpenter, thenzl, agordeev, linux-scsi,
linux-kernel
From: Ching Huang <ching2048@areca.com.tw>
This patch adds code to support system hibernation.
Changes in v2 of 3/17:
* merge patch 18/18 to this patch
Signed-off-by: Ching Huang <ching2048@areca.com.tw>
---
Thanks to Tomas's advice.
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-01 17:54:46.000000000 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-08 19:03:48.000000000 +0800
@@ -89,11 +89,15 @@ 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);
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 intmask_org);
static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb);
static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb);
@@ -167,6 +171,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,
};
/*
@@ -772,6 +778,76 @@ static void arcmsr_free_irq(struct pci_d
free_irq(pdev->irq, acb);
}
+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);
+ arcmsr_free_irq(pdev, acb);
+ del_timer_sync(&acb->eternal_timer);
+ flush_work(&acb->arcmsr_do_message_isr_bh);
+ arcmsr_stop_adapter_bgrb(acb);
+ arcmsr_flush_adapter_cache(acb);
+ 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)) {
+ pr_warn("%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);
+ if (arcmsr_request_irq(pdev, acb) == FAILED)
+ goto controller_stop;
+ arcmsr_iop_init(acb);
+ 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 uint8_t arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb)
{
struct MessageUnit_A __iomem *reg = acb->pmuA;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 3/17] arcmsr: Add code to support system hibernation
2014-08-08 12:05 [PATCH v2 3/17] arcmsr: Add code to support system hibernation Ching Huang
@ 2014-08-08 14:23 ` Tomas Henzl
2014-08-11 11:09 ` Ching Huang
0 siblings, 1 reply; 5+ messages in thread
From: Tomas Henzl @ 2014-08-08 14:23 UTC (permalink / raw)
To: Ching Huang, hch, jbottomley, dan.carpenter, agordeev, linux-scsi,
linux-kernel
On 08/08/2014 02:05 PM, Ching Huang wrote:
> From: Ching Huang <ching2048@areca.com.tw>
>
> This patch adds code to support system hibernation.
>
> Changes in v2 of 3/17:
> * merge patch 18/18 to this patch
Thanks, and please mark the the 18/18 as obsolete - add a comment there
In my previous response were other comments too, you haven't probably
noticed them. I could be wrong with my comments, but if you want a review
you should explain why the code is ok as it is.
>
> Signed-off-by: Ching Huang <ching2048@areca.com.tw>
> ---
>
> Thanks to Tomas's advice.
>
> diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-01 17:54:46.000000000 +0800
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-08 19:03:48.000000000 +0800
> @@ -89,11 +89,15 @@ 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);
> 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 intmask_org);
> static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
> static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb);
> static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb);
> @@ -167,6 +171,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,
> };
> /*
> @@ -772,6 +778,76 @@ static void arcmsr_free_irq(struct pci_d
> free_irq(pdev->irq, acb);
> }
>
> +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);
> + arcmsr_free_irq(pdev, acb);
> + del_timer_sync(&acb->eternal_timer);
> + flush_work(&acb->arcmsr_do_message_isr_bh);
> + arcmsr_stop_adapter_bgrb(acb);
> + arcmsr_flush_adapter_cache(acb);
> + 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)) {
> + pr_warn("%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);
> + if (arcmsr_request_irq(pdev, acb) == FAILED)
> + goto controller_stop;
> + arcmsr_iop_init(acb);
> + 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 uint8_t arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb)
> {
> struct MessageUnit_A __iomem *reg = acb->pmuA;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 3/17] arcmsr: Add code to support system hibernation
2014-08-08 14:23 ` Tomas Henzl
@ 2014-08-11 11:09 ` Ching Huang
2014-08-11 13:07 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Ching Huang @ 2014-08-11 11:09 UTC (permalink / raw)
To: Tomas Henzl
Cc: hch, jbottomley, dan.carpenter, agordeev, linux-scsi,
linux-kernel
Yes. 18/18 is obsolete.
Thanks to Tomas's advice.
Ching
On Fri, 2014-08-08 at 16:23 +0200, Tomas Henzl wrote:
> On 08/08/2014 02:05 PM, Ching Huang wrote:
> > From: Ching Huang <ching2048@areca.com.tw>
> >
> > This patch adds code to support system hibernation.
> >
> > Changes in v2 of 3/17:
> > * merge patch 18/18 to this patch, so 18/18 is obsolete.
>
> Thanks, and please mark the the 18/18 as obsolete - add a comment there
>
> In my previous response were other comments too, you haven't probably
> noticed them. I could be wrong with my comments, but if you want a review
> you should explain why the code is ok as it is.
>
> >
> > Signed-off-by: Ching Huang <ching2048@areca.com.tw>
> > ---
> >
> > Thanks to Tomas's advice.
> >
> > diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> > --- a/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-01 17:54:46.000000000 +0800
> > +++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2014-08-08 19:03:48.000000000 +0800
> > @@ -89,11 +89,15 @@ 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);
> > 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 intmask_org);
> > static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
> > static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb);
> > static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb);
> > @@ -167,6 +171,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,
> > };
> > /*
> > @@ -772,6 +778,76 @@ static void arcmsr_free_irq(struct pci_d
> > free_irq(pdev->irq, acb);
> > }
> >
> > +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);
> > + arcmsr_free_irq(pdev, acb);
> > + del_timer_sync(&acb->eternal_timer);
> > + flush_work(&acb->arcmsr_do_message_isr_bh);
> > + arcmsr_stop_adapter_bgrb(acb);
> > + arcmsr_flush_adapter_cache(acb);
> > + 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)) {
> > + pr_warn("%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);
> > + if (arcmsr_request_irq(pdev, acb) == FAILED)
> > + goto controller_stop;
> > + arcmsr_iop_init(acb);
> > + 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 uint8_t arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb)
> > {
> > struct MessageUnit_A __iomem *reg = acb->pmuA;
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 3/17] arcmsr: Add code to support system hibernation
2014-08-11 11:09 ` Ching Huang
@ 2014-08-11 13:07 ` Dan Carpenter
2014-08-11 13:11 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-08-11 13:07 UTC (permalink / raw)
To: Ching Huang
Cc: Tomas Henzl, hch, jbottomley, agordeev, linux-scsi, linux-kernel
On Mon, Aug 11, 2014 at 07:09:55PM +0800, Ching Huang wrote:
> Yes. 18/18 is obsolete.
> Thanks to Tomas's advice.
>
There is no way to keep track of all the patches because they aren't
in an email thread. Could you resend everything using git-format-patch
to send them as one thread?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/17] arcmsr: Add code to support system hibernation
2014-08-11 13:07 ` Dan Carpenter
@ 2014-08-11 13:11 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2014-08-11 13:11 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ching Huang, Tomas Henzl, jbottomley, agordeev, linux-scsi,
linux-kernel
On Mon, Aug 11, 2014 at 04:07:31PM +0300, Dan Carpenter wrote:
> On Mon, Aug 11, 2014 at 07:09:55PM +0800, Ching Huang wrote:
> > Yes. 18/18 is obsolete.
> > Thanks to Tomas's advice.
> >
>
> There is no way to keep track of all the patches because they aren't
> in an email thread. Could you resend everything using git-format-patch
> to send them as one thread?
Agreed. Also try to use git-send-email to get the threading right.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-11 13:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-08 12:05 [PATCH v2 3/17] arcmsr: Add code to support system hibernation Ching Huang
2014-08-08 14:23 ` Tomas Henzl
2014-08-11 11:09 ` Ching Huang
2014-08-11 13:07 ` Dan Carpenter
2014-08-11 13:11 ` Christoph Hellwig
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).