Merge branches 'misc', 'eeepc-laptop' and 'bugzilla-14445' into release
authorLen Brown <len.brown@intel.com>
Thu, 5 Nov 2009 23:31:18 +0000 (18:31 -0500)
committerLen Brown <len.brown@intel.com>
Thu, 5 Nov 2009 23:31:18 +0000 (18:31 -0500)
22 files changed:
Documentation/thermal/sysfs-api.txt
block/cfq-iosched.c
drivers/acpi/power_meter.c
drivers/acpi/proc.c
drivers/acpi/processor_core.c
drivers/acpi/processor_throttling.c
drivers/acpi/video.c
drivers/ata/ahci.c
drivers/ata/libata-core.c
drivers/ata/sata_via.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/i915_suspend.c
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/platform/x86/eeepc-laptop.c
drivers/thermal/thermal_sys.c
fs/bio.c
mm/backing-dev.c

index 70d68ce..a87dc27 100644 (file)
@@ -1,5 +1,5 @@
 Generic Thermal Sysfs driver How To
-=========================
+===================================
 
 Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com>
 
@@ -10,20 +10,20 @@ Copyright (c)  2008 Intel Corporation
 
 0. Introduction
 
-The generic thermal sysfs provides a set of interfaces for thermal zone devices (sensors)
-and thermal cooling devices (fan, processor...) to register with the thermal management
-solution and to be a part of it.
+The generic thermal sysfs provides a set of interfaces for thermal zone
+devices (sensors) and thermal cooling devices (fan, processor...) to register
+with the thermal management solution and to be a part of it.
 
-This how-to focuses on enabling new thermal zone and cooling devices to participate
-in thermal management.
-This solution is platform independent and any type of thermal zone devices and
-cooling devices should be able to make use of the infrastructure.
+This how-to focuses on enabling new thermal zone and cooling devices to
+participate in thermal management.
+This solution is platform independent and any type of thermal zone devices
+and cooling devices should be able to make use of the infrastructure.
 
-The main task of the thermal sysfs driver is to expose thermal zone attributes as well
-as cooling device attributes to the user space.
-An intelligent thermal management application can make decisions based on inputs
-from thermal zone attributes (the current temperature and trip point temperature)
-and throttle appropriate devices.
+The main task of the thermal sysfs driver is to expose thermal zone attributes
+as well as cooling device attributes to the user space.
+An intelligent thermal management application can make decisions based on
+inputs from thermal zone attributes (the current temperature and trip point
+temperature) and throttle appropriate devices.
 
 [0-*]  denotes any positive number starting from 0
 [1-*]  denotes any positive number starting from 1
@@ -31,77 +31,77 @@ and throttle appropriate devices.
 1. thermal sysfs driver interface functions
 
 1.1 thermal zone device interface
-1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *name, int trips,
-                               void *devdata, struct thermal_zone_device_ops *ops)
-
-       This interface function adds a new thermal zone device (sensor) to
-       /sys/class/thermal folder as thermal_zone[0-*].
-       It tries to bind all the thermal cooling devices registered at the same time.
-
-       name: the thermal zone name.
-       trips: the total number of trip points this thermal zone supports.
-       devdata: device private data
-       ops: thermal zone device call-backs.
-               .bind: bind the thermal zone device with a thermal cooling device.
-               .unbind: unbind the thermal zone device with a thermal cooling device.
-               .get_temp: get the current temperature of the thermal zone.
-               .get_mode: get the current mode (user/kernel) of the thermal zone.
-                          "kernel" means thermal management is done in kernel.
-                          "user" will prevent kernel thermal driver actions upon trip points
-                          so that user applications can take charge of thermal management.
-               .set_mode: set the mode (user/kernel) of the thermal zone.
-               .get_trip_type: get the type of certain trip point.
-               .get_trip_temp: get the temperature above which the certain trip point
-                               will be fired.
+1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *name,
+               int trips, void *devdata, struct thermal_zone_device_ops *ops)
+
+    This interface function adds a new thermal zone device (sensor) to
+    /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
+    thermal cooling devices registered at the same time.
+
+    name: the thermal zone name.
+    trips: the total number of trip points this thermal zone supports.
+    devdata: device private data
+    ops: thermal zone device call-backs.
+       .bind: bind the thermal zone device with a thermal cooling device.
+       .unbind: unbind the thermal zone device with a thermal cooling device.
+       .get_temp: get the current temperature of the thermal zone.
+       .get_mode: get the current mode (user/kernel) of the thermal zone.
+           - "kernel" means thermal management is done in kernel.
+           - "user" will prevent kernel thermal driver actions upon trip points
+             so that user applications can take charge of thermal management.
+       .set_mode: set the mode (user/kernel) of the thermal zone.
+       .get_trip_type: get the type of certain trip point.
+       .get_trip_temp: get the temperature above which the certain trip point
+                       will be fired.
 
 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 
-       This interface function removes the thermal zone device.
-       It deletes the corresponding entry form /sys/class/thermal folder and unbind all
-       the thermal cooling devices it uses.
+    This interface function removes the thermal zone device.
+    It deletes the corresponding entry form /sys/class/thermal folder and
+    unbind all the thermal cooling devices it uses.
 
 1.2 thermal cooling device interface
 1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name,
-                                       void *devdata, struct thermal_cooling_device_ops *)
-
-       This interface function adds a new thermal cooling device (fan/processor/...) to
-       /sys/class/thermal/ folder as cooling_device[0-*].
-       It tries to bind itself to all the thermal zone devices register at the same time.
-       name: the cooling device name.
-       devdata: device private data.
-       ops: thermal cooling devices call-backs.
-               .get_max_state: get the Maximum throttle state of the cooling device.
-               .get_cur_state: get the Current throttle state of the cooling device.
-               .set_cur_state: set the Current throttle state of the cooling device.
+               void *devdata, struct thermal_cooling_device_ops *)
+
+    This interface function adds a new thermal cooling device (fan/processor/...)
+    to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
+    to all the thermal zone devices register at the same time.
+    name: the cooling device name.
+    devdata: device private data.
+    ops: thermal cooling devices call-backs.
+       .get_max_state: get the Maximum throttle state of the cooling device.
+       .get_cur_state: get the Current throttle state of the cooling device.
+       .set_cur_state: set the Current throttle state of the cooling device.
 
 1.2.2 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
 
-       This interface function remove the thermal cooling device.
-       It deletes the corresponding entry form /sys/class/thermal folder and unbind
-       itself from all the thermal zone devices using it.
+    This interface function remove the thermal cooling device.
+    It deletes the corresponding entry form /sys/class/thermal folder and
+    unbind itself from all the thermal zone devices using it.
 
 1.3 interface for binding a thermal zone device with a thermal cooling device
 1.3.1 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
-                       int trip, struct thermal_cooling_device *cdev);
+               int trip, struct thermal_cooling_device *cdev);
 
-       This interface function bind a thermal cooling device to the certain trip point
-       of a thermal zone device.
-       This function is usually called in the thermal zone device .bind callback.
-       tz: the thermal zone device
-       cdev: thermal cooling device
-       trip: indicates which trip point the cooling devices is associated with
-                in this thermal zone.
+    This interface function bind a thermal cooling device to the certain trip
+    point of a thermal zone device.
+    This function is usually called in the thermal zone device .bind callback.
+    tz: the thermal zone device
+    cdev: thermal cooling device
+    trip: indicates which trip point the cooling devices is associated with
+         in this thermal zone.
 
 1.3.2 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
-                               int trip, struct thermal_cooling_device *cdev);
+               int trip, struct thermal_cooling_device *cdev);
 
-       This interface function unbind a thermal cooling device from the certain trip point
-       of a thermal zone device.
-       This function is usually called in the thermal zone device .unbind callback.
-       tz: the thermal zone device
-       cdev: thermal cooling device
-       trip: indicates which trip point the cooling devices is associated with
-               in this thermal zone.
+    This interface function unbind a thermal cooling device from the certain
+    trip point of a thermal zone device. This function is usually called in
+    the thermal zone device .unbind callback.
+    tz: the thermal zone device
+    cdev: thermal cooling device
+    trip: indicates which trip point the cooling devices is associated with
+         in this thermal zone.
 
 2. sysfs attributes structure
 
@@ -114,153 +114,166 @@ if hwmon is compiled in or built as a module.
 
 Thermal zone device sys I/F, created once it's registered:
 /sys/class/thermal/thermal_zone[0-*]:
-       |-----type:                     Type of the thermal zone
-       |-----temp:                     Current temperature
-       |-----mode:                     Working mode of the thermal zone
-       |-----trip_point_[0-*]_temp:    Trip point temperature
-       |-----trip_point_[0-*]_type:    Trip point type
+    |---type:                  Type of the thermal zone
+    |---temp:                  Current temperature
+    |---mode:                  Working mode of the thermal zone
+    |---trip_point_[0-*]_temp: Trip point temperature
+    |---trip_point_[0-*]_type: Trip point type
 
 Thermal cooling device sys I/F, created once it's registered:
 /sys/class/thermal/cooling_device[0-*]:
-       |-----type :                    Type of the cooling device(processor/fan/...)
-       |-----max_state:                Maximum cooling state of the cooling device
-       |-----cur_state:                Current cooling state of the cooling device
+    |---type:                  Type of the cooling device(processor/fan/...)
+    |---max_state:             Maximum cooling state of the cooling device
+    |---cur_state:             Current cooling state of the cooling device
 
 
-These two dynamic attributes are created/removed in pairs.
-They represent the relationship between a thermal zone and its associated cooling device.
-They are created/removed for each
-thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device successful execution.
+Then next two dynamic attributes are created/removed in pairs. They represent
+the relationship between a thermal zone and its associated cooling device.
+They are created/removed for each successful execution of
+thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
 
-/sys/class/thermal/thermal_zone[0-*]
-       |-----cdev[0-*]:                The [0-*]th cooling device in the current thermal zone
-       |-----cdev[0-*]_trip_point:     Trip point that cdev[0-*] is associated with
+/sys/class/thermal/thermal_zone[0-*]:
+    |---cdev[0-*]:             [0-*]th cooling device in current thermal zone
+    |---cdev[0-*]_trip_point:  Trip point that cdev[0-*] is associated with
 
 Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
-the generic thermal driver also creates a hwmon sysfs I/F for each _type_ of
-thermal zone device. E.g. the generic thermal driver registers one hwmon class device
-and build the associated hwmon sysfs I/F for all the registered ACPI thermal zones.
+the generic thermal driver also creates a hwmon sysfs I/F for each _type_
+of thermal zone device. E.g. the generic thermal driver registers one hwmon
+class device and build the associated hwmon sysfs I/F for all the registered
+ACPI thermal zones.
+
 /sys/class/hwmon/hwmon[0-*]:
