Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4953076pxj; Wed, 9 Jun 2021 06:05:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrLq9RrDBUR7aSzxdzqdgeIDsROhvDbBngGSTG0OC7IrFMSXzFl+QGbii6/3cE2RUw7p5c X-Received: by 2002:a05:6402:344:: with SMTP id r4mr30062257edw.226.1623243900125; Wed, 09 Jun 2021 06:05:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623243900; cv=pass; d=google.com; s=arc-20160816; b=DXr0Uvgyd/4+Jt4GCdXHP2wHEV5s34vJFQOx3OrP9wMnYj+UYkPYS2gbL1LvKAfYoS JueVvnUbn4rr74bE9aPAFLA6bsC1vFN/hJM/GHfJEtGSYdxFftal0kODGelu/vpcqaKb r3ydWZHwVaglzIuwkio5TGBYFgOPCh79eWG2gbf2bIqMnaQKpiX64LH+zHrPzW2p9svb BW/yB+RMNsLI7Ftzpz748tcEqhCIYrRj5qyzSbkLyl7uAwy4PqKtpOzmjWB70z5WE4bs os8M42v8jXN56V1lc4j/sFvacSarWFKQenL2ZAg6vap7bPnbvumW1v5Gal0L/ThYosJ4 t/4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=nJTYHFKEvcJW5yuJvHYivybqE8KFb25n7flEo/NXteY=; b=tTu1fSCc3up111zCE6lBUQ+ifnGPGvmN2Vvs08FVv7upYdTD6tHH1M9mPmlU+NiM0A LxM0gC4vJH4rVdmGB8cN61byPOGQ6wRvLNW8QJ0ZOiRJWje/DY0FrUzsTM8/QZng8c/v MxgsMDgH0WZrqZHtfBM+PxhqvNdkzNYzWvEYqjjzZenS5Jw1sSKkQ9Y4Iwwj+zHz+6We X5LjZLY6gv/1hn+uLrD2LA8ZUPxxl1hIBXUm79MdGgHlFa6Bj/UMQ2OPQI7Zds7M4h87 O6BGegv/PEE4GU620Eiz0xbMfrLS5siQ2gAPWGiLu3F1zUiu/dzTzcuVujOBAn3TBNE8 FL/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=bWYZr0w5; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si2394099eds.441.2021.06.09.06.04.36; Wed, 09 Jun 2021 06:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=bWYZr0w5; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233497AbhFIGHf (ORCPT + 99 others); Wed, 9 Jun 2021 02:07:35 -0400 Received: from mail-dm6nam11on2068.outbound.protection.outlook.com ([40.107.223.68]:54497 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229942AbhFIGHe (ORCPT ); Wed, 9 Jun 2021 02:07:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k8PgaVTNXET42QV9zCoIgUIA0DW+bEwgw3WWWWmR77PkITXbk5+Ypx9NzglC5oP8oJUun36d7ud+63IwM+Z71gFGUMJ0s5/YFj9x8AFvLLbSEmSbVDuhVwuF+5oRQD+oDNESbkfFveUYOGjoBF5ua4+P6pD/EdjhgYDqPTyy8RpsUPoFf2jtlMHwHOAqwzvK7oEplOVIFCxZBs0DJuiOLU2uJj/dwD4YRupaOuLEGWWRp0sIeCrlTIwLj58+3VwrbL3tgSU0wiZtrd6iHL0iqIXNDhMIfusbSLa2rYp0yvJP3dD9fE39TDKZbVhYPFLMfVv25GZs14p4Wqb0oJdthw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nJTYHFKEvcJW5yuJvHYivybqE8KFb25n7flEo/NXteY=; b=PhNj1fQVYGV3jqSdqzI9qZFupgC0wW/x8EL668QgHpdcwJu8w39fezvmDMlnjYxB9RMtB8FB3yx++pU8x8QQNG+lckfdPfqKABbpCkCPWp5WIiE4SX94Pqmnv5ffgZ9ABVxqbkmwb8//3mHfC328JCSfS14K8dAYak+5mviT4ttmRTLCWW7mIXt1xGWMTabhEHHI/JGqNQLm4pQUJ35+kb8rZzF7BlvPZAxBHNi17KO6DXpKFyDaH4VYb3jUHzzIgNc9VR62FiA+uB0BuJe3sfc+2kOrQZVtG7Onl20NY4gk/ZbFX8/FXEDkE0YjG5UqMzq+EsE2/9PjgMkKjXMXbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nJTYHFKEvcJW5yuJvHYivybqE8KFb25n7flEo/NXteY=; b=bWYZr0w5pLHGzxcOwPlBwcE3hZ5kf/xwciqltXiV0mN+xDN5VhrdWEwoflylxv7sLlcogkFccnVWgZhFilY8sezt3hkk9B2SVWfOzFfD8As9cGNHtqrlzuaVZ/i7OMC2iAWRT3ZGByqxi7mdvEMK6MtXpWVVyruKSnV0nv+xXrc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN9PR03MB6092.namprd03.prod.outlook.com (2603:10b6:408:11d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 06:05:38 +0000 Received: from BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::502a:5487:b3ee:f61c]) by BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::502a:5487:b3ee:f61c%4]) with mapi id 15.20.4219.021; Wed, 9 Jun 2021 06:05:38 +0000 Date: Wed, 9 Jun 2021 14:05:21 +0800 From: Jisheng Zhang To: Guo Ren Cc: Nick Kossifidis , Christoph Hellwig , Drew Fustini , Anup Patel , Palmer Dabbelt , wefu@redhat.com, "Wei Wu ( =?UTF-8?B?5ZC05Lyf?=)" , linux-riscv , Linux Kernel Mailing List , linux-arch , linux-sunxi@lists.linux.dev, Guo Ren , Paul Walmsley , Benjamin Koch , Matteo Croce , Wei Fu Subject: Re: [PATCH RFC 0/3] riscv: Add DMA_COHERENT support Message-ID: <20210609140521.3038e40e@xhacker.debian> In-Reply-To: References: <1621400656-25678-1-git-send-email-guoren@kernel.org> <20210519052048.GA24853@lst.de> <20210519064435.GA3076809@x1> <20210519065352.GA31590@lst.de> <29733b0931d9dd6a2f0b6919067c7efe@mailhost.ics.forth.gr> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: SJ0PR13CA0191.namprd13.prod.outlook.com (2603:10b6:a03:2c3::16) To BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by SJ0PR13CA0191.namprd13.prod.outlook.com (2603:10b6:a03:2c3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Wed, 9 Jun 2021 06:05:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35e66c63-5c4a-4713-c880-08d92b0c9a71 X-MS-TrafficTypeDiagnostic: BN9PR03MB6092: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M2fOxA78HXwRDfbQKpeTHSv/mfqudkIq2CzGCQ2WdqWrWnbJavZpZfg+DdmAS/QqQwBpFqW/Js4h1stmDjTuz7KO217pnVzD1RFybyrIR6PSJV+d78ORZ9i3JIEhXPNVFgZHUmUD537IsKyQCH6DwSrUhfEyxXEmuGEhaHYVplgSHz4DZFO/3q6YWQeDsIhCyo6trR+wz8+XxjxzNz1dQq1XyV3O3Aj885x8e6jDE3wBgyvDIF5+xoyHK8yl95rcSxOHOOzkVAJgpl90Qoqo3kXq36BLE0Jvh+a9pR6i4Ih4z2uf/X9Y7yeInCBY1pFOlvNsVXUE2FEoJR9jZkxVLi4cmEUi+8+78NZNl6AaVzRQW6I8M/EIRHLZsvCE7R2St1VBG4TYFyFZJ3LkxmFsF5mSnsmUhnZIVZPQhhjCEFTlxjR+11lMVWai2KshdfBfHLNCnIsw1UOYYEVKfd1BIPjk+nyosg6GY6I4ZnIkf0pW7SKkvj1RCEn0DWz+v4wY8RFeq/LNmX9eHwwN6qEZaf6dlpCfxCDKUtXIG44XnDxYzGCH/FdqK+LD6h5vg3Ec2JBMQjhSqjdZRdCw/Zxm9TiSa3YhCAG9Y2MkHKx5PQLL2ATTXnHBUF3v1y81G2lEcb7ZozuJZojQZleEdothTA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR03MB6058.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(376002)(346002)(136003)(39850400004)(66946007)(66556008)(66476007)(83380400001)(53546011)(956004)(6916009)(26005)(16526019)(86362001)(186003)(8676002)(7416002)(6506007)(316002)(478600001)(4326008)(54906003)(55016002)(9686003)(7696005)(52116002)(5660300002)(38350700002)(2906002)(38100700002)(6666004)(1076003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aVNJSVVuSmlyc1JmQUR6a3JZMkVyTTFUOXVMZGQ3RGdDdnFYWW1FdXNlQ1N3?= =?utf-8?B?SDJVenpBZ2MzS3d4UWpMUjVkS1kyVCtJNnpHclVPUXYwNlZsWTVFNkFUSzRH?= =?utf-8?B?TmV6NXd6VjZFMTlVRllydzZhR1R0OVBONWQ3azZpOC9wbE9jdVZoQnlxbHNj?= =?utf-8?B?RHhVZDNnY3ZSc2tRbEZrOEtjaEJDL01VZ2o2QlFNUUZLVWdOaSt6Y013MExa?= =?utf-8?B?azM1dTByV2wrOGZRbnlLY1hIbkh5dStPelpRVmNJOWxsN1ppTStabTZCY2dJ?= =?utf-8?B?NlM1QnBueEZraUx0M1lONkJ4aXRXdlI4TXd0UHJGcit6RVBtRGgxK3RuNmpM?= =?utf-8?B?eXIvR09HY3ZCY2RobVorU0xkbm5ob3JZaDFvUHZEa3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T3FZTE11dWxzcWpuKzk1dHZYaWFHY0VISDVn?= =?utf-8?B?dVVNVGM0ZGt1UDd3R0poM1pTUWpEalJVcHcvMWFOWXFxRFJTajlvZlllSlFa?= =?utf-8?B?b3AydG91OVJHcHZTdng2Q1E1aThrc0FlRVZyYXN4dmF0QjV6bFY1d3R5MFhz?= =?utf-8?B?M1kzUWJxVkYwY2VEWVdPUGRLYlF4ZFkxb1cyc2xvb1hsTnNvUmI4RExySVNB?= =?utf-8?B?SzBKYmNEam41YU9MeEVReEhYUE1jeVZIeUdyRnJmTGRnWmNkZTFsQnhIQjRQ?= =?utf-8?B?TkRlN2R3ZU1wczZxWHBLTUtJY2x1NUI4MGQ2QzV0QXF2VGFyUWdIa05pd2U1?= =?utf-8?B?UEc1cUVWMTJvV1Y5N09wbmx3cVFXSzdoRGZCQ0pYUWdGVllIOFhvQTh0cjRF?= =?utf-8?B?QnYxWjVHZTJJT3J0Tjl2VHRId3p0cFg4QTJ0TnVreDNZdUVLWkZoRFpUU2hM?= =?utf-8?Q?PYgloUhPsksAko8KvgrjWOLKV2A5ohpE2F+G9ws?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35e66c63-5c4a-4713-c880-08d92b0c9a71 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 06:05:38.2377 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TUDfMEROW9xoyOQf8GTuUFF/oxj6e6c6FqZqIg4kfZhI/M/6/Xa89TMK6zgx4sCSBWCX7NCgvmDdZ4htgWEGDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6092 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Jun 2021 11:28:19 +0800 Guo Ren wrote: >=20 >=20 > On Mon, Jun 7, 2021 at 2:14 AM Nick Kossifidis wrote: > > > > =CE=A3=CF=84=CE=B9=CF=82 2021-05-20 04:45, Guo Ren =CE=AD=CE=B3=CF=81= =CE=B1=CF=88=CE=B5: =20 > > > On Wed, May 19, 2021 at 2:53 PM Christoph Hellwig wrote:= =20 > > >> > > >> On Tue, May 18, 2021 at 11:44:35PM -0700, Drew Fustini wrote: =20 > > >> > This patch series looks like it might be useful for the StarFive J= H7100 > > >> > [1] [2] too as it has peripherals on a non-coherent interconnect. = GMAC, > > >> > USB and SDIO require that the L2 cache must be manually flushed af= ter > > >> > DMA operations if the data is intended to be shared with U74 cores= [2]. =20 > > >> > > >> Not too much, given that the SiFive lineage CPUs have an uncached > > >> window, that is a totally different way to allocate uncached memory.= =20 > > > It's a very big MIPS smell. What's the attribute of the uncached > > > window? (uncached + strong-order/ uncached + weak, most vendors still > > > use AXI interconnect, how to deal with a bufferable attribute?) In > > > fact, customers' drivers use different ways to deal with DMA memory i= n > > > non-coherent SOC. Most riscv SOC vendors are from ARM, so giving them > > > the same way in DMA memory is a smart choice. So using PTE attributes > > > is more suitable. > > > > > > 4.4.1 > > > The draft supports custom attribute bits in PTE. > > > =20 > > > > Not only it doesn't support custom attributes on PTEs: > > > > "Bits63=E2=80=9354 are reserved for future standard use and must be zer= oed by > > software for forward compatibility." > > > > It also goes further to say that: > > > > "if any of these bits are set, a page-fault exception is raised" =20 > Agree, when our processor's mmu works in compatible mmu, we must keep > "Bits63=E2=80=9354 bit" zero in Linux. > So, I think this is the first version of the PTE format. >=20 > If the "PBMT" extension proposal is approved, it will cause the second > version of the PTE format. >=20 > Maybe in the future, we'll get more versions of the PTE formats. >=20 > So, seems Linux must support multi versions of PTE formats with one > Image, right? >=20 > Okay, we could stop arguing with the D1 PTE format. And talk about how > to let Linux support multi versions of PTE formats that come from the > future RISC-V privilege spec. >=20 Just my humble opinion: When those bits(63~54) usage are standardized in future RISC-V privilege sp= ec generic Image can still be supported with the following solutions: *alternative patch only fly: If the bit is only need to be set during init, we may insert nop instructio= n(s) at proper place, then patch the nop into set_the_target_bit instruction(s) = by hart's feature. *normal check feature then use: If the feature needs a bit complex code, we could go through the "feature c= heck then use". static key tech can be used here to avoid branches.