[RFC][PATCH 6/6] PCI PM: pci_save/restore_state improvements

From: Adam Belay (abelay_at_novell.com)
Date: 11/16/05

  • Next message: Adam Belay: "[RFC][PATCH 3/6] PCI PM: update pci_set_power_state()"
    To: Linux-pm mailing list <linux-pm@lists.osdl.org>, Greg KH <gregkh@suse.de>
    Date:	Tue, 15 Nov 2005 22:31:42 -0500
    
    

    This patch makes some improvements to pci_save_state and
    pci_restore_state. Instead of saving and restoring all standard
    registers (even read-only ones), it only restores necessary registers.
    Also, the command register is handled more carefully. Let me know if
    I'm missing anything important.

    --- a/drivers/pci/pm.c 2005-11-13 20:32:24.000000000 -0500
    +++ b/drivers/pci/pm.c 2005-11-13 20:29:32.000000000 -0500
    @@ -53,10 +53,13 @@
      */
     int pci_save_state(struct pci_dev *dev)
     {
    - int i;
    - /* XXX: 100% dword access ok here? */
    - for (i = 0; i < 16; i++)
    - pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]);
    + struct pci_dev_config * conf = &dev->saved_config;
    +
    + pci_read_config_word(dev, PCI_COMMAND, &conf->command);
    + pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &conf->cacheline_size);
    + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &conf->latency_timer);
    + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &conf->interrupt_line);
    +
             return 0;
     }
     
    @@ -68,10 +71,20 @@
      */
     int pci_restore_state(struct pci_dev *dev)
     {
    - int i;
    + u16 command;
    + struct pci_dev_config * conf = &dev->saved_config;
    +
    + command = conf->command & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
    + PCI_COMMAND_MASTER);
    +
    + pci_write_config_word(dev, PCI_COMMAND, command);
    + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, conf->cacheline_size);
    + pci_write_config_byte(dev, PCI_LATENCY_TIMER, conf->latency_timer);
    + pci_write_config_byte(dev, PCI_INTERRUPT_PIN, conf->interrupt_line);
    +
    + pci_restore_bars(dev);
    +
     
    - for (i = 0; i < 16; i++)
    - pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
             return 0;
     }
     
    --- a/include/linux/pci.h 2005-11-08 17:10:22.000000000 -0500
    +++ b/include/linux/pci.h 2005-11-13 20:21:20.000000000 -0500
    @@ -68,6 +68,13 @@
     #define DEVICE_COUNT_COMPATIBLE 4
     #define DEVICE_COUNT_RESOURCE 12
     
    +struct pci_dev_config {
    + unsigned short command;
    + unsigned char cacheline_size;
    + unsigned char latency_timer;
    + unsigned char interrupt_line;
    +};
    +
     struct pci_dev_pm {
             unsigned int pm_offset; /* the PCI PM capability offset */
     
    @@ -152,7 +159,7 @@
             unsigned int is_busmaster:1; /* device is busmaster */
             unsigned int no_msi:1; /* device may not use msi */
     
    - u32 saved_config_space[16]; /* config space saved at suspend time */
    + struct pci_dev_config saved_config; /* config space saved for power management */
             struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
             int rom_attr_enabled; /* has display of the rom attribute been enabled? */
             struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Adam Belay: "[RFC][PATCH 3/6] PCI PM: update pci_set_power_state()"

    Relevant Pages

    • Re: max agruments in system_calls
      ... On Wed, 17 Nov 2004, Sharma Sushant wrote: ... > I know I can use struct and stuff arguments inside it, but I want to use more ... You KNOW that you don't have more than 7 registers available ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [RFC][PATCH 6/6] PCI PM: pci_save/restore_state improvements
      ... > registers, it only restores necessary registers. ... > I'm missing anything important. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] mv64x60 iomem annotations
      ... Return the virtual address of the bridge's registers. ... u32 cfg_data, struct pci_controller **hose); ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • device driver for the SGI system clock, mmtimer
      ... The driver has been widely used for applications on the Altix platform. ... +static int mmtimer_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); ... * of the page where the registers are mapped) for the counter in question. ...
      (Linux-Kernel)
    • Re: [RFC] full suspend/resume support for i915 DRM driver
      ... Greg, DRM desperately needs review of its device model usage, can you ... struct drm_sysfs_class; ... * This is the number of cycles out of the backlight modulation cycle for which ... * 855 scratch registers. ...
      (Linux-Kernel)