From: Kamala Narasimhan Date: Mon, 29 Jun 2009 16:55:06 +0000 (-0400) Subject: Add pci-power-management option to enable Dx power management for pass-through devices. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=58e39e3c6276f24b3a78363cd7ce490b9c61103c;p=xenclient%2Ftoolstack.git Add pci-power-management option to enable Dx power management for pass-through devices. Note: This takes care of global Dx power management for devices passed-through to a vm. Per device Dx option will also be added. --- diff --git a/xenops/device.ml b/xenops/device.ml index 5b7bc20..9d0369c 100644 --- a/xenops/device.ml +++ b/xenops/device.ml @@ -885,7 +885,7 @@ let grant_access_resources xc domid resources v = ) ) resources -let add_noexn ~xc ~xs ~hvm ~msitranslate pcidevs domid devid = +let add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = let pcidevs = List.map (fun (domain, bus, slot, func) -> let (irq, resources, driver) = get_from_system domain bus slot func in { domain = domain; bus = bus; slot = slot; func = func; @@ -922,6 +922,7 @@ let add_noexn ~xc ~xs ~hvm ~msitranslate pcidevs domid devid = "num_devs", string_of_int (List.length xsdevs); "state", string_of_int (Xenbus.int_of Xenbus.Initialising); "msitranslate", string_of_int (msitranslate); + "pci_power_mgmt", string_of_int (pci_power_mgmt); ] and frontendlist = [ "backend-id", "0"; "state", string_of_int (Xenbus.int_of Xenbus.Initialising); @@ -929,8 +930,8 @@ let add_noexn ~xc ~xs ~hvm ~msitranslate pcidevs domid devid = Generic.add_device ~xs device (xsdevs @ backendlist) frontendlist; () -let add ~xc ~xs ~hvm ~msitranslate pcidevs domid devid = - try add_noexn ~xc ~xs ~hvm ~msitranslate pcidevs domid devid +let add ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid = + try add_noexn ~xc ~xs ~hvm ~msitranslate ~pci_power_mgmt pcidevs domid devid with exn -> raise (Cannot_add (pcidevs, exn)) diff --git a/xenops/device.mli b/xenops/device.mli index da17c97..b083ad4 100644 --- a/xenops/device.mli +++ b/xenops/device.mli @@ -130,7 +130,7 @@ sig exception Cannot_use_pci_with_no_pciback of t list val add : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> msitranslate:int - -> dev list -> Xc.domid -> int -> unit + -> pci_power_mgmt:int -> dev list -> Xc.domid -> int -> unit val release : xc:Xc.handle -> xs:Xs.xsh -> hvm:bool -> dev list -> Xc.domid -> int -> unit val reset : xs:Xs.xsh -> device -> unit diff --git a/xenvm/vmact.ml b/xenvm/vmact.ml index c87ef3f..24b6c23 100644 --- a/xenvm/vmact.ml +++ b/xenvm/vmact.ml @@ -158,7 +158,8 @@ let add_devices xc xs domid state restore = ) devs in if !bind then Device.PCI.bind devs; - Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate:cfg.pci_msitranslate devs domid devid + Device.PCI.add ~xc ~xs ~hvm:cfg.hvm ~msitranslate:cfg.pci_msitranslate + ~pci_power_mgmt:cfg.pci_power_mgmt devs domid devid ) cfg.pcis; (* add device model *) diff --git a/xenvm/vmconfig.ml b/xenvm/vmconfig.ml index 43b3670..e2ea52f 100644 --- a/xenvm/vmconfig.ml +++ b/xenvm/vmconfig.ml @@ -111,6 +111,7 @@ type config = { extra_local_watches: string list; extra_vm_watches: string list; pci_msitranslate: int; + pci_power_mgmt: int; sound: string option; inject_sci: int; } @@ -267,6 +268,7 @@ let get cfg field = | "power-management" -> string_of_int cfg.power_management | "oem-features" -> string_of_int cfg.oem_features | "pci-msitranslate" -> string_of_int cfg.pci_msitranslate + | "pci-power-management" -> string_of_int cfg.pci_power_mgmt | "inject-sci" -> string_of_int cfg.inject_sci | _ -> raise (Unknown_field field) @@ -298,6 +300,7 @@ let set cfg field value = | "power-management" -> { cfg with power_management = int_of_string value } | "oem-features" -> { cfg with oem_features = int_of_string value } | "pci-msitranslate" -> { cfg with pci_msitranslate = int_of_string value } + | "pci-power-management" -> { cfg with pci_power_mgmt = int_of_string value } | "inject-sci" -> { cfg with inject_sci = int_of_string value } | _ -> raise (Unknown_field field) @@ -349,7 +352,8 @@ let of_file error_report file = and snapshot_mode = ref NoSnapshot and extra_local_watches = ref [] and extra_vm_watches = ref [] - and pci_msitranslate = ref 0 + and pci_msitranslate = ref 0 + and pci_power_mgmt = ref 0 and sound = ref None and inject_sci = ref 0 in @@ -502,6 +506,7 @@ let of_file error_report file = ("extra-local-watch", Config.String set_local_watch); ("extra-vm-watch", Config.String set_vm_watch); ("pci-msitranslate", Config.Set_int pci_msitranslate); + ("pci-power-management", Config.Set_int pci_power_mgmt); ("sound", Config.String (fun s -> sound := Some s)); ("inject-sci", Config.Set_int inject_sci); ] in @@ -599,6 +604,7 @@ let of_file error_report file = extra_local_watches = List.rev !extra_local_watches; extra_vm_watches = List.rev !extra_vm_watches; pci_msitranslate = !pci_msitranslate; + pci_power_mgmt = !pci_power_mgmt; sound = !sound; inject_sci = !inject_sci; } diff --git a/xenvm/xenops.ml b/xenvm/xenops.ml index b59c7a4..e35410e 100644 --- a/xenvm/xenops.ml +++ b/xenvm/xenops.ml @@ -274,7 +274,7 @@ let add_pci ~xc ~xs ~hvm ~domid ~devid ~pci = let pcidevs = List.map (fun d -> Scanf.sscanf d "%04x:%02x:%02x.%1x" (fun a b c d -> (a, b, c, d)) ) (String.split ',' pci) in - Device.PCI.add ~xc ~xs ~hvm ~msitranslate:0 pcidevs domid devid; + Device.PCI.add ~xc ~xs ~hvm ~msitranslate:0 ~pci_power_mgmt:0 pcidevs domid devid; () let del_pci ~xc ~xs ~hvm ~domid ~devid ~pci = diff --git a/xenvm/xenvm.readme b/xenvm/xenvm.readme index 759f3e5..dac8d88 100644 --- a/xenvm/xenvm.readme +++ b/xenvm/xenvm.readme @@ -80,6 +80,8 @@ oem-features = int -- specify whether or not to pass through oem features. Note timer-mode = int -- specify the timer mode used. timeoffset = string -- specify the time offset (i.e. timezone) used. pci-msitranslate = int -- specify whether or not to use MSI-INTx translation for guest. +pci-power-management = int -- specify whether or not to enable Dx power management for + passthrough devices. inject-sci = int -- specify whether or not to inject SCIs like lid close, power button press to guest. Default is to not inject SCIs.