Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6025881rwb; Tue, 17 Jan 2023 23:33:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtotLD/fRGxhKFnGKmrzIoMlrJabI/6VVS1rVa7O6eIvnQ7LrNLQBjVaDj2tOkRMsnUxzeM X-Received: by 2002:a05:6402:10c9:b0:49d:a87f:ba78 with SMTP id p9-20020a05640210c900b0049da87fba78mr5906834edu.35.1674027181189; Tue, 17 Jan 2023 23:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674027181; cv=none; d=google.com; s=arc-20160816; b=sbfXhT5+SZGQM29VXEOme3cUo3HU0Ck4Rue36Di8QuCeZwOsgEzKGfELfJNgKjCoZn 4moEdWsZOAuXuPftLjCd74ywU7QdJ6W9u5/eGBMnNNa4CAyatBmfgzSO9qFUNZUzBC7U fmfGCHr2C1GkQv3gSUQDUVkffkyTcxYuaSd42t9JpXilK9SB3+jMJuFxJrqWWvMUNce1 6T/6yRZjLNkWb4xjOJ0UN0Q1HoaF7zJwS1+kTJOzyxVUo032tbZvG45/Ih5Lqvt1PEvV JdRr+2vB3xZjnE58LQGRld5dV9YZ0Np0sjXJqIC1X0G9V4Or5oWGUGi6dNZzhW5c4l3M j3lA== 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=kuIA/967bi8fJ2s/oMp21AWFew5v50JdzBzuNFK8Osw=; b=jX3IR4hfJjAJ28J5pbRKDXs7O84enevCFqHcR5Jm0aUQHrUX8EjUvsFihx5LrOvs/h URENWziUTozT5f0DRjRbdZZYOG4TYKGMZOJak9RgVl0EKAJjN8+zgBy0xFUKOtVgtByJ rhq6C9IuttfXmzC24jcd48+CN3kS9HRhEujvEohtqCjhPb2AcO9d+8UaIhWaPhG/PDRo 5nO81TmdVQw7SaNbJVC/ewQfKX98cEkfk6E/BDLPNf85syMCblsF7MvzT9VRSVjwCmi5 u156tLjVj94jLA48z+i19z9wymi8MsHKFBBvWSV3p4IB9C8fGbvf6rDKSD1rQ1UhK0Jb 2Q3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jh1dLKQ9; 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 w20-20020a056402269400b0049e338fe4c9si6172454edd.460.2023.01.17.23.32.50; Tue, 17 Jan 2023 23:33:01 -0800 (PST) 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=Jh1dLKQ9; 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 S229760AbjARGte (ORCPT + 46 others); Wed, 18 Jan 2023 01:49:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjARGZZ (ORCPT ); Wed, 18 Jan 2023 01:25:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15A3753E5F for ; Tue, 17 Jan 2023 22:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674022441; 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=kuIA/967bi8fJ2s/oMp21AWFew5v50JdzBzuNFK8Osw=; b=Jh1dLKQ9HMPoV5wpxDiPQJgBRG0NvqRjypxBuRBiJsGEIDPZ/jPxFCv6RuJUFgKuQA2Kvv OIp6yAv/EuQqM5GNNreeYpDXQ7X0mPyb+SLyz18V50p1NP3Q247UM+V4t5RvWKGkB0XyDO H8n6iRJ0NTOKSa4CQGrVV+yaJbeJH0A= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-8-VnT9C7ReN-WoAJBfXxtZJg-1; Wed, 18 Jan 2023 01:13:58 -0500 X-MC-Unique: VnT9C7ReN-WoAJBfXxtZJg-1 Received: by mail-ej1-f71.google.com with SMTP id hq7-20020a1709073f0700b0086fe36ed3d0so5823269ejc.3 for ; Tue, 17 Jan 2023 22:13:58 -0800 (PST) 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:message-id:reply-to; bh=kuIA/967bi8fJ2s/oMp21AWFew5v50JdzBzuNFK8Osw=; b=Ibzeyra/MMkEU7X+KbPnyywo9XhVnhVHbQESp3sCb9L3EpcWCsuz7FgUzJpFWjTz/D 4Euj21uEL7TAzaZlQpJ4rv5g5lBwBIjwqlpVSxJ6PubBX5wsD+6GTZtGRdlbqrfW+91u 1+fqnf+CV8NToI7S6G2j++oCaVWRPzFjo5gxXUwONvUGaZ8AOKWNBmThNpSAM2A8tdgu RLOGZPXRVae5h8Bb71GYPoLqaVk4b+O05itS5jTU/mzhOJESO/9wmEx5mqwjE+8lyQS3 ODI+k5dt2p2vp/kPKeOMvDYUWBzVvLFVK5zAT3WlN+ZR5PPZ3DlJfEtVtHoWmkyX/v9m rGtA== X-Gm-Message-State: AFqh2koQAcyX/I6oGS99ADpNOg0lwWlvCfZ9QOmsIMNyovI5y7p6vseD jQZTcNtRgHp3ou72PEufkWv6TeX7J7wyALxr2BDd95nWdXDNwFlgOuDDcLkXDnBdEciNUTqYz9A l8ZvzA486Apz3HDewYYhVvz4w X-Received: by 2002:a17:906:549:b0:84d:3822:a14e with SMTP id k9-20020a170906054900b0084d3822a14emr5532745eja.64.1674022437317; Tue, 17 Jan 2023 22:13:57 -0800 (PST) X-Received: by 2002:a17:906:549:b0:84d:3822:a14e with SMTP id k9-20020a170906054900b0084d3822a14emr5532728eja.64.1674022437107; Tue, 17 Jan 2023 22:13:57 -0800 (PST) Received: from cassiopeiae.. ([2a02:810d:4b3f:de78:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id 11-20020a170906300b00b008675df83251sm7184811ejz.34.2023.01.17.22.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 22:13:56 -0800 (PST) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@redhat.com, christian.koenig@amd.com, bskeggs@redhat.com, jason@jlekstrand.net, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next 08/14] drm/nouveau: move usercopy helpers to nouveau_drv.h Date: Wed, 18 Jan 2023 07:12:50 +0100 Message-Id: <20230118061256.2689-9-dakr@redhat.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118061256.2689-1-dakr@redhat.com> References: <20230118061256.2689-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Move the usercopy helpers to a common driver header file to make it usable for the new API added in subsequent commits. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_drv.h | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_gem.c | 26 -------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 81350e685b50..20a7f31b9082 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -130,6 +130,32 @@ nouveau_cli(struct drm_file *fpriv) return fpriv ? fpriv->driver_priv : NULL; } +static inline void +u_free(void *addr) +{ + kvfree(addr); +} + +static inline void * +u_memcpya(uint64_t user, unsigned nmemb, unsigned size) +{ + void *mem; + void __user *userptr = (void __force __user *)(uintptr_t)user; + + size *= nmemb; + + mem = kvmalloc(size, GFP_KERNEL); + if (!mem) + return ERR_PTR(-ENOMEM); + + if (copy_from_user(mem, userptr, size)) { + u_free(mem); + return ERR_PTR(-EFAULT); + } + + return mem; +} + #include #include diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 48e6ba00ec27..5dad2d0dd5cb 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -613,32 +613,6 @@ nouveau_gem_pushbuf_validate(struct nouveau_channel *chan, return 0; } -static inline void -u_free(void *addr) -{ - kvfree(addr); -} - -static inline void * -u_memcpya(uint64_t user, unsigned nmemb, unsigned size) -{ - void *mem; - void __user *userptr = (void __force __user *)(uintptr_t)user; - - size *= nmemb; - - mem = kvmalloc(size, GFP_KERNEL); - if (!mem) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(mem, userptr, size)) { - u_free(mem); - return ERR_PTR(-EFAULT); - } - - return mem; -} - static int nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli, struct drm_nouveau_gem_pushbuf *req, -- 2.39.0