From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F914C433ED for ; Mon, 3 May 2021 18:22:45 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98D3A61278 for ; Mon, 3 May 2021 18:22:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98D3A61278 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4EDE383F66; Mon, 3 May 2021 18:22:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uTXRHDq57OtI; Mon, 3 May 2021 18:22:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTP id 3C950837D2; Mon, 3 May 2021 18:22:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ED673C000D; Mon, 3 May 2021 18:22:42 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 44B35C0001 for ; Mon, 3 May 2021 18:22:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 24966401B6 for ; Mon, 3 May 2021 18:22:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=nvidia.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e10nGdYHyjvP for ; Mon, 3 May 2021 18:22:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::602]) by smtp2.osuosl.org (Postfix) with ESMTPS id ADA29400B8 for ; Mon, 3 May 2021 18:22:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDo7SLVuz+HbwBFR8DpaSTasFWtbZpPyk+zZcLvUePujXtXsSasC49xBlyXkraQ3aK52yvjwGh4qit/QPWiK0PzfGO/JNZHqjdv3RwKVaqETdrs5oAYXiZ+J1T3mt24MYmngZfydCLtr2agESTqzGNTVjTQ9iAZzpkDo0XCxyENBUDlFxX6IRE2WiyJdHX83RxbISQ5R8XN3ZtsetnsUisLbMPA3C1R1J6/FYwSgLmprELJk5u3RIbUx38s5mex94KpcEaKUo3qh1OLgUMDsIgMnMpjrTc1rEDEWljgLRyrlyon1HRy2Go73zpvXx6TclvSs9AG5QDiE2xI9qhVeOA== 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=Wh603q+IyN73ofGUEV/YQVGZO2H7r0W0NPpO0A2WQB0=; b=UumbdaHPDQvd21Z5IENd5rWlcjHPgWnrztJHv8SC+QuDlxpRsiDeB36LECeAIGCz0xmzwiWPnH/5F2NZ6Bdn0cV982surzCpMbLDCUNjblVWi3vPvpfRMz6D8HYVe5tfPEb24FcpN5QzaLGOJ6USQAFBvBO6dXfX1j10TqNwx2Zv+/DCkALFCcXchPRJ0+oe7fzVFCpZI4N1fUMXfcPDOxQnyoiuw0Eu6ttuiCEZ0z3C5hj9sqDnNqJVPaZym7IzdpCo3PWtYv4T5AZGM4ED2O2kmTP8u1lKtIRfo4rBQrdNDmFcyD/sjXAZnlC76EYpNj+MkKHWwao8DyQ8swosqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=raithlin.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wh603q+IyN73ofGUEV/YQVGZO2H7r0W0NPpO0A2WQB0=; b=X7prm8j0vltbdUm9AQdhqn6TpNPHPOTJy3uVSSHnzqDaSga9yDEEo10YPqCMNapGbZyqVfyeI+AmJqylSlPz6njJidVgYjl8Lis4VoZszLlCsp/EfRBujSwVnYymOhK05dAm3NeI2VwRCjUgj+TS2D2nuzeAywo6BKbdRXVyU2VmoERDQpAwJ8t6MFBsQkt1eSoylVCwp20Q0JrTI4x5DgI3svqMiU+LaVcEaKg7s0OZOWJMUN6SIRKQETJJOW2/hiCHcTwhW7FubL+vVOQaVwKBSn1HXXVVeFsiQbtNtSYa+lOKHu7k1hh7IdCkVOp3c3/3zfC2If+r3idqvpRNrQ== Received: from MW4PR03CA0041.namprd03.prod.outlook.com (2603:10b6:303:8e::16) by BN8PR12MB3282.namprd12.prod.outlook.com (2603:10b6:408:9e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Mon, 3 May 2021 18:22:37 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::9f) by MW4PR03CA0041.outlook.office365.com (2603:10b6:303:8e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.28 via Frontend Transport; Mon, 3 May 2021 18:22:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; raithlin.com; dkim=none (message not signed) header.d=none;raithlin.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.27 via Frontend Transport; Mon, 3 May 2021 18:22:36 +0000 Received: from [10.2.50.162] (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 3 May 2021 18:22:35 +0000 Subject: Re: [PATCH 03/16] PCI/P2PDMA: Attempt to set map_type if it has not been set To: Logan Gunthorpe , , , , , , References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-4-logang@deltatee.com> <3834be62-3d1b-fc98-d793-e7dcb0a74624@nvidia.com> From: John Hubbard Message-ID: Date: Mon, 3 May 2021 11:22:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e38825af-e751-43d2-78ba-08d90e606d82 X-MS-TrafficTypeDiagnostic: BN8PR12MB3282: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8uXTH+i9MS2FHcEEHX6Ch8ZrhI34sDhqQI9x0IBImJ5+lw8FtMlKIFn0L5bZdBmuUv7PYfw52yhk0FGJVAJNdXZsiOTbxhSIOoKqJb+XvWq9caD4YaJVMbxbfyGKz1miRj4fHMG42z2JqiwJ3Tvqk567yaj2muZxvueDQXghqAGbKNXepOi642WOlhRz3GLcDUgwq9Mn1sdZCmQmxw+VeLdAcJ9bHFjDGcxzDWDWSe6TllNKwfOyoi8o/Bsms+4mbsQCktEQ8o+oK0gaNXwrd1V2mt9SQ48B8xU/TGRwLyqM6rAT+w6+EkzNn6S/r1B6KFON7Z1rwzWdhiRTRgMmo5rgP8EZizsdwtQ+hDjYZk/MoQRrrzBrZXnaWO8FnNZWOatHwFk1WXT0aCmYmfW3Z/FR7Dg3ObeUPAbOhFYgCsz0oWK488uBGuwATgkC5dQtQRlHxHC4n7MGOtV9xgFY51W1OhYOXN4SPol78jaqS8uc6/tmAQpbT96fVZwzYfVCbkMmkNT4sP4YBk/3S99+SBw06vPr3YLdQT3Es93CpssL+ipIsUEOIDuq/BodzUTsdO/UzqlURSxNqSq2mU3hUY6OliKFYGAzV6dTKZeHcwInKAchqHK9xZ/a+OehifNCHFxJw4UHP0dbZvLmnLDhqbm69BfkyihqObsVXV2Eh8/Yc4yeYkXa1+ifGxJMRQiDrGEAujXkY2T/JtGlfz15qQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(396003)(39860400002)(136003)(346002)(376002)(46966006)(36840700001)(31686004)(2616005)(478600001)(426003)(8936002)(7636003)(36860700001)(53546011)(31696002)(336012)(7416002)(16526019)(54906003)(186003)(2906002)(5660300002)(8676002)(83380400001)(86362001)(110136005)(82310400003)(16576012)(316002)(4326008)(70206006)(356005)(70586007)(47076005)(26005)(36756003)(36906005)(82740400003)(2101003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2021 18:22:36.5193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e38825af-e751-43d2-78ba-08d90e606d82 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3282 Cc: Minturn Dave B , Ira Weiny , Daniel Vetter , Dave Hansen , Robin Murphy , Matthew Wilcox , =?UTF-8?Q?Christian_K=c3=b6nig?= , Jason Gunthorpe , Jason Ekstrand , Bjorn Helgaas , Dan Williams , Stephen Bates , Jakowski Andrzej , Christoph Hellwig , Xiong Jianxin X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 5/3/21 9:17 AM, Logan Gunthorpe wrote: >> Returning a "bridge distance" from a "get map type" routine is jarring, >> and I think it is because of a pre-existing problem: the above function >> is severely misnamed. Let's try renaming it (and the other one) to >> approximately: >> >> upstream_bridge_map_type_warn() >> upstream_bridge_map_type() >> >> ...and that should fix that. Well, that, plus tweaking the kernel doc >> comments, which are also confused. I think someone started off thinking >> about distances through PCIe, but in the end, the routine boils down to >> just a few situations that are not distances at all. >> >> Also, the above will read a little better if it is written like this: >> >> ret = xa_to_value(xa_load(&provider->p2pdma->map_types, >> map_types_idx(client))); >> >> if (ret == PCI_P2PDMA_MAP_UNKNOWN) >> ret = upstream_bridge_map_type_warn(provider, client, NULL, >> GFP_ATOMIC); >> >> return ret; >> >> >>> } > > I agree that some of this has evolved in a way that some of the names > are a bit odd now. Could definitely use a cleanup, but that's not really > part of this series. When I have some time I can look at doing a cleanup > series to help with some of this. I'm OK with doing cleanup later. I just tend to call it out when I see it. > >>> static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, >>> @@ -877,7 +884,6 @@ int pci_p2pdma_map_sg_attrs(struct device *dev, struct scatterlist *sg, >>> case PCI_P2PDMA_MAP_BUS_ADDR: >>> return __pci_p2pdma_map_sg(p2p_pgmap, dev, sg, nents); >>> default: >>> - WARN_ON_ONCE(1); >> >> Why? Or at least, why, in this patch? It looks like an accidental >> leftover from something, seeing as how it is not directly related to the >> patch, and is not mentioned at all. > > Before this patch, it was required that users of P2PDMA call > pci_p2pdma_distance_many() in some form before calling > pci_p2pdma_map_sg(). So, by convention, a usable map type had to already > be in the cache. The warning was there to yell at anyone who wrote code > that violated that convention. > > This patch removes that convention and allows users to map P2PDMA pages > sight unseen and if the mapping type isn't in the cache, then it will > determine the mapping type at dma mapping time. Thus, the warning can be > removed and the function can fail normally if the mapping is unsupported. > Let's add some of those words to the commit description, perhaps, it's nice to have. Obviously a minor point though. thanks, -- John Hubbard NVIDIA _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu