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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 F0C1AC2D0A8 for ; Wed, 23 Sep 2020 15:43:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9F0362223E for ; Wed, 23 Sep 2020 15:43:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xup9CpiL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="lkXddpGY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F0362223E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5jL9C3KKlFanXpHd+1FU6KLDaX00tas3yJrSoLmVKxA=; b=xup9CpiLJLPIh5rNX9nJuUOZL DBrEtC9wtASNSUpdJHWF1yuvdtkOPJQjROldPgya6kgHsCt7Ef+RmtVQKRK/Dc6jfC87yiiy/tXeL McSmOIMkjyNyWbTkdNasfXryStTxWIKR2Nz4xt9UcUI6oRrwCIG1obXBrAxX6ofs2ErCNEDNPSd9p DuQLS2Ju73hIiw4vm6nJT9nM37hXO96FWxGukPHZe0fv9ed8SB9aWfCAtTQqJvH7KiBaPa9bv2EHG J4KFJUznHb69o8gjK5WtXh0id8iBdTSSxCWaM1KVn9C4BtZ192MyHuvCmTsWeQdz3DeaUVgefi1UX dAYZ51bpg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6uE-0005XA-9Z; Wed, 23 Sep 2020 15:42:06 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL6uA-0005Vn-Ma for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2020 15:42:04 +0000 Received: by mail-wm1-x342.google.com with SMTP id d4so474680wmd.5 for ; Wed, 23 Sep 2020 08:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ji36v+ulFjvwd5eMeN8llVyHPMW9wU1YMSmHIXO9ifg=; b=lkXddpGY7vbvqAnZWOXPosszH1AFHQb1IU/MCHDD41+5nFlSeUTBehNrMKvcNYUJrH 4gyfbccA+sOmXOeiqQZeu//yfih3raQSN3e7gO17w9/kmQ7iIAg7wyeBw1EGoFntIaEb R4Jhh7+puS8IbHEkdBRngJwPjBCBcisU9EmNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ji36v+ulFjvwd5eMeN8llVyHPMW9wU1YMSmHIXO9ifg=; b=nbZ8z4hMMAOm0EtRcuwhrkBYmpKuWnBk8v7J+HgBdIVlOKolMuhYcSDDkV8ReREXzV rC6pTU+nxCLVhmTamHRFEmYE2GwERFiludcE23Q8WQunx2+VF7oKECrIHL6r+fWxNZmA V5zqO6YpJpHEdpCicfSgUIER9koMzsQmbMgM+WZIcrZe7BunDjy1aO/mx0Q7rth8kRAw 6mcaejH+ai9MyibOCBW7OJwCLa1VbDwqnMyEjRGK0qo4TyGC081J1iPT2s7BQHBu0pc7 rTD2Y3NbEQznfFGJS5ByvNWVALWXQyJEm1JSiBC9shMsp98BgYPGNgQn8DSxPLhUm9k5 yNPQ== X-Gm-Message-State: AOAM530x6ne08GwbCftv743IUwKNbSHDBL4jgH2NSJeVIXHT9P2GsFbW ZkFOeMYH4EkvLhRi6zhIe0kq9Q== X-Google-Smtp-Source: ABdhPJwwId6TQo7OMwHTXQ6XURMt7suTd8zfavBDtc95JayVaqNV1r2q31tRSq7B3vqxfC0aV/hV9Q== X-Received: by 2002:a1c:26c3:: with SMTP id m186mr130882wmm.115.1600875721487; Wed, 23 Sep 2020 08:42:01 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l126sm153435wmf.39.2020.09.23.08.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 08:42:00 -0700 (PDT) Date: Wed, 23 Sep 2020 17:41:58 +0200 From: Daniel Vetter To: Dave Stevenson Subject: Re: [PATCH v2 1/2] drm/vc4: crtc: Rework a bit the CRTC state code Message-ID: <20200923154158.GV438822@phenom.ffwll.local> References: <20200923084032.218619-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 5.7.0-1-amd64 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200923_114202_775042_9B418A0D X-CRM114-Status: GOOD ( 34.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Gover , DRI Development , bcm-kernel-feedback-list@broadcom.com, Maxime Ripard , Phil Elwell , linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 23, 2020 at 03:59:04PM +0100, Dave Stevenson wrote: > Hi Maxime > > On Wed, 23 Sep 2020 at 09:40, Maxime Ripard wrote: > > > > The current CRTC state reset hook in vc4 allocates a vc4_crtc_state > > structure as a drm_crtc_state, and relies on the fact that vc4_crtc_state > > embeds drm_crtc_state as its first member, and therefore can be safely > > casted. > > s/casted/cast > > > However, this is pretty fragile especially since there's no check for this > > in place, and we're going to need to access vc4_crtc_state member at reset > > so this looks like a good occasion to make it more robust. Also your next atomic_check will probably look at this, most definitely in the memcpy to take over the old state. So yeah KASAN should complain if you get this wrong :-) Probably want a Fixes: line for this too. -Daniel > > > > Signed-off-by: Maxime Ripard > > Tested-by: Dave Stevenson > > Based on the issue I perceived with the previous patch, I'm happy. I > haven't thought about how the framework handles losing the state, but > that's not the driver's problem. > > There is still an implicit assumption that drm_crtc_state is the first > member from the implementation of to_vc4_crtc_state in vc4_drv.h. To > make it even more robust that could be a container_of instead. I > haven't checked for any other places that make the assumption though. > > Reviewed-by: Dave Stevenson > > > --- > > > > Changes from v1: > > - new patch > > --- > > drivers/gpu/drm/vc4/vc4_crtc.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c > > index a393f93390a2..7ef20adedee5 100644 > > --- a/drivers/gpu/drm/vc4/vc4_crtc.c > > +++ b/drivers/gpu/drm/vc4/vc4_crtc.c > > @@ -852,11 +852,18 @@ void vc4_crtc_destroy_state(struct drm_crtc *crtc, > > > > void vc4_crtc_reset(struct drm_crtc *crtc) > > { > > + struct vc4_crtc_state *vc4_crtc_state; > > + > > if (crtc->state) > > vc4_crtc_destroy_state(crtc, crtc->state); > > - crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL); > > - if (crtc->state) > > - __drm_atomic_helper_crtc_reset(crtc, crtc->state); > > + > > + vc4_crtc_state = kzalloc(sizeof(*vc4_crtc_state), GFP_KERNEL); > > + if (!vc4_crtc_state) { > > + crtc->state = NULL; > > + return; > > + } > > + > > + __drm_atomic_helper_crtc_reset(crtc, &vc4_crtc_state->base); > > } > > > > static const struct drm_crtc_funcs vc4_crtc_funcs = { > > -- > > 2.26.2 > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel