Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp7861337ybn; Mon, 30 Sep 2019 22:32:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrjHjwzXcD8cmObuGBffQbNIbW6Q1g367s/jBjwyl9UzP7mZax3NnvaUO4i/PIH4Ii5QOD X-Received: by 2002:a17:907:20eb:: with SMTP id rh11mr21913868ejb.25.1569907923066; Mon, 30 Sep 2019 22:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569907923; cv=none; d=google.com; s=arc-20160816; b=NYlP+qJ4cP67Vp4yBvisbDrDaROWjYfpglP030rkbLMCqPMG3Xl6mBcIAxBwsUcfO4 0pIlPbw6u2Z57ImOQEOAVVhaVnevtvVUVucGBKeR9zPvew1fA3BiNyCPNVV/G//yx9D/ BGYftFmNlVmQvYtoNYAhDgNbTkETqPRvGgzd5ciqOje16x2iNiHecSRD0Haf4x2e5RSR u0hhLTIz7ppVf7m4UyLBs8rgR69EtFqBmLuZ5d/pZN5SFF0zDTmVocN1IInq1BJx7zzm AwrdzDAAIXv5gsR7XCfValPvfPkNweF4nNPj+6mOpLA2NG7FG4xy8bp3dag+HOQFMHj6 TeRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=3AjfN33fcO/8zhWHv+kbqvwKHuHEqis8m0ghnQnNYk4=; b=UkyILlFf7uAZPt+Ih/YraSm2gstPDC2MztifwgqHRGFpGKbzx4dZptiMn5p2BXHUX8 3Uz8x0Ks8Er98KS1iAmaYzU0/gaBIhv7ZrGy90qd+IvG+Fj4HRIkCkX2tLyYATszyFKH u33yQbNwyYS0Nv7s6JwRIGgWbHDidplLqET/6aTn3ogGHSal6KfZ8+ZtpdTgPZMPpEyJ YCKTHzvvGxpQ6nE3UTBlBcvAUulbMbAZG1t89wijMMjOiF70CGRsOO2OH2tzFyh9eNoI p34gp4Fr5/Qh2Ns24Aei/clc1jZviXvXMVHu/v7jsgCctLaR5sQCxleJtfHCLX9fr2IF PEIQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si8402564ejz.22.2019.09.30.22.31.26; Mon, 30 Sep 2019 22:32:03 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731389AbfJAF2L convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 Oct 2019 01:28:11 -0400 Received: from mga02.intel.com ([134.134.136.20]:7652 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbfJAF2L (ORCPT ); Tue, 1 Oct 2019 01:28:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 22:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,570,1559545200"; d="scan'208";a="190478749" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 30 Sep 2019 22:28:10 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 30 Sep 2019 22:28:10 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 30 Sep 2019 22:28:09 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.119]) with mapi id 14.03.0439.000; Tue, 1 Oct 2019 13:28:08 +0800 From: "Zhang, Jun" To: Greg KH CC: "labbott@redhat.com" , "sumit.semwal@linaro.org" , "arve@android.com" , "tkjos@android.com" , "maco@android.com" , "joel@joelfernandes.org" , "christian@brauner.io" , "devel@driverdev.osuosl.org" , "Bai, Jie A" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linaro-mm-sig@lists.linaro.org" , "he@osuosl.org" , "Bai@osuosl.org" , "He, Bo" Subject: RE: [PATCH] ion_system_heap: support X86 archtecture Thread-Topic: [PATCH] ion_system_heap: support X86 archtecture Thread-Index: AQHVdppyYu/UDgwp3kCa1tCveaZ4I6dB6ZkAgANY4IA= Date: Tue, 1 Oct 2019 05:28:07 +0000 Message-ID: <88DC34334CA3444C85D647DBFA962C2735B662D8@SHSMSX104.ccr.corp.intel.com> References: <20190929072841.14848-1-jun.zhang@intel.com> <20190929101254.GA1907778@kroah.com> In-Reply-To: <20190929101254.GA1907778@kroah.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjViOGZjNzEtZDcxOS00YTFjLTk4NGUtYTUzYzBjOGNmMjUwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoic25ZeGlQekh3WlRQa1RtNTVxa0VvSEpzV2RmaU5SdG41eWxkbm4reU1Ta3c0aTJpQVEwTUdPODZqUCtsdTNiRiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Greg Sorry, I am newcomer, and I don't know why couldn't use #ifdefs? I only refer some kernel code(V4.19) in drivers/hwtracing/intel_th/msu.c. Could you tell me why? And I tell my workmate to avoid the same case. If I define a config in Kconfig, and static inline function in .h file, then call it? Could you accept it? If not, Could you give me a sample? Thanks, Jun -----Original Message----- From: Greg KH Sent: Sunday, September 29, 2019 6:13 PM To: Zhang, Jun Cc: labbott@redhat.com; sumit.semwal@linaro.org; arve@android.com; tkjos@android.com; maco@android.com; joel@joelfernandes.org; christian@brauner.io; devel@driverdev.osuosl.org; Bai, Jie A ; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; linaro-mm-sig@lists.linaro.org; he@osuosl.org; Bai@osuosl.org; He, Bo Subject: Re: [PATCH] ion_system_heap: support X86 archtecture On Sun, Sep 29, 2019 at 03:28:41PM +0800, jun.zhang@intel.com wrote: > From: zhang jun > > we see tons of warning like: > [ 45.846872] x86/PAT: NDK MediaCodec_:3753 map pfn RAM range req > write-combining for [mem 0x1e7a80000-0x1e7a87fff], got write-back > [ 45.848827] x86/PAT: .vorbis.decoder:4088 map pfn RAM range req > write-combining for [mem 0x1e7a58000-0x1e7a58fff], got write-back > [ 45.848875] x86/PAT: NDK MediaCodec_:3753 map pfn RAM range req > write-combining for [mem 0x1e7a48000-0x1e7a4ffff], got write-back > [ 45.849403] x86/PAT: .vorbis.decoder:4088 map pfn RAM range > req write-combining for [mem 0x1e7a70000-0x1e7a70fff], got write-back > > check the kernel Documentation/x86/pat.txt, it says: > A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range, > vm_insert_pfn Drivers wanting to export some pages to userspace do it > by using mmap interface and a combination of > 1) pgprot_noncached() > 2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn() With > PAT support, a new API pgprot_writecombine is being added. > So, drivers can continue to use the above sequence, with either > pgprot_noncached() or pgprot_writecombine() in step 1, followed by step 2. > > In addition, step 2 internally tracks the region as UC or WC in > memtype list in order to ensure no conflicting mapping. > > Note that this set of APIs only works with IO (non RAM) regions. > If driver ants to export a RAM region, it has to do set_memory_uc() or > set_memory_wc() as step 0 above and also track the usage of those > pages and use set_memory_wb() before the page is freed to free pool. > > the fix follow the pat document, do set_memory_wc() as step 0 and use > the set_memory_wb() before the page is freed. > > Signed-off-by: he, bo > Signed-off-by: zhang jun > Signed-off-by: Bai, Jie A > --- > drivers/staging/android/ion/ion_system_heap.c | 28 > ++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/android/ion/ion_system_heap.c > b/drivers/staging/android/ion/ion_system_heap.c > index b83a1d16bd89..d298b8194820 100644 > --- a/drivers/staging/android/ion/ion_system_heap.c > +++ b/drivers/staging/android/ion/ion_system_heap.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #include "ion.h" > > @@ -134,6 +135,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap, > sg = table->sgl; > list_for_each_entry_safe(page, tmp_page, &pages, lru) { > sg_set_page(sg, page, page_size(page), 0); > + > +#ifdef CONFIG_X86 > + if (!(buffer->flags & ION_FLAG_CACHED)) > + set_memory_wc((unsigned long)page_address(sg_page(sg)), > + PAGE_ALIGN(sg->length) >> PAGE_SHIFT); #endif There is no way to do this without these #ifdefs? That feels odd, why can't you just always test for this? thanks, greg k-h