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=-0.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 4C375C433DF for ; Wed, 17 Jun 2020 07:27:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 22B2F20786 for ; Wed, 17 Jun 2020 07:27:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="dsvQ4Dph"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YfteQO+m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22B2F20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 085826EAB4; Wed, 17 Jun 2020 07:26:09 +0000 (UTC) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF1576E8BE for ; Tue, 16 Jun 2020 15:05:04 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 31B065C00AB; Tue, 16 Jun 2020 11:05:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 16 Jun 2020 11:05:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=+/Free3np84k0kBJDWVF1jSVMhN u9FRY1V3ChXa3w8c=; b=dsvQ4DphF2djb9iaYRtH9j4VQm7shqQLUk5XgA0Vt93 2oVR+dcRcLKX9tAQzm/51Zr/WsRetYV4zAKdDIkGvuF5/92+l0hDyc4R5T3j3S5s 0f/43NQqAiBMsI4JnDB9kuMSx5ECdOiaBR2sz9e3pOFOR8zVWUneOWT9Gkynk5rn 6jK+jgYzW0WNEQXZUfKIJFEfEfvDDsSuyig18T18qtLNoxiEaAnbWv3V6K0dKAHg 8SWSTsOl8Ivbp58Br2yjTLxc9eMyL3PYlkJtPfz8LzBF9Xa2JhAaMUAq3KmHqM5H rRarKnzBKK/Lc8N//p2eqN4RGVtr5OGtR+BE+mrnyJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=+/Free 3np84k0kBJDWVF1jSVMhNu9FRY1V3ChXa3w8c=; b=YfteQO+m0GL348X5GIWnSy 9fs8PdyRFCR/bZqYXpD+IBG6ROAjSUPBs6XyhS85y5QtEOruOlWF8AgrL3IJnpA/ GXsHBR44HS6367JtwebmBDHyzjBZzGRBUdaPEbRFAubNQQ4BjpFZuFdu69sKdk9Q GOdQB/1J1J+p1cHytU5yfHkk+qYqHoxI2qQJBIfkQNEPVDh9nv2iMf1iHgBYIFK0 69S2qqQBZiGD0MiyzmTBqg6MfxE8s1K/DF2M2/659wZymeJQLBMa9GNBEO06zPX7 F/FY/Zaz+UAoxmLs5ftIQJ8CCkPV44/TipaKpFccsTpRq8HnTFu4BJllgqE40B4w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejtddgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepleekgeehhfdutdeljefgleejffehfffgieejhffgueefhfdtveetgeehieeh gedunecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 92996328005A; Tue, 16 Jun 2020 11:04:51 -0400 (EDT) Date: Tue, 16 Jun 2020 17:04:49 +0200 From: Maxime Ripard To: Eric Anholt Subject: Re: [PATCH v3 033/105] drm/vc4: crtc: Assign output to channel automatically Message-ID: <20200616150449.xkgyxd6bwcp3cfkb@gilmour.lan> References: <5186409a2b5d290b78f6b518a2eb8e407bf1e83e.1590594512.git-series.maxime@cerno.tech> MIME-Version: 1.0 In-Reply-To: X-Mailman-Approved-At: Wed, 17 Jun 2020 07:26:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Gover , Dave Stevenson , linux-kernel@vger.kernel.org, DRI Development , bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne , Phil Elwell , linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============1662565227==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============1662565227== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zmtci7znkd6b2wdu" Content-Disposition: inline --zmtci7znkd6b2wdu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Eric, On Wed, May 27, 2020 at 10:23:23AM -0700, Eric Anholt wrote: > On Wed, May 27, 2020 at 8:50 AM Maxime Ripard wrote: > > static int > > vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *stat= e) > > { > > - int ret; > > + unsigned long unassigned_channels =3D GENMASK(NUM_CHANNELS - 1,= 0); > > + struct drm_crtc_state *crtc_state; > > + struct drm_crtc *crtc; > > + int i, ret; > > + > > + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { > > + struct vc4_crtc_state *vc4_crtc_state =3D > > + to_vc4_crtc_state(crtc_state); > > + struct vc4_crtc *vc4_crtc =3D to_vc4_crtc(crtc); > > + bool is_assigned =3D false; > > + unsigned int channel; > > + > > + if (!crtc_state->active) > > + continue; > > + > > + /* > > + * The problem we have to solve here is that we have > > + * up to 7 encoders, connected to up to 6 CRTCs. > > + * > > + * Those CRTCs, depending on the instance, can be > > + * routed to 1, 2 or 3 HVS FIFOs, and we need to set > > + * the change the muxing between FIFOs and outputs in > > + * the HVS accordingly. > > + * > > + * It would be pretty hard to come up with an > > + * algorithm that would generically solve > > + * this. However, the current routing trees we support > > + * allow us to simplify a bit the problem. > > + * > > + * Indeed, with the current supported layouts, if we > > + * try to assign in the ascending crtc index order the > > + * FIFOs, we can't fall into the situation where an > > + * earlier CRTC that had multiple routes is assigned > > + * one that was the only option for a later CRTC. > > + * > > + * If the layout changes and doesn't give us that in > > + * the future, we will need to have something smarter, > > + * but it works so far. > > + */ > > + for_each_set_bit(channel, &unassigned_channels, > > + sizeof(unassigned_channels)) { > > + > > + if (!(BIT(channel) & vc4_crtc->data->hvs_availa= ble_channels)) > > + continue; > > + > > + vc4_crtc_state->assigned_channel =3D channel; > > + unassigned_channels &=3D ~BIT(channel); > > + is_assigned =3D true; > > + break; > > + } > > + > > + if (!is_assigned) > > + return -EINVAL; >=20 > I think this logic is just >=20 > int matching_channels =3D unassigned_channels & > vc4_crtc->data->hvs_available_channels; > if (matching_channels) { > vc4_crtc_state->assigned_channel =3D ffs(matching_channels) - 1; > unassigned_channels &=3D ~BIT(channel); > } else { > return -EINVAL; > } Thanks for that suggestion (and the others), it indeed works as expected. > If you're changing the assignment of a channel, I think you're going > to need to set state->mode_changed or something to trigger a full > modeset, so we don't try to just rewrite the channel of an existing > CRTC while scanning out. Since we won't have any CRTC configuration done outside of atomic_enable / atomic_disable, can we really have a case where we would reallocate a new channel to a CRTC without that CRTC being disabled / enabled? Maxime --zmtci7znkd6b2wdu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXujfkQAKCRDj7w1vZxhR xQm+AP9F9MIRdIiijjgN1Mb4ApZjJiIV3vUc+zN2siB+w5+gXAD+NrbAe75hbs1Y t37PcJ+IJstdGHrCFC+4QRRYyhPxBgY= =qtWX -----END PGP SIGNATURE----- --zmtci7znkd6b2wdu-- --===============1662565227== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1662565227==--