Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp863801rwb; Sat, 1 Oct 2022 09:52:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kO0J42s9wf4WixSMvVQSbVnYCRUMIijRPfeNbyJpsKQaTyDYr/7SvmxEDuosfMufJGtla X-Received: by 2002:a17:90b:2812:b0:205:cdc9:2ccf with SMTP id qb18-20020a17090b281200b00205cdc92ccfmr3957333pjb.97.1664643144506; Sat, 01 Oct 2022 09:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664643144; cv=none; d=google.com; s=arc-20160816; b=05aWmpRbHp2vTxIxnsWvrMZh0BVQ2D7ujQrbsXgDqLrYZ+Qwb//ONA8Xcs/wdkWMi4 0vo4IcRpcw9cE/KH/v53d8I9HM4RkiYGwwaCsrzqYUrzqIQeyHciMD3ivgL86W1ZrrEN KohjkAYTDdvCzcYdz52JIc4Tjy/VPdumESU5OYrUmWRA1Cj7SbMoFLagmFNjpxoRpI4Z woeZwMKybh1h6l5kZ5956spgLNmsKm6VTDALyIjfi8MqGtGZyLsbftxOE1pHDxJUUjVV 4FLUkeByUwjqR31CnV/3Gd5V+fqS7qdUTSoLBSqY5GmxMVCyTo5wu4pxpss1PFXSvpqm 0Scg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dnX59dffWK1EQ9RPt7g3flEI99/gWclWQ2eDM1z8XdM=; b=ebiYAiHdJcXwkKksFShmoZAJ8Di9Jf2oEbH/J5udwT5AcuRGfzg1jVZndpz9LNLosY 9AmFRzLnuSYAiPTw2FIah3qWO+7Y3/Q2fwXXzyaERvvARv8gtkMVnsVONV2ylyBvCyri jgbyltEow+KIa6IPXSvILTzr3emF1QcqGQlzh9u8G5Obcyl4FvQd+H57kNn+dSPxhpEE rdTMvk38roQRJVGYTnWeCj9S0IEf4BFSnJTquMOl6fcN9haRjiHyk6ZHVEWW5kkcsKj+ xxOdUqubvkYF6is07HegdNJjzJW8TgnKiCIXJ8evgLkC0wC9PwxFefPf1gY/bUpifHWt 8UEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FeaxxWMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a056a0022c300b0054a43b9711csi4856928pfj.198.2022.10.01.09.52.13; Sat, 01 Oct 2022 09:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FeaxxWMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiJAQlv (ORCPT + 99 others); Sat, 1 Oct 2022 12:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJAQlM (ORCPT ); Sat, 1 Oct 2022 12:41:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91E21386AC for ; Sat, 1 Oct 2022 09:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664642421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dnX59dffWK1EQ9RPt7g3flEI99/gWclWQ2eDM1z8XdM=; b=FeaxxWMNZi02H+FbvzW4IDMAhzty+9I5Uc3Np8VcldVBJaOI2/OLhB12jlrYDqfebqWDTT hO2qvS4bTe747G0PB2H5GpeksTFSl3FrgpR7QFNxqQNghiyq64bRbmaQHxX1qQn1j/5YGO nOyj/qoxMMpK1V0B6HENID8iN/mmRM8= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-15-l_jQoT7INqaRZC73vpKpKw-1; Sat, 01 Oct 2022 12:40:20 -0400 X-MC-Unique: l_jQoT7INqaRZC73vpKpKw-1 Received: by mail-ed1-f71.google.com with SMTP id e15-20020a056402190f00b0044f41e776a0so5731100edz.0 for ; Sat, 01 Oct 2022 09:40:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=dnX59dffWK1EQ9RPt7g3flEI99/gWclWQ2eDM1z8XdM=; b=hqqeWr6eEmZIoECQHWJtgzE+rQzzG6mq6YxO561Yla2CAOcwoA3zydEntjTibcRLYl cbpWtMMFHYJy0FDXvEZ+fdilFiwKefXlYAGIIWpFOa+KN0RmAkvx3ekHbaYIsULOLe0o EYJsndihIJTeq4Nr52EhQOilIkasnz+AODZJlT63StgMDoAvAKSDGkd3Xq8yMgEXA4si zXY21DjB7zfdgiJPvA4DtHM2aBQPnwxm+qprXWm3YbJSAXxK5nnmjiCK5maD4IG1TpDy rimiuQRslSVNrQOTqUyRj7EauetU72HjktijhIJm+DPn4lLMu3ABvy4q59/vL0T/grxc Ek0A== X-Gm-Message-State: ACrzQf1SLXUAV0iRLf2F9bxPF1zFdLEyjN0EH0r/wLzp5bODNlxN1OLg ns/b1pomdcmuA7DZOQjvQcV/w2/4A3VtZk+qYPbTaiobVp+4Cqfm+ivnNFgqQKM8fuyrWEAofQR +MAPLMjNAIdHSFPf4D5Iktt96 X-Received: by 2002:a17:907:97cd:b0:787:ccc3:fde1 with SMTP id js13-20020a17090797cd00b00787ccc3fde1mr9121361ejc.334.1664642419227; Sat, 01 Oct 2022 09:40:19 -0700 (PDT) X-Received: by 2002:a17:907:97cd:b0:787:ccc3:fde1 with SMTP id js13-20020a17090797cd00b00787ccc3fde1mr9121349ejc.334.1664642419069; Sat, 01 Oct 2022 09:40:19 -0700 (PDT) Received: from pollux.redhat.com ([2a02:810d:4b40:2ee8:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id c20-20020a1709060fd400b0078167cb4536sm2886785ejk.118.2022.10.01.09.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 09:40:18 -0700 (PDT) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, mripard@kernel.org, liviu.dudau@arm.com, brian.starkey@arm.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-misc-next v2 8/9] drm/arm/malidp: drv: protect device resources after removal Date: Sat, 1 Oct 2022 18:39:45 +0200 Message-Id: <20221001163946.534067-9-dakr@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221001163946.534067-1-dakr@redhat.com> References: <20221001163946.534067-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Hardware) resources which are bound to the driver and device lifecycle must not be accessed after the device and driver are unbound. However, the DRM device isn't freed as long as the last user didn't close it, hence userspace can still call into the driver. Therefore protect the critical sections which are accessing those resources with drm_dev_enter() and drm_dev_exit(). Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/arm/malidp_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index aedd30f5f451..8bb8e8d14461 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -234,9 +234,12 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state) struct malidp_drm *malidp = drm_to_malidp(drm); struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state; - int i; + int i, idx; bool fence_cookie = dma_fence_begin_signalling(); + if (!drm_dev_enter(drm, &idx)) + return; + pm_runtime_get_sync(drm->dev); /* @@ -267,6 +270,8 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state) pm_runtime_put(drm->dev); drm_atomic_helper_cleanup_planes(drm, state); + + drm_dev_exit(idx); } static const struct drm_mode_config_helper_funcs malidp_mode_config_helpers = { -- 2.37.3