From patchwork Wed Oct 21 15:52:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 55393 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 731B823024 for ; Wed, 21 Oct 2015 15:55:09 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf22428200wiy.2 for ; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:spamdiagnosticoutput :spamdiagnosticmetadata:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=hOjLY/QKYTJB758nesjjUMloX3nORiR33oWPushtDe4=; b=l0xJhvMq8/aNeMfoI8E+mTuDSv9o2PunuQqGuKNiRrRhtMovUXxtMQ10viv8rVAJW5 eglf7KFzh29N+1YIRMLPpL7I2sudSxj1xhq74eiZihmT2i/f3n49tWyGMZH1I0hE51JX dGuyjcMsE2zTWThtYLgWDvrh3ok8bWRxACyFbalae8SrF1aBfFsbKEtA8dpm0YHMhh0c 5QyzgxjSN7eet+G+PyANgq3VztBaPItE3o91JoPpVl0bXzoHMvurFjI1lEUPzOgOKlbW F8GawrxrDPB0jXN9xMykcj87LE0aAJx5BVdedGu7E90ihG9Dth7imSHB3eJ4nAIHJb9R xGlg== X-Gm-Message-State: ALoCoQkvXnY2LZAwBQVqBzp+s5pQvUJpIUsXgWqFPhj75WGX1bzdPc0LQzr8sLh0wZ8P3Fmet/vZ X-Received: by 10.112.159.4 with SMTP id wy4mr2350264lbb.15.1445442908722; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.80.140 with SMTP id e134ls250180lfb.42.gmail; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) X-Received: by 10.112.158.1 with SMTP id wq1mr5740569lbb.67.1445442908585; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id 39si6875246lft.44.2015.10.21.08.55.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2015 08:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcao8 with SMTP id ao8so41706120lbc.3 for ; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) X-Received: by 10.112.168.228 with SMTP id zz4mr5924014lbb.73.1445442908329; Wed, 21 Oct 2015 08:55:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp67171lbq; Wed, 21 Oct 2015 08:55:07 -0700 (PDT) X-Received: by 10.68.245.33 with SMTP id xl1mr11608150pbc.39.1445442907300; Wed, 21 Oct 2015 08:55:07 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id yv10si14153491pab.172.2015.10.21.08.55.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2015 08:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoviE-0005dl-Ej; Wed, 21 Oct 2015 15:54:02 +0000 Received: from mail-by2on0075.outbound.protection.outlook.com ([207.46.100.75] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zovhc-00052c-Ty for linux-arm-kernel@lists.infradead.org; Wed, 21 Oct 2015 15:53:26 +0000 Received: from BY2PR12CA0035.namprd12.prod.outlook.com (10.160.121.45) by DM3PR12MB0858.namprd12.prod.outlook.com (10.164.7.140) with Microsoft SMTP Server (TLS) id 15.1.300.14; Wed, 21 Oct 2015 15:53:03 +0000 Received: from CO1NAM03FT010.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by BY2PR12CA0035.outlook.office365.com (2a01:111:e400:2c84::45) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Wed, 21 Oct 2015 15:53:03 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by CO1NAM03FT010.mail.protection.outlook.com (10.152.80.104) with Microsoft SMTP Server id 15.1.306.8 via Frontend Transport; Wed, 21 Oct 2015 15:53:01 +0000 X-WSS-ID: 0NWKUSB-07-H0T-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 25DA4CAE655; Wed, 21 Oct 2015 11:52:58 -0400 (EDT) Received: from SATLEXDAG04.amd.com (10.181.40.9) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 21 Oct 2015 10:53:06 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.266.1; Wed, 21 Oct 2015 11:52:58 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device Date: Wed, 21 Oct 2015 08:52:06 -0700 Message-ID: <1445442731-28819-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1445442731-28819-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1445442731-28819-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(36756003)(19580405001)(86362001)(64706001)(229853001)(5008740100001)(50986999)(5003600100002)(87936001)(76176999)(92566002)(47776003)(2201001)(5001770100001)(5003940100001)(97736004)(189998001)(46102003)(77096005)(11100500001)(19580395003)(106466001)(53416004)(105586002)(101416001)(50466002)(2950100001)(48376002)(5007970100001)(50226001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0858; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0858; 2:qiqKof/ADR9u61d10DtJwPPoc849L4iAVvpmZdWzHf5v6F7IXNsSfTkGdUxdUNW6jE+h87FnTMDDHex/xvKUzyFMkpOEQDHJPpG3fNVQowmynwBkwcBvEjoiTbHEk3SFnRG092e7n7uYM/di9OYJ4XCjxlxQhc351EysKI4R5sU=; 3:NIyqOEDh8xypJd+yJuwBKkrXMawc0wiDYFQ7KafJNBIAhL4y0V+jMiqA92khKTgfHCEzLYNoeAGNyNF0WkZJaFytfPGtjv2+QnDsLHURNQyLEXnubdzDuujsuiSv2czupVmlekcx5x4L58uweTx1cy57gI5UB4d31tYYICC05toNYjaLpO5YFPaWYhCN+EFeMI2RL4nXGPpm+RpjczhIwB7DuyTeHS4eUeCvD7fBzOs2yXZjKRsV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A+vBVroBrPsLSE5yJOR3sStUtNPfl/AbqAILCvt6zWXSRnnXFltD819K85Qt2QJseJq5T9hrqSvswjZcInyF8c3wxm8ATE6nwwJiTsOjyIUyYLPTO16N0Rk+sE1o67MebhVm3l6yfb0SwfQkkjKRoEa7Yt37uGrqWYauCXd8kED1arhGboCD1oJpi8HyzO7RLIVNv9QOzQC3R0Yhwu1OE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(102115026); SRVR:DM3PR12MB0858; BCL:0; PCL:0; RULEID:; SRVR:DM3PR12MB0858; X-Forefront-PRVS: 073631BD3D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM3PR12MB0858; 23:IGHQ4y2Lgfh980LZppfzxp9cz2lFXZlzc7YLF9dRw?= =?us-ascii?Q?NNaFeCfkJpMlPPVV17OYOsfpZistQwkvpa6GD9JWFXvJfXEP9ZNSesPjMrVy?= =?us-ascii?Q?XevbHB4UbEr83jk3tGG+9kwVag2cTjw3g2okokSohsa0hGkpVzgTIWFxR04U?= =?us-ascii?Q?HToFhMgFUJ9ygZQ4I7Iuz+OH4jK+Shqhyc7Favb4Dl3aZc0GnsaIs++2P8UG?= =?us-ascii?Q?03U09dbTjz+Cdyw5RG1zhK9kxxE2DHZ213aKTOVqABktzpRd/a45z5NrpcgT?= =?us-ascii?Q?h8Dg5rMP/6EsFO/9qy2fJbHSppBc/827W96h0fQyn30N+MvXHoCMI0bhDAku?= =?us-ascii?Q?5/pdkmRDMEb9g1YJWRIgtE7t4hDrmaX+kQYvsPTC94A/mOkFiRjI2qPB0r9O?= =?us-ascii?Q?AY8zTdZu7PrSAtReAOCLX5tjkTbXLZhqAeQMk9mZHDAPH0jkVlFUboTPVxSi?= =?us-ascii?Q?z1BurkMG3AbLDfOe+M/7iR5l0cVJd+dwImIorPxP1tEUhE2RbR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+lx8PXXvqo+OMgiRARdR9f9y0DMAyWjQMlQkFut8bZh2Em+F8FcduyM7YvS4Nq810M8iyjE36i7WYzuSB0W1W3hqqIajALRNzs2CnhqQOlEAz6S8Of7GqopHwWy SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2015 15:53:01.6284 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB0858 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151021_085325_194502_61D89807 X-CRM114-Status: GOOD ( 14.70 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [207.46.100.75 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.46.100.75 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: thomas.lendacky@amd.com, herbert@gondor.apana.org.au, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, Suravee Suthikulpanit , davem@davemloft.net, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: suravee.suthikulpanit@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Adding acpi_get_dma_attr() to query DMA attributes of ACPI devices. It returns the enum dev_dma_attr, which communicates DMA information more clearly. This API replaces the acpi_check_dma(), which will be removed in subsequent patch. This patch also provides a convenient function, acpi_dma_supported(), to check DMA support of the specified ACPI device. Signed-off-by: Suravee Suthikulpanit Suggested-by: Bjorn Helgaas CC: Rafael J. Wysocki --- drivers/acpi/scan.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 3 +++ include/linux/acpi.h | 10 ++++++++++ 3 files changed, 55 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 01136b8..3be213e 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1328,6 +1328,48 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) kfree(pnp->unique_id); } +/** + * acpi_dma_supported - Check DMA support for the specified device. + * @adev: The pointer to acpi device + * + * Return false if DMA is not supported. Otherwise, return true + */ +bool acpi_dma_supported(struct acpi_device *adev) +{ + if (!adev) + return false; + + if (adev->flags.cca_seen) + return true; + + /* + * Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent + * DMA on "Intel platforms". Presumably that includes all x86 and + * ia64, and other arches will set CONFIG_ACPI_CCA_REQUIRED=y. + */ + if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED)) + return true; + + return false; +} + +/** + * acpi_get_dma_attr - Check the supported DMA attr for the specified device. + * @adev: The pointer to acpi device + * + * Return enum dev_dma_attr. + */ +enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) +{ + if (!acpi_dma_supported(adev)) + return DEV_DMA_NOT_SUPPORTED; + + if (adev->flags.coherent_dma) + return DEV_DMA_COHERENT; + else + return DEV_DMA_NON_COHERENT; +} + static void acpi_init_coherency(struct acpi_device *adev) { unsigned long long cca = 0; diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 5a42204..13417d0 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -567,6 +567,9 @@ struct acpi_pci_root { /* helper */ +bool acpi_dma_supported(struct acpi_device *adev); +enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev); + struct acpi_device *acpi_find_child_device(struct acpi_device *parent, u64 address, bool check_children); int acpi_is_root_bridge(acpi_handle); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index dd39202..c47892c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -569,6 +569,16 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) return false; } +static inline bool acpi_dma_supported(struct acpi_device *adev) +{ + return false; +} + +static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) +{ + return DEV_DMA_NOT_SUPPORTED; +} + #define ACPI_PTR(_ptr) (NULL) #endif /* !CONFIG_ACPI */