-       |-----name:                     The type of the thermal zone devices.
-       |-----temp[1-*]_input:          The current temperature of thermal zone [1-*].
-       |-----temp[1-*]_critical:       The critical trip point of thermal zone [1-*].
+    |---name:                  The type of the thermal zone devices
+    |---temp[1-*]_input:       The current temperature of thermal zone [1-*]
+    |---temp[1-*]_critical:    The critical trip point of thermal zone [1-*]
+
 Please read Documentation/hwmon/sysfs-interface for additional information.
 
 ***************************
 * Thermal zone attributes *
 ***************************
 
-type                           Strings which represent the thermal zone type.
-                               This is given by thermal zone driver as part of registration.
-                               Eg: "acpitz" indicates it's an ACPI thermal device.
-                               In order to keep it consistent with hwmon sys attribute,
-                               this should be a short, lowercase string,
-                               not containing spaces nor dashes.
-                               RO
-                               Required
-
-temp                           Current temperature as reported by thermal zone (sensor)
-                               Unit: millidegree Celsius
-                               RO
-                               Required
-
-mode                           One of the predefined values in [kernel, user]
-                               This file gives information about the algorithm
-                               that is currently managing the thermal zone.
-                               It can be either default kernel based algorithm
-                               or user space application.
-                               RW
-                               Optional
-                               kernel  = Thermal management in kernel thermal zone driver.
-                               user    = Preventing kernel thermal zone driver actions upon
-                                         trip points so that user application can take full
-                                         charge of the thermal management.
-
-trip_point_[0-*]_temp          The temperature above which trip point will be fired
-                               Unit: millidegree Celsius
-                               RO
-                               Optional
-
-trip_point_[0-*]_type          Strings which indicate the type of the trip point
-                               E.g. it can be one of critical, hot, passive,
-                                   active[0-*] for ACPI thermal zone.
-                               RO
-                               Optional
-
-cdev[0-*]                      Sysfs link to the thermal cooling device node where the sys I/F
-                               for cooling device throttling control represents.
-                               RO
-                               Optional
-
-cdev[0-*]_trip_point           The trip point with which cdev[0-*] is associated in this thermal zone
-                               -1 means the cooling device is not associated with any trip point.
-                               RO
-                               Optional
-
-******************************
-* Cooling device  attributes *
-******************************
-
-type                           String which represents the type of device
-                               eg: For generic ACPI: this should be "Fan",
-                               "Processor" or "LCD"
-                               eg. For memory controller device on intel_menlow platform:
-                               this should be "Memory controller"
-                               RO
-                               Required
-
-max_state                      The maximum permissible cooling state of this cooling device.
-                               RO
-                               Required
-
-cur_state                      The current cooling state of this cooling device.
-                               the value can any integer numbers between 0 and max_state,
-                               cur_state == 0 means no cooling
-                               cur_state == max_state means the maximum cooling.
-                               RW
-                               Required
+type
+       Strings which represent the thermal zone type.
+       This is given by thermal zone driver as part of registration.
+       E.g: "acpitz" indicates it's an ACPI thermal device.
+       In order to keep it consistent with hwmon sys attribute; this should
+       be a short, lowercase string, not containing spaces nor dashes.
+       RO, Required
+
+temp
+       Current temperature as reported by thermal zone (sensor).
+       Unit: millidegree Celsius
+       RO, Required
+
+mode
+       One of the predefined values in [kernel, user].
+       This file gives information about the algorithm that is currently
+       managing the thermal zone. It can be either default kernel based
+       algorithm or user space application.
+       kernel  = Thermal management in kernel thermal zone driver.
+       user    = Preventing kernel thermal zone driver actions upon
+                 trip points so that user application can take full
+                 charge of the thermal management.
+       RW, Optional
+
+trip_point_[0-*]_temp
+       The temperature above which trip point will be fired.
+       Unit: millidegree Celsius
+       RO, Optional
+
+trip_point_[0-*]_type
+       Strings which indicate the type of the trip point.
+       E.g. it can be one of critical, hot, passive, active[0-*] for ACPI
+       thermal zone.
+       RO, Optional
+
+cdev[0-*]
+       Sysfs link to the thermal cooling device node where the sys I/F
+       for cooling device throttling control represents.
+       RO, Optional
+
+cdev[0-*]_trip_point
+       The trip point with which cdev[0-*] is associated in this thermal
+       zone; -1 means the cooling device is not associated with any trip
+       point.
+       RO, Optional
+
+passive
+       Attribute is only present for zones in which the passive cooling
+       policy is not supported by native thermal driver. Default is zero
+       and can be set to a temperature (in millidegrees) to enable a
+       passive trip point for the zone. Activation is done by polling with
+       an interval of 1 second.
+       Unit: millidegrees Celsius
+       RW, Optional
+
+*****************************
+* Cooling device attributes *
+*****************************
+
+type
+       String which represents the type of device, e.g:
+       - for generic ACPI: should be "Fan", "Processor" or "LCD"
+       - for memory controller device on intel_menlow platform:
+         should be "Memory controller".
+       RO, Required
+
+max_state
+       The maximum permissible cooling state of this cooling device.
+       RO, Required
+
+cur_state
+       The current cooling state of this cooling device.
+       The value can any integer numbers between 0 and max_state:
+       - cur_state == 0 means no cooling
+       - cur_state == max_state means the maximum cooling.
+       RW, Required
 
 3. A simple implementation
 
-ACPI thermal zone may support multiple trip points like critical/hot/passive/active.
-If an ACPI thermal zone supports critical, passive, active[0] and active[1] at the same time,
-it may register itself as a thermal_zone_device (thermal_zone1) with 4 trip points in all.
-It has one processor and one fan, which are both registered as thermal_cooling_device.
-If the processor is listed in _PSL method, and the fan is listed in _AL0 method,
-the sys I/F structure will be built like this:
+ACPI thermal zone may support multiple trip points like critical, hot,
+passive, active. If an ACPI thermal zone supports critical, passive,
+active[0] and active[1] at the same time, it may register itself as a
+thermal_zone_device (thermal_zone1) with 4 trip points in all.
+It has one processor and one fan, which are both registered as
+thermal_cooling_device.
+
+If the processor is listed in _PSL method, and the fan is listed in _AL0
+method, the sys I/F structure will be built like this:
 
 /sys/class/thermal:
 
 |thermal_zone1:
-       |-----type:                     acpitz
-       |-----temp:                     37000
-       |-----mode:                     kernel
-       |-----trip_point_0_temp:        100000
-       |-----trip_point_0_type:        critical
-       |-----trip_point_1_temp:        80000
-       |-----trip_point_1_type:        passive
-       |-----trip_point_2_temp:        70000
-       |-----trip_point_2_type:        active0
-       |-----trip_point_3_temp:        60000
-       |-----trip_point_3_type:        active1
-       |-----cdev0:                    --->/sys/class/thermal/cooling_device0
-       |-----cdev0_trip_point:         1       /* cdev0 can be used for passive */
-       |-----cdev1:                    --->/sys/class/thermal/cooling_device3
-       |-----cdev1_trip_point:         2       /* cdev1 can be used for active[0]*/
+    |---type:                  acpitz
+    |---temp:                  37000
+    |---mode:                  kernel
+    |---trip_point_0_temp:     100000
+    |---trip_point_0_type:     critical
+    |---trip_point_1_temp:     80000
+    |---trip_point_1_type:     passive
+    |---trip_point_2_temp:     70000
+    |---trip_point_2_type:     active0
+    |---trip_point_3_temp:     60000
+    |---trip_point_3_type:     active1
+    |---cdev0:                 --->/sys/class/thermal/cooling_device0
+    |---cdev0_trip_point:      1       /* cdev0 can be used for passive */
+    |---cdev1:                 --->/sys/class/thermal/cooling_device3
+    |---cdev1_trip_point:      2       /* cdev1 can be used for active[0]*/
 
 |cooling_device0:
-       |-----type:                     Processor
-       |-----max_state:                8
-       |-----cur_state:                0
+    |---type:                  Processor
+    |---max_state:             8
+    |---cur_state:             0
 
 |cooling_device3:
-       |-----type:                     Fan
-       |-----max_state:                2
-       |-----cur_state:                0
+    |---type:                  Fan
+    |---max_state:             2
+    |---cur_state:             0
 
 /sys/class/hwmon:
 
 |hwmon0:
-       |-----name:                     acpitz
-       |-----temp1_input:              37000
-       |-----temp1_crit:               100000
+    |---name:                  acpitz
+    |---temp1_input:           37000
+    |---temp1_crit:            100000
index 069a610..aa1e953 100644 (file)
@@ -196,6 +196,7 @@ enum cfqq_state_flags {
        CFQ_CFQQ_FLAG_slice_new,        /* no requests dispatched in slice */
        CFQ_CFQQ_FLAG_sync,             /* synchronous queue */
        CFQ_CFQQ_FLAG_coop,             /* has done a coop jump of the queue */
+       CFQ_CFQQ_FLAG_coop_preempt,     /* coop preempt */
 };
 
 #define CFQ_CFQQ_FNS(name)                                             \
@@ -222,6 +223,7 @@ CFQ_CFQQ_FNS(prio_changed);
 CFQ_CFQQ_FNS(slice_new);
 CFQ_CFQQ_FNS(sync);
 CFQ_CFQQ_FNS(coop);
+CFQ_CFQQ_FNS(coop_preempt);
 #undef CFQ_CFQQ_FNS
 
 #define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \
@@ -945,10 +947,13 @@ static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd,
 {
        if (!cfqq) {
                cfqq = cfq_get_next_queue(cfqd);
-               if (cfqq)
+               if (cfqq && !cfq_cfqq_coop_preempt(cfqq))
                        cfq_clear_cfqq_coop(cfqq);
        }
 
+       if (cfqq)
+               cfq_clear_cfqq_coop_preempt(cfqq);
+
        __cfq_set_active_queue(cfqd, cfqq);
        return cfqq;
 }
@@ -2051,7 +2056,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
         * it's a metadata request and the current queue is doing regular IO.
         */
        if (rq_is_meta(rq) && !cfqq->meta_pending)
-               return false;
+               return true;
 
        /*
         * Allow an RT request to pre-empt an ongoing non-RT cfqq timeslice.
@@ -2066,8 +2071,16 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
         * if this request is as-good as one we would expect from the
         * current cfqq, let it preempt
         */
