Received: by 10.223.185.116 with SMTP id b49csp741305wrg; Tue, 20 Feb 2018 07:09:43 -0800 (PST) X-Google-Smtp-Source: AH8x225ba9GogstNaEo61ADMzjmQU8IDsYrVvGmIuS2ZK6ZOIKQcqMTIwMsJA8pqWmqER9B5FaoZ X-Received: by 10.101.90.130 with SMTP id c2mr15539568pgt.310.1519139383047; Tue, 20 Feb 2018 07:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519139383; cv=none; d=google.com; s=arc-20160816; b=O6IJFNZ4gh7M1wBuz2ZLlJ8GlB/lEnSYXmqKOgrjrbnyjzUNtI+7ROokGo28txGji3 6mFkdDW9eU0hp4Zc3KZ1A85D2ruMg68mMGgH7/INzEaQre31RX2QlKEf9/UIkPBf2PQ5 aw6pgdT6+SEtrGb5nPrxko55u+VhindBIbTE8tBwUH/mm7U8ftQK+nqwoI5CJ//H/JYs zHC8YUBvXIUDCgoeji4mJpQk0DGSWMJ4KgWvctkuWjPmwhgS5dJxIGRbOquioyt7JwCg XHufl696uD170mWfRxog47twVp59ebWkmFHKILQgNbbK49nHlIDsFj/FegqsWATeHDzw 4pQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=RT36GJgWkCH9+qQCvo//7t3XFGPQC0ZkuTedBV7JbcI=; b=Wthjq0PusHxpibs+x3Iix+Z3SkFEtDBEJgubGt932QqmNNijDbKpRmYJ9Pswr0I3u3 0ByQfa8MqjW7hp8HRLL4PyF+VC2tuxRgKx4CNgrxy8ExOGsQ3PwXAEFvDTs81R3k4hvR hEVU7AfnbS8qgbpwm70WAmSlzJ1RnnIfnwtOQFsaUwhi/cp47kaLGVongEmKtgs+Hj95 6KpClVBk08v2fUSxia1DfzsXLaPPBDWudH8CmMRAt++X5M3nsYIoXCpIMmsdzaXUHpxF 4Tv8heaq785+xmXOyOXsWhl25keEU8RcaKQ8/OTK5vDlmMStzyZh+hPyqM6XgzgtOSx+ EpaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t71si6326281pgb.108.2018.02.20.07.09.28; Tue, 20 Feb 2018 07:09:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752234AbeBTPHb (ORCPT + 99 others); Tue, 20 Feb 2018 10:07:31 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:43762 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751666AbeBTPH3 (ORCPT ); Tue, 20 Feb 2018 10:07:29 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7377B6A90E50B; Tue, 20 Feb 2018 23:07:10 +0800 (CST) Received: from [127.0.0.1] (10.202.227.238) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Tue, 20 Feb 2018 23:07:02 +0800 Subject: Re: [PATCH v14 1/9] LIB: Introduce a generic PIO mapping method To: Andy Shevchenko References: <1519062520-198902-1-git-send-email-john.garry@huawei.com> <1519062520-198902-2-git-send-email-john.garry@huawei.com> CC: Mika Westerberg , "Rafael J. Wysocki" , Lorenzo Pieralisi , "Rafael J. Wysocki" , Hanjun Guo , "Rob Herring" , Bjorn Helgaas , "Arnd Bergmann" , Mark Rutland , Olof Johansson , Dann Frazier , Rob Herring , Joe Perches , Benjamin Herrenschmidt , , "Linux Kernel Mailing List" , ACPI Devel Maling List , Linuxarm , Corey Minyard , devicetree , Linux-Arch , Randy Dunlap From: John Garry Message-ID: <7197ce31-c4c2-d00e-be04-1edc14c3e721@huawei.com> Date: Tue, 20 Feb 2018 15:06:51 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.238] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/02/2018 14:33, Andy Shevchenko wrote: > On Mon, Feb 19, 2018 at 7:48 PM, John Garry wrote: >> From: Zhichang Yuan >> >> In commit 41f8bba7f555 ("of/pci: Add pci_register_io_range() and >> pci_pio_to_address()"), a new I/O space management was supported. With >> that driver, the I/O ranges configured for PCI/PCIe hosts on some >> architectures can be mapped to logical PIO, converted easily between >> CPU address and the corresponding logicial PIO. Based on this, PCI >> I/O devices can be accessed in a memory read/write way through the >> unified in/out accessors. >> >> But on some archs/platforms, there are bus hosts which access I/O >> peripherals with host-local I/O port addresses rather than memory >> addresses after memory-mapped. >> >> To support those devices, a more generic I/O mapping method is introduced >> here. Through this patch, both the CPU addresses and the host-local port >> can be mapped into the logical PIO space with different logical/fake PIOs. >> After this, all the I/O accesses to either PCI MMIO devices or host-local >> I/O peripherals can be unified into the existing I/O accessors defined in >> asm-generic/io.h and be redirected to the right device-specific hooks >> based on the input logical PIO. > Hi Andy, >> +#define PIO_INDIRECT 0x01UL /* indirect IO flag */ >> +#define PIO_CPU_MMIO 0x00UL /* memory mapped io flag */ > > It looks like bitfield, but from use I don't see it. > IIRC, the orignal intention was that this would be a bit value in a bitfield. > Perhaps use enum instead? I'll change to enum to be clear. >> + resource_size_t hwaddr = -1; > >> +unsigned long >> + return -1; >> + return -1; > >> +unsigned long >> + return -1; > >> +type logic_in##bw(unsigned long addr) \ >> + type ret = -1; \ > > All types above are unsigned. I'm not sure it's the best approach to > use -1 implicitly casted to unsigned type. > > I would rather use ~0UL or alike. > Yes, I can change these. Much appreciated, John