Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp257913rwb; Fri, 4 Aug 2023 12:11:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzQyOJ+nxwgL/rC1kvdf5SA5uZ920Y9Cxk4OG8FASPxnu8pI54M4AVRJ73AXbbUEwglcMR X-Received: by 2002:a5d:5641:0:b0:315:963a:4a3e with SMTP id j1-20020a5d5641000000b00315963a4a3emr1742733wrw.7.1691176304273; Fri, 04 Aug 2023 12:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176304; cv=none; d=google.com; s=arc-20160816; b=Ae963DG95Cd2GmXXP9csAoHanAqVFAuvwlgFU2ayzcV2QBocT1C87pMZw73rJRxts7 aw3I1qdhp00oqxRY2FlRhBhMhsZFocj+6Q31PUofYEuVau1f9cxOhz3FVC/AV/+Ilr3A L1BTQ8MsUpqOiF2xKLjQ3zVM6jcIIjhS4J45HCY98o07OaaQVFKOk4lrlyI57KxOB2lm K3Zzn3gIdcP2khMdY07OpWrt37crD/m0k1UXuIRlzWccYFAT+JQngEmbgAG/kTNE2zIq xDfP4vFploKdBbk7V5uCx/12haBQuf+yvlskQ+W2AXBH0xW4oMwFro2TLl05+xKV4Jna RZvQ== 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=sILSYR0gnJ8A9dpqcei0GUdx0191p3j7ECPYiYKPGLY=; fh=K2z4qF9vBIeudG+FAsbdmtc7khu/mu2nGw/y5mnZTR0=; b=X2/5CkixOJJPdjfuzLzs6QO2cPBPEnflIgayi8K5u7YLcOZTqbCnnetaCIPyM4UQER QYY559JNnUNC56Gf3UW45PcFLCjcNQ41RcaodEjVQBh6Pd7QDatqlt7NGfOhwSKcwevY Wd4blOdlgJJBnWZETVM9+iZAIh+/WftJ8g970bNc+ecY8/djh4FN7/3VTltHEM5+FGwv miVxVOlI2y2g5Pp3S0pWoBkyWhR+Z/zIaO6gNaMm6P71f/hJylmbO0SaMNsBstVj2XVK ThyDPQq67ODkwqy+rJ0gCGNcj6sf+NWygEqEnyEHEN7nsUZ5SHJuT/czkBJxgqUii5Lb FdPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EfTrG7fU; 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 d13-20020a1709063ecd00b00992bdcb72f0si1948079ejj.339.2023.08.04.12.11.17; Fri, 04 Aug 2023 12:11:44 -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=EfTrG7fU; 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 S231455AbjHDS0x (ORCPT + 99 others); Fri, 4 Aug 2023 14:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231297AbjHDSZh (ORCPT ); Fri, 4 Aug 2023 14:25:37 -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 D282A4C31 for ; Fri, 4 Aug 2023 11:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691173481; 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=sILSYR0gnJ8A9dpqcei0GUdx0191p3j7ECPYiYKPGLY=; b=EfTrG7fUH0Cx+H0Mgx+2C8stlvzpU8awrgnRmY1HUu4dtSuPh4eSLUlqK+E2MYjatZwKc+ tj55+ZwsHkeb/wLofDpJ18kBMS0DcajFoF4Br8my5rf5BA3rG3qRRJYuXG2OkFOdLZQomk FVSksCF/gB/h+rL0ebG+rmlTF81VE4Q= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-466-CeNdvE0_PfmMhJq2tLSHwA-1; Fri, 04 Aug 2023 14:24:39 -0400 X-MC-Unique: CeNdvE0_PfmMhJq2tLSHwA-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5223d4b9da2so1574406a12.3 for ; Fri, 04 Aug 2023 11:24:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691173478; x=1691778278; 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=sILSYR0gnJ8A9dpqcei0GUdx0191p3j7ECPYiYKPGLY=; b=I4SgxC/F7Owo4xci10aV/6lfTPXKOi3h/FQ4brB8t/kLWJTNo3a/uRKQWqE4QhFXC6 gER3dWBlsH+w37xNBvuUhBO1HOaquwHGaj9YEet8/WUSiKqZ6ZcxSj3ncDttvkBOSpyx 4XD3xVR/tQaZVOkK+MaWxvVl+tK4gB2wat+078j9p7htUfxtgbwIXfHp9z85Hl94ukTf L1rV5jZmZZ9XTulyZHQ5El7PWKMJFoVzrFqhPQNfe1RLQYeHjLMqY1UxJ4afwujodPXs e3IO0LdlrAhXiXt4e6l1KyYj7q69ekeY9h+njObuepwK3V2PII/r92SoBQVQy7qysbqN Exqg== X-Gm-Message-State: AOJu0YyfFx28Z62tvCZO0cGznVY7Qi9zW4XmNwvX/M6pZlCXU+HthiYU VoKsAmsfc0W+dC2RFH4SK23WgVdgtI7wU4xnhH6FJr3mwXLjEALD6qY9+bAPQte29CNVaWpaU2D l46q6t/BUyEmYNMIgp5UqKZm0 X-Received: by 2002:a05:6402:448:b0:51d:d390:143f with SMTP id p8-20020a056402044800b0051dd390143fmr2168716edw.5.1691173478710; Fri, 04 Aug 2023 11:24:38 -0700 (PDT) X-Received: by 2002:a05:6402:448:b0:51d:d390:143f with SMTP id p8-20020a056402044800b0051dd390143fmr2168702edw.5.1691173478516; Fri, 04 Aug 2023 11:24:38 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id r6-20020aa7c146000000b0051e2670d599sm1570383edp.4.2023.08.04.11.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 11:24:38 -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 , Dave Airlie Subject: [PATCH drm-misc-next v10 06/12] drm/nouveau: move usercopy helpers to nouveau_drv.h Date: Fri, 4 Aug 2023 20:23:46 +0200 Message-ID: <20230804182406.5222-7-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230804182406.5222-1-dakr@redhat.com> References: <20230804182406.5222-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 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 Move the usercopy helpers to a common driver header file to make it usable for the new API added in subsequent commits. Reviewed-by: Dave Airlie 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..d28236021971 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 int nmemb, unsigned int 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