-       if (cfq_rq_close(cfqd, rq))
+       if (cfq_rq_close(cfqd, rq) && (!cfq_cfqq_coop(new_cfqq) ||
+           cfqd->busy_queues == 1)) {
+               /*
+                * Mark new queue coop_preempt, so its coop flag will not be
+                * cleared when new queue gets scheduled at the very first time
+                */
+               cfq_mark_cfqq_coop_preempt(new_cfqq);
+               cfq_mark_cfqq_coop(new_cfqq);
                return true;
+       }
 
        return false;
 }
index e6bfd77..2ef7030 100644 (file)
@@ -294,7 +294,11 @@ static int set_acpi_trip(struct acpi_power_meter_resource *resource)
                return -EINVAL;
        }
 
-       return data;
+       /* _PTP returns 0 on success, nonzero otherwise */
+       if (data)
+               return -EINVAL;
+
+       return 0;
 }
 
 static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
index f8b6f55..d0d25e2 100644 (file)
@@ -393,7 +393,7 @@ acpi_system_write_wakeup_device(struct file *file,
        struct list_head *node, *next;
        char strbuf[5];
        char str[5] = "";
-       int len = count;
+       unsigned int len = count;
        struct acpi_device *found_dev = NULL;
 
        if (len > 4)
index c567b46..ec742a4 100644 (file)
@@ -770,7 +770,7 @@ static struct notifier_block acpi_cpu_notifier =
            .notifier_call = acpi_cpu_soft_notify,
 };
 
-static int acpi_processor_add(struct acpi_device *device)
+static int __cpuinit acpi_processor_add(struct acpi_device *device)
 {
        struct acpi_processor *pr = NULL;
        int result = 0;
index 4c6c14c..1c5d7a8 100644 (file)
@@ -1133,15 +1133,15 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
        int result = 0;
        struct acpi_processor_throttling *pthrottling;
 
+       if (!pr)
+               return -EINVAL;
+
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
                          pr->throttling.address,
                          pr->throttling.duty_offset,
                          pr->throttling.duty_width));
 
-       if (!pr)
-               return -EINVAL;
-
        /*
         * Evaluate _PTC, _TSS and _TPC
         * They must all be present or none of them can be used.
index 64e3c58..05dff63 100644 (file)
@@ -1223,7 +1223,7 @@ acpi_video_device_write_state(struct file *file,
        u32 state = 0;
 
 
-       if (!dev || count + 1 > sizeof str)
+       if (!dev || count >= sizeof(str))
                return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
@@ -1280,7 +1280,7 @@ acpi_video_device_write_brightness(struct file *file,
        int i;
 
 
-       if (!dev || !dev->brightness || count + 1 > sizeof str)
+       if (!dev || !dev->brightness || count >= sizeof(str))
                return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
@@ -1562,7 +1562,7 @@ acpi_video_bus_write_POST(struct file *file,
        unsigned long long opt, options;
 
 
-       if (!video || count + 1 > sizeof str)
+       if (!video || count >= sizeof(str))
                return -EINVAL;
 
        status = acpi_video_bus_POST_options(video, &options);
@@ -1602,7 +1602,7 @@ acpi_video_bus_write_DOS(struct file *file,
        unsigned long opt;
 
 
-       if (!video || count + 1 > sizeof str)
+       if (!video || count >= sizeof(str))
                return -EINVAL;
 
        if (copy_from_user(str, buffer, count))
index a06f5d6..a3241a1 100644 (file)
@@ -2718,6 +2718,30 @@ static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
                        },
                        .driver_data = "20071026",      /* yyyymmdd */
                },
+               /*
+                * All BIOS versions for the MSI K9A2 Platinum (MS-7376)
+                * support 64bit DMA.
+                *
+                * BIOS versions earlier than 1.5 had the Manufacturer DMI
+                * fields as "MICRO-STAR INTERANTIONAL CO.,LTD".
+                * This spelling mistake was fixed in BIOS version 1.5, so
+                * 1.5 and later have the Manufacturer as
+                * "MICRO-STAR INTERNATIONAL CO.,LTD".
+                * So try to match on DMI_BOARD_VENDOR of "MICRO-STAR INTER".
+                *
+                * BIOS versions earlier than 1.9 had a Board Product Name
+                * DMI field of "MS-7376". This was changed to be
+                * "K9A2 Platinum (MS-7376)" in version 1.9, but we can still
+                * match on DMI_BOARD_NAME of "MS-7376".
+                */
+               {
+                       .ident = "MSI K9A2 Platinum",
+                       .matches = {
+                               DMI_MATCH(DMI_BOARD_VENDOR,
+                                         "MICRO-STAR INTER"),
+                               DMI_MATCH(DMI_BOARD_NAME, "MS-7376"),
+                       },
+               },
                { }
        };
        const struct dmi_system_id *match;
@@ -2729,18 +2753,24 @@ static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
            !match)
                return false;
 
+       if (!match->driver_data)
+               goto enable_64bit;
+
        dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
        snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
 
-       if (strcmp(buf, match->driver_data) >= 0) {
-               dev_printk(KERN_WARNING, &pdev->dev, "%s: enabling 64bit DMA\n",
-                          match->ident);
-               return true;
-       } else {
+       if (strcmp(buf, match->driver_data) >= 0)
+               goto enable_64bit;
+       else {
                dev_printk(KERN_WARNING, &pdev->dev, "%s: BIOS too old, "
                           "forcing 32bit DMA, update BIOS\n", match->ident);
                return false;
        }
+
+enable_64bit:
+       dev_printk(KERN_WARNING, &pdev->dev, "%s: enabling 64bit DMA\n",
+                  match->ident);
+       return true;
 }
 
 static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
index d7f0f1b..dc72690 100644 (file)
@@ -4919,10 +4919,11 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
  */
 void ata_qc_free(struct ata_queued_cmd *qc)
 {
-       struct ata_port *ap = qc->ap;
+       struct ata_port *ap;
        unsigned int tag;
 
        WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
+       ap = qc->ap;
 
        qc->flags = 0;
        tag = qc->tag;
@@ -4934,11 +4935,13 @@ void ata_qc_free(struct ata_queued_cmd *qc)
 
 void __ata_qc_complete(struct ata_queued_cmd *qc)
 {
-       struct ata_port *ap = qc->ap;
-       struct ata_link *link = qc->dev->link;
+       struct ata_port *ap;
+       struct ata_link *link;
 
        WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
        WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
+       ap = qc->ap;
+       link = qc->dev->link;
 
        if (likely(qc->flags & ATA_QCFLAG_DMAMAP))
                ata_sg_clean(qc);
index bdd43c7..02efd9a 100644 (file)
@@ -93,7 +93,6 @@ static const struct pci_device_id svia_pci_tbl[] = {
        { PCI_VDEVICE(VIA, 0x7372), vt6420 },
        { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */
        { PCI_VDEVICE(VIA, 0x9000), vt8251 },
-       { PCI_VDEVICE(VIA, 0x9040), vt8251 },
 
        { }     /* terminate list */
 };
index 92aeb91..e5b138b 100644 (file)
@@ -1227,8 +1227,7 @@ static int i915_load_modeset_init(struct drm_device *dev,
                goto out;
 
        /* Try to set up FBC with a reasonable compressed buffer size */
-       if (IS_MOBILE(dev) && (IS_I9XX(dev) || IS_I965G(dev) || IS_GM45(dev)) &&
-           i915_powersave) {
+       if (I915_HAS_FBC(dev) && i915_powersave) {
                int cfb_size;
 
                /* Try to get an 8M buffer... */
index c5df223..57204e2 100644 (file)
@@ -296,6 +296,12 @@ typedef struct drm_i915_private {
        u32 saveVBLANK_A;
        u32 saveVSYNC_A;
        u32 saveBCLRPAT_A;
+       u32 saveTRANS_HTOTAL_A;
+       u32 saveTRANS_HBLANK_A;
+       u32 saveTRANS_HSYNC_A;
+       u32 saveTRANS_VTOTAL_A;
+       u32 saveTRANS_VBLANK_A;
+       u32 saveTRANS_VSYNC_A;
        u32 savePIPEASTAT;
        u32 saveDSPASTRIDE;
        u32 saveDSPASIZE;
@@ -304,8 +310,11 @@ typedef struct drm_i915_private {
        u32 saveDSPASURF;
        u32 saveDSPATILEOFF;
        u32 savePFIT_PGM_RATIOS;
+       u32 saveBLC_HIST_CTL;
        u32 saveBLC_PWM_CTL;
        u32 saveBLC_PWM_CTL2;
+       u32 saveBLC_CPU_PWM_CTL;
+       u32 saveBLC_CPU_PWM_CTL2;
        u32 saveFPB0;
        u32 saveFPB1;
        u32 saveDPLL_B;
@@ -317,6 +326,12 @@ typedef struct drm_i915_private {
        u32 saveVBLANK_B;
        u32 saveVSYNC_B;
        u32 saveBCLRPAT_B;
+       u32 saveTRANS_HTOTAL_B;
+       u32 saveTRANS_HBLANK_B;
+       u32 saveTRANS_HSYNC_B;
+       u32 saveTRANS_VTOTAL_B;
+       u32 saveTRANS_VBLANK_B;
+       u32 saveTRANS_VSYNC_B;
        u32 savePIPEBSTAT;
        u32 saveDSPBSTRIDE;
        u32 saveDSPBSIZE;
@@ -342,6 +357,7 @@ typedef struct drm_i915_private {
        u32 savePFIT_CONTROL;
        u32 save_palette_a[256];
        u32 save_palette_b[256];
+       u32 saveDPFC_CB_BASE;
        u32 saveFBC_CFB_BASE;
        u32 saveFBC_LL_BASE;
        u32 saveFBC_CONTROL;
@@ -349,6 +365,12 @@ typedef struct drm_i915_private {
        u32 saveIER;
        u32 saveIIR;
        u32 saveIMR;
+       u32 saveDEIER;
+       u32 saveDEIMR;
+       u32 saveGTIER;
+       u32 saveGTIMR;
+       u32 saveFDI_RXA_IMR;
+       u32 saveFDI_RXB_IMR;
        u32 saveCACHE_MODE_0;
        u32 saveD_STATE;
        u32 saveDSPCLK_GATE_D;
@@ -382,6 +404,16 @@ typedef struct drm_i915_private {
        u32 savePIPEB_DP_LINK_M;
        u32 savePIPEA_DP_LINK_N;
        u32 savePIPEB_DP_LINK_N;
+       u32 saveFDI_RXA_CTL;
+       u32 saveFDI_TXA_CTL;
+       u32 saveFDI_RXB_CTL;
+       u32 saveFDI_TXB_CTL;
+       u32 savePFA_CTL_1;
+       u32 savePFB_CTL_1;
+       u32 savePFA_WIN_SZ;
+       u32 savePFB_WIN_SZ;
+       u32 savePFA_WIN_POS;
+       u32 savePFB_WIN_POS;
 
        struct {
                struct drm_mm gtt_space;
@@ -492,6 +524,8 @@ typedef struct drm_i915_private {
                struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
        } mm;
        struct sdvo_device_mapping sdvo_mappings[2];
+       /* indicate whether the LVDS_BORDER should be enabled or not */
+       unsigned int lvds_border_bits;
 
        /* Reclocking support */
        bool render_reclock_avail;
@@ -981,7 +1015,10 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
 
 #define HAS_FW_BLC(dev) (IS_I9XX(dev) || IS_G4X(dev) || IS_IGDNG(dev))
 #define HAS_PIPE_CXSR(dev) (IS_G4X(dev) || IS_IGDNG(dev))
-#define I915_HAS_FBC(dev) (IS_MOBILE(dev) && (IS_I9XX(dev) || IS_I965G(dev)))
+#define I915_HAS_FBC(dev) (IS_MOBILE(dev) && \
+                          (IS_I9XX(dev) || IS_GM45(dev)) && \
+                          !IS_IGD(dev) && \
+                          !IS_IGDNG(dev))
 
 #define PRIMARY_RINGBUFFER_SIZE         (128*1024)
 
index 0466ddb..1687edf 100644 (file)
 #define   LVDS_PORT_EN                 (1 << 31)
 /* Selects pipe B for LVDS data.  Must be set on pre-965. */
 #define   LVDS_PIPEB_SELECT            (1 << 30)
+/* Enable border for unscaled (or aspect-scaled) display */
+#define   LVDS_BORDER_ENABLE           (1 << 15)
 /*
  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
  * pixel.
 #define   BACKLIGHT_DUTY_CYCLE_SHIFT           (0)
 #define   BACKLIGHT_DUTY_CYCLE_MASK            (0xffff)
 
+#define BLC_HIST_CTL           0x61260
+
 /* TV port control */
 #define TV_CTL                 0x68000
 /** Enables the TV encoder */
 #define   PIPE_START_VBLANK_INTERRUPT_STATUS   (1UL<<2) /* 965 or later */
 #define   PIPE_VBLANK_INTERRUPT_STATUS         (1UL<<1)
 #define   PIPE_OVERLAY_UPDATED_STATUS          (1UL<<0)
+#define   PIPE_BPC_MASK                        (7 << 5) /* Ironlake */
+#define   PIPE_8BPC                            (0 << 5)
+#define   PIPE_10BPC                           (1 << 5)
+#define   PIPE_6BPC                            (2 << 5)
+#define   PIPE_12BPC                           (3 << 5)
 
 #define DSPARB                 0x70030
 #define   DSPARB_CSTART_MASK   (0x7f << 7)
 #define   DSPARB_AEND_SHIFT    0
 
 #define DSPFW1                 0x70034
+#define   DSPFW_SR_SHIFT       23
+#define   DSPFW_CURSORB_SHIFT  16
+#define   DSPFW_PLANEB_SHIFT   8
 #define DSPFW2                 0x70038
+#define   DSPFW_CURSORA_MASK   0x00003f00
+#define   DSPFW_CURSORA_SHIFT  16
 #define DSPFW3                 0x7003c
+#define   DSPFW_HPLL_SR_EN     (1<<31)
+#define   DSPFW_CURSOR_SR_SHIFT        24
 #define   IGD_SELF_REFRESH_EN  (1<<30)
 
 /* FIFO watermark sizes etc */
+#define G4X_FIFO_LINE_SIZE     64
 #define I915_FIFO_LINE_SIZE    64
 #define I830_FIFO_LINE_SIZE    32
+
+#define G4X_FIFO_SIZE          127
 #define I945_FIFO_SIZE         127 /* 945 & 965 */
 #define I915_FIFO_SIZE         95
 #define I855GM_FIFO_SIZE       127 /* In cachelines */
 #define I830_FIFO_SIZE         95
+
+#define G4X_MAX_WM             0x3f
 #define I915_MAX_WM            0x3f
 
 #define IGD_DISPLAY_FIFO       512 /* in 64byte unit */
 #define PFA_CTL_1               0x68080
 #define PFB_CTL_1               0x68880
 #define  PF_ENABLE              (1<<31)
+#define  PF_FILTER_MASK                (3<<23)
+#define  PF_FILTER_PROGRAMMED  (0<<23)
+#define  PF_FILTER_MED_3x3     (1<<23)
+#define  PF_FILTER_EDGE_ENHANCE        (2<<23)
+#define  PF_FILTER_EDGE_SOFTEN (3<<23)
 #define PFA_WIN_SZ             0x68074
 #define PFB_WIN_SZ             0x68874
 #define PFA_WIN_POS            0x68070
 #define  DREF_CPU_SOURCE_OUTPUT_MASK           (3<<13)
 #define  DREF_SSC_SOURCE_DISABLE                (0<<11)
 #define  DREF_SSC_SOURCE_ENABLE                 (2<<11)
-#define  DREF_SSC_SOURCE_MASK                  (2<<11)
+#define  DREF_SSC_SOURCE_MASK                  (3<<11)
 #define  DREF_NONSPREAD_SOURCE_DISABLE          (0<<9)
 #define  DREF_NONSPREAD_CK505_ENABLE           (1<<9)
 #define  DREF_NONSPREAD_SOURCE_ENABLE           (2<<9)
-#define  DREF_NONSPREAD_SOURCE_MASK            (2<<9)
+#define  DREF_NONSPREAD_SOURCE_MASK            (3<<9)
 #define  DREF_SUPERSPREAD_SOURCE_DISABLE        (0<<7)
 #define  DREF_SUPERSPREAD_SOURCE_ENABLE         (2<<7)
 #define  DREF_SSC4_DOWNSPREAD                   (0<<6)
index bd6d8d9..992d561 100644 (file)
 static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
+       u32     dpll_reg;
 
-       if (pipe == PIPE_A)
-               return (I915_READ(DPLL_A) & DPLL_VCO_ENABLE);
-       else
-               return (I915_READ(DPLL_B) & DPLL_VCO_ENABLE);
+       if (IS_IGDNG(dev)) {
+               dpll_reg = (pipe == PIPE_A) ? PCH_DPLL_A: PCH_DPLL_B;
+       } else {
+               dpll_reg = (pipe == PIPE_A) ? DPLL_A: DPLL_B;
+       }
+
+       return (I915_READ(dpll_reg) & DPLL_VCO_ENABLE);
 }
 
 static void i915_save_palette(struct drm_device *dev, enum pipe pipe)
@@ -49,6 +53,9 @@ static void i915_save_palette(struct drm_device *dev, enum pipe pipe)
        if (!i915_pipe_enabled(dev, pipe))
                return;
 
+       if (IS_IGDNG(dev))
+               reg = (pipe == PIPE_A) ? LGC_PALETTE_A : LGC_PALETTE_B;
+
        if (pipe == PIPE_A)
                array = dev_priv->save_palette_a;
        else
@@ -68,6 +75,9 @@ static void i915_restore_palette(struct drm_device *dev, enum pipe pipe)
        if (!i915_pipe_enabled(dev, pipe))
                return;
 
+       if (IS_IGDNG(dev))
+               reg = (pipe == PIPE_A) ? LGC_PALETTE_A : LGC_PALETTE_B;
+
        if (pipe == PIPE_A)
                array = dev_priv->save_palette_a;
        else
@@ -232,10 +242,16 @@ static void i915_save_modeset_reg(struct drm_device *dev)
        /* Pipe & plane A info */
        dev_priv->savePIPEACONF = I915_READ(PIPEACONF);
        dev_priv->savePIPEASRC = I915_READ(PIPEASRC);
-       dev_priv->saveFPA0 = I915_READ(FPA0);
-       dev_priv->saveFPA1 = I915_READ(FPA1);
-       dev_priv->saveDPLL_A = I915_READ(DPLL_A);
-       if (IS_I965G(dev))
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveFPA0 = I915_READ(PCH_FPA0);
+               dev_priv->saveFPA1 = I915_READ(PCH_FPA1);
+               dev_priv->saveDPLL_A = I915_READ(PCH_DPLL_A);
+       } else {
+               dev_priv->saveFPA0 = I915_READ(FPA0);
+               dev_priv->saveFPA1 = I915_READ(FPA1);
+               dev_priv->saveDPLL_A = I915_READ(DPLL_A);
+       }
+       if (IS_I965G(dev) && !IS_IGDNG(dev))
                dev_priv->saveDPLL_A_MD = I915_READ(DPLL_A_MD);
        dev_priv->saveHTOTAL_A = I915_READ(HTOTAL_A);
        dev_priv->saveHBLANK_A = I915_READ(HBLANK_A);
@@ -243,7 +259,24 @@ static void i915_save_modeset_reg(struct drm_device *dev)
        dev_priv->saveVTOTAL_A = I915_READ(VTOTAL_A);
        dev_priv->saveVBLANK_A = I915_READ(VBLANK_A);
        dev_priv->saveVSYNC_A = I915_READ(VSYNC_A);
-       dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
+       if (!IS_IGDNG(dev))
+               dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
+
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveFDI_TXA_CTL = I915_READ(FDI_TXA_CTL);
+               dev_priv->saveFDI_RXA_CTL = I915_READ(FDI_RXA_CTL);
+
+               dev_priv->savePFA_CTL_1 = I915_READ(PFA_CTL_1);
+               dev_priv->savePFA_WIN_SZ = I915_READ(PFA_WIN_SZ);
+               dev_priv->savePFA_WIN_POS = I915_READ(PFA_WIN_POS);
+
+               dev_priv->saveTRANS_HTOTAL_A = I915_READ(TRANS_HTOTAL_A);
+               dev_priv->saveTRANS_HBLANK_A = I915_READ(TRANS_HBLANK_A);
+               dev_priv->saveTRANS_HSYNC_A = I915_READ(TRANS_HSYNC_A);
+               dev_priv->saveTRANS_VTOTAL_A = I915_READ(TRANS_VTOTAL_A);
+               dev_priv->saveTRANS_VBLANK_A = I915_READ(TRANS_VBLANK_A);
+               dev_priv->saveTRANS_VSYNC_A = I915_READ(TRANS_VSYNC_A);
+       }
 
        dev_priv->saveDSPACNTR = I915_READ(DSPACNTR);
        dev_priv->saveDSPASTRIDE = I915_READ(DSPASTRIDE);
@@ -260,10 +293,16 @@ static void i915_save_modeset_reg(struct drm_device *dev)
        /* Pipe & plane B info */
        dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF);
        dev_priv->savePIPEBSRC = I915_READ(PIPEBSRC);
-       dev_priv->saveFPB0 = I915_READ(FPB0);
-       dev_priv->saveFPB1 = I915_READ(FPB1);
-       dev_priv->saveDPLL_B = I915_READ(DPLL_B);
-       if (IS_I965G(dev))
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveFPB0 = I915_READ(PCH_FPB0);
+               dev_priv->saveFPB1 = I915_READ(PCH_FPB1);
+               dev_priv->saveDPLL_B = I915_READ(PCH_DPLL_B);
+       } else {
+               dev_priv->saveFPB0 = I915_READ(FPB0);
+               dev_priv->saveFPB1 = I915_READ(FPB1);
+               dev_priv->saveDPLL_B = I915_READ(DPLL_B);
+       }
+       if (IS_I965G(dev) && !IS_IGDNG(dev))
                dev_priv->saveDPLL_B_MD = I915_READ(DPLL_B_MD);
        dev_priv->saveHTOTAL_B = I915_READ(HTOTAL_B);
        dev_priv->saveHBLANK_B = I915_READ(HBLANK_B);
@@ -271,7 +310,24 @@ static void i915_save_modeset_reg(struct drm_device *dev)
        dev_priv->saveVTOTAL_B = I915_READ(VTOTAL_B);
        dev_priv->saveVBLANK_B = I915_READ(VBLANK_B);
        dev_priv->saveVSYNC_B = I915_READ(VSYNC_B);
-       dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
+       if (!IS_IGDNG(dev))
+               dev_priv->saveBCLRPAT_B = I915_READ(BCLRPAT_B);
+
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveFDI_TXB_CTL = I915_READ(FDI_TXB_CTL);
+               dev_priv->saveFDI_RXB_CTL = I915_READ(FDI_RXB_CTL);
+
+               dev_priv->savePFB_CTL_1 = I915_READ(PFB_CTL_1);
+               dev_priv->savePFB_WIN_SZ = I915_READ(PFB_WIN_SZ);
+               dev_priv->savePFB_WIN_POS = I915_READ(PFB_WIN_POS);
+
+               dev_priv->saveTRANS_HTOTAL_B = I915_READ(TRANS_HTOTAL_B);
+               dev_priv->saveTRANS_HBLANK_B = I915_READ(TRANS_HBLANK_B);
+               dev_priv->saveTRANS_HSYNC_B = I915_READ(TRANS_HSYNC_B);
+               dev_priv->saveTRANS_VTOTAL_B = I915_READ(TRANS_VTOTAL_B);
+               dev_priv->saveTRANS_VBLANK_B = I915_READ(TRANS_VBLANK_B);
+               dev_priv->saveTRANS_VSYNC_B = I915_READ(TRANS_VSYNC_B);
+       }
 
        dev_priv->saveDSPBCNTR = I915_READ(DSPBCNTR);
        dev_priv->saveDSPBSTRIDE = I915_READ(DSPBSTRIDE);
@@ -290,23 +346,41 @@ static void i915_save_modeset_reg(struct drm_device *dev)
 static void i915_restore_modeset_reg(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
+       int dpll_a_reg, fpa0_reg, fpa1_reg;
+       int dpll_b_reg, fpb0_reg, fpb1_reg;
 
        if (drm_core_check_feature(dev, DRIVER_MODESET))
                return;
 
+       if (IS_IGDNG(dev)) {
+               dpll_a_reg = PCH_DPLL_A;
+               dpll_b_reg = PCH_DPLL_B;
+               fpa0_reg = PCH_FPA0;
+               fpb0_reg = PCH_FPB0;
+               fpa1_reg = PCH_FPA1;
+               fpb1_reg = PCH_FPB1;
+       } else {
+               dpll_a_reg = DPLL_A;
+               dpll_b_reg = DPLL_B;
+               fpa0_reg = FPA0;
+               fpb0_reg = FPB0;
+               fpa1_reg = FPA1;
+               fpb1_reg = FPB1;
+       }
+
        /* Pipe & plane A info */
        /* Prime the clock */
        if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) {
-               I915_WRITE(DPLL_A, dev_priv->saveDPLL_A &
+               I915_WRITE(dpll_a_reg, dev_priv->saveDPLL_A &
                           ~DPLL_VCO_ENABLE);
                DRM_UDELAY(150);
        }
-       I915_WRITE(FPA0, dev_priv->saveFPA0);
-       I915_WRITE(FPA1, dev_priv->saveFPA1);
+       I915_WRITE(fpa0_reg, dev_priv->saveFPA0);
+       I915_WRITE(fpa1_reg, dev_priv->saveFPA1);
        /* Actually enable it */
-       I915_WRITE(DPLL_A, dev_priv->saveDPLL_A);
+       I915_WRITE(dpll_a_reg, dev_priv->saveDPLL_A);
        DRM_UDELAY(150);
-       if (IS_I965G(dev))
+       if (IS_I965G(dev) && !IS_IGDNG(dev))
                I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD);
        DRM_UDELAY(150);
 
@@ -317,7 +391,24 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
        I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A);
        I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A);
        I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A);
-       I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
+       if (!IS_IGDNG(dev))
+               I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
+
+       if (IS_IGDNG(dev)) {
+               I915_WRITE(FDI_RXA_CTL, dev_priv->saveFDI_RXA_CTL);
+               I915_WRITE(FDI_TXA_CTL, dev_priv->saveFDI_TXA_CTL);
+
+               I915_WRITE(PFA_CTL_1, dev_priv->savePFA_CTL_1);
+               I915_WRITE(PFA_WIN_SZ, dev_priv->savePFA_WIN_SZ);
+               I915_WRITE(PFA_WIN_POS, dev_priv->savePFA_WIN_POS);
+
+               I915_WRITE(TRANS_HTOTAL_A, dev_priv->saveTRANS_HTOTAL_A);
+               I915_WRITE(TRANS_HBLANK_A, dev_priv->saveTRANS_HBLANK_A);
+               I915_WRITE(TRANS_HSYNC_A, dev_priv->saveTRANS_HSYNC_A);
+               I915_WRITE(TRANS_VTOTAL_A, dev_priv->saveTRANS_VTOTAL_A);
+               I915_WRITE(TRANS_VBLANK_A, dev_priv->saveTRANS_VBLANK_A);
+               I915_WRITE(TRANS_VSYNC_A, dev_priv->saveTRANS_VSYNC_A);
+       }
 
        /* Restore plane info */
        I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE);
@@ -339,14 +430,14 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
 
        /* Pipe & plane B info */
        if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) {
-               I915_WRITE(DPLL_B, dev_priv->saveDPLL_B &
+               I915_WRITE(dpll_b_reg, dev_priv->saveDPLL_B &
                           ~DPLL_VCO_ENABLE);
                DRM_UDELAY(150);
        }
-       I915_WRITE(FPB0, dev_priv->saveFPB0);
-       I915_WRITE(FPB1, dev_priv->saveFPB1);
+       I915_WRITE(fpb0_reg, dev_priv->saveFPB0);
+       I915_WRITE(fpb1_reg, dev_priv->saveFPB1);
        /* Actually enable it */
-       I915_WRITE(DPLL_B, dev_priv->saveDPLL_B);
+       I915_WRITE(dpll_b_reg, dev_priv->saveDPLL_B);
        DRM_UDELAY(150);
        if (IS_I965G(dev))
                I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD);
@@ -359,7 +450,24 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
        I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B);
        I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B);
        I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B);
-       I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
+       if (!IS_IGDNG(dev))
+               I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
+
+       if (IS_IGDNG(dev)) {
+               I915_WRITE(FDI_RXB_CTL, dev_priv->saveFDI_RXB_CTL);
+               I915_WRITE(FDI_TXB_CTL, dev_priv->saveFDI_TXB_CTL);
+
+               I915_WRITE(PFB_CTL_1, dev_priv->savePFB_CTL_1);
+               I915_WRITE(PFB_WIN_SZ, dev_priv->savePFB_WIN_SZ);
+               I915_WRITE(PFB_WIN_POS, dev_priv->savePFB_WIN_POS);
+
+               I915_WRITE(TRANS_HTOTAL_B, dev_priv->saveTRANS_HTOTAL_B);
+               I915_WRITE(TRANS_HBLANK_B, dev_priv->saveTRANS_HBLANK_B);
+               I915_WRITE(TRANS_HSYNC_B, dev_priv->saveTRANS_HSYNC_B);
+               I915_WRITE(TRANS_VTOTAL_B, dev_priv->saveTRANS_VTOTAL_B);
+               I915_WRITE(TRANS_VBLANK_B, dev_priv->saveTRANS_VBLANK_B);
+               I915_WRITE(TRANS_VSYNC_B, dev_priv->saveTRANS_VSYNC_B);
+       }
 
        /* Restore plane info */
        I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE);
@@ -404,21 +512,43 @@ void i915_save_display(struct drm_device *dev)
                dev_priv->saveCURSIZE = I915_READ(CURSIZE);
 
        /* CRT state */
-       dev_priv->saveADPA = I915_READ(ADPA);
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveADPA = I915_READ(PCH_ADPA);
+       } else {
+               dev_priv->saveADPA = I915_READ(ADPA);
+       }
 
        /* LVDS state */
-       dev_priv->savePP_CONTROL = I915_READ(PP_CONTROL);
-       dev_priv->savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS);
-       dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL);
-       if (IS_I965G(dev))
-               dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
-       if (IS_MOBILE(dev) && !IS_I830(dev))
-               dev_priv->saveLVDS = I915_READ(LVDS);
-       if (!IS_I830(dev) && !IS_845G(dev))
+       if (IS_IGDNG(dev)) {
+               dev_priv->savePP_CONTROL = I915_READ(PCH_PP_CONTROL);
+               dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_PCH_CTL1);
+               dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_PCH_CTL2);
+               dev_priv->saveBLC_CPU_PWM_CTL = I915_READ(BLC_PWM_CPU_CTL);
+               dev_priv->saveBLC_CPU_PWM_CTL2 = I915_READ(BLC_PWM_CPU_CTL2);
+               dev_priv->saveLVDS = I915_READ(PCH_LVDS);
+       } else {
+               dev_priv->savePP_CONTROL = I915_READ(PP_CONTROL);
+               dev_priv->savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS);
+               dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL);
+               dev_priv->saveBLC_HIST_CTL = I915_READ(BLC_HIST_CTL);
+               if (IS_I965G(dev))
+                       dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
+               if (IS_MOBILE(dev) && !IS_I830(dev))
+                       dev_priv->saveLVDS = I915_READ(LVDS);
+       }
+
+       if (!IS_I830(dev) && !IS_845G(dev) && !IS_IGDNG(dev))
                dev_priv->savePFIT_CONTROL = I915_READ(PFIT_CONTROL);
