qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
@ 2016-12-05 23:32 Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests Igor Mammedov
                   ` (11 more replies)
  0 siblings, 12 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum


Series cleanups and consolidates scattered memory hotplug
code so it could be easily reused by ARM target later.

As result:
 * added memory hotplug variant to bios tables test
 * all ACPI related parts of memory hotplug are consolidated
   within memory_hotplug.c
 * DSDT table size is reduced ~900 bytes when memory hotplug
   is not enabled (by not generating not used AML)
 * DSDT table size is reduced on 12 bytes per slot
   (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
   enabled due AML reorganization that makes calls to common functions
   smaller as devices and common functions are now within the same scope.

Tested with following guests:
  - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
  - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
    it never worked as memhp is not supported there)

Git tree for testing:
  https://github.com/imammedo/qemu.git memhp_consolidate_v1
viewing:
  https://github.com/imammedo/qemu/commits/memhp_consolidate_v1

Note to maintaner:
  * blobs patch 2/10 should be merged to patch 1/10
  * ACPI tables should be regenarated and applied after series is merged
    as DSDT will cange for all tests cases due removal of inactive
    memory hotplug code.

CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Marcel Apfelbaum <marcel@redhat.com>


Igor Mammedov (10):
  tests: pc: add memory hotplug acpi tables tests
  tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
  memhp: move build_memory_hotplug_aml() into memory_hotplug.c
  memhp: move build_memory_devices() into memory_hotplug.c
  memhp: consolidate scattered MHPD device declaration
  memhp: merge build_memory_devices() into build_memory_hotplug_aml()
  memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  memhp: move memory hotplug only defines to memory_hotplug.c
  memhp: don't generate memory hotplug AML if it's not enabled/supported
  memhp: move DIMM devices into dedicated scope with related common
    methods

 include/hw/acpi/memory_hotplug.h    |  12 +-
 include/hw/acpi/pc-hotplug.h        |  23 --
 hw/acpi/Makefile.objs               |   2 +-
 hw/acpi/ich9.c                      |   3 +-
 hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
 hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
 hw/acpi/piix4.c                     |   3 +-
 hw/i386/acpi-build.c                | 197 +++--------------
 tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
 tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
 tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
 tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
 tests/bios-tables-test.c            |  24 +++
 13 files changed, 479 insertions(+), 467 deletions(-)
 delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
 create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
 create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
 create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
 create mode 100644 tests/acpi-test-data/q35/SRAT.memhp

-- 
2.7.4

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-20 10:40   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 02/10] tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant Igor Mammedov
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/bios-tables-test.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 812f830..5404805 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_tcg_memhp(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".memhp";
+    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
+    free_test_data(&data);
+}
+
+static void test_acpi_piix4_tcg_memhp(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_PC;
+    data.variant = ".memhp";
+    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -887,6 +909,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
         qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
         qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
+        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
+        qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 02/10] tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c Igor Mammedov
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS: note to maintainer

when applied, this patch should be merged with previous patch
  "tests: pc: add memory hotplug acpi tables tests"
to avoid 'make check" failure during bisect
---
 tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
 tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
 tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
 tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
 4 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
 create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
 create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
 create mode 100644 tests/acpi-test-data/q35/SRAT.memhp

diff --git a/tests/acpi-test-data/pc/DSDT.memhp b/tests/acpi-test-data/pc/DSDT.memhp
new file mode 100644
index 0000000000000000000000000000000000000000..a1010c7fb5c526278d743891f2543d873f9ef9b9
GIT binary patch
literal 6613
zcmdT|&2JmW6`$pYw49}+rL?wXD~VXyNt(2_`QgY3S`;RCDUlYJT5~Da#Tw;OmQgB5
z>xB{nQH%f*11L^z0qdeYl{R>`|Ah8W$ffu6+*^vqK3V;}T@J-iS|GW#1Vqhy?>Fyb
z=DjyFG;E{skF$(P|0=HQWjkHGW$6ZZ5@U?U^k1#SZZl`kD6TdoB@&aIeZ?Q+t0-$f
zH;Nmp(x2PzpIrB&&t0kIvCSvyqs^B0*+X}e5$OJ=$2kqurKVkMI-LbeuVmzAxnd*>
zU-PKkEEshrH#aJVq?&SoDamE4)DR#EAc)~c*=m?9$=KH~6&7>$Rifu^mTE@YsvFI;
zw%oKE1?CaQ^@!E_#O12nOMcaLS=Ut#5Bsb){Z+Tc{@6;gfBq-lXMH{+H}$%mO7ZD~
z1R{oV7GrFesjpumZ^&JzbJn_*&HKJ4qfCM;RyMCk7(Z06#YbRztYR0M0S*gGxGNbw
z!d(t`-}vn%(n2#CD_>@lRjX8!*t;yM7ibXGi}<JNi<hIqFllo-7wZijN`oa+uvp~p
zJU_K6dCX&KWQj?u(hl2Uk%?XAbgr%yjUhZ5)e`=y3<LEiy3Az~W^J)8{9lS7UZ?Y>
zxxO)+I5RgsQReX_rV_9quNeAp6DJ2AE%5nO>D%bHQ5IX3o=2Z!p_Z<(w`0EU>`K)t
zh|OLxDzj;o@i<@S8HqpR5&k;<X88g?<R9?w_zaij=892Do#7g#;pis<!s+~~YBh$w
z#+WuAY&|Wh+nd04_u1pvFlLoctx6w9KaR@s(w^^6DW<QRS+S^bDab&fhBhQj&5P)Z
zD3g~|U(E`s$&IPuk)a;!XsDjZiwN|{(4&^+qa@n1bh{xb>?xO#;za1k!HqP&jI^_7
zm#(7}<)@TU3K4oSQ@Rd8v1ZmKMGXW*=*8NGnRcXNRbOM;>y}=+9&yeSb$IBtN$BlL
z+l;0=ZxXxD)EY{t*i_dzrM+hGrd4k+Z#J^$daU)Nn0VCUd)_B49$}l_gPqnU<56~}
zr*`iElt9^3YikDE>RssGk$S0ai^qm+n{7Rw8d3#-Qr$Z|GUOBooam6Fvn}t_-A%4C
z6fS$X#hCY?1$z&-B<5{BbX)9xtM5Ad7cNK1TdEbRHp!~r$jJE0(pQeY^0GEpxq(&f
zB_8m-Hi|yc=ZdymxuMq+0Ms+7X|8-R!4iJ5?XoY4$K&{}^pr<!#N4KFpV&^PI*Blm
z%t1jW(Lks@$yh5pb(+t8G0hUuII@)EPr=_V(`JGiBqzu{E!8wCHv5#ue9!01P*t-&
zx#ZJlns(imzHA3xpqtez#2;8Mj#)?k{$T6b5$jpsdKUhTTF+`HThBTjlVaD$tn<i^
zFrOPSpYzS<#?0qJ%;yH?jdAlhAbxQ4`4RJZ-+X?|d_Kf{-s!Bz5WPKaJ{Fi4DMY6T
zwp_GbMVs(9TT_BHCRf3t-Bs7G1_z$bZyz;%t6mzK;1hmwP3hJ~x_s{=?}PilOYhwM
z@ZSBMJ9j^1j-*@FwL$xx;(S$N&)735i5`ul^1H}0o^<xl6H#DkoemtmQnMw!Zr+s8
z5Hb>r>AGp4)yxtos@tV%8c3tiNNdSvrB;zWMogzuym;I1Qt&14Z>peMl}sj^ArFG{
zJg%km#>#IZJ>G4z13i<;Y-{BS^sqw0Ie+_dOdM<!Bl%99Xq*jW9&>x=y5j=!-s3Z_
z^X4&0b*=AeW}G7WafYOERnTyveyu#M+j>n73qx|B6qK%uBN?r7Tq#z#w;DSZkiQdH
zu5maPU-FK52DB%+kJn<o@^MxEex9s~M~~|Q9J)>p)J*8>b|V=U=!yGv%vnV2ZJ!XA
z$0Orhg1$e_#1fq7o%7jRjM54<h7U3nsU`O*!H|Szp^;L!%w)QIL8>$<!zn44Hr+%}
z3Pr}++wY@dZ<$P6Kt``xrDiFU!=CxqF3N7&Xtj3n=uGYuE}CU4=sQzZ&B_!q%dm&G
zKV{zi{k@&tbo*FwYIA<i?<KmXQLE!Vf+NR~O#d)0Oqejij%3Ih=RC;{51;(<kxMf?
z*F+`s=DH@OiHW^Ma!EuyKHby0ChfS-rTryp$E6)5C4EV|Xj1);sP+ERX1+qDYnJTh
zppbmDs}<%=^nX-N;DW%)W_|feD$g@t{){nPe8)a74}*_j56DBDpEQwA!`W&uoW-yl
z4Bx1h1ov$W2i((U;no0q4#To%){AADM1v|R!k}8F2{fpZk{x2xfaVh6i)nUGdqg~v
z?+`8d%#_cRJ{odpR3%xpXH0g9%@A@vms;ene12v$WD1qSq!9h^@;T0-zKNJHoW|V2
z@H8B1dSscz9w{fGM}CrMutPL$I9$G>T`-Z5()b2=;5Nmky4p`oq;KpPXxm&b-Spmv
zP!CjUOD1w2m%Z<AC(;D>#Q>sKCMfg$qioQ}k<!|GD1|Je(jUG-f(zpa!_sShZGI1-
zoyE-jXyc=Tp)6NRso>n8OIq-DDNgb~Je*<?JmqLj=?ia>7s(e%Nd{jEQtdg!FOoxg
z%HM&1kM0Y{e$WMrJ`v_i#A`u5Jp9|sK=SwR=*^<X5N_~h8LMF8j~uFagEk6W2|V==
z)o-4C^Gu47lIt<6Y}JEB`+gfha3>tl$91u%?5U*T%Kz4FG!Q%AoSleCa2n$)%~?5y
zXAmAZpxz+~1)%=oX!)GZrIlanD}e(yO6CSSVUEya9;<ORPS*gn@Ymb^g}x?_Y@pxD
zsKwCpo8FSa)q&%}I!{-JvPCZm#`(Onzeq%sYA{U|iLWY+su&?P)6V{@1Sqg;-0v#L
zdGsp3HPJi8**_J`r&|SODZXqyjfGT9D}&vj4x0HG?R<Er+S6VO?nxsjf}cuol;99k
zv+s|K(e4If>g>nFVEW>p&@m7_CI*wlI2p7>|Ij#wKtcJ4f$w-a4t&r4-}#RB>cDr(
zoxv;Se|_E2{EjY`lswyX$CM5*%x?FTZktDFoZD8-dw!=WBIi)Dik->ehXVSQ$?3dp
zX9om&ON42toUDPPnFcvA$kV{-yk%$K#YB6fHu#kaQ=&|p_0xkM(`10e1kI6Jg5oUz
zQ-I<(i4dsJ8W+%b7&I@m;uR2Rod|^rt&;*e83w%~wBk3GK&u=I6<QMlnh1lwBeZe>
z<)Kia6-_p9Kna5`3#~~3O@=~+)+qs<3WHu1TBikcIut6j;*}rxIuizcS7=oQR1Jj+
zttkObg+bpFT4x1xHWVtf&I#yT7_=a?BJ+c=v{0zfdP+b~g+Yr#>uCW!9SRj%&j{$5
zFsLrH&I{;#C{$=YE1+k?poY+TPC(CvLWR}^0bK}#mW0+<1oV|qsL=YVfW8_AT@hMe
z6VTT}p+f7TfG(Z{)yfOT%~~VUOFn4h!E`{qZrdkR5a?zBktRY&u7N;D3M6|(kYwsX
zTfuAVz(!jcP!XbrvKS~dhk=Z2y)%@NF_ic~M%I>xGBSrk9mvSuRg%p-XrsI0#&lq#
z-~^336X+v3ZcYa_N=L}?A_RRTSBXXu2zlD4kL1^gMmh`mo=+di{fLp6LXN}az}83P
z6g5(8D5toM5jjPUWEslSM32a?fyTBE<$FX!t}W8_8$bKg@3*vtIO{f~!NB0r{{l^z
Bd0PMg

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/pc/SRAT.memhp b/tests/acpi-test-data/pc/SRAT.memhp
new file mode 100644
index 0000000000000000000000000000000000000000..66ce9a898191d1da961c0c968c04ec56810a5785
GIT binary patch
literal 224
zcmWFzatwLEz`(%x+sWVABUr&HBEUHqD8>jB1F=Cg2*ZH@DxXmUE(2w7!3B`@A=Cj4
c0D}+gFooFF!DO-12=n0X`2kbO3}XOk0FlrO0RR91

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/DSDT.memhp b/tests/acpi-test-data/q35/DSDT.memhp
new file mode 100644
index 0000000000000000000000000000000000000000..ecd0d8564b21016028d8ecd740f8647e0cbf8878
GIT binary patch
literal 9375
zcmdT~U2hx56`dt1YPF=KrL>miPq9wWG-;hslIs-x2u$u$BqOdwk#s&l1Ek%gm6Enu
zC=QS`2p}myKKxLiVH31Zr2{?ZFEl?PZw=6=zV@{!;-{$R-r137mJ$%ZwR#}u&YpAc
zoY~nq%UuPXp!?Uyg|MzxHvM|1Sb3@C2k5he5Y(n`w~@IedV4{o*0*x0jMdxEaT^~M
z+xt;axmmORygm4AFu42Sz`7lYJD<Cs-nkvU|Iy%%AkbTPBFCYI`((dU>G$?pey3~Y
z#1~GU+Z8L9|ANw@zjCAHH!8NfnP=!hEswZl_v?)yU;fIm?Y=KtX}ezz+QRPNYy_6w
zx!Gz7+wZoU!V9MQn;k!M?{(n^FD{SPCWqUFdB^RA|5*KI>EeygUc6iW@)v*q)xFo9
z3;-+mw(-3hQ9ya9u}Z1lr4Q#4eU98uhC9}KII_&><<Y_?Lxq#wE**>rO#S!svX@FM
zAHME}w$xL#>#b^6>9L>!<HzjQTisCPh4|{*oXGU{U5e*lsBQ$sRy*hyz3cr>w=5#+
z8AQ}|`}YIK9gOmS91g^AkUKg$6r-6x4sVM;-Oh`D{%7J)96Ga@t#+qSaArQ3!ihw3
zkrCn@;og{hnubGD+dJ^HjZV4G(}@8rVKA*mdn@G(==3zP9#YPplj`lCqqguj!*W_!
z_^RNm+3E%<MpaYJ0in(SRTX}@x?%Yhd^B75aBrM_Cao$`wcf$icGpKyd0ulkk2KOn
z=S<CtL?qnQ6=Bt^U9l@t*>^<m;Mw&`a12kUy(ylLV~I>0h=H)cdPTf~?<*-N?HxQ3
zZr(g5&dw)^wli@>xCDF-T8@Dk;VsG;r|}O)S<LdGxSu&L=sMFi>+SU0Y1_WC$AzjH
z%*nD+G-1h=snXDdoR;Q6`axRQS6oiBMrl?OX`Iw?9?a>fc~TEj$YUdq-D>!2!pryZ
zZAIG@xqo=sqEq1d|Kdxk)$X?D*5BNl%Vn^7L~~=kDrDP2dri#csozN<sHq^0pf2X7
zGx?(<Yz-0@N5lefMjm4xpeiIL@-sHYOkm@Pm<pN_%mkE~2#JZ&FgDFhH3C|HoRy(z
z$pln|#8g$V?j@G<WSFU-8Oc<GN2u$ZFmz5ZQ$Z&rQw<)Wt}|=s%ra9!v!+gjy3R>M
z=cJ)?($tAi*J&F%Z9}JR>O`pP#15g&^pv4<%G8Na*XbBK9Yd#M>O`pP%o#d!hR&R+
z6QQmXJC$}m^M=m6sS}~DbK1~3ZRngfbt2St&KNpp44pHkPK3J7SwrWnp>x*MiBQ++
z8aiD=r)%m&sOu~kItzx*f~gasu5-@NIcMmcGj$@=b<P_)=MA0nrcQ*qPS4Qk89F^v
zCqiB48AIn8L+2S&CqiB4f}wN4(79mhM5yaLYv?>{=saucM5yarG;}T+Iu}iy2z8z3
zm|2c@!gI{5#GBnY$@CwF#0+BWd4qZ0V4gRb2zBNKgL%PVUND&mb>>BbdC_2AG?@r>
z<|Tu9$zWbGnFw{}Wo9auxy($p$6uCAwQ(aPrgD-cqvn!PbIGiUP}a0zpk>WKYn{fi
zfufDVv4J8$SsA1esG=}XiDOH$aKFPq<(Mf6RUt8zG#IGFDg)J^WS|ntOfpb}7>zPe
ziH#$wsl1j9R6>sp6d{JrSQx0p#t|{q<dT6(C^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*
zoiI>|WhM+%gOY(tC^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G
z5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P>E$G3{-=Xfl4Sd
z$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(t
zC^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P>E$G3{-=X
zfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%
zgOY(tC^N}G5h|T9P>E$G3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P>E$G
z3{-=Xfl4Sd$v_b*oiI>|WhM+%gOY(tC^N}G5h|T9P(+%6BGL^Mp>CiEH3QX{Fi?$2
z2C6a1Ks6=|RAa(GH6|IT#v}vPm@rU{2?N!bWS|<83{+#nKs6=|RAZ8XYD_XvjR^xq
zq|Po36cNrCPbL{CLYxK_5>w4B3>1-?TNo%JHMeA-2-Vz@fg%iqcfJn`6{Gx+f2<zT
z57PTt`YQMKfBH<Cex=g00(u%@wc1-{IPO-3K79HJY=LJZTUBbW(MOFw>b5uE*uvwb
z(bT)n-ZmbBOdUEo?^<KaZ%+ZxE)`~++{allMUS@dOZgu4ITQG7MDK1pvw~U}L>o^=
znv=LkD68M%c|1;`hcz~a-6<?M^B>QMsWjY8VE-1_iIL5lmCq$;2pCP-EA)d#N4!UE
zXODYk=}Ct;qyce!w%=)Ytb5z>7^pn;$JHx|>Uga1ovT;0>J_eD!T9v*74PKgmEJ)}
z+WkazC-n&BeXYFD<^4o?|CI86Ts}ya$K$f^tUl1n2V6c#ln+iRAH?OW$?};;C|}je
zSGjyOQNDUg`D$E#Em?lz5z4P=<=43UTB7{gDdpGV^0j37>?4$~Y2|BNzLqFoJEeRr
zE?-ZUpL~S!b*+4z%hwa->!*~jqkM+8vSfKzmRFkxZY$_98$Y!)`@Ae)^7x|bI!>3o
zjGcm+4)+>k>15xD>Bg?hIWrw@K*rL^z7x}pU1#%VI^30vrIURprW?C%JTo0`RmRfE
zz7x}pT?c2(bhv*RODFqIOgFZ!7tD0HsToTr`%X+ZwocEQ>2RkrmQMDW>D<j{<r@Ou
zx%Kc_d8=LRsFmp80)+oe`>mVB`Wttn-@Ntf;_j<&zVX)XFJFCA^en&CT#r}ewByvQ
zuk&B$tvnuW!*}R?%h!24(BFTIg0d+3^jzL=Y;-KY9ll`s)#po=$oPI3*uDKZ0;T;<
zwOIr*D0ho^l-$^8*pZ;l-a+N+Eq;T5vB>dFm;F|wR9Y_42;>`@39sOH*IrJIoZ+_k
zz%P|bJ6=7DS3l*c-eb3($*A`Mq>;vcbQEnTyHP9>gVFh6@&JuKa%Km;C&rF6*AE9?
zI6;aYt&o*Wg$yU=_v$l#$KS9|lVJ@$FXx5>yvZ0uBAFC3JgQ~J1o4@`bS2@Kd@C9o
z8PJh6xWAqm)yGru`8+w5lOE3nIC7mVG@SA`JKg+gLQgzjV}pg_Xy*i7k&{aH67;oX
zC#K-U(e>V6&(N~M6^1{oP%JI`kQNvgVOZ`Ka*i$Vd!Fv}yj-7FI4ug{&EN%LH%H3E
z_Red#USA4@cL6K9)~fcar4^hrep^MWn@+U5aaDU?R=yh6TXM^sZf&$m<<fQ3qboCf
z^|x>AzEj*DyEwghzAYS04Z~ogjW<cSC+%5b(_a@}IUAyccz6t}ruP^fJ39LO=bsLU
z5e-6I38VR8NXsO|xy9nLD7e2c@`fRuaqgw_OVRFt&L|~0w7jb!UH@9z=r7xX6Xu3t
zwbPF;Bt{Rs@?wZvL|i#?2nuV5?d#VHt4`_O4~59%MU46P?UDRby>WPi8*CyvGZ<`B
zHs{c+%jWl+Rn_|xnsM(!SbizSo=3ADh3!h6NYrRjA~c$HB2c4ANp`858pNf54-<Rj
zeM)_Fe3xR2I}6-t-97H1R+El3N5SNfx&<V!t`wG>iyvacekhrwl1!4w@>W+I2kHCJ
zgysymadQC!>PJ+W4o8%n4n{OiIuxHFq8&G{U-KRhu^_GF35d|!S0{Dg{UF5h&5VI|
z!p-Un(Q7#9%aq=g5Nkd)2DH!}55VPx&o&cp<5<z&Ia~>=`tC)mo|dZH$ji-NzL}@@
zwv|cecOOlQ6do$k#Lx%c!#>DA$Xho0EjfAL;P8X|aXih__-}o39ZV|ykfOho;3NDq
z4dItZM}Pa44~Q?HqxZFb23M>6&w#{bNd1~K;>~-v?BwLV8arb#Tg+N`>FYju3s-Ju
zwLh25SSW<{wf>x)aZ(N*u_F309igJ`&mKzd9X!4EqA%}Crnjo$O>99cgicg(C)^40
zU-$XdTm0g6!`7Ug_Yk_a9sH=FIpmSyr=%km$+PRNu#NwbaGb^7{t^XgTKq-26!6ic
zRue6(iDGa65&_EMhQpUL78^DR-V<<+@sAZ}B%kb@mIppMezAA(d@gL2FoU#pmEOia
zs_r!Md){UFJ5k$;`SfF;1jk|8We<~wvCqVZX-geDj7~oMJ=%ZMV~5d6hp{DlOT1f;
zA+VAe5sw{j+vBk>|KE)rulVD!)7p{$2Jt^X@7Q%7-qF$G*`b>|>jN~GcSgD4wv(dv
z%8t91k^fwh>y%3PuL}BCo!-GyozhQafSte+_*u|d4&a8=SW%5tZe&~jMpyh7`-Sj%

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/SRAT.memhp b/tests/acpi-test-data/q35/SRAT.memhp
new file mode 100644
index 0000000000000000000000000000000000000000..66ce9a898191d1da961c0c968c04ec56810a5785
GIT binary patch
literal 224
zcmWFzatwLEz`(%x+sWVABUr&HBEUHqD8>jB1F=Cg2*ZH@DxXmUE(2w7!3B`@A=Cj4
c0D}+gFooFF!DO-12=n0X`2kbO3}XOk0FlrO0RR91

literal 0
HcmV?d00001

-- 
2.7.4

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 02/10] tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-20 10:42   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() " Igor Mammedov
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/Makefile.objs               |   2 +-
 hw/acpi/memory_hotplug.c            | 247 +++++++++++++++++++++++++++++++++
 hw/acpi/memory_hotplug_acpi_table.c | 262 ------------------------------------
 3 files changed, 248 insertions(+), 263 deletions(-)
 delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 489e63b..834c63b 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,7 +1,7 @@
 common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
-common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
+common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
 common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
 common-obj-$(CONFIG_ACPI) += acpi_interface.o
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index ec4e64b..57ac4fc 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -306,3 +306,250 @@ const VMStateDescription vmstate_memory_hotplug = {
         VMSTATE_END_OF_LIST()
     }
 };
+
+void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
+                              uint16_t io_base, uint16_t io_len)
+{
+    Aml *ifctx;
+    Aml *method;
+    Aml *pci_scope;
+    Aml *mem_ctrl_dev;
+
+    /* scope for memory hotplug controller device node */
+    pci_scope = aml_scope("_SB.PCI0");
+    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
+    {
+        Aml *one = aml_int(1);
+        Aml *zero = aml_int(0);
+        Aml *ret_val = aml_local(0);
+        Aml *slot_arg0 = aml_arg(0);
+        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
+        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
+        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
+
+        aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
+        aml_append(mem_ctrl_dev,
+            aml_name_decl("_UID", aml_string("Memory hotplug resources")));
+
+        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+        ifctx = aml_if(aml_equal(slots_nr, zero));
+        {
+            aml_append(ifctx, aml_return(zero));
+        }
+        aml_append(method, ifctx);
+        /* present, functioning, decoding, not shown in UI */
+        aml_append(method, aml_return(aml_int(0xB)));
+        aml_append(mem_ctrl_dev, method);
+
+        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
+
+        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
+        {
+            Aml *else_ctx;
+            Aml *while_ctx;
+            Aml *idx = aml_local(0);
+            Aml *eject_req = aml_int(3);
+            Aml *dev_chk = aml_int(1);
+
+            ifctx = aml_if(aml_equal(slots_nr, zero));
+            {
+                aml_append(ifctx, aml_return(zero));
+            }
+            aml_append(method, ifctx);
+
+            aml_append(method, aml_store(zero, idx));
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            /* build AML that:
+             * loops over all slots and Notifies DIMMs with
+             * Device Check or Eject Request notifications if
+             * slot has corresponding status bit set and clears
+             * slot status.
+             */
+            while_ctx = aml_while(aml_lless(idx, slots_nr));
+            {
+                Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
+                Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
+
+                aml_append(while_ctx, aml_store(idx, slot_selector));
+                ifctx = aml_if(aml_equal(ins_evt, one));
+                {
+                    aml_append(ifctx,
+                               aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
+                                         idx, dev_chk));
+                    aml_append(ifctx, aml_store(one, ins_evt));
+                }
+                aml_append(while_ctx, ifctx);
+
+                else_ctx = aml_else();
+                ifctx = aml_if(aml_equal(rm_evt, one));
+                {
+                    aml_append(ifctx,
+                        aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
+                                  idx, eject_req));
+                    aml_append(ifctx, aml_store(one, rm_evt));
+                }
+                aml_append(else_ctx, ifctx);
+                aml_append(while_ctx, else_ctx);
+
+                aml_append(while_ctx, aml_add(idx, one, idx));
+            }
+            aml_append(method, while_ctx);
+            aml_append(method, aml_release(ctrl_lock));
+            aml_append(method, aml_return(one));
+        }
+        aml_append(mem_ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
+        {
+            Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
+
+            aml_append(method, aml_store(zero, ret_val));
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            aml_append(method,
+                aml_store(aml_to_integer(slot_arg0), slot_selector));
+
+            ifctx = aml_if(aml_equal(slot_enabled, one));
+            {
+                aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
+            }
+            aml_append(method, ifctx);
+
+            aml_append(method, aml_release(ctrl_lock));
+            aml_append(method, aml_return(ret_val));
+        }
+        aml_append(mem_ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
+        {
+            Aml *mr64 = aml_name("MR64");
+            Aml *mr32 = aml_name("MR32");
+            Aml *crs_tmpl = aml_resource_template();
+            Aml *minl = aml_name("MINL");
+            Aml *minh = aml_name("MINH");
+            Aml *maxl =  aml_name("MAXL");
+            Aml *maxh =  aml_name("MAXH");
+            Aml *lenl = aml_name("LENL");
+            Aml *lenh = aml_name("LENH");
+
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(aml_to_integer(slot_arg0),
+                                         slot_selector));
+
+            aml_append(crs_tmpl,
+                aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
+                                 AML_CACHEABLE, AML_READ_WRITE,
+                                 0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
+                                 0xFFFFFFFFFFFFFFFFULL));
+            aml_append(method, aml_name_decl("MR64", crs_tmpl));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(14), "MINL"));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(18), "MINH"));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(38), "LENL"));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(42), "LENH"));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(22), "MAXL"));
+            aml_append(method,
+                aml_create_dword_field(mr64, aml_int(26), "MAXH"));
+
+            aml_append(method,
+                aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
+            aml_append(method,
+                aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
+            aml_append(method,
+                aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
+            aml_append(method,
+                aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
+
+            /* 64-bit math: MAX = MIN + LEN - 1 */
+            aml_append(method, aml_add(minl, lenl, maxl));
+            aml_append(method, aml_add(minh, lenh, maxh));
+            ifctx = aml_if(aml_lless(maxl, minl));
+            {
+                aml_append(ifctx, aml_add(maxh, one, maxh));
+            }
+            aml_append(method, ifctx);
+            ifctx = aml_if(aml_lless(maxl, one));
+            {
+                aml_append(ifctx, aml_subtract(maxh, one, maxh));
+            }
+            aml_append(method, ifctx);
+            aml_append(method, aml_subtract(maxl, one, maxl));
+
+            /* return 32-bit _CRS if addr/size is in low mem */
+            /* TODO: remove it since all hotplugged DIMMs are in high mem */
+            ifctx = aml_if(aml_equal(maxh, zero));
+            {
+                crs_tmpl = aml_resource_template();
+                aml_append(crs_tmpl,
+                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
+                                     AML_MAX_FIXED, AML_CACHEABLE,
+                                     AML_READ_WRITE,
+                                     0, 0x0, 0xFFFFFFFE, 0,
+                                     0xFFFFFFFF));
+                aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
+                aml_append(ifctx,
+                    aml_create_dword_field(mr32, aml_int(10), "MIN"));
+                aml_append(ifctx,
+                    aml_create_dword_field(mr32, aml_int(14), "MAX"));
+                aml_append(ifctx,
+                    aml_create_dword_field(mr32, aml_int(22), "LEN"));
+                aml_append(ifctx, aml_store(minl, aml_name("MIN")));
+                aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
+                aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
+
+                aml_append(ifctx, aml_release(ctrl_lock));
+                aml_append(ifctx, aml_return(mr32));
+            }
+            aml_append(method, ifctx);
+
+            aml_append(method, aml_release(ctrl_lock));
+            aml_append(method, aml_return(mr64));
+        }
+        aml_append(mem_ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
+                            AML_NOTSERIALIZED);
+        {
+            Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
+
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(aml_to_integer(slot_arg0),
+                                         slot_selector));
+            aml_append(method, aml_store(proximity, ret_val));
+            aml_append(method, aml_release(ctrl_lock));
+            aml_append(method, aml_return(ret_val));
+        }
+        aml_append(mem_ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
+        {
+            Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
+            Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
+
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(aml_to_integer(slot_arg0),
+                                         slot_selector));
+            aml_append(method, aml_store(aml_arg(1), ost_evt));
+            aml_append(method, aml_store(aml_arg(2), ost_status));
+            aml_append(method, aml_release(ctrl_lock));
+        }
+        aml_append(mem_ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
+        {
+            Aml *eject = aml_name(MEMORY_SLOT_EJECT);
+
+            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(aml_to_integer(slot_arg0),
+                                         slot_selector));
+            aml_append(method, aml_store(one, eject));
+            aml_append(method, aml_release(ctrl_lock));
+        }
+        aml_append(mem_ctrl_dev, method);
+    }
+    aml_append(pci_scope, mem_ctrl_dev);
+    aml_append(ctx, pci_scope);
+}
diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
deleted file mode 100644
index c756602..0000000
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Memory hotplug AML code of DSDT ACPI table
- *
- * Copyright (C) 2015 Red Hat Inc
- *
- * Author: Igor Mammedov <imammedo@redhat.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#include "qemu/osdep.h"
-#include "hw/acpi/memory_hotplug.h"
-#include "include/hw/acpi/pc-hotplug.h"
-#include "hw/boards.h"
-
-void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len)
-{
-    Aml *ifctx;
-    Aml *method;
-    Aml *pci_scope;
-    Aml *mem_ctrl_dev;
-
-    /* scope for memory hotplug controller device node */
-    pci_scope = aml_scope("_SB.PCI0");
-    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
-    {
-        Aml *one = aml_int(1);
-        Aml *zero = aml_int(0);
-        Aml *ret_val = aml_local(0);
-        Aml *slot_arg0 = aml_arg(0);
-        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
-        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
-        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
-
-        aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
-        aml_append(mem_ctrl_dev,
-            aml_name_decl("_UID", aml_string("Memory hotplug resources")));
-
-        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        ifctx = aml_if(aml_equal(slots_nr, zero));
-        {
-            aml_append(ifctx, aml_return(zero));
-        }
-        aml_append(method, ifctx);
-        /* present, functioning, decoding, not shown in UI */
-        aml_append(method, aml_return(aml_int(0xB)));
-        aml_append(mem_ctrl_dev, method);
-
-        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
-
-        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
-        {
-            Aml *else_ctx;
-            Aml *while_ctx;
-            Aml *idx = aml_local(0);
-            Aml *eject_req = aml_int(3);
-            Aml *dev_chk = aml_int(1);
-
-            ifctx = aml_if(aml_equal(slots_nr, zero));
-            {
-                aml_append(ifctx, aml_return(zero));
-            }
-            aml_append(method, ifctx);
-
-            aml_append(method, aml_store(zero, idx));
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            /* build AML that:
-             * loops over all slots and Notifies DIMMs with
-             * Device Check or Eject Request notifications if
-             * slot has corresponding status bit set and clears
-             * slot status.
-             */
-            while_ctx = aml_while(aml_lless(idx, slots_nr));
-            {
-                Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
-                Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
-
-                aml_append(while_ctx, aml_store(idx, slot_selector));
-                ifctx = aml_if(aml_equal(ins_evt, one));
-                {
-                    aml_append(ifctx,
-                               aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
-                                         idx, dev_chk));
-                    aml_append(ifctx, aml_store(one, ins_evt));
-                }
-                aml_append(while_ctx, ifctx);
-
-                else_ctx = aml_else();
-                ifctx = aml_if(aml_equal(rm_evt, one));
-                {
-                    aml_append(ifctx,
-                        aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
-                                  idx, eject_req));
-                    aml_append(ifctx, aml_store(one, rm_evt));
-                }
-                aml_append(else_ctx, ifctx);
-                aml_append(while_ctx, else_ctx);
-
-                aml_append(while_ctx, aml_add(idx, one, idx));
-            }
-            aml_append(method, while_ctx);
-            aml_append(method, aml_release(ctrl_lock));
-            aml_append(method, aml_return(one));
-        }
-        aml_append(mem_ctrl_dev, method);
-
-        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
-        {
-            Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
-
-            aml_append(method, aml_store(zero, ret_val));
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method,
-                aml_store(aml_to_integer(slot_arg0), slot_selector));
-
-            ifctx = aml_if(aml_equal(slot_enabled, one));
-            {
-                aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
-            }
-            aml_append(method, ifctx);
-
-            aml_append(method, aml_release(ctrl_lock));
-            aml_append(method, aml_return(ret_val));
-        }
-        aml_append(mem_ctrl_dev, method);
-
-        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
-        {
-            Aml *mr64 = aml_name("MR64");
-            Aml *mr32 = aml_name("MR32");
-            Aml *crs_tmpl = aml_resource_template();
-            Aml *minl = aml_name("MINL");
-            Aml *minh = aml_name("MINH");
-            Aml *maxl =  aml_name("MAXL");
-            Aml *maxh =  aml_name("MAXH");
-            Aml *lenl = aml_name("LENL");
-            Aml *lenh = aml_name("LENH");
-
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(aml_to_integer(slot_arg0),
-                                         slot_selector));
-
-            aml_append(crs_tmpl,
-                aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
-                                 AML_CACHEABLE, AML_READ_WRITE,
-                                 0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
-                                 0xFFFFFFFFFFFFFFFFULL));
-            aml_append(method, aml_name_decl("MR64", crs_tmpl));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(14), "MINL"));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(18), "MINH"));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(38), "LENL"));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(42), "LENH"));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(22), "MAXL"));
-            aml_append(method,
-                aml_create_dword_field(mr64, aml_int(26), "MAXH"));
-
-            aml_append(method,
-                aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
-            aml_append(method,
-                aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
-            aml_append(method,
-                aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
-            aml_append(method,
-                aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
-
-            /* 64-bit math: MAX = MIN + LEN - 1 */
-            aml_append(method, aml_add(minl, lenl, maxl));
-            aml_append(method, aml_add(minh, lenh, maxh));
-            ifctx = aml_if(aml_lless(maxl, minl));
-            {
-                aml_append(ifctx, aml_add(maxh, one, maxh));
-            }
-            aml_append(method, ifctx);
-            ifctx = aml_if(aml_lless(maxl, one));
-            {
-                aml_append(ifctx, aml_subtract(maxh, one, maxh));
-            }
-            aml_append(method, ifctx);
-            aml_append(method, aml_subtract(maxl, one, maxl));
-
-            /* return 32-bit _CRS if addr/size is in low mem */
-            /* TODO: remove it since all hotplugged DIMMs are in high mem */
-            ifctx = aml_if(aml_equal(maxh, zero));
-            {
-                crs_tmpl = aml_resource_template();
-                aml_append(crs_tmpl,
-                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
-                                     AML_MAX_FIXED, AML_CACHEABLE,
-                                     AML_READ_WRITE,
-                                     0, 0x0, 0xFFFFFFFE, 0,
-                                     0xFFFFFFFF));
-                aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
-                aml_append(ifctx,
-                    aml_create_dword_field(mr32, aml_int(10), "MIN"));
-                aml_append(ifctx,
-                    aml_create_dword_field(mr32, aml_int(14), "MAX"));
-                aml_append(ifctx,
-                    aml_create_dword_field(mr32, aml_int(22), "LEN"));
-                aml_append(ifctx, aml_store(minl, aml_name("MIN")));
-                aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
-                aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
-
-                aml_append(ifctx, aml_release(ctrl_lock));
-                aml_append(ifctx, aml_return(mr32));
-            }
-            aml_append(method, ifctx);
-
-            aml_append(method, aml_release(ctrl_lock));
-            aml_append(method, aml_return(mr64));
-        }
-        aml_append(mem_ctrl_dev, method);
-
-        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
-                            AML_NOTSERIALIZED);
-        {
-            Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
-
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(aml_to_integer(slot_arg0),
-                                         slot_selector));
-            aml_append(method, aml_store(proximity, ret_val));
-            aml_append(method, aml_release(ctrl_lock));
-            aml_append(method, aml_return(ret_val));
-        }
-        aml_append(mem_ctrl_dev, method);
-
-        method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
-        {
-            Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
-            Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
-
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(aml_to_integer(slot_arg0),
-                                         slot_selector));
-            aml_append(method, aml_store(aml_arg(1), ost_evt));
-            aml_append(method, aml_store(aml_arg(2), ost_status));
-            aml_append(method, aml_release(ctrl_lock));
-        }
-        aml_append(mem_ctrl_dev, method);
-
-        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
-        {
-            Aml *eject = aml_name(MEMORY_SLOT_EJECT);
-
-            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(aml_to_integer(slot_arg0),
-                                         slot_selector));
-            aml_append(method, aml_store(one, eject));
-            aml_append(method, aml_release(ctrl_lock));
-        }
-        aml_append(mem_ctrl_dev, method);
-    }
-    aml_append(pci_scope, mem_ctrl_dev);
-    aml_append(ctx, pci_scope);
-}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() into memory_hotplug.c
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (2 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-20 10:44   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration Igor Mammedov
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |   2 +
 hw/acpi/memory_hotplug.c         | 124 +++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-build.c             | 124 ---------------------------------------
 3 files changed, 126 insertions(+), 124 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index d2c7452..964c244 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len);
