Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp263948pxu; Thu, 7 Jan 2021 04:32:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDKfp4aWnWGp3PJ6DM9UMGarLll/VwDM8l7Aaqz4apQygpCbnVSq6YpEJeKjGZ1+dqdo0G X-Received: by 2002:a17:906:a29a:: with SMTP id i26mr6078139ejz.45.1610022740836; Thu, 07 Jan 2021 04:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610022740; cv=none; d=google.com; s=arc-20160816; b=cG4DFOlZn3tubEyvlJRLQZy8Zn81ck/BK9rD/+6xGS8jzjFOVceyQE9oUX5/cpaBEf 7wrkziU0Zd0B1c+56I2ghXOIUyGnYYwhySyOJhEopivT1c8FAgmBM8lw0IKzeH5iAYBY IKEC0xBihHHXRunVM7yYP37aZfpqxWsL+SDaXZDJtcgRxXb6rls+rPuQQa9TPdSI6vGJ 2NeApEiMnpQ4OQRXxKMf4dr64zq+2SrD4qDepsutKhHKzWDsRgRGlaY8S3/sERqZT9sV fi1+WthzWyjJkU5ryvtvOv3a85FfigSuccrJOfKGCi3iz/P2zly+JYdq1KUPI8jswTYQ qRdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=7bTa9hCW2Qy7EjEUDXrq1GSOGRJ1LccWmtW1MCQzgvc=; b=NO5kfaO+mP1QKiAklcTGdxi/fPornYG1gA2r3hKk809Zf9kUGOC33V/8xdpejpmJv8 jwmTja+gj9WwyBC/droqoFMXLDEfWY+HT6VcphJ806lFYvIzxHjjmBT+FesA/g0djOu+ 2nAwh2uWZg8UyrTX7vOJXWiGosLVvvkoTCKSF38UoKBQ4LBbP6CXxohNdwG9WhoWYa+R YAnWHbEm1KluFykjgUhbJjVh266c7xI0C3CePbY5BJD1ROPh72mSmG61MIg/rxTJcTxc DhDaPMDMYXa1AGMBIiC/Uq+da679inXK/GDm83l7d6Qu0IIjaKmMZPrMnEVzJK8QIYSS pkqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si2207804edj.120.2021.01.07.04.31.56; Thu, 07 Jan 2021 04:32:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728174AbhAGMam (ORCPT + 99 others); Thu, 7 Jan 2021 07:30:42 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:57299 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725835AbhAGMal (ORCPT ); Thu, 7 Jan 2021 07:30:41 -0500 X-UUID: 019e05679d6c4e05be293d4c8e860417-20210107 X-UUID: 019e05679d6c4e05be293d4c8e860417-20210107 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2097611858; Thu, 07 Jan 2021 20:30:18 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jan 2021 20:30:16 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 7 Jan 2021 20:30:15 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Robin Murphy CC: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , , Christoph Hellwig , David Laight Subject: [PATCH v4 5/7] iommu/io-pgtable: Allow io_pgtable_tlb ops optional Date: Thu, 7 Jan 2021 20:29:07 +0800 Message-ID: <20210107122909.16317-6-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210107122909.16317-1-yong.wu@mediatek.com> References: <20210107122909.16317-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch allows io_pgtable_tlb ops could be null since the IOMMU drivers may use the tlb ops from iommu framework. Signed-off-by: Yong Wu --- include/linux/io-pgtable.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index ea727eb1a1a9..2a5686ca2ba3 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -214,14 +214,16 @@ struct io_pgtable_domain_attr { static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop) { - iop->cfg.tlb->tlb_flush_all(iop->cookie); + if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_all) + iop->cfg.tlb->tlb_flush_all(iop->cookie); } static inline void io_pgtable_tlb_flush_walk(struct io_pgtable *iop, unsigned long iova, size_t size, size_t granule) { - iop->cfg.tlb->tlb_flush_walk(iova, size, granule, iop->cookie); + if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_walk) + iop->cfg.tlb->tlb_flush_walk(iova, size, granule, iop->cookie); } static inline void @@ -229,7 +231,7 @@ io_pgtable_tlb_add_page(struct io_pgtable *iop, struct iommu_iotlb_gather * gather, unsigned long iova, size_t granule) { - if (iop->cfg.tlb->tlb_add_page) + if (iop->cfg.tlb && iop->cfg.tlb->tlb_add_page) iop->cfg.tlb->tlb_add_page(gather, iova, granule, iop->cookie); } -- 2.18.0