-       dev_priv->savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS);
-       dev_priv->savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
-       dev_priv->savePP_DIVISOR = I915_READ(PP_DIVISOR);
+
+       if (IS_IGDNG(dev)) {
+               dev_priv->savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS);
+               dev_priv->savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS);
+               dev_priv->savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR);
+       } else {
+               dev_priv->savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS);
+               dev_priv->savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
+               dev_priv->savePP_DIVISOR = I915_READ(PP_DIVISOR);
+       }
 
        /* Display Port state */
        if (SUPPORTS_INTEGRATED_DP(dev)) {
@@ -437,16 +567,23 @@ void i915_save_display(struct drm_device *dev)
        /* FIXME: save TV & SDVO state */
 
        /* FBC state */
-       dev_priv->saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE);
-       dev_priv->saveFBC_LL_BASE = I915_READ(FBC_LL_BASE);
-       dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2);
-       dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL);
+       if (IS_GM45(dev)) {
+               dev_priv->saveDPFC_CB_BASE = I915_READ(DPFC_CB_BASE);
+       } else {
+               dev_priv->saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE);
+               dev_priv->saveFBC_LL_BASE = I915_READ(FBC_LL_BASE);
+               dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2);
+               dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL);
+       }
 
        /* VGA state */
        dev_priv->saveVGA0 = I915_READ(VGA0);
        dev_priv->saveVGA1 = I915_READ(VGA1);
        dev_priv->saveVGA_PD = I915_READ(VGA_PD);
-       dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);
+       if (IS_IGDNG(dev))
+               dev_priv->saveVGACNTRL = I915_READ(CPU_VGACNTRL);
+       else
+               dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);
 
        i915_save_vga(dev);
 }
@@ -485,22 +622,41 @@ void i915_restore_display(struct drm_device *dev)
                I915_WRITE(CURSIZE, dev_priv->saveCURSIZE);
 
        /* CRT state */
-       I915_WRITE(ADPA, dev_priv->saveADPA);
+       if (IS_IGDNG(dev))
+               I915_WRITE(PCH_ADPA, dev_priv->saveADPA);
+       else
+               I915_WRITE(ADPA, dev_priv->saveADPA);
 
        /* LVDS state */
-       if (IS_I965G(dev))
+       if (IS_I965G(dev) && !IS_IGDNG(dev))
                I915_WRITE(BLC_PWM_CTL2, dev_priv->saveBLC_PWM_CTL2);
-       if (IS_MOBILE(dev) && !IS_I830(dev))
+
+       if (IS_IGDNG(dev)) {
+               I915_WRITE(PCH_LVDS, dev_priv->saveLVDS);
+       } else if (IS_MOBILE(dev) && !IS_I830(dev))
                I915_WRITE(LVDS, dev_priv->saveLVDS);
-       if (!IS_I830(dev) && !IS_845G(dev))
+
+       if (!IS_I830(dev) && !IS_845G(dev) && !IS_IGDNG(dev))
                I915_WRITE(PFIT_CONTROL, dev_priv->savePFIT_CONTROL);
 
-       I915_WRITE(PFIT_PGM_RATIOS, dev_priv->savePFIT_PGM_RATIOS);
-       I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL);
-       I915_WRITE(PP_ON_DELAYS, dev_priv->savePP_ON_DELAYS);
-       I915_WRITE(PP_OFF_DELAYS, dev_priv->savePP_OFF_DELAYS);
-       I915_WRITE(PP_DIVISOR, dev_priv->savePP_DIVISOR);
-       I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL);
+       if (IS_IGDNG(dev)) {
+               I915_WRITE(BLC_PWM_PCH_CTL1, dev_priv->saveBLC_PWM_CTL);
+               I915_WRITE(BLC_PWM_PCH_CTL2, dev_priv->saveBLC_PWM_CTL2);
+               I915_WRITE(BLC_PWM_CPU_CTL, dev_priv->saveBLC_CPU_PWM_CTL);
+               I915_WRITE(BLC_PWM_CPU_CTL2, dev_priv->saveBLC_CPU_PWM_CTL2);
+               I915_WRITE(PCH_PP_ON_DELAYS, dev_priv->savePP_ON_DELAYS);
+               I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->savePP_OFF_DELAYS);
+               I915_WRITE(PCH_PP_DIVISOR, dev_priv->savePP_DIVISOR);
+               I915_WRITE(PCH_PP_CONTROL, dev_priv->savePP_CONTROL);
+       } else {
+               I915_WRITE(PFIT_PGM_RATIOS, dev_priv->savePFIT_PGM_RATIOS);
+               I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL);
+               I915_WRITE(BLC_HIST_CTL, dev_priv->saveBLC_HIST_CTL);
+               I915_WRITE(PP_ON_DELAYS, dev_priv->savePP_ON_DELAYS);
+               I915_WRITE(PP_OFF_DELAYS, dev_priv->savePP_OFF_DELAYS);
+               I915_WRITE(PP_DIVISOR, dev_priv->savePP_DIVISOR);
+               I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL);
+       }
 
        /* Display Port state */
        if (SUPPORTS_INTEGRATED_DP(dev)) {
@@ -511,13 +667,22 @@ void i915_restore_display(struct drm_device *dev)
        /* FIXME: restore TV & SDVO state */
 
        /* FBC info */
-       I915_WRITE(FBC_CFB_BASE, dev_priv->saveFBC_CFB_BASE);
-       I915_WRITE(FBC_LL_BASE, dev_priv->saveFBC_LL_BASE);
-       I915_WRITE(FBC_CONTROL2, dev_priv->saveFBC_CONTROL2);
-       I915_WRITE(FBC_CONTROL, dev_priv->saveFBC_CONTROL);
+       if (IS_GM45(dev)) {
+               g4x_disable_fbc(dev);
+               I915_WRITE(DPFC_CB_BASE, dev_priv->saveDPFC_CB_BASE);
+       } else {
+               i8xx_disable_fbc(dev);
+               I915_WRITE(FBC_CFB_BASE, dev_priv->saveFBC_CFB_BASE);
+               I915_WRITE(FBC_LL_BASE, dev_priv->saveFBC_LL_BASE);
+               I915_WRITE(FBC_CONTROL2, dev_priv->saveFBC_CONTROL2);
+               I915_WRITE(FBC_CONTROL, dev_priv->saveFBC_CONTROL);
+       }
 
        /* VGA state */
-       I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);
+       if (IS_IGDNG(dev))
+               I915_WRITE(CPU_VGACNTRL, dev_priv->saveVGACNTRL);
+       else
+               I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);
        I915_WRITE(VGA0, dev_priv->saveVGA0);
        I915_WRITE(VGA1, dev_priv->saveVGA1);
        I915_WRITE(VGA_PD, dev_priv->saveVGA_PD);
@@ -543,8 +708,17 @@ int i915_save_state(struct drm_device *dev)
        i915_save_display(dev);
 
        /* Interrupt state */
-       dev_priv->saveIER = I915_READ(IER);
-       dev_priv->saveIMR = I915_READ(IMR);
+       if (IS_IGDNG(dev)) {
+               dev_priv->saveDEIER = I915_READ(DEIER);
+               dev_priv->saveDEIMR = I915_READ(DEIMR);
+               dev_priv->saveGTIER = I915_READ(GTIER);
+               dev_priv->saveGTIMR = I915_READ(GTIMR);
+               dev_priv->saveFDI_RXA_IMR = I915_READ(FDI_RXA_IMR);
+               dev_priv->saveFDI_RXB_IMR = I915_READ(FDI_RXB_IMR);
+       } else {
+               dev_priv->saveIER = I915_READ(IER);
+               dev_priv->saveIMR = I915_READ(IMR);
+       }
 
        /* Clock gating state */
        dev_priv->saveD_STATE = I915_READ(D_STATE);
@@ -609,8 +783,17 @@ int i915_restore_state(struct drm_device *dev)
        i915_restore_display(dev);
 
        /* Interrupt state */
-       I915_WRITE (IER, dev_priv->saveIER);
-       I915_WRITE (IMR,  dev_priv->saveIMR);
+       if (IS_IGDNG(dev)) {
+               I915_WRITE(DEIER, dev_priv->saveDEIER);
+               I915_WRITE(DEIMR, dev_priv->saveDEIMR);
+               I915_WRITE(GTIER, dev_priv->saveGTIER);
+               I915_WRITE(GTIMR, dev_priv->saveGTIMR);
+               I915_WRITE(FDI_RXA_IMR, dev_priv->saveFDI_RXA_IMR);
+               I915_WRITE(FDI_RXB_IMR, dev_priv->saveFDI_RXB_IMR);
+       } else {
+               I915_WRITE (IER, dev_priv->saveIER);
+               I915_WRITE (IMR,  dev_priv->saveIMR);
+       }
 
        /* Clock gating state */
        I915_WRITE (D_STATE, dev_priv->saveD_STATE);
index 4337414..96cd256 100644 (file)
@@ -351,20 +351,18 @@ parse_driver_features(struct drm_i915_private *dev_priv,
        struct drm_device *dev = dev_priv->dev;
        struct bdb_driver_features *driver;
 
-       /* set default for chips without eDP */
-       if (!SUPPORTS_EDP(dev)) {
-               dev_priv->edp_support = 0;
-               return;
-       }
-
        driver = find_section(bdb, BDB_DRIVER_FEATURES);
        if (!driver)
                return;
 
-       if (driver->lvds_config == BDB_DRIVER_FEATURE_EDP)
+       if (driver && SUPPORTS_EDP(dev) &&
+           driver->lvds_config == BDB_DRIVER_FEATURE_EDP) {
                dev_priv->edp_support = 1;
+       } else {
+               dev_priv->edp_support = 0;
+       }
 
-       if (driver->dual_frequency)
+       if (driver && driver->dual_frequency)
                dev_priv->render_reclock_avail = true;
 }
 
index 3c14240..3ba6546 100644 (file)
@@ -943,6 +943,7 @@ intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
     clock.m = 5 * (clock.m1 + 2) + (clock.m2 + 2);
     clock.p = (clock.p1 * clock.p2);
     clock.dot = 96000 * clock.m / (clock.n + 2) / clock.p;
+    clock.vco = 0;
     memcpy(best_clock, &clock, sizeof(intel_clock_t));
     return true;
 }
@@ -1260,9 +1261,11 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
                return ret;
        }
 