+void build_memory_devices(Aml *sb_scope, int nr_mem,
+                          uint16_t io_base, uint16_t io_len);
 #endif
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 57ac4fc..67dd3f8 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -553,3 +553,127 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
     aml_append(pci_scope, mem_ctrl_dev);
     aml_append(ctx, pci_scope);
 }
+
+void build_memory_devices(Aml *sb_scope, int nr_mem,
+                          uint16_t io_base, uint16_t io_len)
+{
+    int i;
+    Aml *scope;
+    Aml *crs;
+    Aml *field;
+    Aml *dev;
+    Aml *method;
+    Aml *ifctx;
+
+    /* build memory devices */
+    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
+    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
+    aml_append(scope,
+        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
+    );
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
+    );
+    aml_append(scope, aml_name_decl("_CRS", crs));
+
+    aml_append(scope, aml_operation_region(
+        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
+        aml_int(io_base), io_len)
+    );
+
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+                      AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, /* read only */
+        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
+    aml_append(field, /* read only */
+        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
+    aml_append(field, /* read only */
+        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
+    aml_append(field, /* read only */
+        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
+    aml_append(field, /* read only */
+        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
+    aml_append(scope, field);
+
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
+                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
+    aml_append(field, /* 1 if enabled, read only */
+        aml_named_field(MEMORY_SLOT_ENABLED, 1));
+    aml_append(field,
+        /*(read) 1 if has a insert event. (write) 1 to clear event */
+        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
+    aml_append(field,
+        /* (read) 1 if has a remove event. (write) 1 to clear event */
+        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
+    aml_append(field,
+        /* initiates device eject, write only */
+        aml_named_field(MEMORY_SLOT_EJECT, 1));
+    aml_append(scope, field);
+
+    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+                      AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, /* DIMM selector, write only */
+        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
+    aml_append(field, /* _OST event code, write only */
+        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
+    aml_append(field, /* _OST status code, write only */
+        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
+    aml_append(scope, field);
+    aml_append(sb_scope, scope);
+
+    for (i = 0; i < nr_mem; i++) {
+        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
+        const char *s;
+
+        dev = aml_device("MP%02X", i);
+        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
+
+        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
+        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
+        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
+        s = BASEPATH MEMORY_SLOT_OST_METHOD;
+
+        aml_append(method, aml_return(aml_call4(
+            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
+        )));
+        aml_append(dev, method);
+
+        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
+        aml_append(method, aml_return(aml_call2(
+                   s, aml_name("_UID"), aml_arg(0))));
+        aml_append(dev, method);
+
+        aml_append(sb_scope, dev);
+    }
+
+    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
+     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
+     */
+    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
+    for (i = 0; i < nr_mem; i++) {
+        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
+        aml_append(ifctx,
+            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
+        );
+        aml_append(method, ifctx);
+    }
+    aml_append(sb_scope, method);
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 9708cdc..38dcac7 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1038,130 +1038,6 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
     return crs;
 }
 
-static void build_memory_devices(Aml *sb_scope, int nr_mem,
-                                 uint16_t io_base, uint16_t io_len)
-{
-    int i;
-    Aml *scope;
-    Aml *crs;
-    Aml *field;
-    Aml *dev;
-    Aml *method;
-    Aml *ifctx;
-
-    /* build memory devices */
-    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
-    aml_append(scope,
-        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
-    );
-
-    crs = aml_resource_template();
-    aml_append(crs,
-        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
-    );
-    aml_append(scope, aml_name_decl("_CRS", crs));
-
-    aml_append(scope, aml_operation_region(
-        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
-        aml_int(io_base), io_len)
-    );
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
-                      AML_NOLOCK, AML_PRESERVE);
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
-    aml_append(scope, field);
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
-                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
-    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
-    aml_append(field, /* 1 if enabled, read only */
-        aml_named_field(MEMORY_SLOT_ENABLED, 1));
-    aml_append(field,
-        /*(read) 1 if has a insert event. (write) 1 to clear event */
-        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
-    aml_append(field,
-        /* (read) 1 if has a remove event. (write) 1 to clear event */
-        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
-    aml_append(field,
-        /* initiates device eject, write only */
-        aml_named_field(MEMORY_SLOT_EJECT, 1));
-    aml_append(scope, field);
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
-                      AML_NOLOCK, AML_PRESERVE);
-    aml_append(field, /* DIMM selector, write only */
-        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
-    aml_append(field, /* _OST event code, write only */
-        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
-    aml_append(field, /* _OST status code, write only */
-        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
-    aml_append(scope, field);
-    aml_append(sb_scope, scope);
-
-    for (i = 0; i < nr_mem; i++) {
-        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
-        const char *s;
-
-        dev = aml_device("MP%02X", i);
-        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
-        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
-
-        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        aml_append(dev, method);
-
-        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        aml_append(dev, method);
-
-        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        aml_append(dev, method);
-
-        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_OST_METHOD;
-
-        aml_append(method, aml_return(aml_call4(
-            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
-        )));
-        aml_append(dev, method);
-
-        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
-        aml_append(method, aml_return(aml_call2(
-                   s, aml_name("_UID"), aml_arg(0))));
-        aml_append(dev, method);
-
-        aml_append(sb_scope, dev);
-    }
-
-    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
-     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
-     */
-    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
-    for (i = 0; i < nr_mem; i++) {
-        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
-        aml_append(ifctx,
-            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
-        );
-        aml_append(method, ifctx);
-    }
-    aml_append(sb_scope, method);
-}
-
 static void build_hpet_aml(Aml *table)
 {
     Aml *crs;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (3 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() " Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-20 11:00   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml() Igor Mammedov
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

since static and dynamic parts of memory MHPD device are now
in the same table (DSDT), there is no point keeping
them scattered across the table, so consolidate it
in one place.

There aren't any functional change, only AML text movement
from externally refferenced MHPD scope directly into
MHPD device declaration.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |   2 +-
 hw/acpi/memory_hotplug.c         | 123 +++++++++++++++++++--------------------
 2 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 964c244..c70481e 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
      MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
 
-void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
+void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len);
 void build_memory_devices(Aml *sb_scope, int nr_mem,
                           uint16_t io_base, uint16_t io_len);
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 67dd3f8..fb40a5e 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = {
     }
 };
 
-void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
+void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len)
 {
     Aml *ifctx;
@@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
     pci_scope = aml_scope("_SB.PCI0");
     mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
     {
+        Aml *crs;
+        Aml *field;
         Aml *one = aml_int(1);
         Aml *zero = aml_int(0);
         Aml *ret_val = aml_local(0);
@@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         aml_append(mem_ctrl_dev,
             aml_name_decl("_UID", aml_string("Memory hotplug resources")));
 
+        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
+        aml_append(mem_ctrl_dev,
+            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
+        );
+
+        crs = aml_resource_template();
+        aml_append(crs,
+            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
+        );
+        aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
+
+        aml_append(mem_ctrl_dev, aml_operation_region(
+            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
+            aml_int(io_base), io_len)
+        );
+
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+                          AML_NOLOCK, AML_PRESERVE);
+        aml_append(field, /* read only */
+            aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
+        aml_append(field, /* read only */
+            aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
+        aml_append(field, /* read only */
+            aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
+        aml_append(field, /* read only */
+            aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
+        aml_append(field, /* read only */
+            aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
+        aml_append(mem_ctrl_dev, field);
+
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
+                          AML_NOLOCK, AML_WRITE_AS_ZEROS);
+        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
+        aml_append(field, /* 1 if enabled, read only */
+            aml_named_field(MEMORY_SLOT_ENABLED, 1));
+        aml_append(field,
+            /*(read) 1 if has a insert event. (write) 1 to clear event */
+            aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
+        aml_append(field,
+            /* (read) 1 if has a remove event. (write) 1 to clear event */
+            aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
+        aml_append(field,
+            /* initiates device eject, write only */
+            aml_named_field(MEMORY_SLOT_EJECT, 1));
+        aml_append(mem_ctrl_dev, field);
+
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+                          AML_NOLOCK, AML_PRESERVE);
+        aml_append(field, /* DIMM selector, write only */
+            aml_named_field(MEMORY_SLOT_SLECTOR, 32));
+        aml_append(field, /* _OST event code, write only */
+            aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
+        aml_append(field, /* _OST status code, write only */
+            aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
+        aml_append(mem_ctrl_dev, field);
+
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
         ifctx = aml_if(aml_equal(slots_nr, zero));
         {
@@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
         aml_append(mem_ctrl_dev, method);
     }
     aml_append(pci_scope, mem_ctrl_dev);
-    aml_append(ctx, pci_scope);
+    aml_append(table, pci_scope);
 }
 
 void build_memory_devices(Aml *sb_scope, int nr_mem,
                           uint16_t io_base, uint16_t io_len)
 {
     int i;
-    Aml *scope;
-    Aml *crs;
-    Aml *field;
     Aml *dev;
     Aml *method;
     Aml *ifctx;
 
     /* build memory devices */
-    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
-    aml_append(scope,
-        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
-    );
-
-    crs = aml_resource_template();
-    aml_append(crs,
-        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
-    );
-    aml_append(scope, aml_name_decl("_CRS", crs));
-
-    aml_append(scope, aml_operation_region(
-        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
-        aml_int(io_base), io_len)
-    );
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
-                      AML_NOLOCK, AML_PRESERVE);
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
-    aml_append(field, /* read only */
-        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
-    aml_append(scope, field);
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
-                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
-    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
-    aml_append(field, /* 1 if enabled, read only */
-        aml_named_field(MEMORY_SLOT_ENABLED, 1));
-    aml_append(field,
-        /*(read) 1 if has a insert event. (write) 1 to clear event */
-        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
-    aml_append(field,
-        /* (read) 1 if has a remove event. (write) 1 to clear event */
-        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
-    aml_append(field,
-        /* initiates device eject, write only */
-        aml_named_field(MEMORY_SLOT_EJECT, 1));
-    aml_append(scope, field);
-
-    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
-                      AML_NOLOCK, AML_PRESERVE);
-    aml_append(field, /* DIMM selector, write only */
-        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
-    aml_append(field, /* _OST event code, write only */
-        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
-    aml_append(field, /* _OST status code, write only */
-        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
-    aml_append(scope, field);
-    aml_append(sb_scope, scope);
-
     for (i = 0; i < nr_mem; i++) {
         #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
         const char *s;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml()
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (4 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-21 12:10   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 " Igor Mammedov
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

It consolidates memory hotplug AML in one place within DSDT

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |  2 --
 hw/acpi/memory_hotplug.c         | 14 ++++-----
 hw/i386/acpi-build.c             | 61 ++++++++++++++++++----------------------
 3 files changed, 33 insertions(+), 44 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index c70481e..6dc48d2 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len);
-void build_memory_devices(Aml *sb_scope, int nr_mem,
-                          uint16_t io_base, uint16_t io_len);
 #endif
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index fb40a5e..18b95f2 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len)
 {
+    int i;
     Aml *ifctx;
     Aml *method;
     Aml *pci_scope;
+    Aml *sb_scope;
     Aml *mem_ctrl_dev;
 
     /* scope for memory hotplug controller device node */
@@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     }
     aml_append(pci_scope, mem_ctrl_dev);
     aml_append(table, pci_scope);
-}
-
-void build_memory_devices(Aml *sb_scope, int nr_mem,
-                          uint16_t io_base, uint16_t io_len)
-{
-    int i;
-    Aml *dev;
-    Aml *method;
-    Aml *ifctx;
 
+    sb_scope = aml_scope("_SB");
     /* build memory devices */
     for (i = 0; i < nr_mem; i++) {
         #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
+        Aml *dev;
         const char *s;
 
         dev = aml_device("MP%02X", i);
@@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,
         aml_append(method, ifctx);
     }
     aml_append(sb_scope, method);
+    aml_append(table, sb_scope);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 38dcac7..690e9a0 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
     sb_scope = aml_scope("\\_SB");
     {
-        build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
-                             pm->mem_hp_io_len);
+        Object *pci_host;
+        PCIBus *bus = NULL;
 
-        {
-            Object *pci_host;
-            PCIBus *bus = NULL;
+        pci_host = acpi_get_i386_pci_host();
+        if (pci_host) {
+            bus = PCI_HOST_BRIDGE(pci_host)->bus;
+        }
 
-            pci_host = acpi_get_i386_pci_host();
-            if (pci_host) {
-                bus = PCI_HOST_BRIDGE(pci_host)->bus;
+        if (bus) {
+            Aml *scope = aml_scope("PCI0");
+            /* Scan all PCI buses. Generate tables to support hotplug. */
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+
+            if (misc->tpm_version != TPM_VERSION_UNSPEC) {
+                dev = aml_device("ISA.TPM");
+                aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
+                aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+                crs = aml_resource_template();
+                aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
+                           TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
+                /*
+                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
+                    Rewrite to take IRQ from TPM device model and
+                    fix default IRQ value there to use some unused IRQ
+                 */
+                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
+                aml_append(dev, aml_name_decl("_CRS", crs));
+                aml_append(scope, dev);
             }
 
-            if (bus) {
-                Aml *scope = aml_scope("PCI0");
-                /* Scan all PCI buses. Generate tables to support hotplug. */
-                build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
-
-                if (misc->tpm_version != TPM_VERSION_UNSPEC) {
-                    dev = aml_device("ISA.TPM");
-                    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
-                    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-                    crs = aml_resource_template();
-                    aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
-                               TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
-                    /*
-                        FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
-                        Rewrite to take IRQ from TPM device model and
-                        fix default IRQ value there to use some unused IRQ
-                     */
-                    /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
-                    aml_append(dev, aml_name_decl("_CRS", crs));
-                    aml_append(scope, dev);
-                }
-
-                aml_append(sb_scope, scope);
-            }
+            aml_append(sb_scope, scope);
         }
-        aml_append(dsdt, sb_scope);
     }
+    aml_append(dsdt, sb_scope);
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (5 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml() Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-21 12:31   ` Marcel Apfelbaum
  2016-12-22 15:10   ` [Qemu-devel] [PATCH for-2.9 v2 " Igor Mammedov
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c Igor Mammedov
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

>From this patch all the memory hotplug related AML
bits are consolidated in one place within DSTD.
Follow up patches will utilize that to simplify
memory hotplug related C/AML code.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |  6 +++---
 hw/acpi/memory_hotplug.c         | 42 ++++++++++++++++++++++++++--------------
 hw/i386/acpi-build.c             |  7 ++-----
 3 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 6dc48d2..37e2706 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
 #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
-#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
-     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len);
+                              uint16_t io_base, uint16_t io_len,
+                              const char *res_root,
+                              const char *event_handler_method);
 #endif
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 18b95f2..49e856f 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = {
 };
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len)
+                              uint16_t io_base, uint16_t io_len,
+                              const char *res_root,
+                              const char *event_handler_method)
 {
     int i;
     Aml *ifctx;
     Aml *method;
-    Aml *pci_scope;
     Aml *sb_scope;
     Aml *mem_ctrl_dev;
+    char *scan_path;
+    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
 
-    /* scope for memory hotplug controller device node */
-    pci_scope = aml_scope("_SB.PCI0");
-    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
+    mem_ctrl_dev = aml_device("%s", mhp_res_path);
     {
         Aml *crs;
         Aml *field;
@@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
         }
         aml_append(mem_ctrl_dev, method);
     }
-    aml_append(pci_scope, mem_ctrl_dev);
-    aml_append(table, pci_scope);
+    aml_append(table, mem_ctrl_dev);
 
     sb_scope = aml_scope("_SB");
     /* build memory devices */
     for (i = 0; i < nr_mem; i++) {
-        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
         Aml *dev;
-        const char *s;
+        char *s;
 
         dev = aml_device("MP%02X", i);
         aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
 
         method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path,
+                            MEMORY_SLOT_PROXIMITY_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_OST", 3, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_OST_METHOD;
-
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
         aml_append(method, aml_return(aml_call4(
             s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
         )));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
         aml_append(method, aml_return(aml_call2(
                    s, aml_name("_UID"), aml_arg(0))));
+        g_free(s);
         aml_append(dev, method);
 
         aml_append(sb_scope, dev);
@@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     }
     aml_append(sb_scope, method);
     aml_append(table, sb_scope);
+
+    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
+    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
+    aml_append(method, aml_call0(scan_path));
+    g_free(scan_path);
+    aml_append(table, method);
+
+    g_free(mhp_res_path);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 690e9a0..b7f4682 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
     build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
-                             pm->mem_hp_io_len);
+                             pm->mem_hp_io_len,
+                             "\\_SB.PCI0", "\\_GPE._E03");
 
     scope =  aml_scope("_GPE");
     {
@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             aml_append(scope, method);
         }
 
-        method = aml_method("_E03", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
-        aml_append(scope, method);
-
         if (pcms->acpi_nvdimm_state.is_enabled) {
             method = aml_method("_E04", 0, AML_NOTSERIALIZED);
             aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (6 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 " Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-21 12:32   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported Igor Mammedov
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Move defines used locally only by memory_hotplug.c into it
from header files.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |  3 ---
 include/hw/acpi/pc-hotplug.h     | 22 ----------------------
 hw/acpi/memory_hotplug.c         | 24 ++++++++++++++++++++++++
 3 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 37e2706..91d4045 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -47,9 +47,6 @@ extern const VMStateDescription vmstate_memory_hotplug;
 
 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
-#define MEMORY_HOTPLUG_DEVICE        "MHPD"
-#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
-
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               uint16_t io_base, uint16_t io_len,
                               const char *res_root,
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 6a8d268..a4f513d 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -32,26 +32,4 @@
 #define ACPI_MEMORY_HOTPLUG_IO_LEN 24
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
-#define MEMORY_SLOTS_NUMBER          "MDNR"
-#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
-#define MEMORY_SLOT_ADDR_LOW         "MRBL"
-#define MEMORY_SLOT_ADDR_HIGH        "MRBH"
-#define MEMORY_SLOT_SIZE_LOW         "MRLL"
-#define MEMORY_SLOT_SIZE_HIGH        "MRLH"
-#define MEMORY_SLOT_PROXIMITY        "MPX"
-#define MEMORY_SLOT_ENABLED          "MES"
-#define MEMORY_SLOT_INSERT_EVENT     "MINS"
-#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
-#define MEMORY_SLOT_EJECT            "MEJ"
-#define MEMORY_SLOT_SLECTOR          "MSEL"
-#define MEMORY_SLOT_OST_EVENT        "MOEV"
-#define MEMORY_SLOT_OST_STATUS       "MOSC"
-#define MEMORY_SLOT_LOCK             "MLCK"
-#define MEMORY_SLOT_STATUS_METHOD    "MRST"
-#define MEMORY_SLOT_CRS_METHOD       "MCRS"
-#define MEMORY_SLOT_OST_METHOD       "MOST"
-#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
-#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
-#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
-
 #endif
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 49e856f..da29332 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -7,6 +7,30 @@
 #include "trace.h"
 #include "qapi-event.h"
 
+#define MEMORY_SLOTS_NUMBER          "MDNR"
+#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
+#define MEMORY_SLOT_ADDR_LOW         "MRBL"
+#define MEMORY_SLOT_ADDR_HIGH        "MRBH"
+#define MEMORY_SLOT_SIZE_LOW         "MRLL"
+#define MEMORY_SLOT_SIZE_HIGH        "MRLH"
+#define MEMORY_SLOT_PROXIMITY        "MPX"
+#define MEMORY_SLOT_ENABLED          "MES"
+#define MEMORY_SLOT_INSERT_EVENT     "MINS"
+#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
+#define MEMORY_SLOT_EJECT            "MEJ"
+#define MEMORY_SLOT_SLECTOR          "MSEL"
+#define MEMORY_SLOT_OST_EVENT        "MOEV"
+#define MEMORY_SLOT_OST_STATUS       "MOSC"
+#define MEMORY_SLOT_LOCK             "MLCK"
+#define MEMORY_SLOT_STATUS_METHOD    "MRST"
+#define MEMORY_SLOT_CRS_METHOD       "MCRS"
+#define MEMORY_SLOT_OST_METHOD       "MOST"
+#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
+#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
+#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
+#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
+#define MEMORY_HOTPLUG_DEVICE        "MHPD"
+
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
     ACPIOSTInfo *info = g_new0(ACPIOSTInfo, 1);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (7 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-22 10:55   ` Marcel Apfelbaum
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods Igor Mammedov
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

That reduces DSDT by 910 bytes when memory hotplug
isn't enabled.

While doing so drop intermediate variables/arguments
passing around ACPI_MEMORY_HOTPLUG_IO_LEN and making
it local to memory_hotplug.c, hardcoding it there as
it can't change.

Also don't pass around ACPI_MEMORY_HOTPLUG_BASE through
intermediate variables/arguments where it's not needed.
Instead initialize in module static variable when MMIO
region is mapped and use that within memory_hotplug.c
whenever it's required.
That way MMIO base specified only at one place and AML
with MMIO would always use the same value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/memory_hotplug.h |  3 +--
 include/hw/acpi/pc-hotplug.h     |  1 -
 hw/acpi/ich9.c                   |  3 ++-
 hw/acpi/memory_hotplug.c         | 24 +++++++++++++++++-------
 hw/acpi/piix4.c                  |  3 ++-
 hw/i386/acpi-build.c             |  9 +--------
 6 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 91d4045..db8ebc9 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -30,7 +30,7 @@ typedef struct MemHotplugState {
 } MemHotplugState;
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state);
+                              MemHotplugState *state, uint16_t io_base);
 
 void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp);
@@ -48,7 +48,6 @@ extern const VMStateDescription vmstate_memory_hotplug;
 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len,
                               const char *res_root,
                               const char *event_handler_method);
 #endif
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index a4f513d..31bc919 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -29,7 +29,6 @@
 #define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00
 #define CPU_HOTPLUG_RESOURCE_DEVICE PRES
 
-#define ACPI_MEMORY_HOTPLUG_IO_LEN 24
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
 #endif
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 830c475..5c279bb 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -306,7 +306,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 
     if (pm->acpi_memory_hotplug.is_enabled) {
         acpi_memory_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci),
-                                 &pm->acpi_memory_hotplug);
+                                 &pm->acpi_memory_hotplug,
+                                 ACPI_MEMORY_HOTPLUG_BASE);
     }
 }
 
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index da29332..fb04d24 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -30,6 +30,9 @@
 #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
 #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
+#define MEMORY_HOTPLUG_IO_LEN         24
+
+static uint16_t memhp_io_base;
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -202,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = {
 };
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state)
+                              MemHotplugState *state, uint16_t io_base)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
 
@@ -211,10 +214,12 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
         return;
     }
 
+    assert(!memhp_io_base);
+    memhp_io_base = io_base;
     state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
     memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,
-                          "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN);
-    memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);
+                          "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN);
+    memory_region_add_subregion(as, memhp_io_base, &state->io);
 }
 
 /**
@@ -332,7 +337,6 @@ const VMStateDescription vmstate_memory_hotplug = {
 };
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len,
                               const char *res_root,
                               const char *event_handler_method)
 {
@@ -342,8 +346,13 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     Aml *sb_scope;
     Aml *mem_ctrl_dev;
     char *scan_path;
-    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
+    char *mhp_res_path;
+
+    if (!memhp_io_base) {
+        return;
+    }
 
+    mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
     mem_ctrl_dev = aml_device("%s", mhp_res_path);
     {
         Aml *crs;
@@ -367,13 +376,14 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
 
         crs = aml_resource_template();
         aml_append(crs,
-            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
+            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
+                   MEMORY_HOTPLUG_IO_LEN)
         );
         aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
 
         aml_append(mem_ctrl_dev, aml_operation_region(
             MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
-            aml_int(io_base), io_len)
+            aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
         );
 
         field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 17d36bd..6d99fe4 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -644,7 +644,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
                                  PIIX4_CPU_HOTPLUG_IO_BASE);
 
     if (s->acpi_memory_hotplug.is_enabled) {
-        acpi_memory_hotplug_init(parent, OBJECT(s), &s->acpi_memory_hotplug);
+        acpi_memory_hotplug_init(parent, OBJECT(s), &s->acpi_memory_hotplug,
+                                 ACPI_MEMORY_HOTPLUG_BASE);
     }
 }
 
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b7f4682..f207d4f 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -101,8 +101,6 @@ typedef struct AcpiPmInfo {
     uint32_t gpe0_blk_len;
     uint32_t io_base;
     uint16_t cpu_hp_io_base;
-    uint16_t mem_hp_io_base;
-    uint16_t mem_hp_io_len;
     uint16_t pcihp_io_base;
     uint16_t pcihp_io_len;
 } AcpiPmInfo;
@@ -148,9 +146,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
     }
     assert(obj);
 
-    pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
-    pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
-
     /* Fill in optional s3/s4 related properties */
     o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
     if (o) {
@@ -1925,9 +1920,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
-    build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
-                             pm->mem_hp_io_len,
-                             "\\_SB.PCI0", "\\_GPE._E03");
+    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
 
     scope =  aml_scope("_GPE");
     {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (8 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported Igor Mammedov
@ 2016-12-05 23:32 ` Igor Mammedov
  2016-12-22 12:31   ` Marcel Apfelbaum
  2016-12-16  9:07 ` [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
  2017-01-09 14:22 ` Igor Mammedov
  11 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-05 23:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum

Move DIMM devices from global _SB scope to a new \_SB.MHPC
container along with common methods used by DIMMs:
  MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY

this reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++-----------------------
 1 file changed, 97 insertions(+), 93 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index fb04d24..210073d 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -31,6 +31,7 @@
 #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
 #define MEMORY_HOTPLUG_IO_LEN         24
+#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
 
 static uint16_t memhp_io_base;
 
@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     int i;
     Aml *ifctx;
     Aml *method;
-    Aml *sb_scope;
+    Aml *dev_container;
     Aml *mem_ctrl_dev;
-    char *scan_path;
     char *mhp_res_path;
 
     if (!memhp_io_base) {
@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     mem_ctrl_dev = aml_device("%s", mhp_res_path);
     {
         Aml *crs;
-        Aml *field;
-        Aml *one = aml_int(1);
-        Aml *zero = aml_int(0);
-        Aml *ret_val = aml_local(0);
-        Aml *slot_arg0 = aml_arg(0);
-        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
-        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
-        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
 
         aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
         aml_append(mem_ctrl_dev,
             aml_name_decl("_UID", aml_string("Memory hotplug resources")));
 
-        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-        aml_append(mem_ctrl_dev,
-            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
-        );
-
         crs = aml_resource_template();
         aml_append(crs,
             aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
@@ -386,7 +373,32 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
         );
 
-        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+    }
+    aml_append(table, mem_ctrl_dev);
+
+    dev_container = aml_device(MEMORY_DEVICES_CONTAINER);
+    {
+        Aml *field;
+        Aml *one = aml_int(1);
+        Aml *zero = aml_int(0);
+        Aml *ret_val = aml_local(0);
+        Aml *slot_arg0 = aml_arg(0);
+        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
+        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
+        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
+        char *mmio_path = g_strdup_printf("%s." MEMORY_HOTPLUG_IO_REGION,
+                                          mhp_res_path);
+
+        aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));
+        aml_append(dev_container,
+            aml_name_decl("_UID", aml_string("DIMM devices")));
+
+        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
+        aml_append(dev_container,
+            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
+        );
+
+        field = aml_field(mmio_path, AML_DWORD_ACC,
                           AML_NOLOCK, AML_PRESERVE);
         aml_append(field, /* read only */
             aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
         aml_append(field, /* read only */
             aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
-        aml_append(mem_ctrl_dev, field);
+        aml_append(dev_container, field);
 
-        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
+        field = aml_field(mmio_path, AML_BYTE_ACC,
                           AML_NOLOCK, AML_WRITE_AS_ZEROS);
         aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
         aml_append(field, /* 1 if enabled, read only */
@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
         aml_append(field,
             /* initiates device eject, write only */
             aml_named_field(MEMORY_SLOT_EJECT, 1));
-        aml_append(mem_ctrl_dev, field);
+        aml_append(dev_container, field);
 
-        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
+        field = aml_field(mmio_path, AML_DWORD_ACC,
                           AML_NOLOCK, AML_PRESERVE);
         aml_append(field, /* DIMM selector, write only */
             aml_named_field(MEMORY_SLOT_SLECTOR, 32));
@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
         aml_append(field, /* _OST status code, write only */
             aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
-        aml_append(mem_ctrl_dev, field);
+        aml_append(dev_container, field);
+        g_free(mmio_path);
 
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
         ifctx = aml_if(aml_equal(slots_nr, zero));
@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
         aml_append(method, ifctx);
         /* present, functioning, decoding, not shown in UI */
         aml_append(method, aml_return(aml_int(0xB)));
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
-        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
+        aml_append(dev_container, aml_mutex(MEMORY_SLOT_LOCK, 0));
 
         method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
         {
@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_release(ctrl_lock));
             aml_append(method, aml_return(one));
         }
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
         method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
         {
@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_release(ctrl_lock));
             aml_append(method, aml_return(ret_val));
         }
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
         method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
         {
@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_release(ctrl_lock));
             aml_append(method, aml_return(mr64));
         }
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
         method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
                             AML_NOTSERIALIZED);
@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_release(ctrl_lock));
             aml_append(method, aml_return(ret_val));
         }
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
         method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
         {
@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_store(aml_arg(2), ost_status));
             aml_append(method, aml_release(ctrl_lock));
         }
-        aml_append(mem_ctrl_dev, method);
+        aml_append(dev_container, method);
 
         method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
         {
@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_append(method, aml_store(one, eject));
             aml_append(method, aml_release(ctrl_lock));
         }
-        aml_append(mem_ctrl_dev, method);
-    }
-    aml_append(table, mem_ctrl_dev);
-
-    sb_scope = aml_scope("_SB");
-    /* build memory devices */
-    for (i = 0; i < nr_mem; i++) {
-        Aml *dev;
-        char *s;
-
-        dev = aml_device("MP%02X", i);
-        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
-        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
-
-        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
-        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        g_free(s);
-        aml_append(dev, method);
-
-        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        g_free(s);
-        aml_append(dev, method);
-
-        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
-        s = g_strdup_printf("%s.%s", mhp_res_path,
-                            MEMORY_SLOT_PROXIMITY_METHOD);
-        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-        g_free(s);
-        aml_append(dev, method);
-
-        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
-        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
-        aml_append(method, aml_return(aml_call4(
-            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
-        )));
-        g_free(s);
-        aml_append(dev, method);
-
-        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
-        aml_append(method, aml_return(aml_call2(
-                   s, aml_name("_UID"), aml_arg(0))));
-        g_free(s);
-        aml_append(dev, method);
-
-        aml_append(sb_scope, dev);
-    }
+        aml_append(dev_container, method);
+
+        /* build memory devices */
+        for (i = 0; i < nr_mem; i++) {
+            Aml *dev;
+            const char *s;
+
+            dev = aml_device("MP%02X", i);
+            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
+            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
+
+            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
+            s = MEMORY_SLOT_CRS_METHOD;
+            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+            aml_append(dev, method);
+
+            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+            s = MEMORY_SLOT_STATUS_METHOD;
+            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+            aml_append(dev, method);
+
+            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
+            s = MEMORY_SLOT_PROXIMITY_METHOD;
+            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+            aml_append(dev, method);
+
+            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
+            s = MEMORY_SLOT_OST_METHOD;
+            aml_append(method, aml_return(aml_call4(
+                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
+            )));
+            aml_append(dev, method);
+
+            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+            s = MEMORY_SLOT_EJECT_METHOD;
+            aml_append(method, aml_return(aml_call2(
+                       s, aml_name("_UID"), aml_arg(0))));
+            aml_append(dev, method);
+
+            aml_append(dev_container, dev);
+        }
 
-    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
-     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
-     */
-    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
-    for (i = 0; i < nr_mem; i++) {
-        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
-        aml_append(ifctx,
-            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
-        );
-        aml_append(method, ifctx);
+        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
+         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
+         */
+        method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
+        for (i = 0; i < nr_mem; i++) {
+            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
+            aml_append(ifctx,
+                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
+            );
+            aml_append(method, ifctx);
+        }
+        aml_append(dev_container, method);
     }
-    aml_append(sb_scope, method);
-    aml_append(table, sb_scope);
+    aml_append(table, dev_container);
 
     method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
-    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
-    aml_append(method, aml_call0(scan_path));
-    g_free(scan_path);
+    aml_append(method,
+        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
     aml_append(table, method);
 
     g_free(mhp_res_path);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (9 preceding siblings ...)
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods Igor Mammedov
@ 2016-12-16  9:07 ` Igor Mammedov
  2017-01-09 14:22 ` Igor Mammedov
  11 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-16  9:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Apfelbaum, Eduardo Habkost, Michael S. Tsirkin

On Tue,  6 Dec 2016 00:32:19 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> Series cleanups and consolidates scattered memory hotplug
> code so it could be easily reused by ARM target later.
> 
> As result:
>  * added memory hotplug variant to bios tables test
>  * all ACPI related parts of memory hotplug are consolidated
>    within memory_hotplug.c
>  * DSDT table size is reduced ~900 bytes when memory hotplug
>    is not enabled (by not generating not used AML)
>  * DSDT table size is reduced on 12 bytes per slot
>    (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
>    enabled due AML reorganization that makes calls to common functions
>    smaller as devices and common functions are now within the same scope.
> 
> Tested with following guests:
>   - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
>   - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
>     it never worked as memhp is not supported there)
> 
> Git tree for testing:
>   https://github.com/imammedo/qemu.git memhp_consolidate_v1
> viewing:
>   https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
> 
> Note to maintaner:
>   * blobs patch 2/10 should be merged to patch 1/10
>   * ACPI tables should be regenarated and applied after series is merged
>     as DSDT will cange for all tests cases due removal of inactive
>     memory hotplug code.
> 
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Marcel Apfelbaum <marcel@redhat.com>

ping,

Michael, Marcel
 Could you take a look

 
> Igor Mammedov (10):
>   tests: pc: add memory hotplug acpi tables tests
>   tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
>   memhp: move build_memory_hotplug_aml() into memory_hotplug.c
>   memhp: move build_memory_devices() into memory_hotplug.c
>   memhp: consolidate scattered MHPD device declaration
>   memhp: merge build_memory_devices() into build_memory_hotplug_aml()
>   memhp: move GPE handler_E03 into build_memory_hotplug_aml()
>   memhp: move memory hotplug only defines to memory_hotplug.c
>   memhp: don't generate memory hotplug AML if it's not enabled/supported
>   memhp: move DIMM devices into dedicated scope with related common
>     methods
> 
>  include/hw/acpi/memory_hotplug.h    |  12 +-
>  include/hw/acpi/pc-hotplug.h        |  23 --
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/ich9.c                      |   3 +-
>  hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
>  hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
>  hw/acpi/piix4.c                     |   3 +-
>  hw/i386/acpi-build.c                | 197 +++--------------
>  tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
>  tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
>  tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
>  tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
>  tests/bios-tables-test.c            |  24 +++
>  13 files changed, 479 insertions(+), 467 deletions(-)
>  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>  create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
>  create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
>  create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
>  create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests Igor Mammedov
@ 2016-12-20 10:40   ` Marcel Apfelbaum
  2016-12-20 16:17     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-20 10:40 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  tests/bios-tables-test.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 812f830..5404805 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)
>      free_test_data(&data);
>  }
>

Hi Igor,


> +static void test_acpi_q35_tcg_memhp(void)
> +{
> +    test_data data;
> +
> +    memset(&data, 0, sizeof(data));
> +    data.machine = MACHINE_Q35;
> +    data.variant = ".memhp";
> +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);

Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))

Thanks,
Marcel

> +    free_test_data(&data);
> +}
> +
> +static void test_acpi_piix4_tcg_memhp(void)
> +{
> +    test_data data;
> +
> +    memset(&data, 0, sizeof(data));
> +    data.machine = MACHINE_PC;
> +    data.variant = ".memhp";
> +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
> +    free_test_data(&data);
> +}
> +
>  int main(int argc, char *argv[])
>  {
>      const char *arch = qtest_get_arch();
> @@ -887,6 +909,8 @@ int main(int argc, char *argv[])
>          qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
>          qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
>          qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
> +        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
> +        qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
>      }
>      ret = g_test_run();
>      boot_sector_cleanup(disk);
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c Igor Mammedov
@ 2016-12-20 10:42   ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-20 10:42 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/memory_hotplug.c            | 247 +++++++++++++++++++++++++++++++++
>  hw/acpi/memory_hotplug_acpi_table.c | 262 ------------------------------------
>  3 files changed, 248 insertions(+), 263 deletions(-)
>  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 489e63b..834c63b 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -1,7 +1,7 @@
>  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
>  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
> -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
> +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
>  common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
>  common-obj-$(CONFIG_ACPI) += acpi_interface.o
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index ec4e64b..57ac4fc 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -306,3 +306,250 @@ const VMStateDescription vmstate_memory_hotplug = {
>          VMSTATE_END_OF_LIST()
>      }
>  };
> +
> +void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> +                              uint16_t io_base, uint16_t io_len)
> +{
> +    Aml *ifctx;
> +    Aml *method;
> +    Aml *pci_scope;
> +    Aml *mem_ctrl_dev;
> +
> +    /* scope for memory hotplug controller device node */
> +    pci_scope = aml_scope("_SB.PCI0");
> +    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
> +    {
> +        Aml *one = aml_int(1);
> +        Aml *zero = aml_int(0);
> +        Aml *ret_val = aml_local(0);
> +        Aml *slot_arg0 = aml_arg(0);
> +        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> +        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> +        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
> +
> +        aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> +        aml_append(mem_ctrl_dev,
> +            aml_name_decl("_UID", aml_string("Memory hotplug resources")));
> +
> +        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> +        ifctx = aml_if(aml_equal(slots_nr, zero));
> +        {
> +            aml_append(ifctx, aml_return(zero));
> +        }
> +        aml_append(method, ifctx);
> +        /* present, functioning, decoding, not shown in UI */
> +        aml_append(method, aml_return(aml_int(0xB)));
> +        aml_append(mem_ctrl_dev, method);
> +
> +        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
> +
> +        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
> +        {
> +            Aml *else_ctx;
> +            Aml *while_ctx;
> +            Aml *idx = aml_local(0);
> +            Aml *eject_req = aml_int(3);
> +            Aml *dev_chk = aml_int(1);
> +
> +            ifctx = aml_if(aml_equal(slots_nr, zero));
> +            {
> +                aml_append(ifctx, aml_return(zero));
> +            }
> +            aml_append(method, ifctx);
> +
> +            aml_append(method, aml_store(zero, idx));
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            /* build AML that:
> +             * loops over all slots and Notifies DIMMs with
> +             * Device Check or Eject Request notifications if
> +             * slot has corresponding status bit set and clears
> +             * slot status.
> +             */
> +            while_ctx = aml_while(aml_lless(idx, slots_nr));
> +            {
> +                Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
> +                Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
> +
> +                aml_append(while_ctx, aml_store(idx, slot_selector));
> +                ifctx = aml_if(aml_equal(ins_evt, one));
> +                {
> +                    aml_append(ifctx,
> +                               aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
> +                                         idx, dev_chk));
> +                    aml_append(ifctx, aml_store(one, ins_evt));
> +                }
> +                aml_append(while_ctx, ifctx);
> +
> +                else_ctx = aml_else();
> +                ifctx = aml_if(aml_equal(rm_evt, one));
> +                {
> +                    aml_append(ifctx,
> +                        aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
> +                                  idx, eject_req));
> +                    aml_append(ifctx, aml_store(one, rm_evt));
> +                }
> +                aml_append(else_ctx, ifctx);
> +                aml_append(while_ctx, else_ctx);
> +
> +                aml_append(while_ctx, aml_add(idx, one, idx));
> +            }
> +            aml_append(method, while_ctx);
> +            aml_append(method, aml_release(ctrl_lock));
> +            aml_append(method, aml_return(one));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +
> +        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
> +        {
> +            Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
> +
> +            aml_append(method, aml_store(zero, ret_val));
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            aml_append(method,
> +                aml_store(aml_to_integer(slot_arg0), slot_selector));
> +
> +            ifctx = aml_if(aml_equal(slot_enabled, one));
> +            {
> +                aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
> +            }
> +            aml_append(method, ifctx);
> +
> +            aml_append(method, aml_release(ctrl_lock));
> +            aml_append(method, aml_return(ret_val));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +
> +        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
> +        {
> +            Aml *mr64 = aml_name("MR64");
> +            Aml *mr32 = aml_name("MR32");
> +            Aml *crs_tmpl = aml_resource_template();
> +            Aml *minl = aml_name("MINL");
> +            Aml *minh = aml_name("MINH");
> +            Aml *maxl =  aml_name("MAXL");
> +            Aml *maxh =  aml_name("MAXH");
> +            Aml *lenl = aml_name("LENL");
> +            Aml *lenh = aml_name("LENH");
> +
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> +                                         slot_selector));
> +
> +            aml_append(crs_tmpl,
> +                aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
> +                                 AML_CACHEABLE, AML_READ_WRITE,
> +                                 0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
> +                                 0xFFFFFFFFFFFFFFFFULL));
> +            aml_append(method, aml_name_decl("MR64", crs_tmpl));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(14), "MINL"));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(18), "MINH"));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(38), "LENL"));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(42), "LENH"));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(22), "MAXL"));
> +            aml_append(method,
> +                aml_create_dword_field(mr64, aml_int(26), "MAXH"));
> +
> +            aml_append(method,
> +                aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
> +            aml_append(method,
> +                aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
> +            aml_append(method,
> +                aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
> +            aml_append(method,
> +                aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
> +
> +            /* 64-bit math: MAX = MIN + LEN - 1 */
> +            aml_append(method, aml_add(minl, lenl, maxl));
> +            aml_append(method, aml_add(minh, lenh, maxh));
> +            ifctx = aml_if(aml_lless(maxl, minl));
> +            {
> +                aml_append(ifctx, aml_add(maxh, one, maxh));
> +            }
> +            aml_append(method, ifctx);
> +            ifctx = aml_if(aml_lless(maxl, one));
> +            {
> +                aml_append(ifctx, aml_subtract(maxh, one, maxh));
> +            }
> +            aml_append(method, ifctx);
> +            aml_append(method, aml_subtract(maxl, one, maxl));
> +
> +            /* return 32-bit _CRS if addr/size is in low mem */
> +            /* TODO: remove it since all hotplugged DIMMs are in high mem */
> +            ifctx = aml_if(aml_equal(maxh, zero));
> +            {
> +                crs_tmpl = aml_resource_template();
> +                aml_append(crs_tmpl,
> +                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
> +                                     AML_MAX_FIXED, AML_CACHEABLE,
> +                                     AML_READ_WRITE,
> +                                     0, 0x0, 0xFFFFFFFE, 0,
> +                                     0xFFFFFFFF));
> +                aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
> +                aml_append(ifctx,
> +                    aml_create_dword_field(mr32, aml_int(10), "MIN"));
> +                aml_append(ifctx,
> +                    aml_create_dword_field(mr32, aml_int(14), "MAX"));
> +                aml_append(ifctx,
> +                    aml_create_dword_field(mr32, aml_int(22), "LEN"));
> +                aml_append(ifctx, aml_store(minl, aml_name("MIN")));
> +                aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
> +                aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
> +
> +                aml_append(ifctx, aml_release(ctrl_lock));
> +                aml_append(ifctx, aml_return(mr32));
> +            }
> +            aml_append(method, ifctx);
> +
> +            aml_append(method, aml_release(ctrl_lock));
> +            aml_append(method, aml_return(mr64));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +
> +        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
> +                            AML_NOTSERIALIZED);
> +        {
> +            Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
> +
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> +                                         slot_selector));
> +            aml_append(method, aml_store(proximity, ret_val));
> +            aml_append(method, aml_release(ctrl_lock));
> +            aml_append(method, aml_return(ret_val));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +
> +        method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
> +        {
> +            Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
> +            Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
> +
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> +                                         slot_selector));
> +            aml_append(method, aml_store(aml_arg(1), ost_evt));
> +            aml_append(method, aml_store(aml_arg(2), ost_status));
> +            aml_append(method, aml_release(ctrl_lock));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +
> +        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
> +        {
> +            Aml *eject = aml_name(MEMORY_SLOT_EJECT);
> +
> +            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> +            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> +                                         slot_selector));
> +            aml_append(method, aml_store(one, eject));
> +            aml_append(method, aml_release(ctrl_lock));
> +        }
> +        aml_append(mem_ctrl_dev, method);
> +    }
> +    aml_append(pci_scope, mem_ctrl_dev);
> +    aml_append(ctx, pci_scope);
> +}
> diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
> deleted file mode 100644
> index c756602..0000000
> --- a/hw/acpi/memory_hotplug_acpi_table.c
> +++ /dev/null
> @@ -1,262 +0,0 @@
> -/*
> - * Memory hotplug AML code of DSDT ACPI table
> - *
> - * Copyright (C) 2015 Red Hat Inc
> - *
> - * Author: Igor Mammedov <imammedo@redhat.com>
> - *
> - * This work is licensed under the terms of the GNU GPL, version 2 or later.
> - * See the COPYING file in the top-level directory.
> - */
> -
> -#include "qemu/osdep.h"
> -#include "hw/acpi/memory_hotplug.h"
> -#include "include/hw/acpi/pc-hotplug.h"
> -#include "hw/boards.h"
> -
> -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> -                              uint16_t io_base, uint16_t io_len)
> -{
> -    Aml *ifctx;
> -    Aml *method;
> -    Aml *pci_scope;
> -    Aml *mem_ctrl_dev;
> -
> -    /* scope for memory hotplug controller device node */
> -    pci_scope = aml_scope("_SB.PCI0");
> -    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
> -    {
> -        Aml *one = aml_int(1);
> -        Aml *zero = aml_int(0);
> -        Aml *ret_val = aml_local(0);
> -        Aml *slot_arg0 = aml_arg(0);
> -        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> -        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> -        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
> -
> -        aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
> -        aml_append(mem_ctrl_dev,
> -            aml_name_decl("_UID", aml_string("Memory hotplug resources")));
> -
> -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> -        ifctx = aml_if(aml_equal(slots_nr, zero));
> -        {
> -            aml_append(ifctx, aml_return(zero));
> -        }
> -        aml_append(method, ifctx);
> -        /* present, functioning, decoding, not shown in UI */
> -        aml_append(method, aml_return(aml_int(0xB)));
> -        aml_append(mem_ctrl_dev, method);
> -
> -        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
> -
> -        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
> -        {
> -            Aml *else_ctx;
> -            Aml *while_ctx;
> -            Aml *idx = aml_local(0);
> -            Aml *eject_req = aml_int(3);
> -            Aml *dev_chk = aml_int(1);
> -
> -            ifctx = aml_if(aml_equal(slots_nr, zero));
> -            {
> -                aml_append(ifctx, aml_return(zero));
> -            }
> -            aml_append(method, ifctx);
> -
> -            aml_append(method, aml_store(zero, idx));
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            /* build AML that:
> -             * loops over all slots and Notifies DIMMs with
> -             * Device Check or Eject Request notifications if
> -             * slot has corresponding status bit set and clears
> -             * slot status.
> -             */
> -            while_ctx = aml_while(aml_lless(idx, slots_nr));
> -            {
> -                Aml *ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
> -                Aml *rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
> -
> -                aml_append(while_ctx, aml_store(idx, slot_selector));
> -                ifctx = aml_if(aml_equal(ins_evt, one));
> -                {
> -                    aml_append(ifctx,
> -                               aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
> -                                         idx, dev_chk));
> -                    aml_append(ifctx, aml_store(one, ins_evt));
> -                }
> -                aml_append(while_ctx, ifctx);
> -
> -                else_ctx = aml_else();
> -                ifctx = aml_if(aml_equal(rm_evt, one));
> -                {
> -                    aml_append(ifctx,
> -                        aml_call2(MEMORY_SLOT_NOTIFY_METHOD,
> -                                  idx, eject_req));
> -                    aml_append(ifctx, aml_store(one, rm_evt));
> -                }
> -                aml_append(else_ctx, ifctx);
> -                aml_append(while_ctx, else_ctx);
> -
> -                aml_append(while_ctx, aml_add(idx, one, idx));
> -            }
> -            aml_append(method, while_ctx);
> -            aml_append(method, aml_release(ctrl_lock));
> -            aml_append(method, aml_return(one));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -
> -        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
> -        {
> -            Aml *slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
> -
> -            aml_append(method, aml_store(zero, ret_val));
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            aml_append(method,
> -                aml_store(aml_to_integer(slot_arg0), slot_selector));
> -
> -            ifctx = aml_if(aml_equal(slot_enabled, one));
> -            {
> -                aml_append(ifctx, aml_store(aml_int(0xF), ret_val));
> -            }
> -            aml_append(method, ifctx);
> -
> -            aml_append(method, aml_release(ctrl_lock));
> -            aml_append(method, aml_return(ret_val));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -
> -        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
> -        {
> -            Aml *mr64 = aml_name("MR64");
> -            Aml *mr32 = aml_name("MR32");
> -            Aml *crs_tmpl = aml_resource_template();
> -            Aml *minl = aml_name("MINL");
> -            Aml *minh = aml_name("MINH");
> -            Aml *maxl =  aml_name("MAXL");
> -            Aml *maxh =  aml_name("MAXH");
> -            Aml *lenl = aml_name("LENL");
> -            Aml *lenh = aml_name("LENH");
> -
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> -                                         slot_selector));
> -
> -            aml_append(crs_tmpl,
> -                aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
> -                                 AML_CACHEABLE, AML_READ_WRITE,
> -                                 0, 0x0, 0xFFFFFFFFFFFFFFFEULL, 0,
> -                                 0xFFFFFFFFFFFFFFFFULL));
> -            aml_append(method, aml_name_decl("MR64", crs_tmpl));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(14), "MINL"));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(18), "MINH"));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(38), "LENL"));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(42), "LENH"));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(22), "MAXL"));
> -            aml_append(method,
> -                aml_create_dword_field(mr64, aml_int(26), "MAXH"));
> -
> -            aml_append(method,
> -                aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH), minh));
> -            aml_append(method,
> -                aml_store(aml_name(MEMORY_SLOT_ADDR_LOW), minl));
> -            aml_append(method,
> -                aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH), lenh));
> -            aml_append(method,
> -                aml_store(aml_name(MEMORY_SLOT_SIZE_LOW), lenl));
> -
> -            /* 64-bit math: MAX = MIN + LEN - 1 */
> -            aml_append(method, aml_add(minl, lenl, maxl));
> -            aml_append(method, aml_add(minh, lenh, maxh));
> -            ifctx = aml_if(aml_lless(maxl, minl));
> -            {
> -                aml_append(ifctx, aml_add(maxh, one, maxh));
> -            }
> -            aml_append(method, ifctx);
> -            ifctx = aml_if(aml_lless(maxl, one));
> -            {
> -                aml_append(ifctx, aml_subtract(maxh, one, maxh));
> -            }
> -            aml_append(method, ifctx);
> -            aml_append(method, aml_subtract(maxl, one, maxl));
> -
> -            /* return 32-bit _CRS if addr/size is in low mem */
> -            /* TODO: remove it since all hotplugged DIMMs are in high mem */
> -            ifctx = aml_if(aml_equal(maxh, zero));
> -            {
> -                crs_tmpl = aml_resource_template();
> -                aml_append(crs_tmpl,
> -                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
> -                                     AML_MAX_FIXED, AML_CACHEABLE,
> -                                     AML_READ_WRITE,
> -                                     0, 0x0, 0xFFFFFFFE, 0,
> -                                     0xFFFFFFFF));
> -                aml_append(ifctx, aml_name_decl("MR32", crs_tmpl));
> -                aml_append(ifctx,
> -                    aml_create_dword_field(mr32, aml_int(10), "MIN"));
> -                aml_append(ifctx,
> -                    aml_create_dword_field(mr32, aml_int(14), "MAX"));
> -                aml_append(ifctx,
> -                    aml_create_dword_field(mr32, aml_int(22), "LEN"));
> -                aml_append(ifctx, aml_store(minl, aml_name("MIN")));
> -                aml_append(ifctx, aml_store(maxl, aml_name("MAX")));
> -                aml_append(ifctx, aml_store(lenl, aml_name("LEN")));
> -
> -                aml_append(ifctx, aml_release(ctrl_lock));
> -                aml_append(ifctx, aml_return(mr32));
> -            }
> -            aml_append(method, ifctx);
> -
> -            aml_append(method, aml_release(ctrl_lock));
> -            aml_append(method, aml_return(mr64));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -
> -        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
> -                            AML_NOTSERIALIZED);
> -        {
> -            Aml *proximity = aml_name(MEMORY_SLOT_PROXIMITY);
> -
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> -                                         slot_selector));
> -            aml_append(method, aml_store(proximity, ret_val));
> -            aml_append(method, aml_release(ctrl_lock));
> -            aml_append(method, aml_return(ret_val));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -
> -        method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
> -        {
> -            Aml *ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
> -            Aml *ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
> -
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> -                                         slot_selector));
> -            aml_append(method, aml_store(aml_arg(1), ost_evt));
> -            aml_append(method, aml_store(aml_arg(2), ost_status));
> -            aml_append(method, aml_release(ctrl_lock));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -
> -        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
> -        {
> -            Aml *eject = aml_name(MEMORY_SLOT_EJECT);
> -
> -            aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
> -            aml_append(method, aml_store(aml_to_integer(slot_arg0),
> -                                         slot_selector));
> -            aml_append(method, aml_store(one, eject));
> -            aml_append(method, aml_release(ctrl_lock));
> -        }
> -        aml_append(mem_ctrl_dev, method);
> -    }
> -    aml_append(pci_scope, mem_ctrl_dev);
> -    aml_append(ctx, pci_scope);
> -}
>

