Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8895385rwp; Wed, 19 Jul 2023 17:48:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlEoKKeTfbgs02RewfW1dJn4ohOcXZKL/QCjcSpNRiYbJk2460Lc1G5eHVd872aKZOQlhJnp X-Received: by 2002:a17:902:e744:b0:1b6:6b03:10e7 with SMTP id p4-20020a170902e74400b001b66b0310e7mr4638316plf.5.1689814133904; Wed, 19 Jul 2023 17:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689814133; cv=none; d=google.com; s=arc-20160816; b=tu11UHGb6cfJWqEjfWd801haqEb37+8Fe4Lw/Y0pcvKaryrkV8B5TKpk9PIuNGRYzW +hAWrUxVf86+avo9NFFkiabo0SXTvb+eR7DFBt/yr7XpWu+YEL6Rti6kDgcKIpjs8RLy 5KHd1SbYrCHvxLyryd1MmtJ00Ge2eh5IVvucKVqS90GmD/Mmgb4R4dil9ncWkDafuAAU QuwnoeZ6n9Em7V6TVJdedeHQpd0YCmCzZuCiHExuI80sldrGtE5/FlyDPxctfd87j2xX aBbkcn4L7Dnyii6S2yedi0PAAT4JzhvHkehPItEurmHPu8VcLK7aVmKje0JbtuqBo8i2 qKGA== 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=LEv7G0CEYOPGW2iDjZ4bQ7xPP+mjrUkHdLemyMCnVvw=; fh=grh6qrjW0oxu0S8zfHJMhxWLgUXiZ/TU2uoVe6KOi4w=; b=KldipU4mCf+gj3fQej8B0+wn0qyoiD6nOmeDjvRDz1xg3NAYdbtzG9ameUJLqoQ/Gt N6Z/6jXjHCWWR1sMVzFW27MJHQ2//wDnyg242LMxA1KuXt4nomZZrbjlq/eI8p9M/+a+ zKdjes6J3T4/6wclwlN0sju0tjsR7iRuZb7ci8hF4OEGy+nX8d+QHacFD526wQRT1vOG HUu7PlPD4vPy3XW1EZzzsMIdeW7jFJHfHb6Jf1UIRfq2sANvMD9PuMPshb+2BL8NKQ2Y vitRdpbLRH8hLTFK9d4UfPq64buz2LnA0w97+VhzRciIDwaRZYDmvgPfzFKHP76A0UXM 4Qtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="EhUbe/it"; 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 a1-20020a1709027d8100b001b11168655esi4449282plm.334.2023.07.19.17.48.38; Wed, 19 Jul 2023 17:48:53 -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="EhUbe/it"; 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 S229890AbjGTARI (ORCPT + 99 others); Wed, 19 Jul 2023 20:17:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjGTAQp (ORCPT ); Wed, 19 Jul 2023 20:16:45 -0400 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 CF9AF210B for ; Wed, 19 Jul 2023 17:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689812125; 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=LEv7G0CEYOPGW2iDjZ4bQ7xPP+mjrUkHdLemyMCnVvw=; b=EhUbe/itq9AkMONj8ecRYsZERv5Eah5ZUUV9Bv8KvFOLPMqLHIC/iFL3YpLln2GrpYoEbW FlKh4qXQyDwclZFyv7UY/sWjdV/YLDKTykw34VIYtnQCrvUgPJLTuVyM/rv++JTGmCa9T0 N/UXQgGgofq6oHFAyW7gM+Kfkza8JME= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-aMwc03X6MgGnpPLBLiC9dg-1; Wed, 19 Jul 2023 20:15:23 -0400 X-MC-Unique: aMwc03X6MgGnpPLBLiC9dg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-993d41cbc31so17265066b.1 for ; Wed, 19 Jul 2023 17:15:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689812122; x=1692404122; 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=LEv7G0CEYOPGW2iDjZ4bQ7xPP+mjrUkHdLemyMCnVvw=; b=Hd9JBwX1bx1uj7xaC5L8aqXu/7XkKk+74HmHYpcEsEarWgp2lZxsvD+etka+FZX8/b UvXJIbl2/IO6i01czBBPabun46lxOFoy5LEsNtnakT1dP8I0zqDlKALp//BxaGY7Xxnh CsVqCddWl2Zs/g2J/TXJqhqMeGmrNhiowX5JX/faf4xM5yLWfcKpU1R7frPs83AVNla/ /6Fx8A6ngG2Kq0mDg3ZmFhm1QjsQj+R2ZVphZQmYbfKska4EAfa5rxU7x8bYXHrwA2E4 dBTgsAjsPLtVEqyueFmPPmjFlPCKn5EUbfzx6xKYD2lWm+AQmES5QLXLotUSUIKdxBpH sDcQ== X-Gm-Message-State: ABy/qLaKBS9PPf6O219hYt1lNlglTrVl2sXlqWojc8hVafdLzRqFHjsu 3qcFcWxAFGDfSfcjakQFxECda0suZaEIYJhlSHE92mDwRHRM0A9Q7rVEQrYZyDs3Z0UcTYqGHva OZjQF41TIFqB13RHduiTpTIFH X-Received: by 2002:a17:906:5352:b0:98e:3b89:5dc6 with SMTP id j18-20020a170906535200b0098e3b895dc6mr3910223ejo.48.1689812122313; Wed, 19 Jul 2023 17:15:22 -0700 (PDT) X-Received: by 2002:a17:906:5352:b0:98e:3b89:5dc6 with SMTP id j18-20020a170906535200b0098e3b895dc6mr3910200ejo.48.1689812122115; Wed, 19 Jul 2023 17:15:22 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id c8-20020a170906694800b0098d2261d189sm3028814ejs.19.2023.07.19.17.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 17:15:21 -0700 (PDT) From: Danilo Krummrich To: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net, donald.robson@imgtec.com 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-misc-next v8 06/12] drm/nouveau: move usercopy helpers to nouveau_drv.h Date: Thu, 20 Jul 2023 02:14:27 +0200 Message-ID: <20230720001443.2380-7-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720001443.2380-1-dakr@redhat.com> References: <20230720001443.2380-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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 45ca4eb98f54..a48f42aaeab9 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.41.0