From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 6CB4F1FC7F0 for ; Fri, 17 Jan 2025 11:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737111710; cv=none; b=TkRXM3UtQyhaqnfM+LB93OF0VA07kBXJrTppgo/uoEcDA2NHkX6iogUQq5j2kZl6/xZC8X+sDXosjNqSFn8iYjeNhRq8poNducw0p3C0CFMLsfhRn3FatIRBnY7iSP5SxF2/ffR1beenkvYR5yqirqeOZ232jxDKqtM9Se1Lqio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737111710; c=relaxed/simple; bh=Hp1z9ocGjwtN8MDrn94x6SxksYySCfDqw/WopDHVokQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S56o+yDAyDXgIY2b6Pa7kFRALRjO0nnVH58RN0yygwTUV0NEwfx2wqK3mm5zgq3e3JipWK6JOGjv+KjSHcPenjuULQ3vnVeh5UakIh31kEZ8vejRihkxun+O0afcCnlWuIVZxaLBtt3FpbDGQJYonkXcJ/MTX27N7nn4r7qlML8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mLFOi9Hu; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mLFOi9Hu" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-53e3778bffdso2190389e87.0 for ; Fri, 17 Jan 2025 03:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737111706; x=1737716506; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2/hfVNdiD8ZF1+lHEjxob8Hwbpl53iD8/OV5iv22cOQ=; b=mLFOi9HuY30Y/4F9Wq7xnnG6fdkmlWzhY/7dSs14dNVvcS4+xfpW5UXbm0Ayr0HGkw mRiJmYjYHNnylCB34NxOLeX7anRJkCusHIqAMU5zW0UmMyR/+vk2Y2KW87GF1GJkcUgD OSx94Jdfj/5riQnoYc0lFylsfnWHu0AU0JBuNAETRMP4HeA1db0O4Q2CTcVdu+LlNoNy +/sjaGYAG45hu2kyz9RVNiC6h0L3tvA6ltc0QF/OQtBTxf64pGh0QetsVvhq+bepM/hO YdhEVvvyqWnagpVrFAsoDaf691rN5NkG0/Wz7IP3ehK59yjK/WceIZUPkGwGQo6Je1JT /hpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737111706; x=1737716506; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2/hfVNdiD8ZF1+lHEjxob8Hwbpl53iD8/OV5iv22cOQ=; b=hRqYQrLRLl+L89Q0akyIM2eJ9DDaGBDlk8ChbqX5VF2R9VFF7ivSb6oMhUi51FmShi TPEcw14AYFdMReS8t9yarPlieqtFkGs+KPOfN0rMRVTrQklfUYbUc4fTeJGxLwOoxhRL vNX3poC8pEBGy2ypPp1pN19nmumYeVjeWcrEJguC7UgGM8xe04ZWhmfhiXKYPQTJXtrr dpYkoKWTBN8MF04OTDomPAzdmRTZO56s2Dk11P2VDjA59k7Co81XDINVir/w0eb7EkLo VP1q0gwyinnlPqDElnrt05co3hINjeWvbYqLjz50Gnh+wuF1WD7c5rGzZe4smJn7AdVr vUyQ== X-Forwarded-Encrypted: i=1; AJvYcCWnyL2cxLnB7roH5+UrcAKY5tnce9uhOZvzVnCw9GYKpyISw4NPYRLeoh78z/TMceKKpyMtYpF3Jajns7c=@vger.kernel.org X-Gm-Message-State: AOJu0YwAz/d2XF+pyGeteV124FmawxpdQLrLi9AL4tDVcvm4TDolnFcf 71fTfErn0urU+ZU5uBtXzG4TeP/TWwd52fItnGhILj4GwR+jhG9Y X-Gm-Gg: ASbGncsRnziCGFfT16vg+ZnUYv8jKi9R2tIzDRTSMHMHzcQHpPoE9TEG/7ru0CEVBRC MER/Yu4PWWuPEweQffMdxt5V3AJro6VSESCcgR2QhUqHMOkb0XqAmMSzpznEp3vgjIYz1FhvFKU bibvfVGunhAFyi/cBZ7487ZwogLfjVCUHXI61AuTqz8zRCdoOkL00abL+Ejn5uU6jTKJDybzZqJ oQXr9ozAMZP0zl9GnyitcYFBB0by1il6rYMXIqxWxbHTaW1 X-Google-Smtp-Source: AGHT+IGe9It4lgmzQxKKvYmVgRpdLyID9nZin78MkWk3aMz0P/C1ucyECRHRA+UcEu1r+TOQPaKuzg== X-Received: by 2002:a05:6512:128d:b0:542:238d:d714 with SMTP id 2adb3069b0e04-5439c2855e3mr811983e87.32.1737111705421; Fri, 17 Jan 2025 03:01:45 -0800 (PST) Received: from curiosity ([5.188.167.4]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5439af7364esm313195e87.162.2025.01.17.03.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 03:01:44 -0800 (PST) Date: Fri, 17 Jan 2025 14:01:41 +0300 From: Sergey Matyukevich To: Christoph Hellwig Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Albert Ou , Alexandre Ghiti , Conor Dooley , Robin Murphy , Lad Prabhakar , Geert Uytterhoeven Subject: Re: [PATCH] riscv: select DMA_DIRECT_REMAP by RISCV_ISA_SVPBMT and ERRATA_THEAD_MAE Message-ID: References: <20250116172950.1989748-1-geomatsi@gmail.com> <20250117075238.GA25422@lst.de> <20250117095832.GB2585@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250117095832.GB2585@lst.de> Hi Christoph, On Fri, Jan 17, 2025 at 10:58:32AM +0100, Christoph Hellwig wrote: > On Fri, Jan 17, 2025 at 11:38:47AM +0300, Sergey Matyukevich wrote: > > > Please explain what this is supposed to solve, because the above > > > explanation dosn't make any sense. DMA_DIRECT_REMAP is one > > > of the implementations supporting dma coherent allocatiosn for > > > non-coherent devices. So selecting it from something that > > > just keyes off support for an extension, but not the dma > > > implementation is wrong. > > > > Now DMA_DIRECT_REMAP is selected either by Zicbom (standard) or XTheadCmo > > (vendor) RISC-V extensions. > > Because they need DMA_DIRECT_REMAP to implement DMA coherent. > > > However neither of them can help to implement > > DMA_DIRECT_REMAP on RISC-V. So selection of DMA_DIRECT_REMAP has been > > moved in Kconfigs to Svpbmt and XTheadMae extensions. > > But Svpbmt does not imply that you even need DMA_DIRECT_REMAP. > > Are you tying to solve a problem here? If so can you explain it? Sure. In brief, this about the choice between DMA_GLOBAL_POOL and DMA_DIRECT_REMAP. We can use either of them to work with non-coherent devices. But on RISC-V those two options require different extensions. If we select DMA_GLOBAL_POOL, then we need only cache operations. So on RISC-V it is enough to have Zicbom (standard) or XTheadCmo (vendor) or any other vendor specific cache ops implemented using RISCV_ALTERNATIVE or RISCV_NONSTANDARD_CACHE_OPS. Using DMA_DIRECT_REMAP requires not only cache management operations, but also a way to modify page attributes, e.g. to mark it non-cacheable. So on RISC-V in addition to CMO extensions we also need extensions for page-based memory types such as Svpbmt (standard) or XTheadMae (vendor). Current RISC-V Kconfig files enable DMA_DIRECT_REMAP for Zicbom and XTheadCmo. According to the above comments, this is not good: - it is wrong since Zicbom alone is not enough for DMA_DIRECT_REMAP - it prevents using DMA_GLOBAL_POOL for platforms without support for page-based memory attributes My suggestion was to move DMA_DIRECT_REMAP to the Kconfig entries for Svpbmt and XTheadMae. In this case platforms without Svpbmt support can disable it in kernel config and switch to DMA_GLOBAL_POOL instead. IIUC one of your concerns was selecting DMA_DIRECT_REMAP under config option not related to DMA implementations. Does it make sense to add additional layer similar to RISCV_DMA_NONCOHERENT ? Regards, Sergey