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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5E6CEB64DC for ; Tue, 27 Jun 2023 10:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9ALSYM1L2CJOxbhnOaY2aFfiS9cEAAcIeCTmWGhKYIQ=; b=HDuMnO2+6PFymG i9b2rjDsrSM76q2HZQqZ/oTAGwD7FxECVTKBhH8+of0YcL0QQfUsCOEDG4VTRqgln4r77iT8Dy2ix jxB7gexaf1gDYZn8WcK+mw6eZ+oO9OMEMcRRzAQnF2zIGEOXpT3IuJBGYxIojEMqrwSw7DcLKs6uB atIcftwtOvCI8HC+6gdDH3Ccdlr/P6003OaOiGhQcP+FnqKw5PP9Wc5R2Su7M7rTNgjKNZmwoS3qM tKzbNLzU1jDM1obn3h8a0j338HY9x2Z+6VuaZxNBowT4Cgqxsol1x9f1p9ByR+ooQ4BjGtthpT4w8 2u7LRj89q3ZrWSTszOcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qE6Ls-00D0hk-0q; Tue, 27 Jun 2023 10:55:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qE6Lp-00D0gT-0E for linux-arm-kernel@lists.infradead.org; Tue, 27 Jun 2023 10:55:14 +0000 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230627_035513_160847_1D365A79 X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel