From owner-freebsd-current@freebsd.org Tue May 2 06:35:10 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3980D5A97C for ; Tue, 2 May 2017 06:35:10 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-vk0-x22c.google.com (mail-vk0-x22c.google.com [IPv6:2607:f8b0:400c:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ABFC8782; Tue, 2 May 2017 06:35:10 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-vk0-x22c.google.com with SMTP id i65so28681885vkh.0; Mon, 01 May 2017 23:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SbNF0rUQuYKIXNYzux63scILX+czJ/LfntDPiVHQ2Xw=; b=gdFwQOEuEOWfyxXSUTbmj7A7Nv+jAFPgtaLEflfEjmQ3vjmgxRLiSEVpsFacJmbSew A+obkK/QxA1MsRaulbgfHWWHqEfnbB2yOuHtnw4+h/tImsjv2O1ou/T3HgUDctrWAxAE qy0JQKUBY+APM1F/ER0xzBAPOakl43/nEEF/FSFHy54oJRyhDXzCIrfrpJeyK70hu6YU atvtpV71qPq8KWb6ynPQPS+upAzrbmBiGAAa4WSHZuPDdhu8ip/iurTmFHB2sQQKWYUX Y4vF9pqQjRYjPr2b8h+FW/D/go1iMP2l9SgrdLm4ttuqa5Tz2QtR/KnHQ1wsur971OhR Anaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SbNF0rUQuYKIXNYzux63scILX+czJ/LfntDPiVHQ2Xw=; b=hbH7kTASgXSapwcL6HeI4irIwGeIDCN4pxCE0lhx9PYDf4x1QoSiGDZe7VtloEX00c pxX2ArtUJOxWGazMRuNNo+QY6LFz7f6A6S5DkSgad/cPFZBsxBa8cdXFy+jK2sYk1xJ7 xMMP09UgQlWREXh29sfZHUecZHE6AJQadmgOzqi141u31f61EAKW/CBFnNRRMB1BexqA 8b/X/iiVGyv1Lxyas+KOr6cZfOMzQ63lP1EoMMe4pV3o/S35TvRLq325EPZrnOISE2EY OIFhwvm/HodsSzjUGwFEZsEnrs25uQlnIOm2TkatkT37eLpKoRdQRMEE4o2Ux1NsnHdM YmxQ== X-Gm-Message-State: AN3rC/6hBfb1EPYCEQHgvdXuF9WWKzIdYjdyahHYYUDaI5CE/2Ejn1am /SoloRZrJ00odFt6AI41N43Q+XAwUQ== X-Received: by 10.31.201.65 with SMTP id z62mr11685094vkf.16.1493706909488; Mon, 01 May 2017 23:35:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.76.43 with HTTP; Mon, 1 May 2017 23:35:08 -0700 (PDT) In-Reply-To: References: <1737882.TJdaAP1hO8@ralph.baldwin.cx> <6993108.fO6lomHkak@ralph.baldwin.cx> From: Sepherosa Ziehau Date: Tue, 2 May 2017 14:35:08 +0800 Message-ID: Subject: Re: Add support for ACPI Module Device ACPI0004? To: John Baldwin Cc: Dexuan Cui , "freebsd-current@freebsd.org" , Jung-uk Kim , Yanmin Qiao Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 May 2017 06:35:11 -0000 On Tue, May 2, 2017 at 11:28 AM, Sepherosa Ziehau wrote: > On Tue, May 2, 2017 at 12:25 AM, John Baldwin wrote: >> On Sunday, April 30, 2017 09:02:30 AM Sepherosa Ziehau wrote: >>> On Sat, Apr 29, 2017 at 12:01 AM, John Baldwin wrote: >>> > On Friday, April 28, 2017 05:38:32 PM Sepherosa Ziehau wrote: >>> >> On Thu, Apr 27, 2017 at 12:14 AM, John Baldwin wrote: >>> >> > On Wednesday, April 26, 2017 09:18:48 AM Sepherosa Ziehau wrote: >>> >> >> On Wed, Apr 26, 2017 at 4:36 AM, John Baldwin wrote: >>> >> >> > On Thursday, April 20, 2017 02:29:30 AM Dexuan Cui wrote: >>> >> >> >> > From: John Baldwin [mailto:jhb@freebsd.org] >>> >> >> >> > Sent: Thursday, April 20, 2017 02:34 >>> >> >> >> > > Can we add the support of "ACPI0004" with the below one-line change? >>> >> >> >> > > >>> >> >> >> > > acpi_sysres_probe(device_t dev) >>> >> >> >> > > { >>> >> >> >> > > - static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL }; >>> >> >> >> > > + static char *sysres_ids[] = { "PNP0C01", "PNP0C02", "ACPI0004", NULL }; >>> >> >> >> > > >>> >> >> >> > Hmm, so the role of C01 and C02 is to reserve system resources, though we >>> >> >> >> > in turn allow any child of acpi0 to suballocate those ranges (since historically >>> >> >> >> > c01 and c02 tend to allocate I/O ranges that are then used by things like the >>> >> >> >> > EC, PS/2 keyboard controller, etc.). From my reading of ACPI0004 in the ACPI >>> >> >> >> > 6.1 spec it's not quite clear that ACPI0004 is like that? In particular, it >>> >> >> >> > seems that 004 should only allow direct children to suballocate? This >>> >> >> >> > change might work, but it will allow more devices to allocate the ranges in >>> >> >> >> > _CRS than otherwise. >>> >> >> >> > >>> >> >> >> > Do you have an acpidump from a guest system that contains an ACPI0004 >>> >> >> >> > node that you can share? >>> >> >> >> > >>> >> >> >> > John Baldwin >>> >> >> >> >>> >> >> >> Hi John, >>> >> >> >> Thanks for the help! >>> >> >> >> >>> >> >> >> Please see the attached file, which is got by >>> >> >> >> "acpidump -dt | gzip -c9 > acpidump.dt.gz" >>> >> >> >> >>> >> >> >> In the dump, we can see the "ACPI0004" node (VMOD) is the parent of >>> >> >> >> "VMBus" (VMBS). >>> >> >> >> It looks the _CRS of ACPI0004 is dynamically generated. Though we can't >>> >> >> >> see the length of the MMIO range in the dumped asl code, it does have >>> >> >> >> a 512MB MMIO range [0xFE0000000, 0xFFFFFFFFF]. >>> >> >> >> >>> >> >> >> It looks FreeBSD can't detect ACPI0004 automatically. >>> >> >> >> With the above one-line change, I can first find the child device >>> >> >> >> acpi_sysresource0 of acpi0, then call AcpiWalkResources() to get >>> >> >> >> the _CRS of acpi_sysresource0, i.e. the 512MB MMIO range. >>> >> >> >> >>> >> >> >> If you think we shouldn't touch acpi_sysresource0 here, I guess >>> >> >> >> we can add a new small driver for ACPI0004, just like we added VMBus >>> >> >> >> driver as a child device of acpi0? >>> >> >> > >>> >> >> > Hmmm, so looking at this, the "right" thing is probably to have a device >>> >> >> > driver for the ACPI0004 device that parses its _CRS and then allows its >>> >> >> > child devices to sub-allocate resources from the ranges in _CRS. However, >>> >> >> > this would mean make VMBus be a child of the ACPI0004 device. Suppose >>> >> >> > we called the ACPI0004 driver 'acpi_module' then the 'acpi_module0' device >>> >> >> > would need to create a child device for all of its child devices. Right >>> >> >> > now acpi0 also creates devices for them which is somewhat messy (acpi0 >>> >> >> > creates child devices anywhere in its namespace that have a valid _HID). >>> >> >> > You can find those duplicates and remove them during acpi_module0's attach >>> >> >> > routine before creating its own child device_t devices. (We associate >>> >> >> > a device_t with each Handle when creating device_t's for ACPI handles >>> >> >> > which is how you can find the old device that is a direct child of acpi0 >>> >> >> > so that it can be removed). >>> >> >> >>> >> >> The remove/reassociate vmbus part seems kinda "messy" to me. I'd just >>> >> >> hook up a new acpi0004 driver, and let vmbus parse the _CRS like what >>> >> >> we did to the hyper-v's pcib0. >>> >> > >>> >> > The acpi_pci driver used to do the remove/reassociate part. What acpi0 >>> >> > should probably be doing is only creating device_t nodes for immediate >>> >> > children. This would require an ACPI-aware isa0 for LPC devices below >>> >> > the ISA bus in the ACPI namespace. We haven't done that in part because >>> >> > BIOS vendors are not always consistent in placing LPC devices under an >>> >> > ISA bus. However, you otherwise have no good way to find your parent >>> >> > ACPI0004 device. You could perhaps find your ACPI handle, ask for its >>> >> > parent handle, then ask for the device_t of that handle to find the >>> >> > ACPI0004 device, but then you'd need to have all your bus_alloc_resource >>> >> > calls go to that device, not your "real" parent of acpi0, which means >>> >> > you can't use any of the standard bus_alloc_resource() methods like >>> >> > bus_alloc_resource_any() but would have to manually use BUS_ALLOC_RESOURCE >>> >> > with the ACPI0004 device as the explicit first argument. It is primarily >>> >> > the ability to let ACPI0004's driver transparently intercept all the >>> >> > resource allocation so it can manage that is the reason for "VMBus" >>> >> > to be a child of ACPI0004 rather than its sibling. >>> >> >>> >> Well, there could be more then one ACPI0004 typed devices, which could >>> >> not form a device tree for vmbus. >>> > >>> > Are you saing a vmbus would need resources from multiple ACPI0004 devices? >>> >>> ACPI0004 (and several other PNP ids, see dexuan's submission) is >>> something just like the acpi_sysresource. Not directly related to the >>> vmbus at all. >> >> In the acpidump, the "vmbus" device was a direct child of ACPI0004. This is >> quite different from acpi_sysresource0 which can be in random places in the >> namespace (sometimes it is off of isab0, sometimes it is a child of isab0 or >> of _SB_), and thus devices that suballocate ranges it reserves (like ipmi0 >> or acpi_ec0) are sometimes siblings, etc. That doesn't seem to be true for >> ACPI004 as it is explicitly described as a container object. > > Thanks for the suggestion. We are reorganizing the tree. The > original ACPI device (VMBUS) is left as a resource device, instead of > moving it around. We have reorganized the vmbus tree: https://reviews.freebsd.org/D10565 Thanks, sephe -- Tomorrow Will Never Die