From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83B3C433DB for ; Wed, 17 Feb 2021 01:30:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2757164E2F for ; Wed, 17 Feb 2021 01:30:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2757164E2F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCBfR-0000wi-AP for qemu-devel@archiver.kernel.org; Tue, 16 Feb 2021 20:30:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCBZM-0003pi-HS; Tue, 16 Feb 2021 20:23:56 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:51095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCBZK-00061T-HK; Tue, 16 Feb 2021 20:23:56 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4DgKqL5Tcnz9sTD; Wed, 17 Feb 2021 12:23:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1613525022; bh=fuT9crt80hmtcaWN7YOGo+qTC474tYa3HQcOx0ONHR8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dXC+o7EzeqvKeqwvHcWW5Mp2W9g1VRuCvov+38j3rKRDMFbkN6T0sFaNqR48cPH54 QVNyKbPWXvgbWcqZTcOV1HqD2fQF3+/wur0LCgihChy99v4psbNgPAW0+1MX7rNDhp UqXUcNQlUBEy+iujzaTE9WrQEwauppFNnxTpIDHc= Date: Wed, 17 Feb 2021 11:57:27 +1100 From: David Gibson To: Daniel Henrique Barboza Subject: Re: [PATCH v3 3/7] spapr_drc.c: use spapr_drc_release() in isolate_physical/set_unusable Message-ID: References: <20210211225246.17315-1-danielhb413@gmail.com> <20210211225246.17315-4-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="X+hAQTrZmxCHQDlt" Content-Disposition: inline In-Reply-To: <20210211225246.17315-4-danielhb413@gmail.com> Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --X+hAQTrZmxCHQDlt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 11, 2021 at 07:52:42PM -0300, Daniel Henrique Barboza wrote: > When moving a physical DRC to "Available", drc_isolate_physical() will > move the DRC state to STATE_PHYSICAL_POWERON and, if the DRC is marked > for unplug, call spapr_drc_detach(). For physical DRCs, drck->empty_state > is STATE_PHYSICAL_POWERON, meaning that we're sure that spapr_drc_detach() > will end up calling spapr_drc_release() in the end. >=20 > Likewise, for logical DRCs, drc_set_unusable will move the DRC to "Unusab= le" > state, setting drc->state to STATE_LOGICAL_UNUSABLE, which is the > drck->empty_state for logical DRCs. spapr_drc_detach() will call > spapr_drc_release() in this case as well. >=20 > In both scenarios, spapr_drc_detach() is being used as a spapr_drc_releas= e(), > wrapper, where we also set unplug_requested (which is already true, other= wise > spapr_drc_detach() wouldn't be called in the first place) and check if > drc->state =3D=3D drck->empty_state, which we also know it's guaranteed to > be true because we just set it. >=20 > Just use spapr_drc_release() in these functions to be clear of our intent= ions > in both these functions. >=20 > Signed-off-by: Daniel Henrique Barboza Reviewed-by: David Gibson > --- > hw/ppc/spapr_drc.c | 32 ++++++++++++++++---------------- > 1 file changed, 16 insertions(+), 16 deletions(-) >=20 > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c > index 84bd3c881f..555a25517d 100644 > --- a/hw/ppc/spapr_drc.c > +++ b/hw/ppc/spapr_drc.c > @@ -50,6 +50,20 @@ uint32_t spapr_drc_index(SpaprDrc *drc) > | (drc->id & DRC_INDEX_ID_MASK); > } > =20 > +static void spapr_drc_release(SpaprDrc *drc) > +{ > + SpaprDrcClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); > + > + drck->release(drc->dev); > + > + drc->unplug_requested =3D false; > + g_free(drc->fdt); > + drc->fdt =3D NULL; > + drc->fdt_start_offset =3D 0; > + object_property_del(OBJECT(drc), "device"); > + drc->dev =3D NULL; > +} > + > static uint32_t drc_isolate_physical(SpaprDrc *drc) > { > switch (drc->state) { > @@ -68,7 +82,7 @@ static uint32_t drc_isolate_physical(SpaprDrc *drc) > if (drc->unplug_requested) { > uint32_t drc_index =3D spapr_drc_index(drc); > trace_spapr_drc_set_isolation_state_finalizing(drc_index); > - spapr_drc_detach(drc); > + spapr_drc_release(drc); > } > =20 > return RTAS_OUT_SUCCESS; > @@ -209,7 +223,7 @@ static uint32_t drc_set_unusable(SpaprDrc *drc) > if (drc->unplug_requested) { > uint32_t drc_index =3D spapr_drc_index(drc); > trace_spapr_drc_set_allocation_state_finalizing(drc_index); > - spapr_drc_detach(drc); > + spapr_drc_release(drc); > } > =20 > return RTAS_OUT_SUCCESS; > @@ -372,20 +386,6 @@ void spapr_drc_attach(SpaprDrc *drc, DeviceState *d) > NULL, 0); > } > =20 > -static void spapr_drc_release(SpaprDrc *drc) > -{ > - SpaprDrcClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); > - > - drck->release(drc->dev); > - > - drc->unplug_requested =3D false; > - g_free(drc->fdt); > - drc->fdt =3D NULL; > - drc->fdt_start_offset =3D 0; > - object_property_del(OBJECT(drc), "device"); > - drc->dev =3D NULL; > -} > - > void spapr_drc_detach(SpaprDrc *drc) > { > SpaprDrcClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --X+hAQTrZmxCHQDlt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmAsafcACgkQbDjKyiDZ s5IrChAAjugawqjTquzU2XWp/ndFYuZ0pZ6MQsBQmHemtJD6H5/ZLLOrJg4JuH79 ckbAzJwxq7o9b0JxA8IGGaiOVPSjrd76sMrWFpLarIrCCf7EF5Hv8bT/D9il2GDn tWKN5zAw21FomZacWra2sG+AxeJe2FNjjup6++bf0Ohn2QdBlzqUgh0HjJrA+g4w Yi2aXHlbGkcZZZ4Wz4x5LfL40ws8EZ/MpyrsjIgaoh3NsUOMxT93RYX3Vvw4yEUb 1EaNeAGUBV8jhNN8TnOqnTQLniAYe2Dr4ygZ+mhCBzVGWERsV3i4mP6Sd7vxkNdX UzVd5aP9o+ip1CFpv43XifSWHivf975daaGGjDQedG4UCcUFYDegkUi9k6eUiycm jpQwSkeCyiYjt9gSm6I+tmjmFPxlP9WpdFIHzuZ0Gp4sEz3ln9rZRNGS7UAKtXxx a5qMHAjEUalmCuErmiuyJ2ea7fWhW0NcIZ5rrygoeystqCFx0GH+2+4EBtbCT4UF Doz2Eq57RGTe/KTZAqMcZv3wRMMGj9zbKDMvQgcdPRdVZKbI/JiZwrtBA3PDIusX mXzQz4PE6WRgGy7wSdFkSueEMLNAvQ1OiYnqjOKpcCeWNqKiq5tXAMc7f1fbR/z/ L1n4EGE4Imb4hfcPQPdN8KFfufbMG+MSw57jlQGk6h9O9Gw24Y8= =DwVu -----END PGP SIGNATURE----- --X+hAQTrZmxCHQDlt--