Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp320812rdb; Fri, 5 Jan 2024 10:53:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI8CkNNNf+tzjBg8p1r1XbDwpEayfZDV1y+Kp+XhvC/jdCDcBTp2KCu70Zlw+V+I7kk6mp X-Received: by 2002:a05:6512:2e9:b0:50e:5117:d50b with SMTP id m9-20020a05651202e900b0050e5117d50bmr1248755lfq.137.1704480811482; Fri, 05 Jan 2024 10:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704480811; cv=none; d=google.com; s=arc-20160816; b=s1ROuqu2vVHVbUWH/eCJj2/5Oos/acN4o+ULIPpzhqjkaY01OVxZU+TPcNluDsoh3c UQej3GWU4m5ddVuifDkdvcMB7sPyDW5DmTG326l8nfwoj9jIjaGpLp+CrlX6DZhgi1+W bOX3zt/faT+mwzvWvliSqO59A1yREvB+QQckizSqqtIKFFeG57MzZsEpmUdMGvPh1nMl FF26nbA9EktiyzTpHvu0ULhjdlBZtCS9uUnsOffHMtttXYk8ulnNCt9uGl9hknhwszoz IHcL4YzBVwbFnRKjr3snTY76NvPAxDaLZ6TswE+Zn4nT2JwXVI+HchiR+cPFwLpstXn6 /+IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E5RLd7ocLVw2MqI9ZxAL7gW2fuibCoWG+rN0QayZndw=; fh=5cel2jD5h+yPMXVwxbomyVhwojHUqATy6nFjd4aOh4o=; b=WrCuJjsSJubiC6/tUNxbHUmEnEB5l/HAzOwguySF7E76nSFRPpXjnDs7Dv0yQdH9sR oxgILMKtYyNbOvlrrLSE9CrjI9cF4p28JprpvVHwNP22o3ZsnacbeunJzTK1AUWYl7wY WE/yzFiOn9ImPWajG+kMq0gcvNlmjJ6QJHGqyFslcBYO/zGARJ2XDzo+pTFb2DLtwiR1 SGs6IkKqd6BFTKxrRhbPcgDnQeeAzGhJDmW2R/YAHZCgfed6PGeijfy3u+0GXCTT10Qp oeWmXXdj0evb2Oowo3SoY+rlvR1oDtNwWt/dseAt9vv6crMvPYzFr9MX1HYLH1BcDxpF DKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=koD1jTYA; spf=pass (google.com: domain of linux-kernel+bounces-18264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f19-20020a170906c09300b00a26b06c521fsi785894ejz.364.2024.01.05.10.53.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 10:53:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=koD1jTYA; spf=pass (google.com: domain of linux-kernel+bounces-18264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3D4541F24745 for ; Fri, 5 Jan 2024 18:53:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A71023BB30; Fri, 5 Jan 2024 18:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="koD1jTYA" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935343B2BD for ; Fri, 5 Jan 2024 18:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704480446; bh=Xy26gJL0rfEIAQ3GTzMQ9EaB0QSmN8Rrgbq8+tRhsXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=koD1jTYASaaq0lH30DCRGwRlLF4icZe6o4RtGhMtxdBXY6SQHCj+AAoMWGtCV5jal 3o38uo19aKWom4br+OTJmNgxqtAXnvCQUYJjZ8hDcNButj0PQLLHni40YT501PCe6q ErF+M+MYMwDfZlVE+2dFDViPRVojFs1vXPkPZ8WiG92SaZ7MSFVtT17Scs7uYMdJsy HZalfvQSfjP9e4W+qiuVHBQZioyrxkCXK6FpqhTSHYXKdRKIxj01ioqjERVM7ygUfQ hQGNr+u92vLMktYspBAr0AJKm4va1ejnViBWlDzvwRtDU+HLnQGiP3yS7a15I0yQuP J7987sqBJRbVw== Received: from workpc.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E4CC2378206D; Fri, 5 Jan 2024 18:47:24 +0000 (UTC) From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?UTF-8?q?Christian=20K=C3=B6nig?= , Qiang Yu , Steven Price , Boris Brezillon , Emma Anholt , Melissa Wen Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: [PATCH v19 26/30] drm/shmem-helper: Turn warnings about imported GEM into errors Date: Fri, 5 Jan 2024 21:46:20 +0300 Message-ID: <20240105184624.508603-27-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105184624.508603-1-dmitry.osipenko@collabora.com> References: <20240105184624.508603-1-dmitry.osipenko@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Turn sanity warnings about DRM-SHMEM API misuse into a error conditions for cases where imported GEM is used when it shouldn't be used. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 0d95d723b90d..7d2fe12bd793 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -409,7 +409,8 @@ int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem) struct drm_gem_object *obj = &shmem->base; int ret; - drm_WARN_ON(obj->dev, obj->import_attach); + if (drm_WARN_ON(obj->dev, obj->import_attach)) + return -EINVAL; if (refcount_inc_not_zero(&shmem->pages_pin_count)) return 0; @@ -872,7 +873,8 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) { struct drm_gem_object *obj = &shmem->base; - drm_WARN_ON(obj->dev, obj->import_attach); + if (drm_WARN_ON(obj->dev, obj->import_attach)) + return ERR_PTR(-EINVAL); if (drm_WARN_ON(obj->dev, !shmem->pages)) return ERR_PTR(-ENOMEM); @@ -909,7 +911,8 @@ struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object if (shmem->sgt) return shmem->sgt; - drm_WARN_ON(obj->dev, obj->import_attach); + if (drm_WARN_ON(obj->dev, obj->import_attach)) + return ERR_PTR(-EINVAL); sgt = drm_gem_shmem_get_sg_table(shmem); if (IS_ERR(sgt)) -- 2.43.0