From owner-freebsd-current@freebsd.org Wed Apr 26 01:18:50 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 BAC33D5061F for ; Wed, 26 Apr 2017 01:18:50 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-ua0-x22c.google.com (mail-ua0-x22c.google.com [IPv6:2607:f8b0:400c:c08::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 7421288B; Wed, 26 Apr 2017 01:18:50 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-ua0-x22c.google.com with SMTP id 110so43471703uas.3; Tue, 25 Apr 2017 18:18:50 -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=VckVxAD/lKZAp7q4YHXVILohBupfkpMCIk9QQSvVcj4=; b=qMXgUlEXnoCwyMhtNpRmbRpGB2RS+Ap7pEB7uqFoZQNTU7AhiQ6oqONNsF6gyDd3Ur EGSpIbsSfEH2jJmXDx3oYsl9MyKBLOihHKCQTWxhIgazeopKGd9thtdsWVxUuqHZsXIY 1WjV4NpYv6NoZjF/VNk1Cf3Rm6Yw9cd5SWwCZjwLcEs/pF7sOee+woCsq9Oc4gFHIApy Nia9ouZrXFLbfBZ2G1eJ2CXiCewRva5AnT2YAn1UsceadfsPnXNA/EDdJS8iVnlEVpSv HtJ8Zvdn+6xOf8bvWZlqhGhfu4/nf0ievAy1GHRPm99VHVc7nNEYgk0AmUiuxSZekU8T Rmsw== 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=VckVxAD/lKZAp7q4YHXVILohBupfkpMCIk9QQSvVcj4=; b=bNTikUFAtcA/dWueFe9RvaEK/pTXql+Re4EKtP2P8HqHt2T9e2pYNwPclXsSCIfrS2 fdnzns1Ag/E6BQedv8sEg50VWb3vsGDJhQTmQVs2dyQvoW6UN03C2vKc6g97zfHkAEyx ipxj14y5qLgkOzWU9mPlaie0jePuwE4IO5A5pt5rTVSKviCOOu4KS5GMwbKhzPfPGz90 gGblADjMdaLv25cbYpPYW18LFTkET+A75/hOVDAkEoSeojRp6sRh+3vLhz7PjeqYDYiZ fnqwZyD8C8lhJO5rLpvg6n8+zB5XnFMzwUfriK6+AuSqdyqgGfSvIg7crkcobZj60g5f 2Lnw== X-Gm-Message-State: AN3rC/5CTmFECeH/pWMcqlijQ8Jxn4m35gug4R4jVGULEQG7tqWEgCdo nyp4xQBO1LqnwcH94G+c4epUBPbLNg== X-Received: by 10.176.91.94 with SMTP id v30mr14970018uae.37.1493169529515; Tue, 25 Apr 2017 18:18:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.80.97 with HTTP; Tue, 25 Apr 2017 18:18:48 -0700 (PDT) In-Reply-To: <5144516.9adee9646c@ralph.baldwin.cx> References: <3484633.CMRgrtiqef@ralph.baldwin.cx> <5144516.9adee9646c@ralph.baldwin.cx> From: Sepherosa Ziehau Date: Wed, 26 Apr 2017 09:18:48 +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: Wed, 26 Apr 2017 01:18:50 -0000 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. Thanks, sephe -- Tomorrow Will Never Die