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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AFFBEB64DD for ; Tue, 27 Jun 2023 10:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbjF0KzK (ORCPT ); Tue, 27 Jun 2023 06:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231268AbjF0KzJ (ORCPT ); Tue, 27 Jun 2023 06:55:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 813E219AA; Tue, 27 Jun 2023 03:55:08 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2088D2F4; Tue, 27 Jun 2023 03:55:52 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CAF8C3F64C; Tue, 27 Jun 2023 03:55:04 -0700 (PDT) Message-ID: <73f11258-1562-17c1-969e-b134dcb5f35c@arm.com> Date: Tue, 27 Jun 2023 11:55:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 1/7] swiotlb: make io_tlb_default_mem local to swiotlb.c To: Greg Kroah-Hartman , Petr Tesarik Cc: Stefano Stabellini , Thomas Bogendoerfer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "Rafael J. Wysocki" , Juergen Gross , Oleksandr Tyshchenko , Christoph Hellwig , Marek Szyprowski , Andy Shevchenko , Hans de Goede , Jason Gunthorpe , Kees Cook , Saravana Kannan , "moderated list:XEN HYPERVISOR ARM" , "moderated list:ARM PORT" , open list , "open list:MIPS" , "open list:XEN SWIOTLB SUBSYSTEM" , Roberto Sassu , Kefeng Wang , petr@tesarici.cz References: <2023062745-routing-palace-d0b4@gregkh> Content-Language: en-GB From: Robin Murphy In-Reply-To: <2023062745-routing-palace-d0b4@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On 27/06/2023 11:24 am, Greg Kroah-Hartman wrote: > On Tue, Jun 27, 2023 at 11:54:23AM +0200, Petr Tesarik wrote: >> +/** >> + * is_swiotlb_active() - check if the software IO TLB is initialized >> + * @dev: Device to check, or %NULL for the default IO TLB. >> + */ >> bool is_swiotlb_active(struct device *dev) >> { >> - struct io_tlb_mem *mem = dev->dma_io_tlb_mem; >> + struct io_tlb_mem *mem = dev >> + ? dev->dma_io_tlb_mem >> + : &io_tlb_default_mem; > > That's impossible to read and maintain over time, sorry. > > Please use real "if () else" lines, so that it can be maintained over > time. Moreover, it makes for a horrible interface anyway. If there's a need for a non-specific "is SWIOTLB present at all?" check unrelated to any particular device (which arguably still smells of poking into implementation details...), please encapsulate it in its own distinct helper like, say, is_swiotlb_present(void). However, the more I think about it, the more I doubt that logic like octeon_pci_setup() can continue to work properly at all if SWIOTLB allocation becomes dynamic... :/ Thanks, Robin.