From patchwork Fri Mar 22 22:56:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13600474 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A25578288B for ; Fri, 22 Mar 2024 22:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711148225; cv=none; b=H7xhEHyuKfhjb+nhjoJ7y0QeuqK5eGUgsdqy89MG6zbrSaDqjOW680JvxcGou2+ovC87ZQh7u/vQ2qr/CV4bei6cEKJ8dJsxjXRBJsmgYAJWV3hobn+GnYWBH/pKq7ddzoCqC8CyJkcRnn+go/fGN/MaBxeEMy91jkR/8l8G6j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711148225; c=relaxed/simple; bh=LFBCygmQugB1B+c89cDmQuXR1TkW2sehOLTqu9Lzsnw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V5OupfMXdXohaNSlZiDtyBUR87GbOV2BHmdoK3f+tvwzkZcJ0/+BMq8Xd4YPIMbCSgiCQv0aU1XJjuEAAIjFcPS+i065C/4QFAyzctOLCYuJ4lh6OLKhf7bBS731qY9ENoC9MRlVmNLgfz/LhjUrggFPRJ+JkBQdVBNV6/kuQ54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=c6HtJafS; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c6HtJafS" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-513e6777af4so4881276e87.2 for ; Fri, 22 Mar 2024 15:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711148222; x=1711753022; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jnTUQM6F1e6b3ELJmMukNHuHn8ljSCVj2rp0eJe9i4Q=; b=c6HtJafS1fiZcyyexkWxE/e+l/Fm3Dzg1sj7WueeaoH08LVHFB7ohIB7wgdgU2o/9f pWcp1OVWYsetap0XJJ+pXRCciLDbqi7nUMLEBFqQnteCrwYPF7Ujz0U3xZyKmXvh55s0 0+r/z9zQqpiBGvyStCs7RKBsTOJYjQU211xib4hbd2/kEW6DBED3BpeeAult/97oQoei DEqceCULolFfbV7NZSRgBRVshh/f8h/oxXr9/B8raW5lYZScHBQEiy3HV2zYpz37M2iW SN2qXmpDbOpEKwZQiGzKvqdYPZOC/6HnZa3xyp0Ix3wOx4MYtC04O+TlDKKhTEEoor5v Bcfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711148222; x=1711753022; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jnTUQM6F1e6b3ELJmMukNHuHn8ljSCVj2rp0eJe9i4Q=; b=brl2drAS+/0Mbz1wUDbNMfHSPHfPmXZIjV+umjPxoz6JxXFI54UGGV81w6+GRmn57L h1NdLezoN7R2Cr/SruudfwkjAq4tV5z/+vgtwISd/gc+SYxmJQMa8647oWl7TxHLkKwL dCX3m5fxMFdIYTVYvCaOtovKKj+jnVksubAb1HHSmxhFAaQ+0eLtXXOCaKZWsEpaaFs8 BXUc3xT9zTbFKtgZzeGbPRLYjK3kSoN04xSsyZoBVful1V0kaG5m1cWgIFwYSYMYqAE4 MdIfU8I+qhQcpjl3n1yPD/DYJxXRfN5mK/iNakzAQReSIc7zDB1I1sAu/xLXpOVPEJEb 3Kxg== X-Gm-Message-State: AOJu0YwkDVa+OdP3ndcSZdWX+yKJ7CK38fNn1wsCxZ/kmbHvwEUwfJIb 70p9euBa1HS/z2B1vYBHDJgoXojsJeSQCzbU2rN0xOshQKBFFL5/U51mSacWTeY= X-Google-Smtp-Source: AGHT+IE//GvnT6qlx/PiposzRDpKNmF80Qmxh9pJ/JDbtke1sRUE6ui9aegHDGqw8iiUvh1ekXM8PA== X-Received: by 2002:ac2:5bd0:0:b0:515:642a:a1df with SMTP id u16-20020ac25bd0000000b00515642aa1dfmr598173lfn.63.1711148221756; Fri, 22 Mar 2024 15:57:01 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id e7-20020a196907000000b005158982f42csm78530lfc.16.2024.03.22.15.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 15:57:01 -0700 (PDT) From: Dmitry Baryshkov Date: Sat, 23 Mar 2024 00:56:56 +0200 Subject: [PATCH v4 04/16] drm/msm: move msm_gpummu.c to adreno/a2xx_gpummu.c Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240323-fd-xml-shipped-v4-4-cca5e8457b9e@linaro.org> References: <20240323-fd-xml-shipped-v4-0-cca5e8457b9e@linaro.org> In-Reply-To: <20240323-fd-xml-shipped-v4-0-cca5e8457b9e@linaro.org> To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter Cc: linux-kbuild@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7616; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=LFBCygmQugB1B+c89cDmQuXR1TkW2sehOLTqu9Lzsnw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBl/gy2X7tYXhz+UoNE96ju8fLBe5oe3Q6JKjMD5 3CVHZiltn6JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZf4MtgAKCRCLPIo+Aiko 1egoCACSDHkyQQ6PvfYO64bqjCBwjvlqxVMwBPmi+8P5Kz909201GPD5yjSkJHpK0hLANqLr55r rwuDkUGc7gFKUbFQK4WatkHrfE63dKUFAAAwNZqm2FsxiV+GL30v+YdgZay6YKJNq+LHarwR9GK Hhsf/7KvKZ8Fg7PVoDd4571PnOAzWof8EYKjzTws5kbIIsBubMWii+IMWq2wDYHPLQ2ZUX9C3Lk oZTj37XJZ43AxYAKk2X52YYJq1ats8BjpmeiFW6K4YsdrakG1W2v2Ap+5owFlGwOl3pL/yzu1CR GTOQXNhRwRFqKIkANT80pvWrBa7AOsaKnP8p7nrhb24UREnW X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The msm_gpummu.c implementation is used only on A2xx and it is tied to the A2xx registers. Rename the source file accordingly. Signed-off-by: Dmitry Baryshkov Reviewed-by: Akhil P Oommen --- drivers/gpu/drm/msm/Makefile | 2 +- drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 4 +- drivers/gpu/drm/msm/adreno/a2xx_gpu.h | 4 ++ .../drm/msm/{msm_gpummu.c => adreno/a2xx_gpummu.c} | 45 ++++++++++++---------- drivers/gpu/drm/msm/msm_mmu.h | 5 --- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index b21ae2880c71..26ed4f443149 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -8,6 +8,7 @@ msm-y := \ adreno/adreno_device.o \ adreno/adreno_gpu.o \ adreno/a2xx_gpu.o \ + adreno/a2xx_gpummu.o \ adreno/a3xx_gpu.o \ adreno/a4xx_gpu.o \ adreno/a5xx_gpu.o \ @@ -113,7 +114,6 @@ msm-y += \ msm_ringbuffer.o \ msm_submitqueue.o \ msm_gpu_tracepoints.o \ - msm_gpummu.o msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \ dp/dp_debug.o diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c index 0d8133f3174b..0dc255ddf5ce 100644 --- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c @@ -113,7 +113,7 @@ static int a2xx_hw_init(struct msm_gpu *gpu) uint32_t *ptr, len; int i, ret; - msm_gpummu_params(gpu->aspace->mmu, &pt_base, &tran_error); + a2xx_gpummu_params(gpu->aspace->mmu, &pt_base, &tran_error); DBG("%s", gpu->name); @@ -469,7 +469,7 @@ static struct msm_gpu_state *a2xx_gpu_state_get(struct msm_gpu *gpu) static struct msm_gem_address_space * a2xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev) { - struct msm_mmu *mmu = msm_gpummu_new(&pdev->dev, gpu); + struct msm_mmu *mmu = a2xx_gpummu_new(&pdev->dev, gpu); struct msm_gem_address_space *aspace; aspace = msm_gem_address_space_create(mmu, "gpu", SZ_16M, diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.h b/drivers/gpu/drm/msm/adreno/a2xx_gpu.h index 161a075f94af..53702f19990f 100644 --- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.h @@ -19,4 +19,8 @@ struct a2xx_gpu { }; #define to_a2xx_gpu(x) container_of(x, struct a2xx_gpu, base) +struct msm_mmu *a2xx_gpummu_new(struct device *dev, struct msm_gpu *gpu); +void a2xx_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base, + dma_addr_t *tran_error); + #endif /* __A2XX_GPU_H__ */ diff --git a/drivers/gpu/drm/msm/msm_gpummu.c b/drivers/gpu/drm/msm/adreno/a2xx_gpummu.c similarity index 67% rename from drivers/gpu/drm/msm/msm_gpummu.c rename to drivers/gpu/drm/msm/adreno/a2xx_gpummu.c index f7d1945e0c9f..39641551eeb6 100644 --- a/drivers/gpu/drm/msm/msm_gpummu.c +++ b/drivers/gpu/drm/msm/adreno/a2xx_gpummu.c @@ -5,30 +5,33 @@ #include "msm_drv.h" #include "msm_mmu.h" -#include "adreno/adreno_gpu.h" -#include "adreno/a2xx.xml.h" -struct msm_gpummu { +#include "adreno_gpu.h" +#include "a2xx_gpu.h" + +#include "a2xx.xml.h" + +struct a2xx_gpummu { struct msm_mmu base; struct msm_gpu *gpu; dma_addr_t pt_base; uint32_t *table; }; -#define to_msm_gpummu(x) container_of(x, struct msm_gpummu, base) +#define to_a2xx_gpummu(x) container_of(x, struct a2xx_gpummu, base) #define GPUMMU_VA_START SZ_16M #define GPUMMU_VA_RANGE (0xfff * SZ_64K) #define GPUMMU_PAGE_SIZE SZ_4K #define TABLE_SIZE (sizeof(uint32_t) * GPUMMU_VA_RANGE / GPUMMU_PAGE_SIZE) -static void msm_gpummu_detach(struct msm_mmu *mmu) +static void a2xx_gpummu_detach(struct msm_mmu *mmu) { } -static int msm_gpummu_map(struct msm_mmu *mmu, uint64_t iova, +static int a2xx_gpummu_map(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt, size_t len, int prot) { - struct msm_gpummu *gpummu = to_msm_gpummu(mmu); + struct a2xx_gpummu *gpummu = to_a2xx_gpummu(mmu); unsigned idx = (iova - GPUMMU_VA_START) / GPUMMU_PAGE_SIZE; struct sg_dma_page_iter dma_iter; unsigned prot_bits = 0; @@ -53,9 +56,9 @@ static int msm_gpummu_map(struct msm_mmu *mmu, uint64_t iova, return 0; } -static int msm_gpummu_unmap(struct msm_mmu *mmu, uint64_t iova, size_t len) +static int a2xx_gpummu_unmap(struct msm_mmu *mmu, uint64_t iova, size_t len) { - struct msm_gpummu *gpummu = to_msm_gpummu(mmu); + struct a2xx_gpummu *gpummu = to_a2xx_gpummu(mmu); unsigned idx = (iova - GPUMMU_VA_START) / GPUMMU_PAGE_SIZE; unsigned i; @@ -68,13 +71,13 @@ static int msm_gpummu_unmap(struct msm_mmu *mmu, uint64_t iova, size_t len) return 0; } -static void msm_gpummu_resume_translation(struct msm_mmu *mmu) +static void a2xx_gpummu_resume_translation(struct msm_mmu *mmu) { } -static void msm_gpummu_destroy(struct msm_mmu *mmu) +static void a2xx_gpummu_destroy(struct msm_mmu *mmu) { - struct msm_gpummu *gpummu = to_msm_gpummu(mmu); + struct a2xx_gpummu *gpummu = to_a2xx_gpummu(mmu); dma_free_attrs(mmu->dev, TABLE_SIZE, gpummu->table, gpummu->pt_base, DMA_ATTR_FORCE_CONTIGUOUS); @@ -83,16 +86,16 @@ static void msm_gpummu_destroy(struct msm_mmu *mmu) } static const struct msm_mmu_funcs funcs = { - .detach = msm_gpummu_detach, - .map = msm_gpummu_map, - .unmap = msm_gpummu_unmap, - .destroy = msm_gpummu_destroy, - .resume_translation = msm_gpummu_resume_translation, + .detach = a2xx_gpummu_detach, + .map = a2xx_gpummu_map, + .unmap = a2xx_gpummu_unmap, + .destroy = a2xx_gpummu_destroy, + .resume_translation = a2xx_gpummu_resume_translation, }; -struct msm_mmu *msm_gpummu_new(struct device *dev, struct msm_gpu *gpu) +struct msm_mmu *a2xx_gpummu_new(struct device *dev, struct msm_gpu *gpu) { - struct msm_gpummu *gpummu; + struct a2xx_gpummu *gpummu; gpummu = kzalloc(sizeof(*gpummu), GFP_KERNEL); if (!gpummu) @@ -111,10 +114,10 @@ struct msm_mmu *msm_gpummu_new(struct device *dev, struct msm_gpu *gpu) return &gpummu->base; } -void msm_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base, +void a2xx_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base, dma_addr_t *tran_error) { - dma_addr_t base = to_msm_gpummu(mmu)->pt_base; + dma_addr_t base = to_a2xx_gpummu(mmu)->pt_base; *pt_base = base; *tran_error = base + TABLE_SIZE; /* 32-byte aligned */ diff --git a/drivers/gpu/drm/msm/msm_mmu.h b/drivers/gpu/drm/msm/msm_mmu.h index eb72d3645c1d..88af4f490881 100644 --- a/drivers/gpu/drm/msm/msm_mmu.h +++ b/drivers/gpu/drm/msm/msm_mmu.h @@ -42,7 +42,6 @@ static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev, struct msm_mmu *msm_iommu_new(struct device *dev, unsigned long quirks); struct msm_mmu *msm_iommu_gpu_new(struct device *dev, struct msm_gpu *gpu, unsigned long quirks); -struct msm_mmu *msm_gpummu_new(struct device *dev, struct msm_gpu *gpu); static inline void msm_mmu_set_fault_handler(struct msm_mmu *mmu, void *arg, int (*handler)(void *arg, unsigned long iova, int flags, void *data)) @@ -53,10 +52,6 @@ static inline void msm_mmu_set_fault_handler(struct msm_mmu *mmu, void *arg, struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent); -void msm_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base, - dma_addr_t *tran_error); - - int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr, int *asid); struct iommu_domain_geometry *msm_iommu_get_geometry(struct msm_mmu *mmu);