I suppose we don't need the extra file.


Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() into memory_hotplug.c
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() " Igor Mammedov
@ 2016-12-20 10:44   ` Marcel Apfelbaum
  2016-12-20 16:24     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-20 10:44 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |   2 +
>  hw/acpi/memory_hotplug.c         | 124 +++++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c             | 124 ---------------------------------------
>  3 files changed, 126 insertions(+), 124 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index d2c7452..964c244 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>
>  void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len);
> +void build_memory_devices(Aml *sb_scope, int nr_mem,
> +                          uint16_t io_base, uint16_t io_len);


We add an extra function to the header file, but if it can be used
by the ARM machines is worth it.

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

>  #endif
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 57ac4fc..67dd3f8 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -553,3 +553,127 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>      aml_append(pci_scope, mem_ctrl_dev);
>      aml_append(ctx, pci_scope);
>  }
> +
> +void build_memory_devices(Aml *sb_scope, int nr_mem,
> +                          uint16_t io_base, uint16_t io_len)
> +{
> +    int i;
> +    Aml *scope;
> +    Aml *crs;
> +    Aml *field;
> +    Aml *dev;
> +    Aml *method;
> +    Aml *ifctx;
> +
> +    /* build memory devices */
> +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> +    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> +    aml_append(scope,
> +        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> +    );
> +
> +    crs = aml_resource_template();
> +    aml_append(crs,
> +        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> +    );
> +    aml_append(scope, aml_name_decl("_CRS", crs));
> +
> +    aml_append(scope, aml_operation_region(
> +        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> +        aml_int(io_base), io_len)
> +    );
> +
> +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +                      AML_NOLOCK, AML_PRESERVE);
> +    aml_append(field, /* read only */
> +        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> +    aml_append(field, /* read only */
> +        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> +    aml_append(field, /* read only */
> +        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> +    aml_append(field, /* read only */
> +        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> +    aml_append(field, /* read only */
> +        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> +    aml_append(scope, field);
> +
> +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> +                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> +    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> +    aml_append(field, /* 1 if enabled, read only */
> +        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> +    aml_append(field,
> +        /*(read) 1 if has a insert event. (write) 1 to clear event */
> +        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> +    aml_append(field,
> +        /* (read) 1 if has a remove event. (write) 1 to clear event */
> +        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> +    aml_append(field,
> +        /* initiates device eject, write only */
> +        aml_named_field(MEMORY_SLOT_EJECT, 1));
> +    aml_append(scope, field);
> +
> +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +                      AML_NOLOCK, AML_PRESERVE);
> +    aml_append(field, /* DIMM selector, write only */
> +        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> +    aml_append(field, /* _OST event code, write only */
> +        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> +    aml_append(field, /* _OST status code, write only */
> +        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> +    aml_append(scope, field);
> +    aml_append(sb_scope, scope);
> +
> +    for (i = 0; i < nr_mem; i++) {
> +        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> +        const char *s;
> +
> +        dev = aml_device("MP%02X", i);
> +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> +
> +        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> +        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> +        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> +        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> +        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> +
> +        aml_append(method, aml_return(aml_call4(
> +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> +        )));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> +        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> +        aml_append(method, aml_return(aml_call2(
> +                   s, aml_name("_UID"), aml_arg(0))));
> +        aml_append(dev, method);
> +
> +        aml_append(sb_scope, dev);
> +    }
> +
> +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> +     */
> +    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> +    for (i = 0; i < nr_mem; i++) {
> +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> +        aml_append(ifctx,
> +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> +        );
> +        aml_append(method, ifctx);
> +    }
> +    aml_append(sb_scope, method);
> +}
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 9708cdc..38dcac7 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1038,130 +1038,6 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
>      return crs;
>  }
>
> -static void build_memory_devices(Aml *sb_scope, int nr_mem,
> -                                 uint16_t io_base, uint16_t io_len)
> -{
> -    int i;
> -    Aml *scope;
> -    Aml *crs;
> -    Aml *field;
> -    Aml *dev;
> -    Aml *method;
> -    Aml *ifctx;
> -
> -    /* build memory devices */
> -    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> -    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> -    aml_append(scope,
> -        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> -    );
> -
> -    crs = aml_resource_template();
> -    aml_append(crs,
> -        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> -    );
> -    aml_append(scope, aml_name_decl("_CRS", crs));
> -
> -    aml_append(scope, aml_operation_region(
> -        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> -        aml_int(io_base), io_len)
> -    );
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> -                      AML_NOLOCK, AML_PRESERVE);
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> -    aml_append(scope, field);
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> -                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> -    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> -    aml_append(field, /* 1 if enabled, read only */
> -        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> -    aml_append(field,
> -        /*(read) 1 if has a insert event. (write) 1 to clear event */
> -        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> -    aml_append(field,
> -        /* (read) 1 if has a remove event. (write) 1 to clear event */
> -        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> -    aml_append(field,
> -        /* initiates device eject, write only */
> -        aml_named_field(MEMORY_SLOT_EJECT, 1));
> -    aml_append(scope, field);
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> -                      AML_NOLOCK, AML_PRESERVE);
> -    aml_append(field, /* DIMM selector, write only */
> -        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> -    aml_append(field, /* _OST event code, write only */
> -        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> -    aml_append(field, /* _OST status code, write only */
> -        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> -    aml_append(scope, field);
> -    aml_append(sb_scope, scope);
> -
> -    for (i = 0; i < nr_mem; i++) {
> -        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> -        const char *s;
> -
> -        dev = aml_device("MP%02X", i);
> -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> -
> -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        aml_append(dev, method);
> -
> -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        aml_append(dev, method);
> -
> -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        aml_append(dev, method);
> -
> -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> -
> -        aml_append(method, aml_return(aml_call4(
> -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> -        )));
> -        aml_append(dev, method);
> -
> -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> -        aml_append(method, aml_return(aml_call2(
> -                   s, aml_name("_UID"), aml_arg(0))));
> -        aml_append(dev, method);
> -
> -        aml_append(sb_scope, dev);
> -    }
> -
> -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> -     */
> -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> -    for (i = 0; i < nr_mem; i++) {
> -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> -        aml_append(ifctx,
> -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> -        );
> -        aml_append(method, ifctx);
> -    }
> -    aml_append(sb_scope, method);
> -}
> -
>  static void build_hpet_aml(Aml *table)
>  {
>      Aml *crs;
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration Igor Mammedov
@ 2016-12-20 11:00   ` Marcel Apfelbaum
  2016-12-20 16:34     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-20 11:00 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> since static and dynamic parts of memory MHPD device are now
> in the same table (DSDT), there is no point keeping
> them scattered across the table, so consolidate it
> in one place.
>
> There aren't any functional change, only AML text movement
> from externally refferenced MHPD scope directly into
> MHPD device declaration.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |   2 +-
>  hw/acpi/memory_hotplug.c         | 123 +++++++++++++++++++--------------------
>  2 files changed, 61 insertions(+), 64 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 964c244..c70481e 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>  #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
>       MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
>
> -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len);
>  void build_memory_devices(Aml *sb_scope, int nr_mem,
>                            uint16_t io_base, uint16_t io_len);
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 67dd3f8..fb40a5e 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = {
>      }
>  };
>
> -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len)

The signature of the function is changed, but I see no caller changes.
Is this function used?

>  {
>      Aml *ifctx;
> @@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>      pci_scope = aml_scope("_SB.PCI0");
>      mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
>      {
> +        Aml *crs;
> +        Aml *field;
>          Aml *one = aml_int(1);
>          Aml *zero = aml_int(0);
>          Aml *ret_val = aml_local(0);
> @@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>          aml_append(mem_ctrl_dev,
>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
>
> +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> +        aml_append(mem_ctrl_dev,
> +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> +        );
> +
> +        crs = aml_resource_template();
> +        aml_append(crs,
> +            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> +        );
> +        aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> +
> +        aml_append(mem_ctrl_dev, aml_operation_region(
> +            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> +            aml_int(io_base), io_len)
> +        );
> +
> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +                          AML_NOLOCK, AML_PRESERVE);
> +        aml_append(field, /* read only */
> +            aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> +        aml_append(mem_ctrl_dev, field);
> +
> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> +                          AML_NOLOCK, AML_WRITE_AS_ZEROS);
> +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> +        aml_append(field, /* 1 if enabled, read only */
> +            aml_named_field(MEMORY_SLOT_ENABLED, 1));
> +        aml_append(field,
> +            /*(read) 1 if has a insert event. (write) 1 to clear event */
> +            aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> +        aml_append(field,
> +            /* (read) 1 if has a remove event. (write) 1 to clear event */
> +            aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> +        aml_append(field,
> +            /* initiates device eject, write only */
> +            aml_named_field(MEMORY_SLOT_EJECT, 1));
> +        aml_append(mem_ctrl_dev, field);
> +
> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +                          AML_NOLOCK, AML_PRESERVE);
> +        aml_append(field, /* DIMM selector, write only */
> +            aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> +        aml_append(field, /* _OST event code, write only */
> +            aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> +        aml_append(field, /* _OST status code, write only */
> +            aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> +        aml_append(mem_ctrl_dev, field);
> +
>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>          ifctx = aml_if(aml_equal(slots_nr, zero));
>          {
> @@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>          aml_append(mem_ctrl_dev, method);
>      }
>      aml_append(pci_scope, mem_ctrl_dev);
> -    aml_append(ctx, pci_scope);
> +    aml_append(table, pci_scope);
>  }
>
>  void build_memory_devices(Aml *sb_scope, int nr_mem,
>                            uint16_t io_base, uint16_t io_len)

Do you still need the io_base/io_len parameters here?

Thanks,
Marcel

>  {
>      int i;
> -    Aml *scope;
> -    Aml *crs;
> -    Aml *field;
>      Aml *dev;
>      Aml *method;
>      Aml *ifctx;
>
>      /* build memory devices */
> -    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> -    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> -    aml_append(scope,
> -        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> -    );
> -
> -    crs = aml_resource_template();
> -    aml_append(crs,
> -        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> -    );
> -    aml_append(scope, aml_name_decl("_CRS", crs));
> -
> -    aml_append(scope, aml_operation_region(
> -        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> -        aml_int(io_base), io_len)
> -    );
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> -                      AML_NOLOCK, AML_PRESERVE);
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> -    aml_append(field, /* read only */
> -        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> -    aml_append(scope, field);
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> -                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> -    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> -    aml_append(field, /* 1 if enabled, read only */
> -        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> -    aml_append(field,
> -        /*(read) 1 if has a insert event. (write) 1 to clear event */
> -        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> -    aml_append(field,
> -        /* (read) 1 if has a remove event. (write) 1 to clear event */
> -        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> -    aml_append(field,
> -        /* initiates device eject, write only */
> -        aml_named_field(MEMORY_SLOT_EJECT, 1));
> -    aml_append(scope, field);
> -
> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> -                      AML_NOLOCK, AML_PRESERVE);
> -    aml_append(field, /* DIMM selector, write only */
> -        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> -    aml_append(field, /* _OST event code, write only */
> -        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> -    aml_append(field, /* _OST status code, write only */
> -        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> -    aml_append(scope, field);
> -    aml_append(sb_scope, scope);
> -
>      for (i = 0; i < nr_mem; i++) {
>          #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
>          const char *s;
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
  2016-12-20 10:40   ` Marcel Apfelbaum
@ 2016-12-20 16:17     ` Igor Mammedov
  2016-12-20 17:00       ` Marcel Apfelbaum
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-20 16:17 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On Tue, 20 Dec 2016 12:40:21 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  tests/bios-tables-test.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> > index 812f830..5404805 100644
> > --- a/tests/bios-tables-test.c
> > +++ b/tests/bios-tables-test.c
> > @@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)
> >      free_test_data(&data);
> >  }
> >
> 
> Hi Igor,
> 
> 
> > +static void test_acpi_q35_tcg_memhp(void)
> > +{
> > +    test_data data;
> > +
> > +    memset(&data, 0, sizeof(data));
> > +    data.machine = MACHINE_Q35;
> > +    data.variant = ".memhp";
> > +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
> 
> Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))
I added it to expose SRAT table to guest
so we could detect unexpected changes caused by memory hotplug changes

> 
> Thanks,
> Marcel
> 
> > +    free_test_data(&data);
> > +}
> > +
> > +static void test_acpi_piix4_tcg_memhp(void)
> > +{
> > +    test_data data;
> > +
> > +    memset(&data, 0, sizeof(data));
> > +    data.machine = MACHINE_PC;
> > +    data.variant = ".memhp";
> > +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
> > +    free_test_data(&data);
> > +}
> > +
> >  int main(int argc, char *argv[])
> >  {
> >      const char *arch = qtest_get_arch();
> > @@ -887,6 +909,8 @@ int main(int argc, char *argv[])
> >          qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
> >          qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
> >          qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
> > +        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
> > +        qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
> >      }
> >      ret = g_test_run();
> >      boot_sector_cleanup(disk);
> >

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() into memory_hotplug.c
  2016-12-20 10:44   ` Marcel Apfelbaum
@ 2016-12-20 16:24     ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-20 16:24 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On Tue, 20 Dec 2016 12:44:22 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  include/hw/acpi/memory_hotplug.h |   2 +
> >  hw/acpi/memory_hotplug.c         | 124 +++++++++++++++++++++++++++++++++++++++
> >  hw/i386/acpi-build.c             | 124 ---------------------------------------
> >  3 files changed, 126 insertions(+), 124 deletions(-)
> >
> > diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> > index d2c7452..964c244 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> >
> >  void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> >                                uint16_t io_base, uint16_t io_len);
> > +void build_memory_devices(Aml *sb_scope, int nr_mem,
> > +                          uint16_t io_base, uint16_t io_len);
> 
> 
> We add an extra function to the header file, but if it can be used
> by the ARM machines is worth it.
it's temporary for purpose of clean small/atocmic movement
and it's removed in 6/10

> 
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
> 
> Thanks,
> Marcel
> 
> >  #endif
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index 57ac4fc..67dd3f8 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -553,3 +553,127 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> >      aml_append(pci_scope, mem_ctrl_dev);
> >      aml_append(ctx, pci_scope);
> >  }
> > +
> > +void build_memory_devices(Aml *sb_scope, int nr_mem,
> > +                          uint16_t io_base, uint16_t io_len)
> > +{
> > +    int i;
> > +    Aml *scope;
> > +    Aml *crs;
> > +    Aml *field;
> > +    Aml *dev;
> > +    Aml *method;
> > +    Aml *ifctx;
> > +
> > +    /* build memory devices */
> > +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > +    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> > +    aml_append(scope,
> > +        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> > +    );
> > +
> > +    crs = aml_resource_template();
> > +    aml_append(crs,
> > +        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> > +    );
> > +    aml_append(scope, aml_name_decl("_CRS", crs));
> > +
> > +    aml_append(scope, aml_operation_region(
> > +        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > +        aml_int(io_base), io_len)
> > +    );
> > +
> > +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > +                      AML_NOLOCK, AML_PRESERVE);
> > +    aml_append(field, /* read only */
> > +        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> > +    aml_append(field, /* read only */
> > +        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> > +    aml_append(field, /* read only */
> > +        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> > +    aml_append(field, /* read only */
> > +        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> > +    aml_append(field, /* read only */
> > +        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> > +    aml_append(scope, field);
> > +
> > +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> > +                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> > +    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > +    aml_append(field, /* 1 if enabled, read only */
> > +        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> > +    aml_append(field,
> > +        /*(read) 1 if has a insert event. (write) 1 to clear event */
> > +        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> > +    aml_append(field,
> > +        /* (read) 1 if has a remove event. (write) 1 to clear event */
> > +        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> > +    aml_append(field,
> > +        /* initiates device eject, write only */
> > +        aml_named_field(MEMORY_SLOT_EJECT, 1));
> > +    aml_append(scope, field);
> > +
> > +    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > +                      AML_NOLOCK, AML_PRESERVE);
> > +    aml_append(field, /* DIMM selector, write only */
> > +        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> > +    aml_append(field, /* _OST event code, write only */
> > +        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> > +    aml_append(field, /* _OST status code, write only */
> > +        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> > +    aml_append(scope, field);
> > +    aml_append(sb_scope, scope);
> > +
> > +    for (i = 0; i < nr_mem; i++) {
> > +        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> > +        const char *s;
> > +
> > +        dev = aml_device("MP%02X", i);
> > +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > +
> > +        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> > +        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > +        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> > +        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> > +        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> > +
> > +        aml_append(method, aml_return(aml_call4(
> > +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > +        )));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> > +        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> > +        aml_append(method, aml_return(aml_call2(
> > +                   s, aml_name("_UID"), aml_arg(0))));
> > +        aml_append(dev, method);
> > +
> > +        aml_append(sb_scope, dev);
> > +    }
> > +
> > +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > +     */
> > +    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> > +    for (i = 0; i < nr_mem; i++) {
> > +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > +        aml_append(ifctx,
> > +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > +        );
> > +        aml_append(method, ifctx);
> > +    }
> > +    aml_append(sb_scope, method);
> > +}
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 9708cdc..38dcac7 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1038,130 +1038,6 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
> >      return crs;
> >  }
> >
> > -static void build_memory_devices(Aml *sb_scope, int nr_mem,
> > -                                 uint16_t io_base, uint16_t io_len)
> > -{
> > -    int i;
> > -    Aml *scope;
> > -    Aml *crs;
> > -    Aml *field;
> > -    Aml *dev;
> > -    Aml *method;
> > -    Aml *ifctx;
> > -
> > -    /* build memory devices */
> > -    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > -    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> > -    aml_append(scope,
> > -        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> > -    );
> > -
> > -    crs = aml_resource_template();
> > -    aml_append(crs,
> > -        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> > -    );
> > -    aml_append(scope, aml_name_decl("_CRS", crs));
> > -
> > -    aml_append(scope, aml_operation_region(
> > -        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > -        aml_int(io_base), io_len)
> > -    );
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > -                      AML_NOLOCK, AML_PRESERVE);
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> > -    aml_append(scope, field);
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> > -                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> > -    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > -    aml_append(field, /* 1 if enabled, read only */
> > -        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> > -    aml_append(field,
> > -        /*(read) 1 if has a insert event. (write) 1 to clear event */
> > -        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> > -    aml_append(field,
> > -        /* (read) 1 if has a remove event. (write) 1 to clear event */
> > -        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> > -    aml_append(field,
> > -        /* initiates device eject, write only */
> > -        aml_named_field(MEMORY_SLOT_EJECT, 1));
> > -    aml_append(scope, field);
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > -                      AML_NOLOCK, AML_PRESERVE);
> > -    aml_append(field, /* DIMM selector, write only */
> > -        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> > -    aml_append(field, /* _OST event code, write only */
> > -        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> > -    aml_append(field, /* _OST status code, write only */
> > -        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> > -    aml_append(scope, field);
> > -    aml_append(sb_scope, scope);
> > -
> > -    for (i = 0; i < nr_mem; i++) {
> > -        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> > -        const char *s;
> > -
> > -        dev = aml_device("MP%02X", i);
> > -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > -
> > -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> > -
> > -        aml_append(method, aml_return(aml_call4(
> > -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > -        )));
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> > -        aml_append(method, aml_return(aml_call2(
> > -                   s, aml_name("_UID"), aml_arg(0))));
> > -        aml_append(dev, method);
> > -
> > -        aml_append(sb_scope, dev);
> > -    }
> > -
> > -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > -     */
> > -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> > -    for (i = 0; i < nr_mem; i++) {
> > -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > -        aml_append(ifctx,
> > -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > -        );
> > -        aml_append(method, ifctx);
> > -    }
> > -    aml_append(sb_scope, method);
> > -}
> > -
> >  static void build_hpet_aml(Aml *table)
> >  {
> >      Aml *crs;
> >
> 
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
  2016-12-20 11:00   ` Marcel Apfelbaum
@ 2016-12-20 16:34     ` Igor Mammedov
  2016-12-21 11:54       ` Marcel Apfelbaum
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-20 16:34 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Eduardo Habkost, Michael S. Tsirkin

On Tue, 20 Dec 2016 13:00:35 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > since static and dynamic parts of memory MHPD device are now
> > in the same table (DSDT), there is no point keeping
> > them scattered across the table, so consolidate it
> > in one place.
> >
> > There aren't any functional change, only AML text movement
> > from externally refferenced MHPD scope directly into
> > MHPD device declaration.
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  include/hw/acpi/memory_hotplug.h |   2 +-
> >  hw/acpi/memory_hotplug.c         | 123 +++++++++++++++++++--------------------
> >  2 files changed, 61 insertions(+), 64 deletions(-)
> >
> > diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> > index 964c244..c70481e 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> >  #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
> >       MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
> >
> > -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> > +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                uint16_t io_base, uint16_t io_len);
> >  void build_memory_devices(Aml *sb_scope, int nr_mem,
> >                            uint16_t io_base, uint16_t io_len);
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index 67dd3f8..fb40a5e 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = {
> >      }
> >  };
> >
> > -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> > +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                uint16_t io_base, uint16_t io_len)
> 
> The signature of the function is changed, but I see no caller changes.
> Is this function used?
There is no need to change callers, it's in acpi-build.c,
this change is here for better documenting what this argument means
within build_memory_hotplug_aml(), see it at the end of patch.

> 
> >  {
> >      Aml *ifctx;
> > @@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> >      pci_scope = aml_scope("_SB.PCI0");
> >      mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
> >      {
> > +        Aml *crs;
> > +        Aml *field;
> >          Aml *one = aml_int(1);
> >          Aml *zero = aml_int(0);
> >          Aml *ret_val = aml_local(0);
> > @@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> >          aml_append(mem_ctrl_dev,
> >              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
> >
> > +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > +        aml_append(mem_ctrl_dev,
> > +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> > +        );
> > +
> > +        crs = aml_resource_template();
> > +        aml_append(crs,
> > +            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> > +        );
> > +        aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> > +
> > +        aml_append(mem_ctrl_dev, aml_operation_region(
> > +            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > +            aml_int(io_base), io_len)
> > +        );
> > +
> > +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > +                          AML_NOLOCK, AML_PRESERVE);
> > +        aml_append(field, /* read only */
> > +            aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> > +        aml_append(mem_ctrl_dev, field);
> > +
> > +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> > +                          AML_NOLOCK, AML_WRITE_AS_ZEROS);
> > +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > +        aml_append(field, /* 1 if enabled, read only */
> > +            aml_named_field(MEMORY_SLOT_ENABLED, 1));
> > +        aml_append(field,
> > +            /*(read) 1 if has a insert event. (write) 1 to clear event */
> > +            aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> > +        aml_append(field,
> > +            /* (read) 1 if has a remove event. (write) 1 to clear event */
> > +            aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> > +        aml_append(field,
> > +            /* initiates device eject, write only */
> > +            aml_named_field(MEMORY_SLOT_EJECT, 1));
> > +        aml_append(mem_ctrl_dev, field);
> > +
> > +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > +                          AML_NOLOCK, AML_PRESERVE);
> > +        aml_append(field, /* DIMM selector, write only */
> > +            aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> > +        aml_append(field, /* _OST event code, write only */
> > +            aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> > +        aml_append(field, /* _OST status code, write only */
> > +            aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> > +        aml_append(mem_ctrl_dev, field);
> > +
> >          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> >          ifctx = aml_if(aml_equal(slots_nr, zero));
> >          {
> > @@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
> >          aml_append(mem_ctrl_dev, method);
> >      }
> >      aml_append(pci_scope, mem_ctrl_dev);
> > -    aml_append(ctx, pci_scope);
> > +    aml_append(table, pci_scope);
> >  }
> >
> >  void build_memory_devices(Aml *sb_scope, int nr_mem,
> >                            uint16_t io_base, uint16_t io_len)
> 
> Do you still need the io_base/io_len parameters here?
> 
> Thanks,
> Marcel
> 
> >  {
> >      int i;
> > -    Aml *scope;
> > -    Aml *crs;
> > -    Aml *field;
> >      Aml *dev;
> >      Aml *method;
> >      Aml *ifctx;
> >
> >      /* build memory devices */
> > -    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > -    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
> > -    aml_append(scope,
> > -        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> > -    );
> > -
> > -    crs = aml_resource_template();
> > -    aml_append(crs,
> > -        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> > -    );
> > -    aml_append(scope, aml_name_decl("_CRS", crs));
> > -
> > -    aml_append(scope, aml_operation_region(
> > -        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > -        aml_int(io_base), io_len)
> > -    );
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > -                      AML_NOLOCK, AML_PRESERVE);
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> > -    aml_append(field, /* read only */
> > -        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> > -    aml_append(scope, field);
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> > -                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
> > -    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > -    aml_append(field, /* 1 if enabled, read only */
> > -        aml_named_field(MEMORY_SLOT_ENABLED, 1));
> > -    aml_append(field,
> > -        /*(read) 1 if has a insert event. (write) 1 to clear event */
> > -        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
> > -    aml_append(field,
> > -        /* (read) 1 if has a remove event. (write) 1 to clear event */
> > -        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
> > -    aml_append(field,
> > -        /* initiates device eject, write only */
> > -        aml_named_field(MEMORY_SLOT_EJECT, 1));
> > -    aml_append(scope, field);
> > -
> > -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > -                      AML_NOLOCK, AML_PRESERVE);
> > -    aml_append(field, /* DIMM selector, write only */
> > -        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> > -    aml_append(field, /* _OST event code, write only */
> > -        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> > -    aml_append(field, /* _OST status code, write only */
> > -        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> > -    aml_append(scope, field);
> > -    aml_append(sb_scope, scope);
> > -
> >      for (i = 0; i < nr_mem; i++) {
> >          #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> >          const char *s;
> >
> 
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
  2016-12-20 16:17     ` Igor Mammedov
@ 2016-12-20 17:00       ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-20 17:00 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On 12/20/2016 06:17 PM, Igor Mammedov wrote:
> On Tue, 20 Dec 2016 12:40:21 +0200
> Marcel Apfelbaum <marcel@redhat.com> wrote:
>
>> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>> ---
>>>  tests/bios-tables-test.c | 24 ++++++++++++++++++++++++
>>>  1 file changed, 24 insertions(+)
>>>
>>> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
>>> index 812f830..5404805 100644
>>> --- a/tests/bios-tables-test.c
>>> +++ b/tests/bios-tables-test.c
>>> @@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)
>>>      free_test_data(&data);
>>>  }
>>>
>>
>> Hi Igor,
>>
>>
>>> +static void test_acpi_q35_tcg_memhp(void)
>>> +{
>>> +    test_data data;
>>> +
>>> +    memset(&data, 0, sizeof(data));
>>> +    data.machine = MACHINE_Q35;
>>> +    data.variant = ".memhp";
>>> +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
>>
>> Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))
> I added it to expose SRAT table to guest
> so we could detect unexpected changes caused by memory hotplug changes
>

Thanks

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>


>>
>> Thanks,
>> Marcel
>>
>>> +    free_test_data(&data);
>>> +}
>>> +
>>> +static void test_acpi_piix4_tcg_memhp(void)
>>> +{
>>> +    test_data data;
>>> +
>>> +    memset(&data, 0, sizeof(data));
>>> +    data.machine = MACHINE_PC;
>>> +    data.variant = ".memhp";
>>> +    test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data);
>>> +    free_test_data(&data);
>>> +}
>>> +
>>>  int main(int argc, char *argv[])
>>>  {
>>>      const char *arch = qtest_get_arch();
>>> @@ -887,6 +909,8 @@ int main(int argc, char *argv[])
>>>          qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
>>>          qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
>>>          qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
>>> +        qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
>>> +        qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
>>>      }
>>>      ret = g_test_run();
>>>      boot_sector_cleanup(disk);
>>>
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
  2016-12-20 16:34     ` Igor Mammedov
@ 2016-12-21 11:54       ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-21 11:54 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Eduardo Habkost, Michael S. Tsirkin

On 12/20/2016 06:34 PM, Igor Mammedov wrote:
> On Tue, 20 Dec 2016 13:00:35 +0200
> Marcel Apfelbaum <marcel@redhat.com> wrote:
>
>> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
>>> since static and dynamic parts of memory MHPD device are now
>>> in the same table (DSDT), there is no point keeping
>>> them scattered across the table, so consolidate it
>>> in one place.
>>>
>>> There aren't any functional change, only AML text movement
>>> from externally refferenced MHPD scope directly into
>>> MHPD device declaration.
>>>
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>> ---
>>>  include/hw/acpi/memory_hotplug.h |   2 +-
>>>  hw/acpi/memory_hotplug.c         | 123 +++++++++++++++++++--------------------
>>>  2 files changed, 61 insertions(+), 64 deletions(-)
>>>
>>> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
>>> index 964c244..c70481e 100644
>>> --- a/include/hw/acpi/memory_hotplug.h
>>> +++ b/include/hw/acpi/memory_hotplug.h
>>> @@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>>>  #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
>>>       MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
>>>
>>> -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>>> +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>                                uint16_t io_base, uint16_t io_len);
>>>  void build_memory_devices(Aml *sb_scope, int nr_mem,
>>>                            uint16_t io_base, uint16_t io_len);
>>> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
>>> index 67dd3f8..fb40a5e 100644
>>> --- a/hw/acpi/memory_hotplug.c
>>> +++ b/hw/acpi/memory_hotplug.c
>>> @@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = {
>>>      }
>>>  };
>>>
>>> -void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>>> +void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>                                uint16_t io_base, uint16_t io_len)
>>
>> The signature of the function is changed, but I see no caller changes.
>> Is this function used?
> There is no need to change callers, it's in acpi-build.c,
> this change is here for better documenting what this argument means
> within build_memory_hotplug_aml(), see it at the end of patch.
>

Sorry, the io_base and io_len parameters are not new.

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

>>
>>>  {
>>>      Aml *ifctx;
>>> @@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>>>      pci_scope = aml_scope("_SB.PCI0");
>>>      mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
>>>      {
>>> +        Aml *crs;
>>> +        Aml *field;
>>>          Aml *one = aml_int(1);
>>>          Aml *zero = aml_int(0);
>>>          Aml *ret_val = aml_local(0);
>>> @@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>>>          aml_append(mem_ctrl_dev,
>>>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
>>>
>>> +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
>>> +        aml_append(mem_ctrl_dev,
>>> +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
>>> +        );
>>> +
>>> +        crs = aml_resource_template();
>>> +        aml_append(crs,
>>> +            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
>>> +        );
>>> +        aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
>>> +
>>> +        aml_append(mem_ctrl_dev, aml_operation_region(
>>> +            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
>>> +            aml_int(io_base), io_len)
>>> +        );
>>> +
>>> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
>>> +                          AML_NOLOCK, AML_PRESERVE);
>>> +        aml_append(field, /* read only */
>>> +            aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
>>> +        aml_append(field, /* read only */
>>> +            aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
>>> +        aml_append(field, /* read only */
>>> +            aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
>>> +        aml_append(field, /* read only */
>>> +            aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
>>> +        aml_append(field, /* read only */
>>> +            aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
>>> +        aml_append(mem_ctrl_dev, field);
>>> +
>>> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
>>> +                          AML_NOLOCK, AML_WRITE_AS_ZEROS);
>>> +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>>> +        aml_append(field, /* 1 if enabled, read only */
>>> +            aml_named_field(MEMORY_SLOT_ENABLED, 1));
>>> +        aml_append(field,
>>> +            /*(read) 1 if has a insert event. (write) 1 to clear event */
>>> +            aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
>>> +        aml_append(field,
>>> +            /* (read) 1 if has a remove event. (write) 1 to clear event */
>>> +            aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
>>> +        aml_append(field,
>>> +            /* initiates device eject, write only */
>>> +            aml_named_field(MEMORY_SLOT_EJECT, 1));
>>> +        aml_append(mem_ctrl_dev, field);
>>> +
>>> +        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
>>> +                          AML_NOLOCK, AML_PRESERVE);
>>> +        aml_append(field, /* DIMM selector, write only */
>>> +            aml_named_field(MEMORY_SLOT_SLECTOR, 32));
>>> +        aml_append(field, /* _OST event code, write only */
>>> +            aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
>>> +        aml_append(field, /* _OST status code, write only */
>>> +            aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
>>> +        aml_append(mem_ctrl_dev, field);
>>> +
>>>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>>>          ifctx = aml_if(aml_equal(slots_nr, zero));
>>>          {
>>> @@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
>>>          aml_append(mem_ctrl_dev, method);
>>>      }
>>>      aml_append(pci_scope, mem_ctrl_dev);
>>> -    aml_append(ctx, pci_scope);
>>> +    aml_append(table, pci_scope);
>>>  }
>>>
>>>  void build_memory_devices(Aml *sb_scope, int nr_mem,
>>>                            uint16_t io_base, uint16_t io_len)
>>
>> Do you still need the io_base/io_len parameters here?
>>
>> Thanks,
>> Marcel
>>
>>>  {
>>>      int i;
>>> -    Aml *scope;
>>> -    Aml *crs;
>>> -    Aml *field;
>>>      Aml *dev;
>>>      Aml *method;
>>>      Aml *ifctx;
>>>
>>>      /* build memory devices */
>>> -    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
>>> -    scope = aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
>>> -    aml_append(scope,
>>> -        aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
>>> -    );
>>> -
>>> -    crs = aml_resource_template();
>>> -    aml_append(crs,
>>> -        aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
>>> -    );
>>> -    aml_append(scope, aml_name_decl("_CRS", crs));
>>> -
>>> -    aml_append(scope, aml_operation_region(
>>> -        MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
>>> -        aml_int(io_base), io_len)
>>> -    );
>>> -
>>> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
>>> -                      AML_NOLOCK, AML_PRESERVE);
>>> -    aml_append(field, /* read only */
>>> -        aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
>>> -    aml_append(field, /* read only */
>>> -        aml_named_field(MEMORY_SLOT_ADDR_HIGH, 32));
>>> -    aml_append(field, /* read only */
>>> -        aml_named_field(MEMORY_SLOT_SIZE_LOW, 32));
>>> -    aml_append(field, /* read only */
>>> -        aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
>>> -    aml_append(field, /* read only */
>>> -        aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
>>> -    aml_append(scope, field);
>>> -
>>> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
>>> -                      AML_NOLOCK, AML_WRITE_AS_ZEROS);
>>> -    aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>>> -    aml_append(field, /* 1 if enabled, read only */
>>> -        aml_named_field(MEMORY_SLOT_ENABLED, 1));
>>> -    aml_append(field,
>>> -        /*(read) 1 if has a insert event. (write) 1 to clear event */
>>> -        aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
>>> -    aml_append(field,
>>> -        /* (read) 1 if has a remove event. (write) 1 to clear event */
>>> -        aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
>>> -    aml_append(field,
>>> -        /* initiates device eject, write only */
>>> -        aml_named_field(MEMORY_SLOT_EJECT, 1));
>>> -    aml_append(scope, field);
>>> -
>>> -    field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
>>> -                      AML_NOLOCK, AML_PRESERVE);
>>> -    aml_append(field, /* DIMM selector, write only */
>>> -        aml_named_field(MEMORY_SLOT_SLECTOR, 32));
>>> -    aml_append(field, /* _OST event code, write only */
>>> -        aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
>>> -    aml_append(field, /* _OST status code, write only */
>>> -        aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
>>> -    aml_append(scope, field);
>>> -    aml_append(sb_scope, scope);
>>> -
>>>      for (i = 0; i < nr_mem; i++) {
>>>          #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
>>>          const char *s;
>>>
>>
>>
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml()
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml() Igor Mammedov
@ 2016-12-21 12:10   ` Marcel Apfelbaum
  2016-12-21 12:54     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-21 12:10 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> It consolidates memory hotplug AML in one place within DSDT
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |  2 --
>  hw/acpi/memory_hotplug.c         | 14 ++++-----
>  hw/i386/acpi-build.c             | 61 ++++++++++++++++++----------------------
>  3 files changed, 33 insertions(+), 44 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index c70481e..6dc48d2 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len);
> -void build_memory_devices(Aml *sb_scope, int nr_mem,
> -                          uint16_t io_base, uint16_t io_len);
>  #endif
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index fb40a5e..18b95f2 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len)
>  {
> +    int i;
>      Aml *ifctx;
>      Aml *method;
>      Aml *pci_scope;
> +    Aml *sb_scope;
>      Aml *mem_ctrl_dev;
>
>      /* scope for memory hotplug controller device node */
> @@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>      }
>      aml_append(pci_scope, mem_ctrl_dev);
>      aml_append(table, pci_scope);
> -}
> -
> -void build_memory_devices(Aml *sb_scope, int nr_mem,
> -                          uint16_t io_base, uint16_t io_len)
> -{
> -    int i;
> -    Aml *dev;
> -    Aml *method;
> -    Aml *ifctx;
>
> +    sb_scope = aml_scope("_SB");


One question here, before this patch the mem devices were
added to \\_SB scope, now they are added to _SB.

I suppose is OK? Is there any change in the DSDT? Can we see a diff?

Thanks,
Marcel

>      /* build memory devices */
>      for (i = 0; i < nr_mem; i++) {
>          #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> +        Aml *dev;
>          const char *s;
>
>          dev = aml_device("MP%02X", i);
> @@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,
>          aml_append(method, ifctx);
>      }
>      aml_append(sb_scope, method);
> +    aml_append(table, sb_scope);
>  }
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 38dcac7..690e9a0 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>
>      sb_scope = aml_scope("\\_SB");
>      {
> -        build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
> -                             pm->mem_hp_io_len);
> +        Object *pci_host;
> +        PCIBus *bus = NULL;
>
> -        {
> -            Object *pci_host;
> -            PCIBus *bus = NULL;
> +        pci_host = acpi_get_i386_pci_host();
> +        if (pci_host) {
> +            bus = PCI_HOST_BRIDGE(pci_host)->bus;
> +        }
>
> -            pci_host = acpi_get_i386_pci_host();
> -            if (pci_host) {
> -                bus = PCI_HOST_BRIDGE(pci_host)->bus;
> +        if (bus) {
> +            Aml *scope = aml_scope("PCI0");
> +            /* Scan all PCI buses. Generate tables to support hotplug. */
> +            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
> +
> +            if (misc->tpm_version != TPM_VERSION_UNSPEC) {
> +                dev = aml_device("ISA.TPM");
> +                aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
> +                aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
> +                crs = aml_resource_template();
> +                aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> +                           TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> +                /*
> +                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
> +                    Rewrite to take IRQ from TPM device model and
> +                    fix default IRQ value there to use some unused IRQ
> +                 */
> +                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
> +                aml_append(dev, aml_name_decl("_CRS", crs));
> +                aml_append(scope, dev);
>              }
>
> -            if (bus) {
> -                Aml *scope = aml_scope("PCI0");
> -                /* Scan all PCI buses. Generate tables to support hotplug. */
> -                build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
> -
> -                if (misc->tpm_version != TPM_VERSION_UNSPEC) {
> -                    dev = aml_device("ISA.TPM");
> -                    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
> -                    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
> -                    crs = aml_resource_template();
> -                    aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> -                               TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> -                    /*
> -                        FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
> -                        Rewrite to take IRQ from TPM device model and
> -                        fix default IRQ value there to use some unused IRQ
> -                     */
> -                    /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
> -                    aml_append(dev, aml_name_decl("_CRS", crs));
> -                    aml_append(scope, dev);
> -                }
> -
> -                aml_append(sb_scope, scope);
> -            }
> +            aml_append(sb_scope, scope);
>          }
> -        aml_append(dsdt, sb_scope);
>      }
> +    aml_append(dsdt, sb_scope);
>
>      /* copy AML table into ACPI tables blob and patch header there */
>      g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 " Igor Mammedov
@ 2016-12-21 12:31   ` Marcel Apfelbaum
  2016-12-21 13:39     ` Igor Mammedov
  2016-12-22 15:10   ` [Qemu-devel] [PATCH for-2.9 v2 " Igor Mammedov
  1 sibling, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-21 12:31 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> From this patch all the memory hotplug related AML
> bits are consolidated in one place within DSTD.
> Follow up patches will utilize that to simplify
> memory hotplug related C/AML code.


I didn't quite understand what you mean...

>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |  6 +++---
>  hw/acpi/memory_hotplug.c         | 42 ++++++++++++++++++++++++++--------------
>  hw/i386/acpi-build.c             |  7 ++-----
>  3 files changed, 32 insertions(+), 23 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 6dc48d2..37e2706 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>
>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
> -     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
>
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> -                              uint16_t io_base, uint16_t io_len);
> +                              uint16_t io_base, uint16_t io_len,
> +                              const char *res_root,
> +                              const char *event_handler_method);
>  #endif
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 18b95f2..49e856f 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = {
>  };
>
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> -                              uint16_t io_base, uint16_t io_len)
> +                              uint16_t io_base, uint16_t io_len,
> +                              const char *res_root,
> +                              const char *event_handler_method)
>  {
>      int i;
>      Aml *ifctx;
>      Aml *method;
> -    Aml *pci_scope;
>      Aml *sb_scope;
>      Aml *mem_ctrl_dev;
> +    char *scan_path;
> +    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
>
> -    /* scope for memory hotplug controller device node */
> -    pci_scope = aml_scope("_SB.PCI0");
> -    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
> +    mem_ctrl_dev = aml_device("%s", mhp_res_path);


Will mem_ctrl_dev's name will have an extra "." suffix now?

>      {
>          Aml *crs;
>          Aml *field;
> @@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>          }
>          aml_append(mem_ctrl_dev, method);
>      }
> -    aml_append(pci_scope, mem_ctrl_dev);
> -    aml_append(table, pci_scope);
> +    aml_append(table, mem_ctrl_dev);
>
>      sb_scope = aml_scope("_SB");
>      /* build memory devices */
>      for (i = 0; i < nr_mem; i++) {
> -        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
>          Aml *dev;
> -        const char *s;
> +        char *s;
>
>          dev = aml_device("MP%02X", i);
>          aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>          aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>
>          method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);

Same question here, do we get ".." in the path? Maybe is OK?


Thanks,
Marcel

>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        g_free(s);
>          aml_append(dev, method);
>
>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        g_free(s);
>          aml_append(dev, method);
>
>          method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> +        s = g_strdup_printf("%s.%s", mhp_res_path,
> +                            MEMORY_SLOT_PROXIMITY_METHOD);
>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        g_free(s);
>          aml_append(dev, method);
>
>          method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> -
> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
>          aml_append(method, aml_return(aml_call4(
>              s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>          )));
> +        g_free(s);
>          aml_append(dev, method);
>
>          method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> -        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
>          aml_append(method, aml_return(aml_call2(
>                     s, aml_name("_UID"), aml_arg(0))));
> +        g_free(s);
>          aml_append(dev, method);
>
>          aml_append(sb_scope, dev);
> @@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>      }
>      aml_append(sb_scope, method);
>      aml_append(table, sb_scope);
> +
> +    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
> +    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
> +    aml_append(method, aml_call0(scan_path));
> +    g_free(scan_path);
> +    aml_append(table, method);
> +
> +    g_free(mhp_res_path);
>  }
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 690e9a0..b7f4682 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>                         "\\_SB.PCI0", "\\_GPE._E02");
>      }
>      build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
> -                             pm->mem_hp_io_len);
> +                             pm->mem_hp_io_len,
> +                             "\\_SB.PCI0", "\\_GPE._E03");
>
>      scope =  aml_scope("_GPE");
>      {
> @@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>              aml_append(scope, method);
>          }
>
> -        method = aml_method("_E03", 0, AML_NOTSERIALIZED);
> -        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
> -        aml_append(scope, method);
> -
>          if (pcms->acpi_nvdimm_state.is_enabled) {
>              method = aml_method("_E04", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c Igor Mammedov
@ 2016-12-21 12:32   ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-21 12:32 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> Move defines used locally only by memory_hotplug.c into it
> from header files.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |  3 ---
>  include/hw/acpi/pc-hotplug.h     | 22 ----------------------
>  hw/acpi/memory_hotplug.c         | 24 ++++++++++++++++++++++++
>  3 files changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 37e2706..91d4045 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -47,9 +47,6 @@ extern const VMStateDescription vmstate_memory_hotplug;
>
>  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>
> -#define MEMORY_HOTPLUG_DEVICE        "MHPD"
> -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> -
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                uint16_t io_base, uint16_t io_len,
>                                const char *res_root,
> diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
> index 6a8d268..a4f513d 100644
> --- a/include/hw/acpi/pc-hotplug.h
> +++ b/include/hw/acpi/pc-hotplug.h
> @@ -32,26 +32,4 @@
>  #define ACPI_MEMORY_HOTPLUG_IO_LEN 24
>  #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
>
> -#define MEMORY_SLOTS_NUMBER          "MDNR"
> -#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
> -#define MEMORY_SLOT_ADDR_LOW         "MRBL"
> -#define MEMORY_SLOT_ADDR_HIGH        "MRBH"
> -#define MEMORY_SLOT_SIZE_LOW         "MRLL"
> -#define MEMORY_SLOT_SIZE_HIGH        "MRLH"
> -#define MEMORY_SLOT_PROXIMITY        "MPX"
> -#define MEMORY_SLOT_ENABLED          "MES"
> -#define MEMORY_SLOT_INSERT_EVENT     "MINS"
> -#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
> -#define MEMORY_SLOT_EJECT            "MEJ"
> -#define MEMORY_SLOT_SLECTOR          "MSEL"
> -#define MEMORY_SLOT_OST_EVENT        "MOEV"
> -#define MEMORY_SLOT_OST_STATUS       "MOSC"
> -#define MEMORY_SLOT_LOCK             "MLCK"
> -#define MEMORY_SLOT_STATUS_METHOD    "MRST"
> -#define MEMORY_SLOT_CRS_METHOD       "MCRS"
> -#define MEMORY_SLOT_OST_METHOD       "MOST"
> -#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
> -#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
> -#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> -
>  #endif
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 49e856f..da29332 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -7,6 +7,30 @@
>  #include "trace.h"
>  #include "qapi-event.h"
>
> +#define MEMORY_SLOTS_NUMBER          "MDNR"
> +#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
> +#define MEMORY_SLOT_ADDR_LOW         "MRBL"
> +#define MEMORY_SLOT_ADDR_HIGH        "MRBH"
> +#define MEMORY_SLOT_SIZE_LOW         "MRLL"
> +#define MEMORY_SLOT_SIZE_HIGH        "MRLH"
> +#define MEMORY_SLOT_PROXIMITY        "MPX"
> +#define MEMORY_SLOT_ENABLED          "MES"
> +#define MEMORY_SLOT_INSERT_EVENT     "MINS"
> +#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
> +#define MEMORY_SLOT_EJECT            "MEJ"
> +#define MEMORY_SLOT_SLECTOR          "MSEL"
> +#define MEMORY_SLOT_OST_EVENT        "MOEV"
> +#define MEMORY_SLOT_OST_STATUS       "MOSC"
> +#define MEMORY_SLOT_LOCK             "MLCK"
> +#define MEMORY_SLOT_STATUS_METHOD    "MRST"
> +#define MEMORY_SLOT_CRS_METHOD       "MCRS"
> +#define MEMORY_SLOT_OST_METHOD       "MOST"
> +#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
> +#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
> +#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> +#define MEMORY_HOTPLUG_DEVICE        "MHPD"
> +
>  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
>  {
>      ACPIOSTInfo *info = g_new0(ACPIOSTInfo, 1);
>

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml()
  2016-12-21 12:10   ` Marcel Apfelbaum
@ 2016-12-21 12:54     ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-21 12:54 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On Wed, 21 Dec 2016 14:10:33 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > It consolidates memory hotplug AML in one place within DSDT
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  include/hw/acpi/memory_hotplug.h |  2 --
> >  hw/acpi/memory_hotplug.c         | 14 ++++-----
> >  hw/i386/acpi-build.c             | 61 ++++++++++++++++++----------------------
> >  3 files changed, 33 insertions(+), 44 deletions(-)
> >
> > diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> > index c70481e..6dc48d2 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> >
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                uint16_t io_base, uint16_t io_len);
> > -void build_memory_devices(Aml *sb_scope, int nr_mem,
> > -                          uint16_t io_base, uint16_t io_len);
> >  #endif
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index fb40a5e..18b95f2 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                uint16_t io_base, uint16_t io_len)
> >  {
> > +    int i;
> >      Aml *ifctx;
> >      Aml *method;
> >      Aml *pci_scope;
> > +    Aml *sb_scope;
> >      Aml *mem_ctrl_dev;
> >
> >      /* scope for memory hotplug controller device node */
> > @@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >      }
> >      aml_append(pci_scope, mem_ctrl_dev);
> >      aml_append(table, pci_scope);
> > -}
> > -
> > -void build_memory_devices(Aml *sb_scope, int nr_mem,
> > -                          uint16_t io_base, uint16_t io_len)
> > -{
> > -    int i;
> > -    Aml *dev;
> > -    Aml *method;
> > -    Aml *ifctx;
> >
> > +    sb_scope = aml_scope("_SB");  
> 
> 
> One question here, before this patch the mem devices were
> added to \\_SB scope, now they are added to _SB.
> 
> I suppose is OK? Is there any change in the DSDT? Can we see a diff?

It's ok as sb_scope is added to root context (i.e. table), below in this patch.

This patch doesn't change logic, it only gets rid of
Scope (\_SB.PCI0.MHPD) by moving elements from it to
preceding device declaration which above scope refers to:
    Scope (_SB.PCI0) { Device (MHPD) { ... } }
and places MTFY method right after this declaration.

In other words the patch does exactly what commit message says,
"It consolidates memory hotplug AML in one place within DSDT"


here is diff at this point but it's not really useful as it doesn't
capture enough context to see where AML is being moved.
To get full tables to compare one need run:

make && make tests/bios-tables-test
QTEST_QEMU_BINARY=./x86_64-softmmu/qemu-system-x86_64 V=1 tests/bios-tables-test

diff --git a/tmp/asl-EQAJSY.dsl b/tmp/asl-ZSBJSY.dsl
index b4809b1..1cf0a30 100644
--- a/tmp/asl-EQAJSY.dsl
+++ b/tmp/asl-ZSBJSY.dsl
@@ -5,13 +5,13 @@
  * 
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of tests/acpi-test-data/pc/DSDT.bridge, Wed Dec 21 13:34:30 2016
+ * Disassembly of /tmp/aml-AKBJSY, Wed Dec 21 13:34:30 2016
  *
  * Original Table Header:
  *     Signature        "DSDT"
- *     Length           0x00001EBB (7867)
+ *     Length           0x00001EAF (7855)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0x35
+ *     Checksum         0x44
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
@@ -798,6 +798,42 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
         {
             Name (_HID, "PNP0A06" /* Generic Container Device */)  // _HID: Hardware ID
             Name (_UID, "Memory hotplug resources")  // _UID: Unique ID
+            Name (MDNR, Zero)
+            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+            {
+                IO (Decode16,
+                    0x0A00,             // Range Minimum
+                    0x0A00,             // Range Maximum
+                    0x00,               // Alignment
+                    0x18,               // Length
+                    )
+            })
+            OperationRegion (HPMR, SystemIO, 0x0A00, 0x18)
+            Field (HPMR, DWordAcc, NoLock, Preserve)
+            {
+                MRBL,   32, 
+                MRBH,   32, 
+                MRLL,   32, 
+                MRLH,   32, 
+                MPX,    32
+            }
+
+            Field (HPMR, ByteAcc, NoLock, WriteAsZeros)
+            {
+                Offset (0x14), 
+                MES,    1, 
+                MINS,   1, 
+                MRMV,   1, 
+                MEJ,    1
+            }
+
+            Field (HPMR, DWordAcc, NoLock, Preserve)
+            {
+                MSEL,   32, 
+                MOEV,   32, 
+                MOSC,   32
+            }
+
             Method (_STA, 0, NotSerialized)  // _STA: Status
             {
                 If (MDNR == Zero)
@@ -944,6 +980,13 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
         }
     }
 
+    Scope (_SB)
+    {
+        Method (MTFY, 2, NotSerialized)
+        {
+        }
+    }
+
     Scope (_GPE)
     {
         Name (_HID, "ACPI0006" /* GPE Block Device */)  // _HID: Hardware ID
@@ -1084,49 +1127,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
 
     Scope (\_SB)
     {
-        Scope (\_SB.PCI0.MHPD)
-        {
-            Name (MDNR, Zero)
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                IO (Decode16,
-                    0x0A00,             // Range Minimum
-                    0x0A00,             // Range Maximum
-                    0x00,               // Alignment
-                    0x18,               // Length
-                    )
-            })
-            OperationRegion (HPMR, SystemIO, 0x0A00, 0x18)
-            Field (HPMR, DWordAcc, NoLock, Preserve)
-            {
-                MRBL,   32, 
-                MRBH,   32, 
-                MRLL,   32, 
-                MRLH,   32, 
-                MPX,    32
-            }
-
-            Field (HPMR, ByteAcc, NoLock, WriteAsZeros)
-            {
-                Offset (0x14), 
-                MES,    1, 
-                MINS,   1, 
-                MRMV,   1, 
-                MEJ,    1
-            }
-
-            Field (HPMR, DWordAcc, NoLock, Preserve)
-            {
-                MSEL,   32, 
-                MOEV,   32, 
-                MOSC,   32
-            }
-        }
-
-        Method (MTFY, 2, NotSerialized)
-        {
-        }
-
         Scope (PCI0)
         {
             Name (BSEL, Zero)


> 
> Thanks,
> Marcel
> 
> >      /* build memory devices */
> >      for (i = 0; i < nr_mem; i++) {
> >          #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> > +        Aml *dev;
> >          const char *s;
> >
> >          dev = aml_device("MP%02X", i);
> > @@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,
> >          aml_append(method, ifctx);
> >      }
> >      aml_append(sb_scope, method);
> > +    aml_append(table, sb_scope);
> >  }
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 38dcac7..690e9a0 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >
> >      sb_scope = aml_scope("\\_SB");
> >      {
> > -        build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
> > -                             pm->mem_hp_io_len);
> > +        Object *pci_host;
> > +        PCIBus *bus = NULL;
> >
> > -        {
> > -            Object *pci_host;
> > -            PCIBus *bus = NULL;
> > +        pci_host = acpi_get_i386_pci_host();
> > +        if (pci_host) {
> > +            bus = PCI_HOST_BRIDGE(pci_host)->bus;
> > +        }
> >
> > -            pci_host = acpi_get_i386_pci_host();
> > -            if (pci_host) {
> > -                bus = PCI_HOST_BRIDGE(pci_host)->bus;
> > +        if (bus) {
> > +            Aml *scope = aml_scope("PCI0");
> > +            /* Scan all PCI buses. Generate tables to support hotplug. */
> > +            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
> > +
> > +            if (misc->tpm_version != TPM_VERSION_UNSPEC) {
> > +                dev = aml_device("ISA.TPM");
> > +                aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
> > +                aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
> > +                crs = aml_resource_template();
> > +                aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> > +                           TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> > +                /*
> > +                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
> > +                    Rewrite to take IRQ from TPM device model and
> > +                    fix default IRQ value there to use some unused IRQ
> > +                 */
> > +                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
> > +                aml_append(dev, aml_name_decl("_CRS", crs));
> > +                aml_append(scope, dev);
> >              }
> >
> > -            if (bus) {
> > -                Aml *scope = aml_scope("PCI0");
> > -                /* Scan all PCI buses. Generate tables to support hotplug. */
> > -                build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
> > -
> > -                if (misc->tpm_version != TPM_VERSION_UNSPEC) {
> > -                    dev = aml_device("ISA.TPM");
> > -                    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
> > -                    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
> > -                    crs = aml_resource_template();
> > -                    aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
> > -                               TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
> > -                    /*
> > -                        FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
> > -                        Rewrite to take IRQ from TPM device model and
> > -                        fix default IRQ value there to use some unused IRQ
> > -                     */
> > -                    /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
> > -                    aml_append(dev, aml_name_decl("_CRS", crs));
> > -                    aml_append(scope, dev);
> > -                }
> > -
> > -                aml_append(sb_scope, scope);
> > -            }
> > +            aml_append(sb_scope, scope);
> >          }
> > -        aml_append(dsdt, sb_scope);
> >      }
> > +    aml_append(dsdt, sb_scope);
> >
> >      /* copy AML table into ACPI tables blob and patch header there */
> >      g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
> >  
> 

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  2016-12-21 12:31   ` Marcel Apfelbaum
@ 2016-12-21 13:39     ` Igor Mammedov
  2016-12-22 10:45       ` Marcel Apfelbaum
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-21 13:39 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On Wed, 21 Dec 2016 14:31:45 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > From this patch all the memory hotplug related AML
> > bits are consolidated in one place within DSTD.
> > Follow up patches will utilize that to simplify
> > memory hotplug related C/AML code.  
> 
> 
> I didn't quite understand what you mean...
me neither :/, it's quite useless commit message,
how about this one instead:

--
build hotplug event handler method body in generic
hw/acpi/memory_hotplug.c and make hw/i386/acpi-build.c
only provide target specific full name of the event
handler.
That removes hardcoded MEMORY_HOTPLUG_HANDLER_PATH and
allows to do target specific memory hotplug AML placement
and wiring it with a target specific hotplug event handler
(it's GPE for i386 and would be GPIO for ARM).

PS:
similar approach has been used with CPU hotplug as part of commit:
(d2238cb6 acpi: cpuhp: implement hot-add parts of CPU hotplug interface)
--


> 
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  include/hw/acpi/memory_hotplug.h |  6 +++---
> >  hw/acpi/memory_hotplug.c         | 42 ++++++++++++++++++++++++++--------------
> >  hw/i386/acpi-build.c             |  7 ++-----
> >  3 files changed, 32 insertions(+), 23 deletions(-)
> >
> > diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> > index 6dc48d2..37e2706 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> >
> >  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> >  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
> > -     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
> >
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > -                              uint16_t io_base, uint16_t io_len);
> > +                              uint16_t io_base, uint16_t io_len,
> > +                              const char *res_root,
> > +                              const char *event_handler_method);
> >  #endif
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index 18b95f2..49e856f 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = {
> >  };
> >
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > -                              uint16_t io_base, uint16_t io_len)
> > +                              uint16_t io_base, uint16_t io_len,
> > +                              const char *res_root,
> > +                              const char *event_handler_method)
> >  {
> >      int i;
> >      Aml *ifctx;
> >      Aml *method;
> > -    Aml *pci_scope;
> >      Aml *sb_scope;
> >      Aml *mem_ctrl_dev;
> > +    char *scan_path;
> > +    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
> >
> > -    /* scope for memory hotplug controller device node */
> > -    pci_scope = aml_scope("_SB.PCI0");
> > -    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
> > +    mem_ctrl_dev = aml_device("%s", mhp_res_path);  
> 
> 
> Will mem_ctrl_dev's name will have an extra "." suffix now?
nope it will be declared with target specific full path rather
than within separately created static scope:

-    Scope (_SB.PCI0)
+    Device (\_SB.PCI0.MHPD) // concat (res_root, ".", MEMORY_HOTPLUG_DEVICE)
     {
-        Device (MHPD)
...
and event handler would change like this:

+    Method (\_GPE._E03, 0, NotSerialized)  // _Exx: Edge-Triggered GPE
+    {
+        \_SB.PCI0.MHPD.MSCN ()
+    }
+
     Scope (_GPE)
     {
         Name (_HID, "ACPI0006" /* GPE Block Device */)  // _HID: Hardware ID
-        Method (_E03, 0, NotSerialized)  // _Exx: Edge-Triggered GPE
-        {
-            \_SB.PCI0.MHPD.MSCN ()
-        }



> 
> >      {
> >          Aml *crs;
> >          Aml *field;
> > @@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >          }
> >          aml_append(mem_ctrl_dev, method);
> >      }
> > -    aml_append(pci_scope, mem_ctrl_dev);
> > -    aml_append(table, pci_scope);
> > +    aml_append(table, mem_ctrl_dev);
> >
> >      sb_scope = aml_scope("_SB");
> >      /* build memory devices */
> >      for (i = 0; i < nr_mem; i++) {
> > -        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
> >          Aml *dev;
> > -        const char *s;
> > +        char *s;
> >
> >          dev = aml_device("MP%02X", i);
> >          aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> >          aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> >
> >          method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
> > +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);  
> 
> Same question here, do we get ".." in the path? Maybe is OK?
nope, it dynamic equivalent of original static 'BASEPATH MEMORY_SLOT_CRS_METHOD;'
where BASEPATH is replaced with
  concat(mhp_res_path, ".", MEMORY_SLOT_CRS_METHOD)

this 'for' loop changes are temporary and are part of transition
to dynamic mem hotplug AML placement. See patch 10/10 which simplifies
names within this 'for' loop and reduces AML size as result by placing
called methods within the same scope/container.
 
> Thanks,
> Marcel
> 
> >          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        g_free(s);
> >          aml_append(dev, method);
> >
> >          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
> > +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
> >          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        g_free(s);
> >          aml_append(dev, method);
> >
> >          method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
> > +        s = g_strdup_printf("%s.%s", mhp_res_path,
> > +                            MEMORY_SLOT_PROXIMITY_METHOD);
> >          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        g_free(s);
> >          aml_append(dev, method);
> >
> >          method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_OST_METHOD;
> > -
> > +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
> >          aml_append(method, aml_return(aml_call4(
> >              s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> >          )));
> > +        g_free(s);
> >          aml_append(dev, method);
> >
> >          method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> > -        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
> > +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
> >          aml_append(method, aml_return(aml_call2(
> >                     s, aml_name("_UID"), aml_arg(0))));
> > +        g_free(s);
> >          aml_append(dev, method);
> >
> >          aml_append(sb_scope, dev);
> > @@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >      }
> >      aml_append(sb_scope, method);
> >      aml_append(table, sb_scope);
> > +
> > +    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
> > +    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
> > +    aml_append(method, aml_call0(scan_path));
> > +    g_free(scan_path);
> > +    aml_append(table, method);
> > +
> > +    g_free(mhp_res_path);
> >  }
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 690e9a0..b7f4682 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >                         "\\_SB.PCI0", "\\_GPE._E02");
> >      }
> >      build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
> > -                             pm->mem_hp_io_len);
> > +                             pm->mem_hp_io_len,
> > +                             "\\_SB.PCI0", "\\_GPE._E03");
> >
> >      scope =  aml_scope("_GPE");
> >      {
> > @@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >              aml_append(scope, method);
> >          }
> >
> > -        method = aml_method("_E03", 0, AML_NOTSERIALIZED);
> > -        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
> > -        aml_append(scope, method);
> > -
> >          if (pcms->acpi_nvdimm_state.is_enabled) {
> >              method = aml_method("_E04", 0, AML_NOTSERIALIZED);
> >              aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
> >  
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  2016-12-21 13:39     ` Igor Mammedov
@ 2016-12-22 10:45       ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-22 10:45 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On 12/21/2016 03:39 PM, Igor Mammedov wrote:
> On Wed, 21 Dec 2016 14:31:45 +0200
> Marcel Apfelbaum <marcel@redhat.com> wrote:
>
>> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
>>> From this patch all the memory hotplug related AML
>>> bits are consolidated in one place within DSTD.
>>> Follow up patches will utilize that to simplify
>>> memory hotplug related C/AML code.
>>
>>
>> I didn't quite understand what you mean...
> me neither :/, it's quite useless commit message,
> how about this one instead:
>
> --
> build hotplug event handler method body in generic
> hw/acpi/memory_hotplug.c and make hw/i386/acpi-build.c
> only provide target specific full name of the event
> handler.
> That removes hardcoded MEMORY_HOTPLUG_HANDLER_PATH and
> allows to do target specific memory hotplug AML placement
> and wiring it with a target specific hotplug event handler
> (it's GPE for i386 and would be GPIO for ARM).
>

Works for me.

> PS:
> similar approach has been used with CPU hotplug as part of commit:
> (d2238cb6 acpi: cpuhp: implement hot-add parts of CPU hotplug interface)
> --
>
>
>>
>>>
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>> ---
>>>  include/hw/acpi/memory_hotplug.h |  6 +++---
>>>  hw/acpi/memory_hotplug.c         | 42 ++++++++++++++++++++++++++--------------
>>>  hw/i386/acpi-build.c             |  7 ++-----
>>>  3 files changed, 32 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
>>> index 6dc48d2..37e2706 100644
>>> --- a/include/hw/acpi/memory_hotplug.h
>>> +++ b/include/hw/acpi/memory_hotplug.h
>>> @@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>>>
>>>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
>>>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>>> -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
>>> -     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
>>>
>>>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>> -                              uint16_t io_base, uint16_t io_len);
>>> +                              uint16_t io_base, uint16_t io_len,
>>> +                              const char *res_root,
>>> +                              const char *event_handler_method);
>>>  #endif
>>> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
>>> index 18b95f2..49e856f 100644
>>> --- a/hw/acpi/memory_hotplug.c
>>> +++ b/hw/acpi/memory_hotplug.c
>>> @@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = {
>>>  };
>>>
>>>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>> -                              uint16_t io_base, uint16_t io_len)
>>> +                              uint16_t io_base, uint16_t io_len,
>>> +                              const char *res_root,
>>> +                              const char *event_handler_method)
>>>  {
>>>      int i;
>>>      Aml *ifctx;
>>>      Aml *method;
>>> -    Aml *pci_scope;
>>>      Aml *sb_scope;
>>>      Aml *mem_ctrl_dev;
>>> +    char *scan_path;
>>> +    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
>>>
>>> -    /* scope for memory hotplug controller device node */
>>> -    pci_scope = aml_scope("_SB.PCI0");
>>> -    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
>>> +    mem_ctrl_dev = aml_device("%s", mhp_res_path);
>>
>>
>> Will mem_ctrl_dev's name will have an extra "." suffix now?
> nope it will be declared with target specific full path rather
> than within separately created static scope:

Right, I mismatched the printf arguments..

>
> -    Scope (_SB.PCI0)
> +    Device (\_SB.PCI0.MHPD) // concat (res_root, ".", MEMORY_HOTPLUG_DEVICE)
>      {
> -        Device (MHPD)
> ...
> and event handler would change like this:
>
> +    Method (\_GPE._E03, 0, NotSerialized)  // _Exx: Edge-Triggered GPE
> +    {
> +        \_SB.PCI0.MHPD.MSCN ()
> +    }
> +
>      Scope (_GPE)
>      {
>          Name (_HID, "ACPI0006" /* GPE Block Device */)  // _HID: Hardware ID
> -        Method (_E03, 0, NotSerialized)  // _Exx: Edge-Triggered GPE
> -        {
> -            \_SB.PCI0.MHPD.MSCN ()
> -        }
>
>

OK

>
>>
>>>      {
>>>          Aml *crs;
>>>          Aml *field;
>>> @@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>          }
>>>          aml_append(mem_ctrl_dev, method);
>>>      }
>>> -    aml_append(pci_scope, mem_ctrl_dev);
>>> -    aml_append(table, pci_scope);
>>> +    aml_append(table, mem_ctrl_dev);
>>>
>>>      sb_scope = aml_scope("_SB");
>>>      /* build memory devices */
>>>      for (i = 0; i < nr_mem; i++) {
>>> -        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
>>>          Aml *dev;
>>> -        const char *s;
>>> +        char *s;
>>>
>>>          dev = aml_device("MP%02X", i);
>>>          aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>>>          aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>>>
>>>          method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
>>> -        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
>>> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
>>
>> Same question here, do we get ".." in the path? Maybe is OK?
> nope, it dynamic equivalent of original static 'BASEPATH MEMORY_SLOT_CRS_METHOD;'
> where BASEPATH is replaced with
>   concat(mhp_res_path, ".", MEMORY_SLOT_CRS_METHOD)
>
> this 'for' loop changes are temporary and are part of transition
> to dynamic mem hotplug AML placement. See patch 10/10 which simplifies
> names within this 'for' loop and reduces AML size as result by placing
> called methods within the same scope/container.
>

Thanks for the explanations.

>> Thanks,
>> Marcel
>>
>>>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +        g_free(s);
>>>          aml_append(dev, method);
>>>
>>>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>>> -        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
>>> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
>>>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +        g_free(s);
>>>          aml_append(dev, method);
>>>
>>>          method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
>>> -        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
>>> +        s = g_strdup_printf("%s.%s", mhp_res_path,
>>> +                            MEMORY_SLOT_PROXIMITY_METHOD);
>>>          aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +        g_free(s);
>>>          aml_append(dev, method);
>>>
>>>          method = aml_method("_OST", 3, AML_NOTSERIALIZED);
>>> -        s = BASEPATH MEMORY_SLOT_OST_METHOD;
>>> -
>>> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
>>>          aml_append(method, aml_return(aml_call4(
>>>              s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>>>          )));
>>> +        g_free(s);
>>>          aml_append(dev, method);
>>>
>>>          method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>>> -        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
>>> +        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
>>>          aml_append(method, aml_return(aml_call2(
>>>                     s, aml_name("_UID"), aml_arg(0))));
>>> +        g_free(s);
>>>          aml_append(dev, method);
>>>
>>>          aml_append(sb_scope, dev);
>>> @@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>      }
>>>      aml_append(sb_scope, method);
>>>      aml_append(table, sb_scope);
>>> +
>>> +    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
>>> +    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
>>> +    aml_append(method, aml_call0(scan_path));
>>> +    g_free(scan_path);
>>> +    aml_append(table, method);
>>> +
>>> +    g_free(mhp_res_path);
>>>  }
>>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>>> index 690e9a0..b7f4682 100644
>>> --- a/hw/i386/acpi-build.c
>>> +++ b/hw/i386/acpi-build.c
>>> @@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>>>                         "\\_SB.PCI0", "\\_GPE._E02");
>>>      }
>>>      build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
>>> -                             pm->mem_hp_io_len);
>>> +                             pm->mem_hp_io_len,
>>> +                             "\\_SB.PCI0", "\\_GPE._E03");
>>>
>>>      scope =  aml_scope("_GPE");
>>>      {
>>> @@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>>>              aml_append(scope, method);
>>>          }
>>>
>>> -        method = aml_method("_E03", 0, AML_NOTSERIALIZED);
>>> -        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
>>> -        aml_append(scope, method);
>>> -
>>>          if (pcms->acpi_nvdimm_state.is_enabled) {
>>>              method = aml_method("_E04", 0, AML_NOTSERIALIZED);
>>>              aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
>>>
>>
>


Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported Igor Mammedov
@ 2016-12-22 10:55   ` Marcel Apfelbaum
  0 siblings, 0 replies; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-22 10:55 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> That reduces DSDT by 910 bytes when memory hotplug
> isn't enabled.
>
> While doing so drop intermediate variables/arguments
> passing around ACPI_MEMORY_HOTPLUG_IO_LEN and making
> it local to memory_hotplug.c, hardcoding it there as
> it can't change.
>
> Also don't pass around ACPI_MEMORY_HOTPLUG_BASE through
> intermediate variables/arguments where it's not needed.
> Instead initialize in module static variable when MMIO
> region is mapped and use that within memory_hotplug.c
> whenever it's required.
> That way MMIO base specified only at one place and AML
> with MMIO would always use the same value.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/hw/acpi/memory_hotplug.h |  3 +--
>  include/hw/acpi/pc-hotplug.h     |  1 -
>  hw/acpi/ich9.c                   |  3 ++-
>  hw/acpi/memory_hotplug.c         | 24 +++++++++++++++++-------
>  hw/acpi/piix4.c                  |  3 ++-
>  hw/i386/acpi-build.c             |  9 +--------
>  6 files changed, 23 insertions(+), 20 deletions(-)
>
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 91d4045..db8ebc9 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -30,7 +30,7 @@ typedef struct MemHotplugState {
>  } MemHotplugState;
>
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state);
> +                              MemHotplugState *state, uint16_t io_base);
>
>  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
>                           DeviceState *dev, Error **errp);
> @@ -48,7 +48,6 @@ extern const VMStateDescription vmstate_memory_hotplug;
>  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> -                              uint16_t io_base, uint16_t io_len,
>                                const char *res_root,
>                                const char *event_handler_method);
>  #endif
> diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
> index a4f513d..31bc919 100644
> --- a/include/hw/acpi/pc-hotplug.h
> +++ b/include/hw/acpi/pc-hotplug.h
> @@ -29,7 +29,6 @@
>  #define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00
>  #define CPU_HOTPLUG_RESOURCE_DEVICE PRES
>
> -#define ACPI_MEMORY_HOTPLUG_IO_LEN 24
>  #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
>
>  #endif
> diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
> index 830c475..5c279bb 100644
> --- a/hw/acpi/ich9.c
> +++ b/hw/acpi/ich9.c
> @@ -306,7 +306,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
>
>      if (pm->acpi_memory_hotplug.is_enabled) {
>          acpi_memory_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci),
> -                                 &pm->acpi_memory_hotplug);
> +                                 &pm->acpi_memory_hotplug,
> +                                 ACPI_MEMORY_HOTPLUG_BASE);
>      }
>  }
>
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index da29332..fb04d24 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -30,6 +30,9 @@
>  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> +#define MEMORY_HOTPLUG_IO_LEN         24
> +
> +static uint16_t memhp_io_base;
>
>  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
>  {
> @@ -202,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = {
>  };
>
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state)
> +                              MemHotplugState *state, uint16_t io_base)
>  {
>      MachineState *machine = MACHINE(qdev_get_machine());
>
> @@ -211,10 +214,12 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
>          return;
>      }
>
> +    assert(!memhp_io_base);
> +    memhp_io_base = io_base;
>      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
>      memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,
> -                          "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN);
> -    memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);
> +                          "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN);
> +    memory_region_add_subregion(as, memhp_io_base, &state->io);
>  }
>
>  /**
> @@ -332,7 +337,6 @@ const VMStateDescription vmstate_memory_hotplug = {
>  };
>
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> -                              uint16_t io_base, uint16_t io_len,
>                                const char *res_root,
>                                const char *event_handler_method)
>  {
> @@ -342,8 +346,13 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>      Aml *sb_scope;
>      Aml *mem_ctrl_dev;
>      char *scan_path;
> -    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
> +    char *mhp_res_path;
> +
> +    if (!memhp_io_base) {
> +        return;
> +    }
>

I would split the functional change from the refactoring  code,
but if Michael is OK with it:

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

> +    mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
>      mem_ctrl_dev = aml_device("%s", mhp_res_path);
>      {
>          Aml *crs;
> @@ -367,13 +376,14 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>
>          crs = aml_resource_template();
>          aml_append(crs,
> -            aml_io(AML_DECODE16, io_base, io_base, 0, io_len)
> +            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> +                   MEMORY_HOTPLUG_IO_LEN)
>          );
>          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
>
>          aml_append(mem_ctrl_dev, aml_operation_region(
>              MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> -            aml_int(io_base), io_len)
> +            aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
>          );
>
>          field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index 17d36bd..6d99fe4 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -644,7 +644,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
>                                   PIIX4_CPU_HOTPLUG_IO_BASE);
>
>      if (s->acpi_memory_hotplug.is_enabled) {
> -        acpi_memory_hotplug_init(parent, OBJECT(s), &s->acpi_memory_hotplug);
> +        acpi_memory_hotplug_init(parent, OBJECT(s), &s->acpi_memory_hotplug,
> +                                 ACPI_MEMORY_HOTPLUG_BASE);
>      }
>  }
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index b7f4682..f207d4f 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -101,8 +101,6 @@ typedef struct AcpiPmInfo {
>      uint32_t gpe0_blk_len;
>      uint32_t io_base;
>      uint16_t cpu_hp_io_base;
> -    uint16_t mem_hp_io_base;
> -    uint16_t mem_hp_io_len;
>      uint16_t pcihp_io_base;
>      uint16_t pcihp_io_len;
>  } AcpiPmInfo;
> @@ -148,9 +146,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
>      }
>      assert(obj);
>
> -    pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
> -    pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
> -
>      /* Fill in optional s3/s4 related properties */
>      o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
>      if (o) {
> @@ -1925,9 +1920,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
>                         "\\_SB.PCI0", "\\_GPE._E02");
>      }
> -    build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
> -                             pm->mem_hp_io_len,
> -                             "\\_SB.PCI0", "\\_GPE._E03");
> +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
>
>      scope =  aml_scope("_GPE");
>      {
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods Igor Mammedov
@ 2016-12-22 12:31   ` Marcel Apfelbaum
  2016-12-22 13:31     ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-22 12:31 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Michael S. Tsirkin, Eduardo Habkost

On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> Move DIMM devices from global _SB scope to a new \_SB.MHPC
> container along with common methods used by DIMMs:
>   MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY
>
> this reduces AML size on 12 * #slots bytes,
> i.e. up to 3072 bytes for 265 slots.
>

Can you please explain how the bytes number are reduced?
Is it because the devices path is now relative to the new container?
If so, can you give an example of before/after?

> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++-----------------------
>  1 file changed, 97 insertions(+), 93 deletions(-)
>
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index fb04d24..210073d 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -31,6 +31,7 @@
>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
>  #define MEMORY_HOTPLUG_IO_LEN         24
> +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
>
>  static uint16_t memhp_io_base;
>
> @@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>      int i;
>      Aml *ifctx;
>      Aml *method;
> -    Aml *sb_scope;
> +    Aml *dev_container;
>      Aml *mem_ctrl_dev;
> -    char *scan_path;
>      char *mhp_res_path;
>
>      if (!memhp_io_base) {
> @@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>      mem_ctrl_dev = aml_device("%s", mhp_res_path);
>      {
>          Aml *crs;
> -        Aml *field;
> -        Aml *one = aml_int(1);
> -        Aml *zero = aml_int(0);
> -        Aml *ret_val = aml_local(0);
> -        Aml *slot_arg0 = aml_arg(0);
> -        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> -        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> -        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
>
>          aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));

Do we need the above declaration twice? Here is the first occurrence.

>          aml_append(mem_ctrl_dev,
>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
>
> -        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> -        aml_append(mem_ctrl_dev,
> -            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> -        );
> -
>          crs = aml_resource_template();
>          aml_append(crs,
>              aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> @@ -386,7 +373,32 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
>          );
>
> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +    }
> +    aml_append(table, mem_ctrl_dev);
> +
> +    dev_container = aml_device(MEMORY_DEVICES_CONTAINER);
> +    {
> +        Aml *field;
> +        Aml *one = aml_int(1);
> +        Aml *zero = aml_int(0);
> +        Aml *ret_val = aml_local(0);
> +        Aml *slot_arg0 = aml_arg(0);
> +        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> +        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> +        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
> +        char *mmio_path = g_strdup_printf("%s." MEMORY_HOTPLUG_IO_REGION,
> +                                          mhp_res_path);
> +
> +        aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));

And here is the second occurrence.



Thanks,
Marcel

> +        aml_append(dev_container,
> +            aml_name_decl("_UID", aml_string("DIMM devices")));
> +
> +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> +        aml_append(dev_container,
> +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> +        );
> +
> +        field = aml_field(mmio_path, AML_DWORD_ACC,
>                            AML_NOLOCK, AML_PRESERVE);
>          aml_append(field, /* read only */
>              aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> @@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
>          aml_append(field, /* read only */
>              aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> -        aml_append(mem_ctrl_dev, field);
> +        aml_append(dev_container, field);
>
> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> +        field = aml_field(mmio_path, AML_BYTE_ACC,
>                            AML_NOLOCK, AML_WRITE_AS_ZEROS);
>          aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>          aml_append(field, /* 1 if enabled, read only */
> @@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>          aml_append(field,
>              /* initiates device eject, write only */
>              aml_named_field(MEMORY_SLOT_EJECT, 1));
> -        aml_append(mem_ctrl_dev, field);
> +        aml_append(dev_container, field);
>
> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> +        field = aml_field(mmio_path, AML_DWORD_ACC,
>                            AML_NOLOCK, AML_PRESERVE);
>          aml_append(field, /* DIMM selector, write only */
>              aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> @@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
>          aml_append(field, /* _OST status code, write only */
>              aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> -        aml_append(mem_ctrl_dev, field);
> +        aml_append(dev_container, field);
> +        g_free(mmio_path);
>
>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>          ifctx = aml_if(aml_equal(slots_nr, zero));
> @@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>          aml_append(method, ifctx);
>          /* present, functioning, decoding, not shown in UI */
>          aml_append(method, aml_return(aml_int(0xB)));
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
> -        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
> +        aml_append(dev_container, aml_mutex(MEMORY_SLOT_LOCK, 0));
>
>          method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
>          {
> @@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_release(ctrl_lock));
>              aml_append(method, aml_return(one));
>          }
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
>          method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
>          {
> @@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_release(ctrl_lock));
>              aml_append(method, aml_return(ret_val));
>          }
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
>          method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
>          {
> @@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_release(ctrl_lock));
>              aml_append(method, aml_return(mr64));
>          }
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
>          method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
>                              AML_NOTSERIALIZED);
> @@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_release(ctrl_lock));
>              aml_append(method, aml_return(ret_val));
>          }
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
>          method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
>          {
> @@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_store(aml_arg(2), ost_status));
>              aml_append(method, aml_release(ctrl_lock));
>          }
> -        aml_append(mem_ctrl_dev, method);
> +        aml_append(dev_container, method);
>
>          method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
>          {
> @@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_append(method, aml_store(one, eject));
>              aml_append(method, aml_release(ctrl_lock));
>          }
> -        aml_append(mem_ctrl_dev, method);
> -    }
> -    aml_append(table, mem_ctrl_dev);
> -
> -    sb_scope = aml_scope("_SB");
> -    /* build memory devices */
> -    for (i = 0; i < nr_mem; i++) {
> -        Aml *dev;
> -        char *s;
> -
> -        dev = aml_device("MP%02X", i);
> -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> -
> -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        g_free(s);
> -        aml_append(dev, method);
> -
> -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        g_free(s);
> -        aml_append(dev, method);
> -
> -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> -        s = g_strdup_printf("%s.%s", mhp_res_path,
> -                            MEMORY_SLOT_PROXIMITY_METHOD);
> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -        g_free(s);
> -        aml_append(dev, method);
> -
> -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
> -        aml_append(method, aml_return(aml_call4(
> -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> -        )));
> -        g_free(s);
> -        aml_append(dev, method);
> -
> -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
> -        aml_append(method, aml_return(aml_call2(
> -                   s, aml_name("_UID"), aml_arg(0))));
> -        g_free(s);
> -        aml_append(dev, method);
> -
> -        aml_append(sb_scope, dev);
> -    }
> +        aml_append(dev_container, method);
> +
> +        /* build memory devices */
> +        for (i = 0; i < nr_mem; i++) {
> +            Aml *dev;
> +            const char *s;
> +
> +            dev = aml_device("MP%02X", i);
> +            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> +            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> +
> +            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> +            s = MEMORY_SLOT_CRS_METHOD;
> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +            aml_append(dev, method);
> +
> +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> +            s = MEMORY_SLOT_STATUS_METHOD;
> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +            aml_append(dev, method);
> +
> +            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> +            s = MEMORY_SLOT_PROXIMITY_METHOD;
> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +            aml_append(dev, method);
> +
> +            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> +            s = MEMORY_SLOT_OST_METHOD;
> +            aml_append(method, aml_return(aml_call4(
> +                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> +            )));
> +            aml_append(dev, method);
> +
> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> +            s = MEMORY_SLOT_EJECT_METHOD;
> +            aml_append(method, aml_return(aml_call2(
> +                       s, aml_name("_UID"), aml_arg(0))));
> +            aml_append(dev, method);
> +
> +            aml_append(dev_container, dev);
> +        }
>
> -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> -     */
> -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> -    for (i = 0; i < nr_mem; i++) {
> -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> -        aml_append(ifctx,
> -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> -        );
> -        aml_append(method, ifctx);
> +        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> +         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> +         */
> +        method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> +        for (i = 0; i < nr_mem; i++) {
> +            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> +            aml_append(ifctx,
> +                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> +            );
> +            aml_append(method, ifctx);
> +        }
> +        aml_append(dev_container, method);
>      }
> -    aml_append(sb_scope, method);
> -    aml_append(table, sb_scope);
> +    aml_append(table, dev_container);
>
>      method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
> -    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
> -    aml_append(method, aml_call0(scan_path));
> -    g_free(scan_path);
> +    aml_append(method,
> +        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
>      aml_append(table, method);
>
>      g_free(mhp_res_path);
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
  2016-12-22 12:31   ` Marcel Apfelbaum
@ 2016-12-22 13:31     ` Igor Mammedov
  2016-12-22 13:53       ` Marcel Apfelbaum
  0 siblings, 1 reply; 37+ messages in thread
From: Igor Mammedov @ 2016-12-22 13:31 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On Thu, 22 Dec 2016 14:31:19 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
> > Move DIMM devices from global _SB scope to a new \_SB.MHPC
> > container along with common methods used by DIMMs:
> >   MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY
> >
> > this reduces AML size on 12 * #slots bytes,
> > i.e. up to 3072 bytes for 265 slots.
> >  
> 
> Can you please explain how the bytes number are reduced?
> Is it because the devices path is now relative to the new container?
yes

> If so, can you give an example of before/after?
as example:

-        Device (MP02)
-        {
-            Name (_UID, "0x02")  // _UID: Unique ID
-            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
-            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
-            {
-                Return (\_SB.PCI0.MHPD.MCRS (_UID))
-            }
-
-            Method (_STA, 0, NotSerialized)  // _STA: Status
-            {
-                Return (\_SB.PCI0.MHPD.MRST (_UID))
-            }
-
-            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
-            {
-                Return (\_SB.PCI0.MHPD.MPXM (_UID))
-            }
-
-            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
-            {
-                Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2))
-            }
-
-            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
-            {
-                Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0))
-            }
-        }
----
+        Device (MP02)
+        {
+            Name (_UID, "0x02")  // _UID: Unique ID
+            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
+            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
+            {
+                Return (MCRS (_UID))
+            }
+
+            Method (_STA, 0, NotSerialized)  // _STA: Status
+            {
+                Return (MRST (_UID))
+            }
+
+            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
+            {
+                Return (MPXM (_UID))
+            }
+
+            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
+            {
+                Return (MOST (_UID, Arg0, Arg1, Arg2))
+            }
+
+            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
+            {
+                Return (MEJ0 (_UID, Arg0))
+            }
+        }

> 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++-----------------------
> >  1 file changed, 97 insertions(+), 93 deletions(-)
> >
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index fb04d24..210073d 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -31,6 +31,7 @@
> >  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> >  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> >  #define MEMORY_HOTPLUG_IO_LEN         24
> > +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> >
> >  static uint16_t memhp_io_base;
> >
> > @@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >      int i;
> >      Aml *ifctx;
> >      Aml *method;
> > -    Aml *sb_scope;
> > +    Aml *dev_container;
> >      Aml *mem_ctrl_dev;
> > -    char *scan_path;
> >      char *mhp_res_path;
> >
> >      if (!memhp_io_base) {
> > @@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >      mem_ctrl_dev = aml_device("%s", mhp_res_path);
> >      {
> >          Aml *crs;
> > -        Aml *field;
> > -        Aml *one = aml_int(1);
> > -        Aml *zero = aml_int(0);
> > -        Aml *ret_val = aml_local(0);
> > -        Aml *slot_arg0 = aml_arg(0);
> > -        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> > -        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> > -        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
> >
> >          aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));  
> 
> Do we need the above declaration twice? Here is the first occurrence.
> 
> >          aml_append(mem_ctrl_dev,
> >              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
[...]

> > +
> > +    dev_container = aml_device(MEMORY_DEVICES_CONTAINER);
> > +    {
[...]
> > +        aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));  
> 
> And here is the second occurrence.
It's different containers, the first one is for MMIO registers
for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS
and the second is for memory devices \_SB.MHPC which consumes resources
outside of PCI0._CRS scope.

 
> 
> Thanks,
> Marcel
> 
> > +        aml_append(dev_container,
> > +            aml_name_decl("_UID", aml_string("DIMM devices")));
> > +
> > +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > +        aml_append(dev_container,
> > +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> > +        );
> > +
> > +        field = aml_field(mmio_path, AML_DWORD_ACC,
> >                            AML_NOLOCK, AML_PRESERVE);
> >          aml_append(field, /* read only */
> >              aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> > @@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> >          aml_append(field, /* read only */
> >              aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> > -        aml_append(mem_ctrl_dev, field);
> > +        aml_append(dev_container, field);
> >
> > -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> > +        field = aml_field(mmio_path, AML_BYTE_ACC,
> >                            AML_NOLOCK, AML_WRITE_AS_ZEROS);
> >          aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> >          aml_append(field, /* 1 if enabled, read only */
> > @@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >          aml_append(field,
> >              /* initiates device eject, write only */
> >              aml_named_field(MEMORY_SLOT_EJECT, 1));
> > -        aml_append(mem_ctrl_dev, field);
> > +        aml_append(dev_container, field);
> >
> > -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> > +        field = aml_field(mmio_path, AML_DWORD_ACC,
> >                            AML_NOLOCK, AML_PRESERVE);
> >          aml_append(field, /* DIMM selector, write only */
> >              aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> > @@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> >          aml_append(field, /* _OST status code, write only */
> >              aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> > -        aml_append(mem_ctrl_dev, field);
> > +        aml_append(dev_container, field);
> > +        g_free(mmio_path);
> >
> >          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> >          ifctx = aml_if(aml_equal(slots_nr, zero));
> > @@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >          aml_append(method, ifctx);
> >          /* present, functioning, decoding, not shown in UI */
> >          aml_append(method, aml_return(aml_int(0xB)));
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> > -        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
> > +        aml_append(dev_container, aml_mutex(MEMORY_SLOT_LOCK, 0));
> >
> >          method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
> >          {
> > @@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_release(ctrl_lock));
> >              aml_append(method, aml_return(one));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> >          method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
> >          {
> > @@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_release(ctrl_lock));
> >              aml_append(method, aml_return(ret_val));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> >          method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
> >          {
> > @@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_release(ctrl_lock));
> >              aml_append(method, aml_return(mr64));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> >          method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
> >                              AML_NOTSERIALIZED);
> > @@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_release(ctrl_lock));
> >              aml_append(method, aml_return(ret_val));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> >          method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
> >          {
> > @@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_store(aml_arg(2), ost_status));
> >              aml_append(method, aml_release(ctrl_lock));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > +        aml_append(dev_container, method);
> >
> >          method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
> >          {
> > @@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >              aml_append(method, aml_store(one, eject));
> >              aml_append(method, aml_release(ctrl_lock));
> >          }
> > -        aml_append(mem_ctrl_dev, method);
> > -    }
> > -    aml_append(table, mem_ctrl_dev);
> > -
> > -    sb_scope = aml_scope("_SB");
> > -    /* build memory devices */
> > -    for (i = 0; i < nr_mem; i++) {
> > -        Aml *dev;
> > -        char *s;
> > -
> > -        dev = aml_device("MP%02X", i);
> > -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > -
> > -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> > -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        g_free(s);
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        g_free(s);
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> > -        s = g_strdup_printf("%s.%s", mhp_res_path,
> > -                            MEMORY_SLOT_PROXIMITY_METHOD);
> > -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -        g_free(s);
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> > -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
> > -        aml_append(method, aml_return(aml_call4(
> > -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > -        )));
> > -        g_free(s);
> > -        aml_append(dev, method);
> > -
> > -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> > -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
> > -        aml_append(method, aml_return(aml_call2(
> > -                   s, aml_name("_UID"), aml_arg(0))));
> > -        g_free(s);
> > -        aml_append(dev, method);
> > -
> > -        aml_append(sb_scope, dev);
> > -    }
> > +        aml_append(dev_container, method);
> > +
> > +        /* build memory devices */
> > +        for (i = 0; i < nr_mem; i++) {
> > +            Aml *dev;
> > +            const char *s;
> > +
> > +            dev = aml_device("MP%02X", i);
> > +            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > +            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > +
> > +            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> > +            s = MEMORY_SLOT_CRS_METHOD;
> > +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +            aml_append(dev, method);
> > +
> > +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > +            s = MEMORY_SLOT_STATUS_METHOD;
> > +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +            aml_append(dev, method);
> > +
> > +            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> > +            s = MEMORY_SLOT_PROXIMITY_METHOD;
> > +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +            aml_append(dev, method);
> > +
> > +            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> > +            s = MEMORY_SLOT_OST_METHOD;
> > +            aml_append(method, aml_return(aml_call4(
> > +                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > +            )));
> > +            aml_append(dev, method);
> > +
> > +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> > +            s = MEMORY_SLOT_EJECT_METHOD;
> > +            aml_append(method, aml_return(aml_call2(
> > +                       s, aml_name("_UID"), aml_arg(0))));
> > +            aml_append(dev, method);
> > +
> > +            aml_append(dev_container, dev);
> > +        }
> >
> > -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > -     */
> > -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> > -    for (i = 0; i < nr_mem; i++) {
> > -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > -        aml_append(ifctx,
> > -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > -        );
> > -        aml_append(method, ifctx);
> > +        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > +         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > +         */
> > +        method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> > +        for (i = 0; i < nr_mem; i++) {
> > +            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > +            aml_append(ifctx,
> > +                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > +            );
> > +            aml_append(method, ifctx);
> > +        }
> > +        aml_append(dev_container, method);
> >      }
> > -    aml_append(sb_scope, method);
> > -    aml_append(table, sb_scope);
> > +    aml_append(table, dev_container);
> >
> >      method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
> > -    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
> > -    aml_append(method, aml_call0(scan_path));
> > -    g_free(scan_path);
> > +    aml_append(method,
> > +        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
> >      aml_append(table, method);
> >
> >      g_free(mhp_res_path);
> >  
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
  2016-12-22 13:31     ` Igor Mammedov
@ 2016-12-22 13:53       ` Marcel Apfelbaum
  2016-12-22 14:10         ` Igor Mammedov
  0 siblings, 1 reply; 37+ messages in thread
From: Marcel Apfelbaum @ 2016-12-22 13:53 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, Michael S. Tsirkin, Eduardo Habkost

On 12/22/2016 03:31 PM, Igor Mammedov wrote:
> On Thu, 22 Dec 2016 14:31:19 +0200
> Marcel Apfelbaum <marcel@redhat.com> wrote:
>
>> On 12/06/2016 01:32 AM, Igor Mammedov wrote:
>>> Move DIMM devices from global _SB scope to a new \_SB.MHPC
>>> container along with common methods used by DIMMs:
>>>   MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY
>>>
>>> this reduces AML size on 12 * #slots bytes,
>>> i.e. up to 3072 bytes for 265 slots.
>>>
>>
>> Can you please explain how the bytes number are reduced?
>> Is it because the devices path is now relative to the new container?
> yes
>
>> If so, can you give an example of before/after?
> as example:
>
> -        Device (MP02)
> -        {
> -            Name (_UID, "0x02")  // _UID: Unique ID
> -            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
> -            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
> -            {
> -                Return (\_SB.PCI0.MHPD.MCRS (_UID))
> -            }
> -
> -            Method (_STA, 0, NotSerialized)  // _STA: Status
> -            {
> -                Return (\_SB.PCI0.MHPD.MRST (_UID))
> -            }
> -
> -            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
> -            {
> -                Return (\_SB.PCI0.MHPD.MPXM (_UID))
> -            }
> -
> -            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
> -            {
> -                Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2))
> -            }
> -
> -            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> -            {
> -                Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0))
> -            }
> -        }
> ----
> +        Device (MP02)
> +        {
> +            Name (_UID, "0x02")  // _UID: Unique ID
> +            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
> +            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
> +            {
> +                Return (MCRS (_UID))
> +            }
> +
> +            Method (_STA, 0, NotSerialized)  // _STA: Status
> +            {
> +                Return (MRST (_UID))
> +            }
> +
> +            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
> +            {
> +                Return (MPXM (_UID))
> +            }
> +
> +            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
> +            {
> +                Return (MOST (_UID, Arg0, Arg1, Arg2))
> +            }
> +
> +            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> +            {
> +                Return (MEJ0 (_UID, Arg0))
> +            }
> +        }
>

Thanks for the confirmation.

>>
>>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>>> ---
>>>  hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++-----------------------
>>>  1 file changed, 97 insertions(+), 93 deletions(-)
>>>
>>> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
>>> index fb04d24..210073d 100644
>>> --- a/hw/acpi/memory_hotplug.c
>>> +++ b/hw/acpi/memory_hotplug.c
>>> @@ -31,6 +31,7 @@
>>>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>>>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
>>>  #define MEMORY_HOTPLUG_IO_LEN         24
>>> +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
>>>
>>>  static uint16_t memhp_io_base;
>>>
>>> @@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>      int i;
>>>      Aml *ifctx;
>>>      Aml *method;
>>> -    Aml *sb_scope;
>>> +    Aml *dev_container;
>>>      Aml *mem_ctrl_dev;
>>> -    char *scan_path;
>>>      char *mhp_res_path;
>>>
>>>      if (!memhp_io_base) {
>>> @@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>      mem_ctrl_dev = aml_device("%s", mhp_res_path);
>>>      {
>>>          Aml *crs;
>>> -        Aml *field;
>>> -        Aml *one = aml_int(1);
>>> -        Aml *zero = aml_int(0);
>>> -        Aml *ret_val = aml_local(0);
>>> -        Aml *slot_arg0 = aml_arg(0);
>>> -        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
>>> -        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
>>> -        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
>>>
>>>          aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
>>
>> Do we need the above declaration twice? Here is the first occurrence.
>>
>>>          aml_append(mem_ctrl_dev,
>>>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
> [...]
>
>>> +
>>> +    dev_container = aml_device(MEMORY_DEVICES_CONTAINER);
>>> +    {
> [...]
>>> +        aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));
>>
>> And here is the second occurrence.
> It's different containers, the first one is for MMIO registers
> for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS
> and the second is for memory devices \_SB.MHPC which consumes resources
> outside of PCI0._CRS scope.
>

Understood, here is my last R-b tag, however I want to point out
that I only looked at the re-factoring steps and my acpi-based memory hotplug
knowledge is rather limited.


Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Thanks,
Marcel

>
>>
>> Thanks,
>> Marcel
>>
>>> +        aml_append(dev_container,
>>> +            aml_name_decl("_UID", aml_string("DIMM devices")));
>>> +
>>> +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
>>> +        aml_append(dev_container,
>>> +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
>>> +        );
>>> +
>>> +        field = aml_field(mmio_path, AML_DWORD_ACC,
>>>                            AML_NOLOCK, AML_PRESERVE);
>>>          aml_append(field, /* read only */
>>>              aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
>>> @@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
>>>          aml_append(field, /* read only */
>>>              aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
>>> -        aml_append(mem_ctrl_dev, field);
>>> +        aml_append(dev_container, field);
>>>
>>> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
>>> +        field = aml_field(mmio_path, AML_BYTE_ACC,
>>>                            AML_NOLOCK, AML_WRITE_AS_ZEROS);
>>>          aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>>>          aml_append(field, /* 1 if enabled, read only */
>>> @@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>          aml_append(field,
>>>              /* initiates device eject, write only */
>>>              aml_named_field(MEMORY_SLOT_EJECT, 1));
>>> -        aml_append(mem_ctrl_dev, field);
>>> +        aml_append(dev_container, field);
>>>
>>> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
>>> +        field = aml_field(mmio_path, AML_DWORD_ACC,
>>>                            AML_NOLOCK, AML_PRESERVE);
>>>          aml_append(field, /* DIMM selector, write only */
>>>              aml_named_field(MEMORY_SLOT_SLECTOR, 32));
>>> @@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
>>>          aml_append(field, /* _OST status code, write only */
>>>              aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
>>> -        aml_append(mem_ctrl_dev, field);
>>> +        aml_append(dev_container, field);
>>> +        g_free(mmio_path);
>>>
>>>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>>>          ifctx = aml_if(aml_equal(slots_nr, zero));
>>> @@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>          aml_append(method, ifctx);
>>>          /* present, functioning, decoding, not shown in UI */
>>>          aml_append(method, aml_return(aml_int(0xB)));
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>> -        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
>>> +        aml_append(dev_container, aml_mutex(MEMORY_SLOT_LOCK, 0));
>>>
>>>          method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
>>>          {
>>> @@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_release(ctrl_lock));
>>>              aml_append(method, aml_return(one));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>>          method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
>>>          {
>>> @@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_release(ctrl_lock));
>>>              aml_append(method, aml_return(ret_val));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>>          method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
>>>          {
>>> @@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_release(ctrl_lock));
>>>              aml_append(method, aml_return(mr64));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>>          method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
>>>                              AML_NOTSERIALIZED);
>>> @@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_release(ctrl_lock));
>>>              aml_append(method, aml_return(ret_val));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>>          method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
>>>          {
>>> @@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_store(aml_arg(2), ost_status));
>>>              aml_append(method, aml_release(ctrl_lock));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> +        aml_append(dev_container, method);
>>>
>>>          method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
>>>          {
>>> @@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>>>              aml_append(method, aml_store(one, eject));
>>>              aml_append(method, aml_release(ctrl_lock));
>>>          }
>>> -        aml_append(mem_ctrl_dev, method);
>>> -    }
>>> -    aml_append(table, mem_ctrl_dev);
>>> -
>>> -    sb_scope = aml_scope("_SB");
>>> -    /* build memory devices */
>>> -    for (i = 0; i < nr_mem; i++) {
>>> -        Aml *dev;
>>> -        char *s;
>>> -
>>> -        dev = aml_device("MP%02X", i);
>>> -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>>> -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>>> -
>>> -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
>>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
>>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> -        g_free(s);
>>> -        aml_append(dev, method);
>>> -
>>> -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
>>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> -        g_free(s);
>>> -        aml_append(dev, method);
>>> -
>>> -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
>>> -        s = g_strdup_printf("%s.%s", mhp_res_path,
>>> -                            MEMORY_SLOT_PROXIMITY_METHOD);
>>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> -        g_free(s);
>>> -        aml_append(dev, method);
>>> -
>>> -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
>>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
>>> -        aml_append(method, aml_return(aml_call4(
>>> -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>>> -        )));
>>> -        g_free(s);
>>> -        aml_append(dev, method);
>>> -
>>> -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
>>> -        aml_append(method, aml_return(aml_call2(
>>> -                   s, aml_name("_UID"), aml_arg(0))));
>>> -        g_free(s);
>>> -        aml_append(dev, method);
>>> -
>>> -        aml_append(sb_scope, dev);
>>> -    }
>>> +        aml_append(dev_container, method);
>>> +
>>> +        /* build memory devices */
>>> +        for (i = 0; i < nr_mem; i++) {
>>> +            Aml *dev;
>>> +            const char *s;
>>> +
>>> +            dev = aml_device("MP%02X", i);
>>> +            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>>> +            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>>> +
>>> +            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
>>> +            s = MEMORY_SLOT_CRS_METHOD;
>>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +            aml_append(dev, method);
>>> +
>>> +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>>> +            s = MEMORY_SLOT_STATUS_METHOD;
>>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +            aml_append(dev, method);
>>> +
>>> +            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
>>> +            s = MEMORY_SLOT_PROXIMITY_METHOD;
>>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>>> +            aml_append(dev, method);
>>> +
>>> +            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
>>> +            s = MEMORY_SLOT_OST_METHOD;
>>> +            aml_append(method, aml_return(aml_call4(
>>> +                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>>> +            )));
>>> +            aml_append(dev, method);
>>> +
>>> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>>> +            s = MEMORY_SLOT_EJECT_METHOD;
>>> +            aml_append(method, aml_return(aml_call2(
>>> +                       s, aml_name("_UID"), aml_arg(0))));
>>> +            aml_append(dev, method);
>>> +
>>> +            aml_append(dev_container, dev);
>>> +        }
>>>
>>> -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
>>> -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
>>> -     */
>>> -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
>>> -    for (i = 0; i < nr_mem; i++) {
>>> -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>>> -        aml_append(ifctx,
>>> -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
>>> -        );
>>> -        aml_append(method, ifctx);
>>> +        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
>>> +         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
>>> +         */
>>> +        method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
>>> +        for (i = 0; i < nr_mem; i++) {
>>> +            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>>> +            aml_append(ifctx,
>>> +                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
>>> +            );
>>> +            aml_append(method, ifctx);
>>> +        }
>>> +        aml_append(dev_container, method);
>>>      }
>>> -    aml_append(sb_scope, method);
>>> -    aml_append(table, sb_scope);
>>> +    aml_append(table, dev_container);
>>>
>>>      method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
>>> -    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
>>> -    aml_append(method, aml_call0(scan_path));
>>> -    g_free(scan_path);
>>> +    aml_append(method,
>>> +        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
>>>      aml_append(table, method);
>>>
>>>      g_free(mhp_res_path);
>>>
>>
>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
  2016-12-22 13:53       ` Marcel Apfelbaum
@ 2016-12-22 14:10         ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-22 14:10 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, Eduardo Habkost, Michael S. Tsirkin

On Thu, 22 Dec 2016 15:53:55 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 12/22/2016 03:31 PM, Igor Mammedov wrote:
> > On Thu, 22 Dec 2016 14:31:19 +0200
> > Marcel Apfelbaum <marcel@redhat.com> wrote:
> >  
> >> On 12/06/2016 01:32 AM, Igor Mammedov wrote:  
> >>> Move DIMM devices from global _SB scope to a new \_SB.MHPC
> >>> container along with common methods used by DIMMs:
> >>>   MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY
> >>>
> >>> this reduces AML size on 12 * #slots bytes,
> >>> i.e. up to 3072 bytes for 265 slots.
> >>>  
> >>
> >> Can you please explain how the bytes number are reduced?
> >> Is it because the devices path is now relative to the new container?  
> > yes
> >  
> >> If so, can you give an example of before/after?  
> > as example:
> >
> > -        Device (MP02)
> > -        {
> > -            Name (_UID, "0x02")  // _UID: Unique ID
> > -            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
> > -            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
> > -            {
> > -                Return (\_SB.PCI0.MHPD.MCRS (_UID))
> > -            }
> > -
> > -            Method (_STA, 0, NotSerialized)  // _STA: Status
> > -            {
> > -                Return (\_SB.PCI0.MHPD.MRST (_UID))
> > -            }
> > -
> > -            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
> > -            {
> > -                Return (\_SB.PCI0.MHPD.MPXM (_UID))
> > -            }
> > -
> > -            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
> > -            {
> > -                Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2))
> > -            }
> > -
> > -            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> > -            {
> > -                Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0))
> > -            }
> > -        }
> > ----
> > +        Device (MP02)
> > +        {
> > +            Name (_UID, "0x02")  // _UID: Unique ID
> > +            Name (_HID, EisaId ("PNP0C80") /* Memory Device */)  // _HID: Hardware ID
> > +            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
> > +            {
> > +                Return (MCRS (_UID))
> > +            }
> > +
> > +            Method (_STA, 0, NotSerialized)  // _STA: Status
> > +            {
> > +                Return (MRST (_UID))
> > +            }
> > +
> > +            Method (_PXM, 0, NotSerialized)  // _PXM: Device Proximity
> > +            {
> > +                Return (MPXM (_UID))
> > +            }
> > +
> > +            Method (_OST, 3, NotSerialized)  // _OST: OSPM Status Indication
> > +            {
> > +                Return (MOST (_UID, Arg0, Arg1, Arg2))
> > +            }
> > +
> > +            Method (_EJ0, 1, NotSerialized)  // _EJx: Eject Device
> > +            {
> > +                Return (MEJ0 (_UID, Arg0))
> > +            }
> > +        }
> >  
> 
> Thanks for the confirmation.
> 
> >>  
> >>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> >>> ---
> >>>  hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++-----------------------
> >>>  1 file changed, 97 insertions(+), 93 deletions(-)
> >>>
> >>> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> >>> index fb04d24..210073d 100644
> >>> --- a/hw/acpi/memory_hotplug.c
> >>> +++ b/hw/acpi/memory_hotplug.c
> >>> @@ -31,6 +31,7 @@
> >>>  #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> >>>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> >>>  #define MEMORY_HOTPLUG_IO_LEN         24
> >>> +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> >>>
> >>>  static uint16_t memhp_io_base;
> >>>
> >>> @@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>      int i;
> >>>      Aml *ifctx;
> >>>      Aml *method;
> >>> -    Aml *sb_scope;
> >>> +    Aml *dev_container;
> >>>      Aml *mem_ctrl_dev;
> >>> -    char *scan_path;
> >>>      char *mhp_res_path;
> >>>
> >>>      if (!memhp_io_base) {
> >>> @@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>      mem_ctrl_dev = aml_device("%s", mhp_res_path);
> >>>      {
> >>>          Aml *crs;
> >>> -        Aml *field;
> >>> -        Aml *one = aml_int(1);
> >>> -        Aml *zero = aml_int(0);
> >>> -        Aml *ret_val = aml_local(0);
> >>> -        Aml *slot_arg0 = aml_arg(0);
> >>> -        Aml *slots_nr = aml_name(MEMORY_SLOTS_NUMBER);
> >>> -        Aml *ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
> >>> -        Aml *slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
> >>>
> >>>          aml_append(mem_ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));  
> >>
> >> Do we need the above declaration twice? Here is the first occurrence.
> >>  
> >>>          aml_append(mem_ctrl_dev,
> >>>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));  
> > [...]
> >  
> >>> +
> >>> +    dev_container = aml_device(MEMORY_DEVICES_CONTAINER);
> >>> +    {  
> > [...]  
> >>> +        aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));  
> >>
> >> And here is the second occurrence.  
> > It's different containers, the first one is for MMIO registers
> > for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS
> > and the second is for memory devices \_SB.MHPC which consumes resources
> > outside of PCI0._CRS scope.
> >  
> 
> Understood, here is my last R-b tag, however I want to point out
> that I only looked at the re-factoring steps and my acpi-based memory hotplug
> knowledge is rather limited.
> 
> 
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Thanks,

It's pretty much series subj says cleanups/consolidation.
The only sort of 'functional' change is that memory hotplug
AML is generated only if memory hotplug is enabled, freeing
some guest memory when memory hotplug in not in use.

 
> Thanks,
> Marcel
> 
> >  
> >>
> >> Thanks,
> >> Marcel
> >>  
> >>> +        aml_append(dev_container,
> >>> +            aml_name_decl("_UID", aml_string("DIMM devices")));
> >>> +
> >>> +        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> >>> +        aml_append(dev_container,
> >>> +            aml_name_decl(MEMORY_SLOTS_NUMBER, aml_int(nr_mem))
> >>> +        );
> >>> +
> >>> +        field = aml_field(mmio_path, AML_DWORD_ACC,
> >>>                            AML_NOLOCK, AML_PRESERVE);
> >>>          aml_append(field, /* read only */
> >>>              aml_named_field(MEMORY_SLOT_ADDR_LOW, 32));
> >>> @@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));
> >>>          aml_append(field, /* read only */
> >>>              aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
> >>> -        aml_append(mem_ctrl_dev, field);
> >>> +        aml_append(dev_container, field);
> >>>
> >>> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
> >>> +        field = aml_field(mmio_path, AML_BYTE_ACC,
> >>>                            AML_NOLOCK, AML_WRITE_AS_ZEROS);
> >>>          aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> >>>          aml_append(field, /* 1 if enabled, read only */
> >>> @@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>          aml_append(field,
> >>>              /* initiates device eject, write only */
> >>>              aml_named_field(MEMORY_SLOT_EJECT, 1));
> >>> -        aml_append(mem_ctrl_dev, field);
> >>> +        aml_append(dev_container, field);
> >>>
> >>> -        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
> >>> +        field = aml_field(mmio_path, AML_DWORD_ACC,
> >>>                            AML_NOLOCK, AML_PRESERVE);
> >>>          aml_append(field, /* DIMM selector, write only */
> >>>              aml_named_field(MEMORY_SLOT_SLECTOR, 32));
> >>> @@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
> >>>          aml_append(field, /* _OST status code, write only */
> >>>              aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
> >>> -        aml_append(mem_ctrl_dev, field);
> >>> +        aml_append(dev_container, field);
> >>> +        g_free(mmio_path);
> >>>
> >>>          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> >>>          ifctx = aml_if(aml_equal(slots_nr, zero));
> >>> @@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>          aml_append(method, ifctx);
> >>>          /* present, functioning, decoding, not shown in UI */
> >>>          aml_append(method, aml_return(aml_int(0xB)));
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>> -        aml_append(mem_ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
> >>> +        aml_append(dev_container, aml_mutex(MEMORY_SLOT_LOCK, 0));
> >>>
> >>>          method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0, AML_NOTSERIALIZED);
> >>>          {
> >>> @@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>              aml_append(method, aml_return(one));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>>          method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1, AML_NOTSERIALIZED);
> >>>          {
> >>> @@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>              aml_append(method, aml_return(ret_val));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>>          method = aml_method(MEMORY_SLOT_CRS_METHOD, 1, AML_SERIALIZED);
> >>>          {
> >>> @@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>              aml_append(method, aml_return(mr64));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>>          method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1,
> >>>                              AML_NOTSERIALIZED);
> >>> @@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>              aml_append(method, aml_return(ret_val));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>>          method = aml_method(MEMORY_SLOT_OST_METHOD, 4, AML_NOTSERIALIZED);
> >>>          {
> >>> @@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_store(aml_arg(2), ost_status));
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> +        aml_append(dev_container, method);
> >>>
> >>>          method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2, AML_NOTSERIALIZED);
> >>>          {
> >>> @@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >>>              aml_append(method, aml_store(one, eject));
> >>>              aml_append(method, aml_release(ctrl_lock));
> >>>          }
> >>> -        aml_append(mem_ctrl_dev, method);
> >>> -    }
> >>> -    aml_append(table, mem_ctrl_dev);
> >>> -
> >>> -    sb_scope = aml_scope("_SB");
> >>> -    /* build memory devices */
> >>> -    for (i = 0; i < nr_mem; i++) {
> >>> -        Aml *dev;
> >>> -        char *s;
> >>> -
> >>> -        dev = aml_device("MP%02X", i);
> >>> -        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> >>> -        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> >>> -
> >>> -        method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> >>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
> >>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> -        g_free(s);
> >>> -        aml_append(dev, method);
> >>> -
> >>> -        method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> >>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
> >>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> -        g_free(s);
> >>> -        aml_append(dev, method);
> >>> -
> >>> -        method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> >>> -        s = g_strdup_printf("%s.%s", mhp_res_path,
> >>> -                            MEMORY_SLOT_PROXIMITY_METHOD);
> >>> -        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> -        g_free(s);
> >>> -        aml_append(dev, method);
> >>> -
> >>> -        method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> >>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
> >>> -        aml_append(method, aml_return(aml_call4(
> >>> -            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> >>> -        )));
> >>> -        g_free(s);
> >>> -        aml_append(dev, method);
> >>> -
> >>> -        method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> >>> -        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
> >>> -        aml_append(method, aml_return(aml_call2(
> >>> -                   s, aml_name("_UID"), aml_arg(0))));
> >>> -        g_free(s);
> >>> -        aml_append(dev, method);
> >>> -
> >>> -        aml_append(sb_scope, dev);
> >>> -    }
> >>> +        aml_append(dev_container, method);
> >>> +
> >>> +        /* build memory devices */
> >>> +        for (i = 0; i < nr_mem; i++) {
> >>> +            Aml *dev;
> >>> +            const char *s;
> >>> +
> >>> +            dev = aml_device("MP%02X", i);
> >>> +            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> >>> +            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> >>> +
> >>> +            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
> >>> +            s = MEMORY_SLOT_CRS_METHOD;
> >>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> +            aml_append(dev, method);
> >>> +
> >>> +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> >>> +            s = MEMORY_SLOT_STATUS_METHOD;
> >>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> +            aml_append(dev, method);
> >>> +
> >>> +            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
> >>> +            s = MEMORY_SLOT_PROXIMITY_METHOD;
> >>> +            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> >>> +            aml_append(dev, method);
> >>> +
> >>> +            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
> >>> +            s = MEMORY_SLOT_OST_METHOD;
> >>> +            aml_append(method, aml_return(aml_call4(
> >>> +                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> >>> +            )));
> >>> +            aml_append(dev, method);
> >>> +
> >>> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> >>> +            s = MEMORY_SLOT_EJECT_METHOD;
> >>> +            aml_append(method, aml_return(aml_call2(
> >>> +                       s, aml_name("_UID"), aml_arg(0))));
> >>> +            aml_append(dev, method);
> >>> +
> >>> +            aml_append(dev_container, dev);
> >>> +        }
> >>>
> >>> -    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> >>> -     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> >>> -     */
> >>> -    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> >>> -    for (i = 0; i < nr_mem; i++) {
> >>> -        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> >>> -        aml_append(ifctx,
> >>> -            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> >>> -        );
> >>> -        aml_append(method, ifctx);
> >>> +        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> >>> +         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> >>> +         */
> >>> +        method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
> >>> +        for (i = 0; i < nr_mem; i++) {
> >>> +            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> >>> +            aml_append(ifctx,
> >>> +                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> >>> +            );
> >>> +            aml_append(method, ifctx);
> >>> +        }
> >>> +        aml_append(dev_container, method);
> >>>      }
> >>> -    aml_append(sb_scope, method);
> >>> -    aml_append(table, sb_scope);
> >>> +    aml_append(table, dev_container);
> >>>
> >>>      method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
> >>> -    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
> >>> -    aml_append(method, aml_call0(scan_path));
> >>> -    g_free(scan_path);
> >>> +    aml_append(method,
> >>> +        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
> >>>      aml_append(table, method);
> >>>
> >>>      g_free(mhp_res_path);
> >>>  
> >>  
> >  
> 
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [Qemu-devel] [PATCH for-2.9 v2 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 " Igor Mammedov
  2016-12-21 12:31   ` Marcel Apfelbaum
@ 2016-12-22 15:10   ` Igor Mammedov
  1 sibling, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2016-12-22 15:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, mst

build hotplug event handler method body in generic
hw/acpi/memory_hotplug.c and make hw/i386/acpi-build.c
only provide target specific full name of the event
handler.
That removes hardcoded MEMORY_HOTPLUG_HANDLER_PATH and
allows to do target specific memory hotplug AML placement
and wiring it with a target specific hotplug event handler
(it's GPE for i386 and would be GPIO for ARM).

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
v2:
  - fix commit message

---
 include/hw/acpi/memory_hotplug.h |  6 +++---
 hw/acpi/memory_hotplug.c         | 42 ++++++++++++++++++++++++++--------------
 hw/i386/acpi-build.c             |  7 ++-----
 3 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 6dc48d2..37e2706 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
 #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
-#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \
-     MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len);
+                              uint16_t io_base, uint16_t io_len,
+                              const char *res_root,
+                              const char *event_handler_method);
 #endif
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 18b95f2..49e856f 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = {
 };
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
-                              uint16_t io_base, uint16_t io_len)
+                              uint16_t io_base, uint16_t io_len,
+                              const char *res_root,
+                              const char *event_handler_method)
 {
     int i;
     Aml *ifctx;
     Aml *method;
-    Aml *pci_scope;
     Aml *sb_scope;
     Aml *mem_ctrl_dev;
+    char *scan_path;
+    char *mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root);
 
-    /* scope for memory hotplug controller device node */
-    pci_scope = aml_scope("_SB.PCI0");
-    mem_ctrl_dev = aml_device(MEMORY_HOTPLUG_DEVICE);
+    mem_ctrl_dev = aml_device("%s", mhp_res_path);
     {
         Aml *crs;
         Aml *field;
@@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
         }
         aml_append(mem_ctrl_dev, method);
     }
-    aml_append(pci_scope, mem_ctrl_dev);
-    aml_append(table, pci_scope);
+    aml_append(table, mem_ctrl_dev);
 
     sb_scope = aml_scope("_SB");
     /* build memory devices */
     for (i = 0; i < nr_mem; i++) {
-        #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
         Aml *dev;
-        const char *s;
+        char *s;
 
         dev = aml_device("MP%02X", i);
         aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
 
         method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_CRS_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_STA", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_STATUS_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path,
+                            MEMORY_SLOT_PROXIMITY_METHOD);
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_OST", 3, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_OST_METHOD;
-
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_OST_METHOD);
         aml_append(method, aml_return(aml_call4(
             s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
         )));
+        g_free(s);
         aml_append(dev, method);
 
         method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
+        s = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_EJECT_METHOD);
         aml_append(method, aml_return(aml_call2(
                    s, aml_name("_UID"), aml_arg(0))));
+        g_free(s);
         aml_append(dev, method);
 
         aml_append(sb_scope, dev);
@@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     }
     aml_append(sb_scope, method);
     aml_append(table, sb_scope);
+
+    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
+    scan_path = g_strdup_printf("%s.%s", mhp_res_path, MEMORY_SLOT_SCAN_METHOD);
+    aml_append(method, aml_call0(scan_path));
+    g_free(scan_path);
+    aml_append(table, method);
+
+    g_free(mhp_res_path);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f8a5f47..034f2b4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
     build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
-                             pm->mem_hp_io_len);
+                             pm->mem_hp_io_len,
+                             "\\_SB.PCI0", "\\_GPE._E03");
 
     scope =  aml_scope("_GPE");
     {
@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             aml_append(scope, method);
         }
 
-        method = aml_method("_E03", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
-        aml_append(scope, method);
-
         if (pcms->acpi_nvdimm_state.is_enabled) {
             method = aml_method("_E04", 0, AML_NOTSERIALIZED);
             aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
  2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
                   ` (10 preceding siblings ...)
  2016-12-16  9:07 ` [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
@ 2017-01-09 14:22 ` Igor Mammedov
  2017-01-09 14:39   ` Michael S. Tsirkin
  2017-01-10  5:08   ` Michael S. Tsirkin
  11 siblings, 2 replies; 37+ messages in thread
From: Igor Mammedov @ 2017-01-09 14:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin

On Tue,  6 Dec 2016 00:32:19 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> Series cleanups and consolidates scattered memory hotplug
> code so it could be easily reused by ARM target later.
> 
> As result:
>  * added memory hotplug variant to bios tables test
>  * all ACPI related parts of memory hotplug are consolidated
>    within memory_hotplug.c
>  * DSDT table size is reduced ~900 bytes when memory hotplug
>    is not enabled (by not generating not used AML)
>  * DSDT table size is reduced on 12 bytes per slot
>    (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
>    enabled due AML reorganization that makes calls to common functions
>    smaller as devices and common functions are now within the same scope.
> 
> Tested with following guests:
>   - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
>   - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
>     it never worked as memhp is not supported there)

Michael,

Marcel's already reviewed this series a while ago could you
pull it in your tree if there aren't any questions?


> Git tree for testing:
>   https://github.com/imammedo/qemu.git memhp_consolidate_v1
> viewing:
>   https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
> 
> Note to maintaner:
>   * blobs patch 2/10 should be merged to patch 1/10
>   * ACPI tables should be regenarated and applied after series is merged
>     as DSDT will cange for all tests cases due removal of inactive
>     memory hotplug code.
> 
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: Marcel Apfelbaum <marcel@redhat.com>
> 
> 
> Igor Mammedov (10):
>   tests: pc: add memory hotplug acpi tables tests
>   tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
>   memhp: move build_memory_hotplug_aml() into memory_hotplug.c
>   memhp: move build_memory_devices() into memory_hotplug.c
>   memhp: consolidate scattered MHPD device declaration
>   memhp: merge build_memory_devices() into build_memory_hotplug_aml()
>   memhp: move GPE handler_E03 into build_memory_hotplug_aml()
>   memhp: move memory hotplug only defines to memory_hotplug.c
>   memhp: don't generate memory hotplug AML if it's not enabled/supported
>   memhp: move DIMM devices into dedicated scope with related common
>     methods
> 
>  include/hw/acpi/memory_hotplug.h    |  12 +-
>  include/hw/acpi/pc-hotplug.h        |  23 --
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/ich9.c                      |   3 +-
>  hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
>  hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
>  hw/acpi/piix4.c                     |   3 +-
>  hw/i386/acpi-build.c                | 197 +++--------------
>  tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
>  tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
>  tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
>  tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
>  tests/bios-tables-test.c            |  24 +++
>  13 files changed, 479 insertions(+), 467 deletions(-)
>  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>  create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
>  create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
>  create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
>  create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
  2017-01-09 14:22 ` Igor Mammedov
@ 2017-01-09 14:39   ` Michael S. Tsirkin
  2017-01-10  5:08   ` Michael S. Tsirkin
  1 sibling, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2017-01-09 14:39 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel

On Mon, Jan 09, 2017 at 03:22:01PM +0100, Igor Mammedov wrote:
> On Tue,  6 Dec 2016 00:32:19 +0100
> Igor Mammedov <imammedo@redhat.com> wrote:
> 
> > Series cleanups and consolidates scattered memory hotplug
> > code so it could be easily reused by ARM target later.
> > 
> > As result:
> >  * added memory hotplug variant to bios tables test
> >  * all ACPI related parts of memory hotplug are consolidated
> >    within memory_hotplug.c
> >  * DSDT table size is reduced ~900 bytes when memory hotplug
> >    is not enabled (by not generating not used AML)
> >  * DSDT table size is reduced on 12 bytes per slot
> >    (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
> >    enabled due AML reorganization that makes calls to common functions
> >    smaller as devices and common functions are now within the same scope.
> > 
> > Tested with following guests:
> >   - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
> >   - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
> >     it never worked as memhp is not supported there)
> 
> Michael,
> 
> Marcel's already reviewed this series a while ago could you
> pull it in your tree if there aren't any questions?

Yes I plan to merge it., just trying to figure out
why my previous pull did not get there.

> 
> > Git tree for testing:
> >   https://github.com/imammedo/qemu.git memhp_consolidate_v1
> > viewing:
> >   https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
> > 
> > Note to maintaner:
> >   * blobs patch 2/10 should be merged to patch 1/10
> >   * ACPI tables should be regenarated and applied after series is merged
> >     as DSDT will cange for all tests cases due removal of inactive
> >     memory hotplug code.
> > 
> > CC: "Michael S. Tsirkin" <mst@redhat.com>
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: Marcel Apfelbaum <marcel@redhat.com>
> > 
> > 
> > Igor Mammedov (10):
> >   tests: pc: add memory hotplug acpi tables tests
> >   tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
> >   memhp: move build_memory_hotplug_aml() into memory_hotplug.c
> >   memhp: move build_memory_devices() into memory_hotplug.c
> >   memhp: consolidate scattered MHPD device declaration
> >   memhp: merge build_memory_devices() into build_memory_hotplug_aml()
> >   memhp: move GPE handler_E03 into build_memory_hotplug_aml()
> >   memhp: move memory hotplug only defines to memory_hotplug.c
> >   memhp: don't generate memory hotplug AML if it's not enabled/supported
> >   memhp: move DIMM devices into dedicated scope with related common
> >     methods
> > 
> >  include/hw/acpi/memory_hotplug.h    |  12 +-
> >  include/hw/acpi/pc-hotplug.h        |  23 --
> >  hw/acpi/Makefile.objs               |   2 +-
> >  hw/acpi/ich9.c                      |   3 +-
> >  hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
> >  hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
> >  hw/acpi/piix4.c                     |   3 +-
> >  hw/i386/acpi-build.c                | 197 +++--------------
> >  tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
> >  tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
> >  tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
> >  tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
> >  tests/bios-tables-test.c            |  24 +++
> >  13 files changed, 479 insertions(+), 467 deletions(-)
> >  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> >  create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
> >  create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
> >  create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
> >  create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
> > 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
  2017-01-09 14:22 ` Igor Mammedov
  2017-01-09 14:39   ` Michael S. Tsirkin
@ 2017-01-10  5:08   ` Michael S. Tsirkin
  2017-01-10 12:29     ` Igor Mammedov
  1 sibling, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2017-01-10  5:08 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel

On Mon, Jan 09, 2017 at 03:22:01PM +0100, Igor Mammedov wrote:
> On Tue,  6 Dec 2016 00:32:19 +0100
> Igor Mammedov <imammedo@redhat.com> wrote:
> 
> > Series cleanups and consolidates scattered memory hotplug
> > code so it could be easily reused by ARM target later.
> > 
> > As result:
> >  * added memory hotplug variant to bios tables test
> >  * all ACPI related parts of memory hotplug are consolidated
> >    within memory_hotplug.c
> >  * DSDT table size is reduced ~900 bytes when memory hotplug
> >    is not enabled (by not generating not used AML)
> >  * DSDT table size is reduced on 12 bytes per slot
> >    (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
> >    enabled due AML reorganization that makes calls to common functions
> >    smaller as devices and common functions are now within the same scope.
> > 
> > Tested with following guests:
> >   - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
> >   - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
> >     it never worked as memhp is not supported there)
> 
> Michael,
> 
> Marcel's already reviewed this series a while ago could you
> pull it in your tree if there aren't any questions?

I merged this and updated expected files accordingly.

Could you please check expected files in my tree
to make sure it looks good?

Thanks!

> 
> > Git tree for testing:
> >   https://github.com/imammedo/qemu.git memhp_consolidate_v1
> > viewing:
> >   https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
> > 
> > Note to maintaner:
> >   * blobs patch 2/10 should be merged to patch 1/10
> >   * ACPI tables should be regenarated and applied after series is merged
> >     as DSDT will cange for all tests cases due removal of inactive
> >     memory hotplug code.
> > 
> > CC: "Michael S. Tsirkin" <mst@redhat.com>
> > CC: Eduardo Habkost <ehabkost@redhat.com>
> > CC: Marcel Apfelbaum <marcel@redhat.com>
> > 
> > 
> > Igor Mammedov (10):
> >   tests: pc: add memory hotplug acpi tables tests
> >   tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
> >   memhp: move build_memory_hotplug_aml() into memory_hotplug.c
> >   memhp: move build_memory_devices() into memory_hotplug.c
> >   memhp: consolidate scattered MHPD device declaration
> >   memhp: merge build_memory_devices() into build_memory_hotplug_aml()
> >   memhp: move GPE handler_E03 into build_memory_hotplug_aml()
> >   memhp: move memory hotplug only defines to memory_hotplug.c
> >   memhp: don't generate memory hotplug AML if it's not enabled/supported
> >   memhp: move DIMM devices into dedicated scope with related common
> >     methods
> > 
> >  include/hw/acpi/memory_hotplug.h    |  12 +-
> >  include/hw/acpi/pc-hotplug.h        |  23 --
> >  hw/acpi/Makefile.objs               |   2 +-
> >  hw/acpi/ich9.c                      |   3 +-
> >  hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
> >  hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
> >  hw/acpi/piix4.c                     |   3 +-
> >  hw/i386/acpi-build.c                | 197 +++--------------
> >  tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
> >  tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
> >  tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
> >  tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
> >  tests/bios-tables-test.c            |  24 +++
> >  13 files changed, 479 insertions(+), 467 deletions(-)
> >  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> >  create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
> >  create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
> >  create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
> >  create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
> > 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation
  2017-01-10  5:08   ` Michael S. Tsirkin
@ 2017-01-10 12:29     ` Igor Mammedov
  0 siblings, 0 replies; 37+ messages in thread
From: Igor Mammedov @ 2017-01-10 12:29 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

On Tue, 10 Jan 2017 07:08:57 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Mon, Jan 09, 2017 at 03:22:01PM +0100, Igor Mammedov wrote:
> > On Tue,  6 Dec 2016 00:32:19 +0100
> > Igor Mammedov <imammedo@redhat.com> wrote:
> >   
> > > Series cleanups and consolidates scattered memory hotplug
> > > code so it could be easily reused by ARM target later.
> > > 
> > > As result:
> > >  * added memory hotplug variant to bios tables test
> > >  * all ACPI related parts of memory hotplug are consolidated
> > >    within memory_hotplug.c
> > >  * DSDT table size is reduced ~900 bytes when memory hotplug
> > >    is not enabled (by not generating not used AML)
> > >  * DSDT table size is reduced on 12 bytes per slot
> > >    (i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug
> > >    enabled due AML reorganization that makes calls to common functions
> > >    smaller as devices and common functions are now within the same scope.
> > > 
> > > Tested with following guests:
> > >   - RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
> > >   - XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise
> > >     it never worked as memhp is not supported there)  
> > 
> > Michael,
> > 
> > Marcel's already reviewed this series a while ago could you
> > pull it in your tree if there aren't any questions?  
> 
> I merged this and updated expected files accordingly.
> 
> Could you please check expected files in my tree
> to make sure it looks good?
Merge looks good to me.
I've gave your pci branch a quick memhp testing,
hot-add/remove works as expected with RHEL7/WS2012r2.

Thanks!

> 
> Thanks!
> 
> >   
> > > Git tree for testing:
> > >   https://github.com/imammedo/qemu.git memhp_consolidate_v1
> > > viewing:
> > >   https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
> > > 
> > > Note to maintaner:
> > >   * blobs patch 2/10 should be merged to patch 1/10
> > >   * ACPI tables should be regenarated and applied after series is merged
> > >     as DSDT will cange for all tests cases due removal of inactive
> > >     memory hotplug code.
> > > 
> > > CC: "Michael S. Tsirkin" <mst@redhat.com>
> > > CC: Eduardo Habkost <ehabkost@redhat.com>
> > > CC: Marcel Apfelbaum <marcel@redhat.com>
> > > 
> > > 
> > > Igor Mammedov (10):
> > >   tests: pc: add memory hotplug acpi tables tests
> > >   tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
> > >   memhp: move build_memory_hotplug_aml() into memory_hotplug.c
> > >   memhp: move build_memory_devices() into memory_hotplug.c
> > >   memhp: consolidate scattered MHPD device declaration
> > >   memhp: merge build_memory_devices() into build_memory_hotplug_aml()
> > >   memhp: move GPE handler_E03 into build_memory_hotplug_aml()
> > >   memhp: move memory hotplug only defines to memory_hotplug.c
> > >   memhp: don't generate memory hotplug AML if it's not enabled/supported
> > >   memhp: move DIMM devices into dedicated scope with related common
> > >     methods
> > > 
> > >  include/hw/acpi/memory_hotplug.h    |  12 +-
> > >  include/hw/acpi/pc-hotplug.h        |  23 --
> > >  hw/acpi/Makefile.objs               |   2 +-
> > >  hw/acpi/ich9.c                      |   3 +-
> > >  hw/acpi/memory_hotplug.c            | 420 +++++++++++++++++++++++++++++++++++-
> > >  hw/acpi/memory_hotplug_acpi_table.c | 262 ----------------------
> > >  hw/acpi/piix4.c                     |   3 +-
> > >  hw/i386/acpi-build.c                | 197 +++--------------
> > >  tests/acpi-test-data/pc/DSDT.memhp  | Bin 0 -> 6613 bytes
> > >  tests/acpi-test-data/pc/SRAT.memhp  | Bin 0 -> 224 bytes
> > >  tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes
> > >  tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes
> > >  tests/bios-tables-test.c            |  24 +++
> > >  13 files changed, 479 insertions(+), 467 deletions(-)
> > >  delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> > >  create mode 100644 tests/acpi-test-data/pc/DSDT.memhp
> > >  create mode 100644 tests/acpi-test-data/pc/SRAT.memhp
> > >  create mode 100644 tests/acpi-test-data/q35/DSDT.memhp
> > >  create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
> > >   
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2017-01-10 12:29 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-05 23:32 [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests Igor Mammedov
2016-12-20 10:40   ` Marcel Apfelbaum
2016-12-20 16:17     ` Igor Mammedov
2016-12-20 17:00       ` Marcel Apfelbaum
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 02/10] tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant Igor Mammedov
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c Igor Mammedov
2016-12-20 10:42   ` Marcel Apfelbaum
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() " Igor Mammedov
2016-12-20 10:44   ` Marcel Apfelbaum
2016-12-20 16:24     ` Igor Mammedov
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration Igor Mammedov
2016-12-20 11:00   ` Marcel Apfelbaum
2016-12-20 16:34     ` Igor Mammedov
2016-12-21 11:54       ` Marcel Apfelbaum
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml() Igor Mammedov
2016-12-21 12:10   ` Marcel Apfelbaum
2016-12-21 12:54     ` Igor Mammedov
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 " Igor Mammedov
2016-12-21 12:31   ` Marcel Apfelbaum
2016-12-21 13:39     ` Igor Mammedov
2016-12-22 10:45       ` Marcel Apfelbaum
2016-12-22 15:10   ` [Qemu-devel] [PATCH for-2.9 v2 " Igor Mammedov
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c Igor Mammedov
2016-12-21 12:32   ` Marcel Apfelbaum
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported Igor Mammedov
2016-12-22 10:55   ` Marcel Apfelbaum
2016-12-05 23:32 ` [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods Igor Mammedov
2016-12-22 12:31   ` Marcel Apfelbaum
2016-12-22 13:31     ` Igor Mammedov
2016-12-22 13:53       ` Marcel Apfelbaum
2016-12-22 14:10         ` Igor Mammedov
2016-12-16  9:07 ` [Qemu-devel] [PATCH for-2.9 00/10] pc: acpi: memory hotplug cleanup/consolidation Igor Mammedov
2017-01-09 14:22 ` Igor Mammedov
2017-01-09 14:39   ` Michael S. Tsirkin
2017-01-10  5:08   ` Michael S. Tsirkin
2017-01-10 12:29     ` Igor Mammedov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).