From nobody Wed Nov 5 17:40:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496738069839190.6376442982894; Tue, 6 Jun 2017 01:34:29 -0700 (PDT) Received: from localhost ([::1]:36819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dI9wa-00052d-4G for importer@patchew.org; Tue, 06 Jun 2017 04:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dI9uj-0003Ot-ON for qemu-devel@nongnu.org; Tue, 06 Jun 2017 04:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dI9ui-00022T-KW for qemu-devel@nongnu.org; Tue, 06 Jun 2017 04:32:33 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:40837) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dI9ui-00021i-8c; Tue, 06 Jun 2017 04:32:32 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3whlL25rXgz9s82; Tue, 6 Jun 2017 18:32:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496737946; bh=ruJILlHWIT8AqsEorEMd2UzdR9WTadSE0BrodSdvn/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J9hLyhIynJVTMYihcfYfo2LUcHP4111sME5JNQrz6r/wKWjXG8f/ZZ9HHukkZ7K+j 7ChRthgaRmebdjSGhMrbVZfU8UR/UQmD7Hc5alEqJy+/dp3sCszCgRtifzgx57kff3 pCS2OJg3s0otgjTtrxqQ6zCehzs1S+tFDyrpNJaI= From: David Gibson To: mdroth@linux.vnet.ibm.com Date: Tue, 6 Jun 2017 18:32:19 +1000 Message-Id: <20170606083221.9299-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606083221.9299-1-david@gibson.dropbear.id.au> References: <20170606083221.9299-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 5/7] spapr: Clean up RTAS set-indicator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, sursingh@redhat.com, groug@kaod.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In theory the RTAS set-indicator call can be used for a number of "indicators" defined by PAPR. In practice the only ones we're ever likely to implement are those used for Dynamic Reconfiguration (i.e. hotplug). Because of this, the current implementation determines the associated DRC object, before dispatching based on the type of indicator. However, this means we also need a check that we're dealing with a DR related indicator at all, which duplicates some of the logic from the switch further down. Even though it means a bit of code duplication, things work out cleaner if we delegate the DRC lookup to the individual indicator type functions - and it also allows some further cleanups. While we're there, remove references to "sensor", a copy/paste artefact from the related, but distinct "get-sensor" call. Signed-off-by: David Gibson Reviewed-by: Michael Roth --- hw/ppc/spapr_drc.c | 84 ++++++++++++++++++++++++++++---------------------= ---- hw/ppc/trace-events | 2 -- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 1fc51c9..6c2fa93 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -869,74 +869,78 @@ out: * RTAS calls */ =20 -static bool sensor_type_is_dr(uint32_t sensor_type) +static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state) { - switch (sensor_type) { - case RTAS_SENSOR_TYPE_ISOLATION_STATE: - case RTAS_SENSOR_TYPE_DR: - case RTAS_SENSOR_TYPE_ALLOCATION_STATE: - return true; + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); + sPAPRDRConnectorClass *drck; + + if (!drc) { + return RTAS_OUT_PARAM_ERROR; } =20 - return false; + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_isolation_state(drc, state); } =20 -static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, - uint32_t token, uint32_t nargs, - target_ulong args, uint32_t nret, - target_ulong rets) +static uint32_t rtas_set_allocation_state(uint32_t idx, uint32_t state) { - uint32_t sensor_type; - uint32_t sensor_index; - uint32_t sensor_state; - uint32_t ret =3D RTAS_OUT_SUCCESS; - sPAPRDRConnector *drc; + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); sPAPRDRConnectorClass *drck; =20 - if (nargs !=3D 3 || nret !=3D 1) { - ret =3D RTAS_OUT_PARAM_ERROR; - goto out; + if (!drc) { + return RTAS_OUT_PARAM_ERROR; } =20 - sensor_type =3D rtas_ld(args, 0); - sensor_index =3D rtas_ld(args, 1); - sensor_state =3D rtas_ld(args, 2); + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_allocation_state(drc, state); +} =20 - if (!sensor_type_is_dr(sensor_type)) { - goto out_unimplemented; - } +static uint32_t rtas_set_indicator_state(uint32_t idx, uint32_t state) +{ + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); + sPAPRDRConnectorClass *drck; =20 - /* if this is a DR sensor we can assume sensor_index =3D=3D drc_index = */ - drc =3D spapr_drc_by_index(sensor_index); if (!drc) { - trace_spapr_rtas_set_indicator_invalid(sensor_index); + return RTAS_OUT_PARAM_ERROR; + } + + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_indicator_state(drc, state); +} + +static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, + uint32_t token, + uint32_t nargs, target_ulong args, + uint32_t nret, target_ulong rets) +{ + uint32_t type, idx, state; + uint32_t ret =3D RTAS_OUT_SUCCESS; + + if (nargs !=3D 3 || nret !=3D 1) { ret =3D RTAS_OUT_PARAM_ERROR; goto out; } - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); =20 - switch (sensor_type) { + type =3D rtas_ld(args, 0); + idx =3D rtas_ld(args, 1); + state =3D rtas_ld(args, 2); + + switch (type) { case RTAS_SENSOR_TYPE_ISOLATION_STATE: - ret =3D drck->set_isolation_state(drc, sensor_state); + ret =3D rtas_set_isolation_state(idx, state); break; case RTAS_SENSOR_TYPE_DR: - ret =3D drck->set_indicator_state(drc, sensor_state); + ret =3D rtas_set_indicator_state(idx, state); break; case RTAS_SENSOR_TYPE_ALLOCATION_STATE: - ret =3D drck->set_allocation_state(drc, sensor_state); + ret =3D rtas_set_allocation_state(idx, state); break; default: - goto out_unimplemented; + ret =3D RTAS_OUT_NOT_SUPPORTED; } =20 out: rtas_st(rets, 0, ret); - return; - -out_unimplemented: - /* currently only DR-related sensors are implemented */ - trace_spapr_rtas_set_indicator_not_supported(sensor_index, sensor_type= ); - rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); } =20 static void rtas_get_sensor_state(PowerPCCPU *cpu, sPAPRMachineState *spap= r, diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 4979397..581fa85 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -60,8 +60,6 @@ spapr_ovec_parse_vector(int vector, int byte, uint16_t ve= c_len, uint8_t entry) " spapr_ovec_populate_dt(int byte, uint16_t vec_len, uint8_t entry) "encodin= g guest vector byte %3d / %3d: 0x%.2x" =20 # hw/ppc/spapr_rtas.c -spapr_rtas_set_indicator_invalid(uint32_t index) "sensor index: 0x%"PRIx32 -spapr_rtas_set_indicator_not_supported(uint32_t index, uint32_t type) "sen= sor index: 0x%"PRIx32", type: %"PRIu32 spapr_rtas_get_sensor_state_not_supported(uint32_t index, uint32_t type) "= sensor index: 0x%"PRIx32", type: %"PRIu32 spapr_rtas_get_sensor_state_invalid(uint32_t index) "sensor index: 0x%"PRI= x32 spapr_rtas_ibm_configure_connector_invalid(uint32_t index) "DRC index: 0x%= "PRIx32 --=20 2.9.4