Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp93340rwe; Thu, 13 Apr 2023 22:58:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0vKvVe2Xs8I7lSXV2HlPE7KKgjhkLw483HjqaEBdwKexKtgTmZgHnE4Gu1Jhu521hELoP X-Received: by 2002:a17:902:f690:b0:1a6:6b30:2b3b with SMTP id l16-20020a170902f69000b001a66b302b3bmr1709714plg.64.1681451916305; Thu, 13 Apr 2023 22:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681451916; cv=none; d=google.com; s=arc-20160816; b=lwE53hJ7DUjH2SlfzZ0+MkHi5fuoAMjrgacZpi96VuZdr3sIAw5tNeVFiIqYUpqfIP T5LHtNFwuTqij8mFes4p340ht6Bfgn1lnRdW/Bf9Lw+2dlgq4vjhc6QQwQKnEBjtAXZC FTqjNfsK7rBDg/I81SUliXKdal7v7Ih+AdFmFWVL9XE4iU4uM0G4BIk+obKQZ55wOO48 lb/WS6aKEbEIeXXyYckBMbN1tpK6gbA8Nex8/8LqyKFkfR7B57G+R4NjBwwi2vDY1I9p w2a7CMUx/Ui2pYDMt1mfoUlkF/1lPdzkYxe+q/ngPJeTubZ+6iilV7/G32sWIKRIt8wq Kxrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vDEmKAwqsAzYhB9mA/dekTjtCBjY4b15AmaH++f9BvY=; b=eL+p4ZSoPAP8FUaF4rl7F/gkbiVnKWw1dF4tiaJ9nl7/OYRcRaUIuYer0+srUkbnkc UtnPn90oTa+l3hPHk9pnEscFGTBWc+CAwo0Asgg7EoANADpelSx1HoDhw/2XAgnkmbxr e33Cutb/6LuYX5Fx9xpzoDwIvgTPIA/KmnplGcfI8mlu+MJTOoe/0XV3vDFLbknySimw p+iwegn30q6ylZZRe0+xjEJ4e5yxdJll/VVr4Gy6LhnU9HYXrmmtgY3se/7YZUQQSjPZ S1yFfkKsjE2yilU3GYU8pFVfmQXKH8/3bsXUSmV/4wVw7isXO0PwxG2zCJCMaxJYf2EU aF4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="Csiz/Mdq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a63834a000000b00518c256b38asi551346pge.785.2023.04.13.22.58.23; Thu, 13 Apr 2023 22:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="Csiz/Mdq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjDNF5c (ORCPT + 99 others); Fri, 14 Apr 2023 01:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjDNF5a (ORCPT ); Fri, 14 Apr 2023 01:57:30 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67DBF4EEA; Thu, 13 Apr 2023 22:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=vDEmKAwqsAzYhB9mA/dekTjtCBjY4b15AmaH++f9BvY=; b=Csiz/MdqOxesMZcuF5yeFmGPKm gVLN/72UmzB8H04ZwM8m4Hf5XOEYh+wmaVS10wkiDAgeWG8XDIbkkTrRTAWpVo6G9QevEDEmLEFOM K724Te9jy0zacsuaIOLmI5/D4Kxx4yqbFx9jG8+MOleS+9GMDdVoivmSvY6ZJpT/tu0o9URKHQBdT eYk4ZfvpQPo6kY2F9ks+EQ2ear3gBHMC7uu384IsedKe6a2nH7owoo7Air5lp8acC0gFtG7+CMySI VUeZMJcIqhWEc1HfAswU1Vi8oqFZWSVIXNezgjlibnf0o0i9XykYMCLKxXtoxbW1RnQ2IvPT6aBSa JTI/tgsw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pnCR7-008Pvy-0p; Fri, 14 Apr 2023 05:57:29 +0000 Date: Thu, 13 Apr 2023 22:57:29 -0700 From: Christoph Hellwig To: Kelvin.Cao@microchip.com Cc: hch@infradead.org, dmaengine@vger.kernel.org, vkoul@kernel.org, George.Ge@microchip.com, linux-kernel@vger.kernel.org, logang@deltatee.com Subject: Re: [PATCH v2 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver Message-ID: References: <20230403180630.4186061-1-kelvin.cao@microchip.com> <20230403180630.4186061-2-kelvin.cao@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 13, 2023 at 11:22:14PM +0000, Kelvin.Cao@microchip.com wrote: > On Mon, 2023-04-10 at 18:42 +0200, Christoph Hellwig wrote: > > > > > +???? writew((__force u16)cpu_to_le16(SWITCHTEC_DMA_SQ_SIZE), > > > +??????????? &swdma_chan->mmio_chan_fw->sq_size); > > > +???? writew((__force u16)cpu_to_le16(SWITCHTEC_DMA_CQ_SIZE), > > > +??????????? &swdma_chan->mmio_chan_fw->cq_size); > > > > This looks broken to me, writew always expects cpu endian arguments > > and byte swaps on big endian systems. > > Do you mean writew assumes the peripherals be little-endian, and will > do the swap when host is bit-endian? Yes. All the standard mmio accessors ({read,write}{b,w,l,q}) do that. > > But I find the whole pcim_iomap_table concept very confusing to the > > reader of the driver, and given that it doesn't really use many > > devm or pcim routines I'd suggest removing them all and sticking to > > one well understood way of manging resource lifetimes. > > I didn't get it. Do you have specific suggestion? - instead of pcim_enable_device call pci_enable_device, and then just call pci_disable_device in ->remove and on error - instead of pcim_iomap_regions, call pci_request_mem_regions on probe, and pci_release_mem_regions on release / fail, and then do an ioremap(pci_resource_start(pdev, 1) for the actual bar (and iounmap on release/fail) instead of pcim_iomap_table. > > dma_set_mask_and_coherent for a smaller mask will never succeed when > > trying to set it to a larger one failed.? So you can remove the > > second > > call here. > > By default the kernel assumes the device can address 32-bit address > space, Yes. > I wonder why it wouldn't allow 32-bit mask when it failes 64- > bit? The kernel never fails setting a 64-bit DMA mask, it only fails setting too small masks.