From patchwork Fri Jan 31 00:18:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vishal Moola (Oracle)" X-Patchwork-Id: 13955035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75E83C0218F for ; Fri, 31 Jan 2025 00:19:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 066892800DE; Thu, 30 Jan 2025 19:19:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F32282800DC; Thu, 30 Jan 2025 19:19:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D849E2800DE; Thu, 30 Jan 2025 19:19:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B50DB2800DC for ; Thu, 30 Jan 2025 19:19:41 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5F2E2120421 for ; Fri, 31 Jan 2025 00:19:41 +0000 (UTC) X-FDA: 83065838562.07.C79D650 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf14.hostedemail.com (Postfix) with ESMTP id 848C6100015 for ; Fri, 31 Jan 2025 00:19:39 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TK1YWWda; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738282779; a=rsa-sha256; cv=none; b=R8jQIm49VPJsxo2RvryzvZRILPWtG52l19o3EA9yQ/IIOjC7F43+Kc7+I3FHbEopC1bMT+ la3/qgSKw8A/7i6e0mLGZNUQiCk23lNOUo002OUKyO/U42hN7G5IoKb0ynooctGrQZ+k7L jT7O9DchVaxeDequaPdx8kdiayql6D0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TK1YWWda; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738282779; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eu4iajeZxMqtVBb9GVR/egkCI7uYsEZ5rCFcV7XgAIk=; b=q4OyqkKD3srf72dH53qGdjXXKsczYxHMuGUO4OMOD3VnkHcx8ghBKvu5LZ8Of53JG8IQYA +Fw71fNtoOEktMQIljSF4DzPSk3vx0bnGzqgbGMm+bWRJRA6llxEqUz/A4NFKqmEsiZyJW MntnJ+RNBFmXuaJ4HTPNrQ/tQtfHSpw= Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21631789fcdso34294635ad.1 for ; Thu, 30 Jan 2025 16:19:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738282778; x=1738887578; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eu4iajeZxMqtVBb9GVR/egkCI7uYsEZ5rCFcV7XgAIk=; b=TK1YWWdashCN/ZoOl6KJmOicr6P/W5SQ8gpi7LKR2alwuEdYruFnrU/Y/M9WSLT7Nx R/H7hi1fOdSNEVUoalAkOizXE9KWx4d3TH9T32Eo6ln8T6iUl48v/aZGTb9IZGJGu3Z1 Kcv9iY85ij0BeoaIom+PsGoCNpIME4eVdFDhiu37lJ+IWMg7vQEJF/KXAPboOwey2PKw ZQmpyCWnATNhsXKHtE9C6+hR4NiZmqBiw7JSrtF1YJksMzfzhtUXBuKoIwJAW3B1wTbX DSGEPrSKXVyAxTdEjPucvXUaYWEak2w6NTcXE8eb2p1RNr400TRJ5CDNZdfJBmqwhn1w 62Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738282778; x=1738887578; 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=eu4iajeZxMqtVBb9GVR/egkCI7uYsEZ5rCFcV7XgAIk=; b=DiyFdcAK1Wmj+CIEKqaRprsBx8a/lu0ESJ/84kr4xLpyqG4FhnLchsm6k4ywIMECx3 auvnSvfLCY1An0MeF1IyB/DZ4SQTvBAR43h9zF25Ya4+gGOFxI4YYcRmo3gXu+Q0HvCH LPXjkuUIV4VS314m3e8QaAPusikT2RU0RC/3kd+VnLYM8CS4W8SMIceC9zkUQZh4e03M LZK3p1GvFaMVTcFGssKI7gem1qHD4x4KvD6u2flcxT8147cXr1dQt+6S13MGPmo08xOD DmsK2Dqu6DXQ/34+8je0TFshPYz0mhbjk5S4IAy9/JKXSxEz4vFJReEgaF9FGdhKay/r AHaQ== X-Gm-Message-State: AOJu0YybXaXhCe6M+j3Xy5PuUS01arvZ0T4W/vIIecUBhPoktICjGlhb 1SXnI5dtcdWqgzWd0WuI8DvJPQQpjQLWizaShr2NXYL4uXQG5Xci X-Gm-Gg: ASbGnctxB1QMRy7JhDsfkdlX5yEOZj535Fl51IgHFicgE59o5Y47hyOTeax3WYcTrle 8ak0RrxS0g72yLlqpy7YsJ/79pqQRB/Fu+7plex4RKVRqTZttSQJ0yGZenO3v5cgDtcuWP7N07V DKlMAuO6Xpvu/aYouk1AXRg0qvYr25uCeJrH0NcaN4lDHPCmRd+3NGpJ990Sde4QTxg5vGZDPy4 Oi9cZDaU7fthnf83+x2K946byosEbky7GAJMXDaFLL5tPH7uWB0eMPn1n0sc8iF7X3+VtrSAcsb aggZeuDRnGGYNyspOgzMAwTIL9ZEQ4XUkC34PVBhPhD/AMJzBQ== X-Google-Smtp-Source: AGHT+IFWUrM+SSQZrqyoWMSFp3NDXsO+kZxdPxA8Q4VeZa5JZviHD3s/5EQZ9UOZA/4M1BU6EsIymg== X-Received: by 2002:a05:6a00:2b43:b0:725:ebc2:c321 with SMTP id d2e1a72fcca58-72ff2b659e1mr2202540b3a.4.1738282778289; Thu, 30 Jan 2025 16:19:38 -0800 (PST) Received: from fedora.. (c-67-164-59-41.hsd1.ca.comcast.net. [67.164.59.41]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-72fe6429218sm2148234b3a.66.2025.01.30.16.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 16:19:37 -0800 (PST) From: "Vishal Moola (Oracle)" To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@infradead.org, urezki@gmail.com, intel-gfx@lists.freedesktop.org, "Vishal Moola (Oracle)" Subject: [PATCH 2/2] drm: Use vmap_file() in shmem_pin_map() Date: Thu, 30 Jan 2025 16:18:06 -0800 Message-ID: <20250131001806.92349-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250131001806.92349-1-vishal.moola@gmail.com> References: <20250131001806.92349-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 848C6100015 X-Stat-Signature: y46ikgbzkmaxmuwf5fbhktyo3x4ttz6r X-Rspam-User: X-HE-Tag: 1738282779-29241 X-HE-Meta: U2FsdGVkX18Cq0F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1bD0InJXacAG11LK5w3P+GtOfvtIyu1Xi4zraCgGWdANJWKkppvsqntLIDJyWQM7A1XZY7PkZO2gzGgNyFSt2B1KMoRrJaPl4M5u9u6QmL9ckORxfQRLJynemaByQd2ZqlRtppJWe/94mtNwXep1KV+KbwGgTHqOQ8EEIDb0dVvDfch5yCkOVSFLFhcE4wsDyxxfZSdsobt6Bqas4hUfaToDiWVwkloYSJUZ0Rr1XTI/GqeW8DCF/GCeuwC9JpaLtntwlbwvlNOyiHCcEC8mWd0o9W1VxaiHMeM5b7bcbV7AfYa+vModzPUVmxwy91PqwOj34drYv+dH3ELNdxjIUq3++2hd8THcZph32lFTTxOA2JcLtb5kV6cUjEHToyZzU0om1D+LVIJJHE84ZCAvKlz0zeGqK9MC9c7VbpJMPZUReYHfs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We no longer need to allocate a new array of pages to map this file to kernel virtual space. This simplifies shmem_pin_map(), and gets rid of a user of VM_MAP_PUT_PAGES. Signed-off-by: Vishal Moola (Oracle) --- drivers/gpu/drm/i915/gt/shmem_utils.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index bb696b29ee2c..79d930ed5229 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -57,32 +57,15 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj) void *shmem_pin_map(struct file *file) { - struct page **pages; - size_t n_pages, i; void *vaddr; - n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT; - pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL); - if (!pages) - return NULL; - - for (i = 0; i < n_pages; i++) { - pages[i] = shmem_read_mapping_page_gfp(file->f_mapping, i, - GFP_KERNEL); - if (IS_ERR(pages[i])) - goto err_page; - } + vaddr = vmap_file(file->f_mapping, 0, file->f_mapping->host->i_size, + VM_MAP, PAGE_KERNEL); - vaddr = vmap(pages, n_pages, VM_MAP_PUT_PAGES, PAGE_KERNEL); if (!vaddr) - goto err_page; + return NULL; mapping_set_unevictable(file->f_mapping); return vaddr; -err_page: - while (i--) - put_page(pages[i]); - kvfree(pages); - return NULL; } void shmem_unpin_map(struct file *file, void *ptr)