-       /* Pre-i965 needs to install a fence for tiled scan-out */
-       if (!IS_I965G(dev) &&
-           obj_priv->fence_reg == I915_FENCE_REG_NONE &&
+       /* Install a fence for tiled scan-out. Pre-i965 always needs a fence,
+        * whereas 965+ only requires a fence if using framebuffer compression.
+        * For simplicity, we always install a fence as the cost is not that onerous.
+        */
+       if (obj_priv->fence_reg == I915_FENCE_REG_NONE &&
            obj_priv->tiling_mode != I915_TILING_NONE) {
                ret = i915_gem_object_get_fence_reg(obj);
                if (ret != 0) {
@@ -1513,7 +1516,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
                /* Enable panel fitting for LVDS */
                if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
                        temp = I915_READ(pf_ctl_reg);
-                       I915_WRITE(pf_ctl_reg, temp | PF_ENABLE);
+                       I915_WRITE(pf_ctl_reg, temp | PF_ENABLE | PF_FILTER_MED_3x3);
 
                        /* currently full aspect */
                        I915_WRITE(pf_win_pos, 0);
@@ -1801,6 +1804,8 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
        case DRM_MODE_DPMS_ON:
        case DRM_MODE_DPMS_STANDBY:
        case DRM_MODE_DPMS_SUSPEND:
+               intel_update_watermarks(dev);
+
                /* Enable the DPLL */
                temp = I915_READ(dpll_reg);
                if ((temp & DPLL_VCO_ENABLE) == 0) {
@@ -1838,7 +1843,6 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
 
                /* Give the overlay scaler a chance to enable if it's on this pipe */
                //intel_crtc_dpms_video(crtc, true); TODO
-               intel_update_watermarks(dev);
        break;
        case DRM_MODE_DPMS_OFF:
                intel_update_watermarks(dev);
@@ -2082,7 +2086,7 @@ fdi_reduce_ratio(u32 *num, u32 *den)
 #define LINK_N 0x80000
 
 static void
-igdng_compute_m_n(int bytes_per_pixel, int nlanes,
+igdng_compute_m_n(int bits_per_pixel, int nlanes,
                int pixel_clock, int link_clock,
                struct fdi_m_n *m_n)
 {
@@ -2092,7 +2096,8 @@ igdng_compute_m_n(int bytes_per_pixel, int nlanes,
 
        temp = (u64) DATA_N * pixel_clock;
        temp = div_u64(temp, link_clock);
-       m_n->gmch_m = div_u64(temp * bytes_per_pixel, nlanes);
+       m_n->gmch_m = div_u64(temp * bits_per_pixel, nlanes);
+       m_n->gmch_m >>= 3; /* convert to bytes_per_pixel */
        m_n->gmch_n = DATA_N;
        fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
 
@@ -2140,6 +2145,13 @@ static struct intel_watermark_params igd_cursor_hplloff_wm = {
        IGD_CURSOR_GUARD_WM,
        IGD_FIFO_LINE_SIZE
 };
+static struct intel_watermark_params g4x_wm_info = {
+       G4X_FIFO_SIZE,
+       G4X_MAX_WM,
+       G4X_MAX_WM,
+       2,
+       G4X_FIFO_LINE_SIZE,
+};
 static struct intel_watermark_params i945_wm_info = {
        I945_FIFO_SIZE,
        I915_MAX_WM,
@@ -2430,17 +2442,74 @@ static int i830_get_fifo_size(struct drm_device *dev, int plane)
        return size;
 }
 
-static void g4x_update_wm(struct drm_device *dev, int unused, int unused2,
-                         int unused3, int unused4)
+static void g4x_update_wm(struct drm_device *dev,  int planea_clock,
+                         int planeb_clock, int sr_hdisplay, int pixel_size)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       u32 fw_blc_self = I915_READ(FW_BLC_SELF);
+       int total_size, cacheline_size;
+       int planea_wm, planeb_wm, cursora_wm, cursorb_wm, cursor_sr;
+       struct intel_watermark_params planea_params, planeb_params;
+       unsigned long line_time_us;
+       int sr_clock, sr_entries = 0, entries_required;
 
-       if (i915_powersave)
-               fw_blc_self |= FW_BLC_SELF_EN;
-       else
-               fw_blc_self &= ~FW_BLC_SELF_EN;
-       I915_WRITE(FW_BLC_SELF, fw_blc_self);
+       /* Create copies of the base settings for each pipe */
+       planea_params = planeb_params = g4x_wm_info;
+
+       /* Grab a couple of global values before we overwrite them */
+       total_size = planea_params.fifo_size;
+       cacheline_size = planea_params.cacheline_size;
+
+       /*
+        * Note: we need to make sure we don't overflow for various clock &
+        * latency values.
+        * clocks go from a few thousand to several hundred thousand.
+        * latency is usually a few thousand
+        */
+       entries_required = ((planea_clock / 1000) * pixel_size * latency_ns) /
+               1000;
+       entries_required /= G4X_FIFO_LINE_SIZE;
+       planea_wm = entries_required + planea_params.guard_size;
+
+       entries_required = ((planeb_clock / 1000) * pixel_size * latency_ns) /
+               1000;
+       entries_required /= G4X_FIFO_LINE_SIZE;
+       planeb_wm = entries_required + planeb_params.guard_size;
+
+       cursora_wm = cursorb_wm = 16;
+       cursor_sr = 32;
+
+       DRM_DEBUG("FIFO watermarks - A: %d, B: %d\n", planea_wm, planeb_wm);
+
+       /* Calc sr entries for one plane configs */
+       if (sr_hdisplay && (!planea_clock || !planeb_clock)) {
+               /* self-refresh has much higher latency */
+               const static int sr_latency_ns = 12000;
+
+               sr_clock = planea_clock ? planea_clock : planeb_clock;
+               line_time_us = ((sr_hdisplay * 1000) / sr_clock);
+
+               /* Use ns/us then divide to preserve precision */
+               sr_entries = (((sr_latency_ns / line_time_us) + 1) *
+                             pixel_size * sr_hdisplay) / 1000;
+               sr_entries = roundup(sr_entries / cacheline_size, 1);
+               DRM_DEBUG("self-refresh entries: %d\n", sr_entries);
+               I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN);
+       }
+
+       DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, SR %d\n",
+                 planea_wm, planeb_wm, sr_entries);
+
+       planea_wm &= 0x3f;
+       planeb_wm &= 0x3f;
+
+       I915_WRITE(DSPFW1, (sr_entries << DSPFW_SR_SHIFT) |
+                  (cursorb_wm << DSPFW_CURSORB_SHIFT) |
+                  (planeb_wm << DSPFW_PLANEB_SHIFT) | planea_wm);
+       I915_WRITE(DSPFW2, (I915_READ(DSPFW2) & DSPFW_CURSORA_MASK) |
+                  (cursora_wm << DSPFW_CURSORA_SHIFT));
+       /* HPLL off in SR has some issues on G4x... disable it */
+       I915_WRITE(DSPFW3, (I915_READ(DSPFW3) & ~DSPFW_HPLL_SR_EN) |
+                  (cursor_sr << DSPFW_CURSOR_SR_SHIFT));
 }
 
 static void i965_update_wm(struct drm_device *dev, int unused, int unused2,
@@ -2586,6 +2655,9 @@ static void intel_update_watermarks(struct drm_device *dev)
        unsigned long planea_clock = 0, planeb_clock = 0, sr_clock = 0;
        int enabled = 0, pixel_size = 0;
 
+       if (!dev_priv->display.update_wm)
+               return;
+
        /* Get the clock config from both planes */
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                intel_crtc = to_intel_crtc(crtc);
@@ -2763,7 +2835,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
 
        /* FDI link */
        if (IS_IGDNG(dev)) {
-               int lane, link_bw;
+               int lane, link_bw, bpp;
                /* eDP doesn't require FDI link, so just set DP M/N
                   according to current link config */
                if (is_edp) {
@@ -2782,10 +2854,72 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
                        lane = 4;
                        link_bw = 270000;
                }
-               igdng_compute_m_n(3, lane, target_clock,
+
+               /* determine panel color depth */
+               temp = I915_READ(pipeconf_reg);
+
+               switch (temp & PIPE_BPC_MASK) {
+               case PIPE_8BPC:
+                       bpp = 24;
+                       break;
+               case PIPE_10BPC:
+                       bpp = 30;
+                       break;
+               case PIPE_6BPC:
+                       bpp = 18;
+                       break;
+               case PIPE_12BPC:
+                       bpp = 36;
+                       break;
+               default:
+                       DRM_ERROR("unknown pipe bpc value\n");
+                       bpp = 24;
+               }
+
+               igdng_compute_m_n(bpp, lane, target_clock,
                                  link_bw, &m_n);
        }
 
+       /* Ironlake: try to setup display ref clock before DPLL
+        * enabling. This is only under driver's control after
+        * PCH B stepping, previous chipset stepping should be
+        * ignoring this setting.
+        */
+       if (IS_IGDNG(dev)) {
+               temp = I915_READ(PCH_DREF_CONTROL);
+               /* Always enable nonspread source */
+               temp &= ~DREF_NONSPREAD_SOURCE_MASK;
+               temp |= DREF_NONSPREAD_SOURCE_ENABLE;
+               I915_WRITE(PCH_DREF_CONTROL, temp);
+               POSTING_READ(PCH_DREF_CONTROL);
+
+               temp &= ~DREF_SSC_SOURCE_MASK;
+               temp |= DREF_SSC_SOURCE_ENABLE;
+               I915_WRITE(PCH_DREF_CONTROL, temp);
+               POSTING_READ(PCH_DREF_CONTROL);
+
+               udelay(200);
+
+               if (is_edp) {
+                       if (dev_priv->lvds_use_ssc) {
+                               temp |= DREF_SSC1_ENABLE;
+                               I915_WRITE(PCH_DREF_CONTROL, temp);
+                               POSTING_READ(PCH_DREF_CONTROL);
+
+                               udelay(200);
+
+                               temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
+                               temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD;
+                               I915_WRITE(PCH_DREF_CONTROL, temp);
+                               POSTING_READ(PCH_DREF_CONTROL);
+                       } else {
+                               temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD;
+                               I915_WRITE(PCH_DREF_CONTROL, temp);
+                               POSTING_READ(PCH_DREF_CONTROL);
+                       }
+               }
+       }
+
        if (IS_IGD(dev)) {
                fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2;
                if (has_reduced_clock)
@@ -2936,6 +3070,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
 
                lvds = I915_READ(lvds_reg);
                lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP | LVDS_PIPEB_SELECT;
+               /* set the corresponsding LVDS_BORDER bit */
+               lvds |= dev_priv->lvds_border_bits;
                /* Set the B0-B3 data pairs corresponding to whether we're going to
                 * set the DPLLs for dual-channel mode or not.
                 */
@@ -4124,7 +4260,9 @@ void intel_init_clock_gating(struct drm_device *dev)
         * Disable clock gating reported to work incorrectly according to the
         * specs, but enable as much else as we can.
         */
-       if (IS_G4X(dev)) {
+       if (IS_IGDNG(dev)) {
+               return;
+       } else if (IS_G4X(dev)) {
                uint32_t dspclk_gate;
                I915_WRITE(RENCLK_GATE_D1, 0);
                I915_WRITE(RENCLK_GATE_D2, VF_UNIT_CLOCK_GATE_DISABLE |
@@ -4212,7 +4350,9 @@ static void intel_init_display(struct drm_device *dev)
                        i830_get_display_clock_speed;
 
        /* For FIFO watermark updates */
-       if (IS_G4X(dev))
+       if (IS_IGDNG(dev))
+               dev_priv->display.update_wm = NULL;
+       else if (IS_G4X(dev))
                dev_priv->display.update_wm = g4x_update_wm;
        else if (IS_I965G(dev))
                dev_priv->display.update_wm = i965_update_wm;
index f4856a5..d834475 100644 (file)
@@ -400,7 +400,7 @@ intel_dp_i2c_init(struct intel_output *intel_output, const char *name)
 {
        struct intel_dp_priv   *dp_priv = intel_output->dev_priv;
 
-       DRM_ERROR("i2c_init %s\n", name);
+       DRM_DEBUG_KMS("i2c_init %s\n", name);
        dp_priv->algo.running = false;
        dp_priv->algo.address = 0;
        dp_priv->algo.aux_ch = intel_dp_i2c_aux_ch;
index 808bbe4..05598ae 100644 (file)
@@ -380,7 +380,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
                                adjusted_mode->crtc_vblank_start + vsync_pos;
                /* keep the vsync width constant */
                adjusted_mode->crtc_vsync_end =
-                               adjusted_mode->crtc_vblank_start + vsync_width;
+                               adjusted_mode->crtc_vsync_start + vsync_width;
                border = 1;
                break;
        case DRM_MODE_SCALE_ASPECT:
@@ -526,6 +526,14 @@ out:
        lvds_priv->pfit_control = pfit_control;
        lvds_priv->pfit_pgm_ratios = pfit_pgm_ratios;
        /*
+        * When there exists the border, it means that the LVDS_BORDR
+        * should be enabled.
+        */
+       if (border)
+               dev_priv->lvds_border_bits |= LVDS_BORDER_ENABLE;
+       else
+               dev_priv->lvds_border_bits &= ~(LVDS_BORDER_ENABLE);
+       /*
         * XXX: It would be nice to support lower refresh rates on the
         * panels to reduce power consumption, and perhaps match the
         * user's requested refresh rate.
index d379e74..4226e53 100644 (file)
@@ -150,8 +150,6 @@ struct eeepc_hotk {
 /* The actual device the driver binds to */
 static struct eeepc_hotk *ehotk;
 
-static void eeepc_rfkill_hotplug(bool real);
-
 /* Platform device/driver */
 static int eeepc_hotk_thaw(struct device *device);
 static int eeepc_hotk_restore(struct device *device);
@@ -345,16 +343,7 @@ static bool eeepc_wlan_rfkill_blocked(void)
 static int eeepc_rfkill_set(void *data, bool blocked)
 {
        unsigned long asl = (unsigned long)data;
-       int ret;
-
-       if (asl != CM_ASL_WLAN)
-               return set_acpi(asl, !blocked);
-
-       /* hack to avoid panic with rt2860sta */
-       if (blocked)
-               eeepc_rfkill_hotplug(false);
-       ret = set_acpi(asl, !blocked);
-       return ret;
+       return set_acpi(asl, !blocked);
 }
 
 static const struct rfkill_ops eeepc_rfkill_ops = {
@@ -367,7 +356,8 @@ static void __devinit eeepc_enable_camera(void)
         * If the following call to set_acpi() fails, it's because there's no
         * camera so we can ignore the error.
         */
-       set_acpi(CM_ASL_CAMERA, 1);
+       if (get_acpi(CM_ASL_CAMERA) == 0)
+               set_acpi(CM_ASL_CAMERA, 1);
 }
 
 /*
@@ -654,13 +644,13 @@ static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
        return 0;
 }
 
-static void eeepc_rfkill_hotplug(bool real)
+static void eeepc_rfkill_hotplug(void)
 {
        struct pci_dev *dev;
        struct pci_bus *bus;
-       bool blocked = real ? eeepc_wlan_rfkill_blocked() : true;
+       bool blocked = eeepc_wlan_rfkill_blocked();
 
-       if (real && ehotk->wlan_rfkill)
+       if (ehotk->wlan_rfkill)
                rfkill_set_sw_state(ehotk->wlan_rfkill, blocked);
 
        mutex_lock(&ehotk->hotplug_lock);
@@ -703,7 +693,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
        if (event != ACPI_NOTIFY_BUS_CHECK)
                return;
 
-       eeepc_rfkill_hotplug(true);
+       eeepc_rfkill_hotplug();
 }
 
 static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
@@ -861,7 +851,7 @@ static int eeepc_hotk_restore(struct device *device)
 {
        /* Refresh both wlan rfkill state and pci hotplug */
        if (ehotk->wlan_rfkill)
-               eeepc_rfkill_hotplug(true);
+               eeepc_rfkill_hotplug();
 
        if (ehotk->bluetooth_rfkill)
                rfkill_set_sw_state(ehotk->bluetooth_rfkill,
@@ -1004,7 +994,7 @@ static void eeepc_rfkill_exit(void)
         * Refresh pci hotplug in case the rfkill state was changed after
         * eeepc_unregister_rfkill_notifier()
         */
-       eeepc_rfkill_hotplug(true);
+       eeepc_rfkill_hotplug();
        if (ehotk->hotplug_slot)
                pci_hp_deregister(ehotk->hotplug_slot);
 
@@ -1120,7 +1110,7 @@ static int eeepc_rfkill_init(struct device *dev)
         * Refresh pci hotplug in case the rfkill state was changed during
         * setup.
         */
-       eeepc_rfkill_hotplug(true);
+       eeepc_rfkill_hotplug();
 
 exit:
        if (result && result != -ENODEV)
index 4e83c29..6f8d8f9 100644 (file)
@@ -180,15 +180,15 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
 
        switch (type) {
        case THERMAL_TRIP_CRITICAL:
-               return sprintf(buf, "critical");
+               return sprintf(buf, "critical\n");
        case THERMAL_TRIP_HOT:
-               return sprintf(buf, "hot");
+               return sprintf(buf, "hot\n");
        case THERMAL_TRIP_PASSIVE:
-               return sprintf(buf, "passive");
+               return sprintf(buf, "passive\n");
        case THERMAL_TRIP_ACTIVE:
-               return sprintf(buf, "active");
+               return sprintf(buf, "active\n");
        default:
-               return sprintf(buf, "unknown");
+               return sprintf(buf, "unknown\n");
        }
 }
 
index 402cb84..12da5db 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -325,8 +325,16 @@ static void bio_fs_destructor(struct bio *bio)
  *     @gfp_mask: allocation mask to use
  *     @nr_iovecs: number of iovecs
  *
- *     Allocate a new bio with @nr_iovecs bvecs.  If @gfp_mask
- *     contains __GFP_WAIT, the allocation is guaranteed to succeed.
+ *     bio_alloc will allocate a bio and associated bio_vec array that can hold
+ *     at least @nr_iovecs entries. Allocations will be done from the
+ *     fs_bio_set. Also see @bio_alloc_bioset and @bio_kmalloc.
+ *
+ *     If %__GFP_WAIT is set, then bio_alloc will always be able to allocate
+ *     a bio. This is due to the mempool guarantees. To make this work, callers
+ *     must never allocate more than 1 bio at a time from this pool. Callers
+ *     that need to allocate more than 1 bio must always submit the previously
+ *     allocated bio for IO before attempting to allocate a new one. Failure to
+ *     do so can cause livelocks under memory pressure.
  *
  *     RETURNS:
  *     Pointer to new bio on success, NULL on failure.
@@ -350,21 +358,13 @@ static void bio_kmalloc_destructor(struct bio *bio)
 }
 
 /**
- * bio_alloc - allocate a bio for I/O
+ * bio_kmalloc - allocate a bio for I/O using kmalloc()
  * @gfp_mask:   the GFP_ mask given to the slab allocator
  * @nr_iovecs: number of iovecs to pre-allocate
  *
  * Description:
- *   bio_alloc will allocate a bio and associated bio_vec array that can hold
- *   at least @nr_iovecs entries. Allocations will be done from the
- *   fs_bio_set. Also see @bio_alloc_bioset.
- *
- *   If %__GFP_WAIT is set, then bio_alloc will always be able to allocate
- *   a bio. This is due to the mempool guarantees. To make this work, callers
- *   must never allocate more than 1 bio at a time from this pool. Callers
- *   that need to allocate more than 1 bio must always submit the previously
- *   allocated bio for IO before attempting to allocate a new one. Failure to
- *   do so can cause livelocks under memory pressure.
+ *   Allocate a new bio with @nr_iovecs bvecs.  If @gfp_mask contains
+ *   %__GFP_WAIT, the allocation is guaranteed to succeed.
  *
  **/
 struct bio *bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
@@ -407,7 +407,7 @@ EXPORT_SYMBOL(zero_fill_bio);
  *
  * Description:
  *   Put a reference to a &struct bio, either one you have gotten with
- *   bio_alloc or bio_get. The last put of a bio will free it.
+ *   bio_alloc, bio_get or bio_clone. The last put of a bio will free it.
  **/
 void bio_put(struct bio *bio)
 {
index 1065b71..11aee09 100644 (file)
@@ -628,6 +628,8 @@ static void bdi_prune_sb(struct backing_dev_info *bdi)
 void bdi_unregister(struct backing_dev_info *bdi)
 {
        if (bdi->dev) {
+               bdi_prune_sb(bdi);
+
                if (!bdi_cap_flush_forker(bdi))
                        bdi_wb_shutdown(bdi);
                bdi_debug_unregister(bdi);
@@ -697,7 +699,6 @@ void bdi_destroy(struct backing_dev_info *bdi)
                spin_unlock(&inode_lock);
        }
 
-       bdi_prune_sb(bdi);
        bdi_unregister(bdi);
 
        for (i = 0; i < NR_BDI_STAT_ITEMS; i++)