RE: [PATCH v3 6/6] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling

2023-04-17 Thread Dan Williams
Terry Bowman wrote:
> From: Robert Richter 
> 
> RCEC AER corrected and uncorrectable internal errors (CIE/UIE) are
> disabled by default. [1][2] Enable them to receive CXL downstream port
> errors of a Restricted CXL Host (RCH).
> 
> [1] CXL 3.0 Spec, 12.2.1.1 - RCH Downstream Port Detected Errors
> [2] PCIe Base Spec 6.0, 7.8.4.3 Uncorrectable Error Mask Register,
> 7.8.4.6 Correctable Error Mask Register

My comment on patch5 to make CXL link details a first class property of a
'struct pci_dev':

http://lore.kernel.org/r/643debf5af445_1b6629...@dwillia2-xfh.jf.intel.com.notmuch/

...also applies here.

Other than that nothing more from me on this one beyond what Bjorn and
Jonathan have said. I do agree with Robert about being cautious about
only enabling this for CXL devices for now and not all internal errors
for all AER capable devices globally. The rationale being that CXL
devices are a new link on top of PCIe and abuse/reuse internal errors
when they are conceptually functionally equivalent to PCIe link errors.


Re: [PATCH 12/33] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor}

2023-04-17 Thread kernel test robot
Hi Vishal,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on next-20230417]
[cannot apply to s390/features powerpc/next powerpc/fixes geert-m68k/for-next 
geert-m68k/for-linus linus/master v6.3-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git 
mm-everything
patch link:
https://lore.kernel.org/r/20230417205048.15870-13-vishal.moola%40gmail.com
patch subject: [PATCH 12/33] mm: Create ptdesc equivalents for 
pgtable_{pte,pmd}_page_{ctor,dtor}
config: sh-allmodconfig 
(https://download.01.org/0day-ci/archive/20230418/202304180959.yfctfvkw-...@intel.com/config)
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/d53de56a2dbf659b53aee1aa2eac60bcc936f10b
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
git checkout d53de56a2dbf659b53aee1aa2eac60bcc936f10b
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sh olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sh prepare

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202304180959.yfctfvkw-...@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/sh/kernel/asm-offsets.c:14:
   include/linux/mm.h: In function 'virt_to_ptdesc':
   include/linux/mm.h:2723:16: error: implicit declaration of function 
'page_ptdesc' [-Werror=implicit-function-declaration]
2723 | return page_ptdesc(virt_to_head_page(x));
 |^~~
   include/linux/mm.h:2723:16: warning: returning 'int' from a function with 
return type 'struct ptdesc *' makes pointer from integer without a cast 
[-Wint-conversion]
2723 | return page_ptdesc(virt_to_head_page(x));
 |^
   In file included from arch/sh/include/asm/thread_info.h:13,
from include/linux/thread_info.h:60,
from include/asm-generic/preempt.h:5,
from ./arch/sh/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/mm.h:7:
   include/linux/mm.h: In function 'ptdesc_to_virt':
   include/linux/mm.h:2728:29: error: implicit declaration of function 
'ptdesc_page'; did you mean 'pte_page'? [-Werror=implicit-function-declaration]
2728 | return page_to_virt(ptdesc_page(pt));
 | ^~~
   arch/sh/include/asm/page.h:139:27: note: in definition of macro '___va'
 139 | #define ___va(x)((x)+PAGE_OFFSET)
 |   ^
   include/linux/mm.h:117:25: note: in expansion of macro '__va'
 117 | #define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
 | ^~~~
   include/linux/mm.h:117:30: note: in expansion of macro 'PFN_PHYS'
 117 | #define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
 |  ^~~~
   include/asm-generic/memory_model.h:64:21: note: in expansion of macro 
'__page_to_pfn'
  64 | #define page_to_pfn __page_to_pfn
 | ^
   include/linux/mm.h:2728:16: note: in expansion of macro 'page_to_virt'
2728 | return page_to_virt(ptdesc_page(pt));
 |^~~~
   include/asm-generic/memory_model.h:46:35: warning: initialization of 'const 
struct page *' from 'int' makes pointer from integer without a cast 
[-Wint-conversion]
  46 | ({  const struct page *__pg = (pg); \
 |   ^
   arch/sh/include/asm/page.h:139:27: note: in definition of macro '___va'
 139 | #define ___va(x)((x)+PAGE_OFFSET)
 |   ^
   include/linux/mm.h:117:25: note: in expansion of macro '__va'

Re: [PATCH 04/33] mm: add utility functions for ptdesc

2023-04-17 Thread kernel test robot
Hi Vishal,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on s390/features powerpc/next powerpc/fixes 
geert-m68k/for-next geert-m68k/for-linus linus/master v6.3-rc7 next-20230417]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git 
mm-everything
patch link:
https://lore.kernel.org/r/20230417205048.15870-5-vishal.moola%40gmail.com
patch subject: [PATCH 04/33] mm: add utility functions for ptdesc
config: sh-allmodconfig 
(https://download.01.org/0day-ci/archive/20230418/202304180913.p1buxrbb-...@intel.com/config)
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/1b6f8137ca50a543ad2937092836635ca58c78ce
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
git checkout 1b6f8137ca50a543ad2937092836635ca58c78ce
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sh olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=sh prepare

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202304180913.p1buxrbb-...@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from arch/sh/kernel/asm-offsets.c:14:
   include/linux/mm.h: In function 'virt_to_ptdesc':
>> include/linux/mm.h:2723:16: error: implicit declaration of function 
>> 'page_ptdesc' [-Werror=implicit-function-declaration]
2723 | return page_ptdesc(virt_to_head_page(x));
 |^~~
>> include/linux/mm.h:2723:16: warning: returning 'int' from a function with 
>> return type 'struct ptdesc *' makes pointer from integer without a cast 
>> [-Wint-conversion]
2723 | return page_ptdesc(virt_to_head_page(x));
 |^
   In file included from arch/sh/include/asm/thread_info.h:13,
from include/linux/thread_info.h:60,
from include/asm-generic/preempt.h:5,
from ./arch/sh/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/mm.h:7:
   include/linux/mm.h: In function 'ptdesc_to_virt':
>> include/linux/mm.h:2728:29: error: implicit declaration of function 
>> 'ptdesc_page'; did you mean 'pte_page'? 
>> [-Werror=implicit-function-declaration]
2728 | return page_to_virt(ptdesc_page(pt));
 | ^~~
   arch/sh/include/asm/page.h:139:27: note: in definition of macro '___va'
 139 | #define ___va(x)((x)+PAGE_OFFSET)
 |   ^
   include/linux/mm.h:117:25: note: in expansion of macro '__va'
 117 | #define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
 | ^~~~
   include/linux/mm.h:117:30: note: in expansion of macro 'PFN_PHYS'
 117 | #define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x)))
 |  ^~~~
   include/asm-generic/memory_model.h:64:21: note: in expansion of macro 
'__page_to_pfn'
  64 | #define page_to_pfn __page_to_pfn
 | ^
   include/linux/mm.h:2728:16: note: in expansion of macro 'page_to_virt'
2728 | return page_to_virt(ptdesc_page(pt));
 |^~~~
>> include/asm-generic/memory_model.h:46:35: warning: initialization of 'const 
>> struct page *' from 'int' makes pointer from integer without a cast 
>> [-Wint-conversion]
  46 | ({  const struct page *__pg = (pg); \
 |   ^
   arch/sh/include/asm/page.h:139:27: note: in definition of macro '___va'
 139 | #define ___va(x)((x)+PAGE_OFFSET)
 |   ^
   include/linux/mm.h:117:25: note: in expans

RE: [PATCH v3 5/6] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler

2023-04-17 Thread Dan Williams
Terry Bowman wrote:
> From: Robert Richter 
> 
> In Restricted CXL Device (RCD) mode a CXL device is exposed as an
> RCiEP, but CXL downstream and upstream ports are not enumerated and
> not visible in the PCIe hierarchy. Protocol and link errors are sent
> to an RCEC.
> 
> Restricted CXL host (RCH) downstream port-detected errors are signaled
> as internal AER errors, either Uncorrectable Internal Error (UIE) or
> Corrected Internal Errors (CIE). The error source is the id of the
> RCEC. A CXL handler must then inspect the error status in various CXL
> registers residing in the dport's component register space (CXL RAS
> cap) or the dport's RCRB (AER ext cap). [1]
> 
> Errors showing up in the RCEC's error handler must be handled and
> connected to the CXL subsystem. Implement this by forwarding the error
> to all CXL devices below the RCEC. Since the entire CXL device is
> controlled only using PCIe Configuration Space of device 0, Function
> 0, only pass it there [2]. These devices have the Memory Device class
> code set (PCI_CLASS_MEMORY_CXL, 502h) and the existing cxl_pci driver
> can implement the handler. In addition to errors directed to the CXL
> endpoint device, the handler must also inspect the CXL downstream
> port's CXL RAS and PCIe AER external capabilities that is connected to
> the device.
> 
> Since CXL downstream port errors are signaled using internal errors,
> the handler requires those errors to be unmasked. This is subject of a
> follow-on patch.
> 
> The reason for choosing this implementation is that a CXL RCEC device
> is bound to the AER port driver, but the driver does not allow it to
> register a custom specific handler to support CXL. Connecting the RCEC
> hard-wired with a CXL handler does not work, as the CXL subsystem
> might not be present all the time. The alternative to add an
> implementation to the portdrv to allow the registration of a custom
> RCEC error handler isn't worth doing it as CXL would be its only user.
> Instead, just check for an CXL RCEC and pass it down to the connected
> CXL device's error handler. With this approach the code can entirely
> be implemented in the PCIe AER driver and is independent of the CXL
> subsystem. The CXL driver only provides the handler.
> 
> [1] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
> [2] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices
> 
> Co-developed-by: Terry Bowman 
> Signed-off-by: Robert Richter 
> Signed-off-by: Terry Bowman 
> Cc: "Oliver O'Halloran" 
> Cc: Bjorn Helgaas 
> Cc: Mahesh J Salgaonkar 
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-...@vger.kernel.org
> ---
>  drivers/pci/pcie/Kconfig |  8 ++
>  drivers/pci/pcie/aer.c   | 61 
>  2 files changed, 69 insertions(+)
> 
> diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
> index 228652a59f27..b0dbd864d3a3 100644
> --- a/drivers/pci/pcie/Kconfig
> +++ b/drivers/pci/pcie/Kconfig
> @@ -49,6 +49,14 @@ config PCIEAER_INJECT
> gotten from:
>
> https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/
>  
> +config PCIEAER_CXL
> + bool "PCI Express CXL RAS support"
> + default y
> + depends on PCIEAER && CXL_PCI
> + help
> +   This enables CXL error handling for Restricted CXL Hosts
> +   (RCHs).
> +
>  #
>  # PCI Express ECRC
>  #
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 7a25b62d9e01..171a08fd8ebd 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -946,6 +946,65 @@ static bool find_source_device(struct pci_dev *parent,
>   return true;
>  }
>  
> +#ifdef CONFIG_PCIEAER_CXL
> +
> +static bool is_cxl_mem_dev(struct pci_dev *dev)
> +{
> + /*
> +  * A CXL device is controlled only using PCIe Configuration
> +  * Space of device 0, Function 0.
> +  */
> + if (dev->devfn != PCI_DEVFN(0, 0))
> + return false;
> +
> + /* Right now there is only a CXL.mem driver */
> + if ((dev->class >> 8) != PCI_CLASS_MEMORY_CXL)
> + return false;
> +
> + return true;
> +}

This part feels broken because most the errors of concern here are CXL
link generic and that can involve CXL.cache and CXL.mem errors on
devices that are not PCI_CLASS_MEMORY_CXL. This situation feels like it
wants formal acknowledgement in 'struct pci_dev' that CXL links ride on
top of PCIe links.

If it were not for RCRBs then the PCI core could just do:

dvsec = pci_find_dvsec_capability(pdev, PCI_DVSEC_VENDOR_ID_CXL,
  CXL_DVSEC_FLEXBUS_PORT);

...at bus scan time to identify devices with active CXL links. RCRBs
unfortunately make it so the link presence can not be detected until a
CXL driver is loaded to read that DVSEC out of MMIO space.

However, I still think that looks like a CXL aware driver registering a
'struct cxl_link' (for lack of a better name) object with a
corresponding PCI device. That link can indicate whether this 

[PATCH 06/11] ASoC: fsl: use asoc_dummy_dlc

2023-04-17 Thread Kuninori Morimoto
Now we can share asoc_dummy_dlc. This patch use it.

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/fsl/imx-audmix.c | 14 +-
 sound/soc/fsl/imx-card.c   | 11 +--
 sound/soc/fsl/imx-rpmsg.c  |  3 +--
 sound/soc/fsl/imx-spdif.c  |  6 ++
 4 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
index 2c57fe9d2d08..8287b366eea1 100644
--- a/sound/soc/fsl/imx-audmix.c
+++ b/sound/soc/fsl/imx-audmix.c
@@ -207,8 +207,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
for (i = 0; i < num_dai; i++) {
struct snd_soc_dai_link_component *dlc;
 
-   /* for CPU/Codec x 2 */
-   dlc = devm_kcalloc(>dev, 4, sizeof(*dlc), GFP_KERNEL);
+   /* for CPU x 2 */
+   dlc = devm_kcalloc(>dev, 2, sizeof(*dlc), GFP_KERNEL);
if (!dlc)
return -ENOMEM;
 
@@ -239,15 +239,13 @@ static int imx_audmix_probe(struct platform_device *pdev)
}
 
priv->dai[i].cpus = [0];
-   priv->dai[i].codecs = [1];
+   priv->dai[i].codecs = _dummy_dlc;
 
priv->dai[i].num_cpus = 1;
priv->dai[i].num_codecs = 1;
 
priv->dai[i].name = dai_name;
priv->dai[i].stream_name = "HiFi-AUDMIX-FE";
-   priv->dai[i].codecs->dai_name = "snd-soc-dummy-dai";
-   priv->dai[i].codecs->name = "snd-soc-dummy";
priv->dai[i].cpus->of_node = args.np;
priv->dai[i].cpus->dai_name = dev_name(_pdev->dev);
priv->dai[i].dynamic = 1;
@@ -264,15 +262,13 @@ static int imx_audmix_probe(struct platform_device *pdev)
be_cp = devm_kasprintf(>dev, GFP_KERNEL,
   "AUDMIX-Capture-%d", i);
 
-   priv->dai[num_dai + i].cpus = [2];
-   priv->dai[num_dai + i].codecs = [3];
+   priv->dai[num_dai + i].cpus = [1];
+   priv->dai[num_dai + i].codecs = _dummy_dlc;
 
priv->dai[num_dai + i].num_cpus = 1;
priv->dai[num_dai + i].num_codecs = 1;
 
priv->dai[num_dai + i].name = be_name;
-   priv->dai[num_dai + i].codecs->dai_name = "snd-soc-dummy-dai";
-   priv->dai[num_dai + i].codecs->name = "snd-soc-dummy";
priv->dai[num_dai + i].cpus->of_node = audmix_np;
priv->dai[num_dai + i].cpus->dai_name = be_name;
priv->dai[num_dai + i].no_pcm = 1;
diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 64a4d7e9db60..78e2e3932ba5 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -615,17 +615,8 @@ static int imx_card_parse_of(struct imx_card_data *data)
plat_data->type = CODEC_AK5552;
 
} else {
-   dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
-   if (!dlc) {
-   ret = -ENOMEM;
-   goto err;
-   }
-
-   link->codecs = dlc;
+   link->codecs = _dummy_dlc;
link->num_codecs = 1;
-
-   link->codecs->dai_name = "snd-soc-dummy-dai";
-   link->codecs->name = "snd-soc-dummy";
}
 
if (!strncmp(link->name, "HiFi-ASRC-FE", 12)) {
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 89178106fe2c..93fc976e98dc 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -92,8 +92,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
/* Optional codec node */
ret = of_parse_phandle_with_fixed_args(np, "audio-codec", 0, 0, );
if (ret) {
-   data->dai.codecs->dai_name = "snd-soc-dummy-dai";
-   data->dai.codecs->name = "snd-soc-dummy";
+   *data->dai.codecs = asoc_dummy_dlc;
} else {
struct clk *clk;
 
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c
index 114b49660193..547be9438333 100644
--- a/sound/soc/fsl/imx-spdif.c
+++ b/sound/soc/fsl/imx-spdif.c
@@ -26,22 +26,20 @@ static int imx_spdif_audio_probe(struct platform_device 
*pdev)
}
 
data = devm_kzalloc(>dev, sizeof(*data), GFP_KERNEL);
-   comp = devm_kzalloc(>dev, 2 * sizeof(*comp), GFP_KERNEL);
+   comp = devm_kzalloc(>dev, sizeof(*comp), GFP_KERNEL);
if (!data || !comp) {
ret = -ENOMEM;
goto end;
}
 
data->dai.cpus  = [0];
-   data->dai.codecs= [1];
+   data->dai.codecs= _dummy_dlc;
 
data->dai.num_cpus  = 1;
data->dai.num_codecs= 1;
 
data->dai.name = "S/PDIF PCM";
data->dai.stream_name = "S/PDIF PCM";
-   

Re: [PATCH 24/33] m68k: Convert various functions to use ptdescs

2023-04-17 Thread kernel test robot
Hi Vishal,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on next-20230417]
[cannot apply to s390/features powerpc/next powerpc/fixes geert-m68k/for-next 
geert-m68k/for-linus linus/master v6.3-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git 
mm-everything
patch link:
https://lore.kernel.org/r/20230417205048.15870-25-vishal.moola%40gmail.com
patch subject: [PATCH 24/33] m68k: Convert various functions to use ptdescs
config: m68k-allyesconfig 
(https://download.01.org/0day-ci/archive/20230418/202304180652.leolmanq-...@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/630b38053b213e6138d3deb3e4325b24ad6dcb1f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Vishal-Moola-Oracle/s390-Use-_pt_s390_gaddr-for-gmap-address-tracking/20230418-045832
git checkout 630b38053b213e6138d3deb3e4325b24ad6dcb1f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=m68k SHELL=/bin/bash arch/m68k/mm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202304180652.leolmanq-...@intel.com/

All warnings (new ones prefixed by >>):

   arch/m68k/mm/motorola.c: In function 'free_pointer_table':
>> arch/m68k/mm/motorola.c:204:56: warning: passing argument 1 of 
>> 'virt_to_ptdesc' makes pointer from integer without a cast [-Wint-conversion]
 204 | ptdesc_pte_dtor(virt_to_ptdesc(page));
 |^~~~
 ||
 |long unsigned 
int
   In file included from arch/m68k/mm/motorola.c:15:
   include/linux/mm.h:2721:57: note: expected 'const void *' but argument is of 
type 'long unsigned int'
2721 | static inline struct ptdesc *virt_to_ptdesc(const void *x)
 | ^
   arch/m68k/mm/motorola.c: At top level:
   arch/m68k/mm/motorola.c:418:13: warning: no previous prototype for 
'paging_init' [-Wmissing-prototypes]
 418 | void __init paging_init(void)
 | ^~~


vim +/virt_to_ptdesc +204 arch/m68k/mm/motorola.c

   185  
   186  int free_pointer_table(void *table, int type)
   187  {
   188  ptable_desc *dp;
   189  unsigned long ptable = (unsigned long)table;
   190  unsigned long page = ptable & PAGE_MASK;
   191  unsigned int mask = 1U << ((ptable - page)/ptable_size(type));
   192  
   193  dp = PD_PTABLE(page);
   194  if (PD_MARKBITS (dp) & mask)
   195  panic ("table already free!");
   196  
   197  PD_MARKBITS (dp) |= mask;
   198  
   199  if (PD_MARKBITS(dp) == ptable_mask(type)) {
   200  /* all tables in page are free, free page */
   201  list_del(dp);
   202  mmu_page_dtor((void *)page);
   203  if (type == TABLE_PTE)
 > 204  ptdesc_pte_dtor(virt_to_ptdesc(page));
   205  free_page (page);
   206  return 1;
   207  } else if (ptable_list[type].next != dp) {
   208  /*
   209   * move this descriptor to the front of the list, since
   210   * it has one or more free tables.
   211   */
   212  list_move(dp, _list[type]);
   213  }
   214  return 0;
   215  }
   216  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Re: [PATCH v3 5/6] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler

2023-04-17 Thread Robert Richter
On 14.04.23 16:32:54, Bjorn Helgaas wrote:
> On Thu, Apr 13, 2023 at 01:40:52PM +0200, Robert Richter wrote:
> > On 12.04.23 17:02:33, Bjorn Helgaas wrote:
> > > On Tue, Apr 11, 2023 at 01:03:01PM -0500, Terry Bowman wrote:
> > > > From: Robert Richter 
> 
> > ...
> > Let's assume just a simple CXL RCH topology:
> > 
> > PCI hierarchy:
> > 
> >   -
> >   | ACPI0016  |--   Host bridge (CXL host)
> >   | - CEDT| |
> >---|   - RCRB base | |
> >|  - :
> >|   |
> >|   |
> >|  --- -
> >|  | RCiEP   |.| RCEC  | Endpoint (CXL dev)
> >|  | - BDF   | | - BDF |
> >|  |   | - PCIe AER  | -
> >|  |   | - CXL dvsec |
> >|  |   |   (v2: reg loc) |
> >|  |   |   - Comp regs   |
> >|  |   | - CXL RAS   |
> >|  |   ---
> >:  :
> >   
> > CXL hierarchy:
> > 
> >::
> >:  --|
> >|  | CXL root port  |<
> >|  ||
> >|->| - dport RCRB   |<
> >|  |   - PCIe AER   ||
> >|  |   - Comp regs  ||
> >|  | - CXL RAS  ||
> >|  --|
> >|  : |
> >|  |   --|
> >|  --->| CXL endpoint   |-
> >|  | (v1: RCRB) |
> >-->| - uport RCRB   |
> >   |   - Comp regs  |
> >   | - CXL RAS  |
> >   --
> > 
> > Dport detected errors are reported using PCIe AER and CXL RAS caps in
> > the dports RCRB.
> > 
> > Uport detected errors are reported using RCiEP's PCIe AER cap and
> > either the uport's RCRB RAS cap or the RAS cap of the comp regs
> > located using CXL DVSEC register locator.
> > 
> > In all cases the RCEC is used with either the RCEC (dport errors) or
> > the RCiEP (uport errors) error source id (BDF: bus, dev, func).
> 
> I'm mostly interested in the PCI entities involved because that's all
> aer.c can deal with.  For the above, I think the PCI core only knows
> about these:
> 
>   00:00.0 RCEC  with AER, RCEC EA includes 00:01.0
>   00:01.0 RCiEP with AER
> 
> aer_irq() would handle AER interrupts from 00:00.0.
> cxl_handle_error() would be called for 00:00.0 and would call
> handle_error_source() for everything below it (only 00:01.0 here).
> 
> > > The current code uses pcie_walk_rcec() in this path, which basically
> > > searches below a Root Port or RCEC for devices that have an AER error
> > > status bit set, add them to the e_info[] list, and call
> > > handle_error_source() for each one:
> > 
> > For reference, this series adds support to handle RCH downstream
> > port-detected errors as described in CXL 3.0, 12.2.1.1.
> > 
> > This flow looks correct to me, see comments inline.
> 
> We seem to be on the same page here, so I'll trim it out.
> 
> > ...
> > > So we insert cxl_handle_error() in handle_error_source(), where it
> > > gets called for the RCEC, and then it uses pcie_walk_rcec() again to
> > > forcibly call handle_error_source() for *every* device "below" the
> > > RCEC (even though they don't have AER error status bits set).
> > 
> > The CXL device contains the links to the dport's caps. Also, there can
> > be multiple RCs with CXL devs connected to it. So we must search for
> > all CXL devices now, determine the corresponding dport and inspect
> > both, PCIe AER and CXL RAS caps.
> > 
> > > Then handle_error_source() ultimately calls the CXL driver err_handler
> > > entry points (.cor_error_detected(), .error_detected(), etc), which
> > > can look at the CXL-specific error status in the CXL RAS or RCRB or
> > > whatever.
> > 
> > The AER driver (portdrv) does not have the knowledge of CXL internals.
> > Thus the approach is to pass dport errors to the cxl_mem driver to
> > handle it there in addition to cxl mem dev errors.
> > 
> > > So this basically looks like a workaround for the fact that the AER
> > > code only calls handle_error_source() when it finds AER error status,
> > > and CXL doesn't *set* that AER error status.  There's not that much
> > > code here, but it seems like a quite a bit of complexity in an area
> > > that is already pretty complicated.
> 
> My main point here (correct me if I got this wrong) is that:
> 
>   - A RCEC generates an AER interrupt
> 
>   - find_source_device() searches all devices below the RCEC and
> builds a list everything for which to call handle_error_source()

find_source_device() does not walk the RCEC if the error source is the
RCEC itself (note that 

[PATCH v2 2/2] start_kernel: omit prevent_tail_call_optimization for newer toolchains

2023-04-17 Thread ndesaulniers
prevent_tail_call_optimization was added in
commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
to work around stack canaries getting inserted into functions that would
initialize the stack canary in the first place.

Now that we have no_stack_protector function attribute (gcc-11+,
clang-7+) and use it on start_kernel, remove the call to
prevent_tail_call_optimization such that we may one day remove it
outright.

Reviewed-by: Nathan Chancellor 
Acked-by: Peter Zijlstra (Intel) 
Signed-off-by: Nick Desaulniers 
---
 init/main.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/init/main.c b/init/main.c
index 1265c8d11052..c6eef497c8c9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1152,7 +1152,13 @@ void start_kernel(void)
/* Do the rest non-__init'ed, we're now alive */
arch_call_rest_init();
 
+   /*
+* Avoid stack canaries in callers of boot_init_stack_canary for gcc-10
+* and older.
+*/
+#if !__has_attribute(__no_stack_protector__)
prevent_tail_call_optimization();
+#endif
 }
 
 /* Call all constructor functions linked into the kernel. */

-- 
2.40.0.634.g4ca3ef3211-goog



[PATCH v2 1/2] start_kernel: add no_stack_protector fn attr

2023-04-17 Thread ndesaulniers
Back during the discussion of
commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
we discussed the need for a function attribute to control the omission
of stack protectors on a per-function basis; at the time Clang had
support for no_stack_protector but GCC did not. This was fixed in
gcc-11. Now that the function attribute is available, let's start using
it.

Callers of boot_init_stack_canary need to use this function attribute
unless they're compiled with -fno-stack-protector, otherwise the canary
stored in the stack slot of the caller will differ upon the call to
boot_init_stack_canary. This will lead to a call to __stack_chk_fail
then panic.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94722
Link: 
https://lore.kernel.org/all/20200316130414.gc12...@hirez.programming.kicks-ass.net/
Tested-by: Nathan Chancellor 
Acked-by: Michael Ellerman  (powerpc)
Acked-by: Miguel Ojeda 
Acked-by: Peter Zijlstra (Intel) 
Signed-off-by: Nick Desaulniers 
---
 arch/powerpc/kernel/smp.c   |  1 +
 include/linux/compiler_attributes.h | 12 
 init/main.c |  3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index f62e5e651bcd..48acae0da034 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1603,6 +1603,7 @@ static void add_cpu_to_masks(int cpu)
 }
 
 /* Activate a secondary processor. */
+__no_stack_protector
 void start_secondary(void *unused)
 {
unsigned int cpu = raw_smp_processor_id();
diff --git a/include/linux/compiler_attributes.h 
b/include/linux/compiler_attributes.h
index e659cb6fded3..84864767a56a 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -255,6 +255,18 @@
  */
 #define __noreturn  __attribute__((__noreturn__))
 
+/*
+ * Optional: only supported since GCC >= 11.1, clang >= 7.0.
+ *
+ *   gcc: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
+ *   clang: 
https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
+ */
+#if __has_attribute(__no_stack_protector__)
+# define __no_stack_protector  __attribute__((__no_stack_protector__))
+#else
+# define __no_stack_protector
+#endif
+
 /*
  * Optional: not supported by gcc.
  *
diff --git a/init/main.c b/init/main.c
index 5d6365510173..1265c8d11052 100644
--- a/init/main.c
+++ b/init/main.c
@@ -941,7 +941,8 @@ static void __init print_unknown_bootoptions(void)
memblock_free(unknown_options, len);
 }
 
-asmlinkage __visible void __init __no_sanitize_address __noreturn 
start_kernel(void)
+asmlinkage __visible __init __no_sanitize_address __noreturn 
__no_stack_protector
+void start_kernel(void)
 {
char *command_line;
char *after_dashes;

-- 
2.40.0.634.g4ca3ef3211-goog



[PATCH v2 0/2] start_kernel: omit stack canary

2023-04-17 Thread ndesaulniers
A security research paper was recently published detailing Catch Handler
Oriented Programming (CHOP) attacks.
https://download.vusec.net/papers/chop_ndss23.pdf
The TL;DR being that C++ structured exception handling runtimes are
attractive gadgets for Jump Oriented Programming (JOP) attacks.

In response to this, a mitigation was developed under embargo in
clang-16 to check the stack canary before calling noreturn functions.
https://bugs.chromium.org/p/llvm/issues/detail?id=30

This started causing boot failures in Android kernel trees downstream of
stable linux-4.14.y that had proto-LTO support, as reported by Nathan
Chancellor.
https://github.com/ClangBuiltLinux/linux/issues/1815

Josh Poimboeuf recently sent a series to explicitly annotate more
functions as noreturn. Nathan noticed the series, and tested it finding
that it now caused boot failures with clang-16+ on mainline (raising the
visibility and urgency of the issue).
https://lore.kernel.org/cover.1680912057.git.jpoim...@kernel.org/
V2 of this series is rebased on tip/objtool/core @
88b478ee5c7b080b70c68d6e9b3da6c2b518ceb0 now that that series has been
picked up.

Once the embargo was lifted, I asked questions such as "what does C++
structured exception handling have to do with C code" and "surely GCC
didn't ship the same mitigation for C code (narrator: 'They did not:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a25982ada523689c8745d7fb4b1b93c8f5dab2e7')?"

I now have a patch out for LLVM to undo this mess (or at least limit it
to C++ functions that may throw, similar to GCC's mitigation); it hasn't
landed yet but we're close to consensus and I expect it to land
imminently.
https://reviews.llvm.org/D147975

Remember this thread?  (Pepperidge farms remembers...)
https://lore.kernel.org/all/20200314164451.346497-1-sly...@gentoo.org/

That reminded me that years ago we discussed a function attribute for
no_stack_protector.
https://lore.kernel.org/all/20200316130414.gc12...@hirez.programming.kicks-ass.net/

GCC didn't have one at the time, it now does. In addition to the LLVM
fix, I'd like to introduce this in the kernel so that we might start
using it in additional places:
* https://lore.kernel.org/linux-pm/20200915172658.1432732-1-r...@google.com/
* 
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolva...@google.com/
And eventually remove the final macro expansion site of
prevent_tail_call_optimization.

With the LLVM fix, this series isn't required, but I'd like to start
paving the way to use these function attributes since I think they are a
sweet spot in terms of granularity (as opposed to trying to move
start_kernel to its own TU compiled with -fno-stack-protector).

Signed-off-by: Nick Desaulniers 
---
Changes in v2:
- Rebase to avoid conflicts with Josh's changes.
- Fix comment style as per Peter.
- Pick up tags.
- Link to v1: 
https://lore.kernel.org/r/20230412-no_stackp-v1-0-46a69b507...@google.com
(sorry for the spam with v2, mrincon is helping me get kinks worked out
with b4 and our corporate mailer)

---
Nick Desaulniers (2):
  start_kernel: add no_stack_protector fn attr
  start_kernel: omit prevent_tail_call_optimization for newer toolchains

 arch/powerpc/kernel/smp.c   |  1 +
 include/linux/compiler_attributes.h | 12 
 init/main.c |  9 -
 3 files changed, 21 insertions(+), 1 deletion(-)
---
base-commit: 88b478ee5c7b080b70c68d6e9b3da6c2b518ceb0
change-id: 20230412-no_stackp-a98168a2bb0a

Best regards,
-- 
Nick Desaulniers 



[PATCH 2/2] start_kernel: omit prevent_tail_call_optimization for newer toolchains

2023-04-17 Thread ndesaulniers
prevent_tail_call_optimization was added in
commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
to work around stack canaries getting inserted into functions that would
initialize the stack canary in the first place.

Now that we have no_stack_protector function attribute (gcc-11+,
clang-7+) and use it on start_kernel, remove the call to
prevent_tail_call_optimization such that we may one day remove it
outright.

Reviewed-by: Nathan Chancellor 
Acked-by: Peter Zijlstra (Intel) 
Signed-off-by: Nick Desaulniers 
---
 init/main.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/init/main.c b/init/main.c
index 1265c8d11052..c6eef497c8c9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1152,7 +1152,13 @@ void start_kernel(void)
/* Do the rest non-__init'ed, we're now alive */
arch_call_rest_init();
 
+   /*
+* Avoid stack canaries in callers of boot_init_stack_canary for gcc-10
+* and older.
+*/
+#if !__has_attribute(__no_stack_protector__)
prevent_tail_call_optimization();
+#endif
 }
 
 /* Call all constructor functions linked into the kernel. */

-- 
2.40.0.634.g4ca3ef3211-goog



[PATCH 0/2] start_kernel: omit stack canary

2023-04-17 Thread ndesaulniers
A security research paper was recently published detailing Catch Handler
Oriented Programming (CHOP) attacks.
https://download.vusec.net/papers/chop_ndss23.pdf
The TL;DR being that C++ structured exception handling runtimes are
attractive gadgets for Jump Oriented Programming (JOP) attacks.

In response to this, a mitigation was developed under embargo in
clang-16 to check the stack canary before calling noreturn functions.
https://bugs.chromium.org/p/llvm/issues/detail?id=30

This started causing boot failures in Android kernel trees downstream of
stable linux-4.14.y that had proto-LTO support, as reported by Nathan
Chancellor.
https://github.com/ClangBuiltLinux/linux/issues/1815

Josh Poimboeuf recently sent a series to explicitly annotate more
functions as noreturn. Nathan noticed the series, and tested it finding
that it now caused boot failures with clang-16+ on mainline (raising the
visibility and urgency of the issue).
https://lore.kernel.org/cover.1680912057.git.jpoim...@kernel.org/
V2 of this series is rebased on tip/objtool/core @
88b478ee5c7b080b70c68d6e9b3da6c2b518ceb0 now that that series has been
picked up.

Once the embargo was lifted, I asked questions such as "what does C++
structured exception handling have to do with C code" and "surely GCC
didn't ship the same mitigation for C code (narrator: 'They did not:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a25982ada523689c8745d7fb4b1b93c8f5dab2e7')?"

I now have a patch out for LLVM to undo this mess (or at least limit it
to C++ functions that may throw, similar to GCC's mitigation); it hasn't
landed yet but we're close to consensus and I expect it to land
imminently.
https://reviews.llvm.org/D147975

Remember this thread?  (Pepperidge farms remembers...)
https://lore.kernel.org/all/20200314164451.346497-1-sly...@gentoo.org/

That reminded me that years ago we discussed a function attribute for
no_stack_protector.
https://lore.kernel.org/all/20200316130414.gc12...@hirez.programming.kicks-ass.net/

GCC didn't have one at the time, it now does. In addition to the LLVM
fix, I'd like to introduce this in the kernel so that we might start
using it in additional places:
* https://lore.kernel.org/linux-pm/20200915172658.1432732-1-r...@google.com/
* 
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolva...@google.com/
And eventually remove the final macro expansion site of
prevent_tail_call_optimization.

With the LLVM fix, this series isn't required, but I'd like to start
paving the way to use these function attributes since I think they are a
sweet spot in terms of granularity (as opposed to trying to move
start_kernel to its own TU compiled with -fno-stack-protector).

Changes V1 -> V2:
* Rebase to avoid conflicts with Josh's changes.
* Fix comment style as per Peter.
* Pick up tags.

Signed-off-by: Nick Desaulniers 
---
Nick Desaulniers (2):
  start_kernel: add no_stack_protector fn attr
  start_kernel: omit prevent_tail_call_optimization for newer toolchains

 arch/powerpc/kernel/smp.c   |  1 +
 include/linux/compiler_attributes.h | 12 
 init/main.c |  9 -
 3 files changed, 21 insertions(+), 1 deletion(-)
---
base-commit: 88b478ee5c7b080b70c68d6e9b3da6c2b518ceb0
change-id: 20230412-no_stackp-a98168a2bb0a

Best regards,
-- 
Nick Desaulniers 



[PATCH 1/2] start_kernel: add no_stack_protector fn attr

2023-04-17 Thread ndesaulniers
Back during the discussion of
commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
we discussed the need for a function attribute to control the omission
of stack protectors on a per-function basis; at the time Clang had
support for no_stack_protector but GCC did not. This was fixed in
gcc-11. Now that the function attribute is available, let's start using
it.

Callers of boot_init_stack_canary need to use this function attribute
unless they're compiled with -fno-stack-protector, otherwise the canary
stored in the stack slot of the caller will differ upon the call to
boot_init_stack_canary. This will lead to a call to __stack_chk_fail
then panic.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94722
Link: 
https://lore.kernel.org/all/20200316130414.gc12...@hirez.programming.kicks-ass.net/
Tested-by: Nathan Chancellor 
Acked-by: Michael Ellerman  (powerpc)
Acked-by: Miguel Ojeda 
Acked-by: Peter Zijlstra (Intel) 
Signed-off-by: Nick Desaulniers 
---
 arch/powerpc/kernel/smp.c   |  1 +
 include/linux/compiler_attributes.h | 12 
 init/main.c |  3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index f62e5e651bcd..48acae0da034 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1603,6 +1603,7 @@ static void add_cpu_to_masks(int cpu)
 }
 
 /* Activate a secondary processor. */
+__no_stack_protector
 void start_secondary(void *unused)
 {
unsigned int cpu = raw_smp_processor_id();
diff --git a/include/linux/compiler_attributes.h 
b/include/linux/compiler_attributes.h
index e659cb6fded3..84864767a56a 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -255,6 +255,18 @@
  */
 #define __noreturn  __attribute__((__noreturn__))
 
+/*
+ * Optional: only supported since GCC >= 11.1, clang >= 7.0.
+ *
+ *   gcc: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
+ *   clang: 
https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
+ */
+#if __has_attribute(__no_stack_protector__)
+# define __no_stack_protector  __attribute__((__no_stack_protector__))
+#else
+# define __no_stack_protector
+#endif
+
 /*
  * Optional: not supported by gcc.
  *
diff --git a/init/main.c b/init/main.c
index 5d6365510173..1265c8d11052 100644
--- a/init/main.c
+++ b/init/main.c
@@ -941,7 +941,8 @@ static void __init print_unknown_bootoptions(void)
memblock_free(unknown_options, len);
 }
 
-asmlinkage __visible void __init __no_sanitize_address __noreturn 
start_kernel(void)
+asmlinkage __visible __init __no_sanitize_address __noreturn 
__no_stack_protector
+void start_kernel(void)
 {
char *command_line;
char *after_dashes;

-- 
2.40.0.634.g4ca3ef3211-goog



Re: [PATCH v3 5/6] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler

2023-04-17 Thread Robert Richter
Hi Jonathan,

On 17.04.23 17:54:31, Jonathan Cameron wrote:
> On Fri, 14 Apr 2023 16:35:05 +0200
> Robert Richter  wrote:
> 
> > On 14.04.23 13:19:50, Jonathan Cameron wrote:
> > > On Tue, 11 Apr 2023 13:03:01 -0500
> > > Terry Bowman  wrote:
> > >   
> > > > From: Robert Richter 
> > > > 
> > > > In Restricted CXL Device (RCD) mode a CXL device is exposed as an
> > > > RCiEP, but CXL downstream and upstream ports are not enumerated and
> > > > not visible in the PCIe hierarchy. Protocol and link errors are sent
> > > > to an RCEC.
> > > > 
> > > > Restricted CXL host (RCH) downstream port-detected errors are signaled
> > > > as internal AER errors, either Uncorrectable Internal Error (UIE) or
> > > > Corrected Internal Errors (CIE). The error source is the id of the
> > > > RCEC. A CXL handler must then inspect the error status in various CXL
> > > > registers residing in the dport's component register space (CXL RAS
> > > > cap) or the dport's RCRB (AER ext cap). [1]
> > > > 
> > > > Errors showing up in the RCEC's error handler must be handled and
> > > > connected to the CXL subsystem. Implement this by forwarding the error
> > > > to all CXL devices below the RCEC. Since the entire CXL device is
> > > > controlled only using PCIe Configuration Space of device 0, Function
> > > > 0, only pass it there [2]. These devices have the Memory Device class
> > > > code set (PCI_CLASS_MEMORY_CXL, 502h) and the existing cxl_pci driver
> > > > can implement the handler.  
> > > 
> > > This comment implies only class code compliant drivers.  Sure we don't
> > > have drivers for anything else yet, but we should try to avoid saying
> > > there won't be any (which I think above implies).
> > > 
> > > You have a comment in the code, but maybe relaxing the description above
> > > to "currently support devices have..."  
> > 
> > It is used here to identify CXL memory devices and limit the
> > enablement to those. The spec requires this to be set for CXL mem devs
> > (see cxl 3.0, 8.1.12.2).
> > 
> > There could be other CXL devices (e.g. cache), but other drivers are
> > not yet implemented. That is what I am referring to. The check makes
> > sure there is actually a driver with a handler for it (cxl_pci).
> 
> Understood on intent. My worry is that the above can be read as a
> statement on hardware restrictions, rathe than on what software currently
> implements.  Meh. Minor point so I don't care that much!
> Unlikely anyone will read the patch description after it merges anyway ;)

I have updated the description ...

> > > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> > > > index 7a25b62d9e01..171a08fd8ebd 100644
> > > > --- a/drivers/pci/pcie/aer.c
> > > > +++ b/drivers/pci/pcie/aer.c
> > > > @@ -946,6 +946,65 @@ static bool find_source_device(struct pci_dev 
> > > > *parent,
> > > > return true;
> > > >  }
> > > >  
> > > > +#ifdef CONFIG_PCIEAER_CXL
> > > > +
> > > > +static bool is_cxl_mem_dev(struct pci_dev *dev)
> > > > +{
> > > > +   /*
> > > > +* A CXL device is controlled only using PCIe Configuration
> > > > +* Space of device 0, Function 0.  
> > > 
> > > That's not true in general.   Definitely true that CXL protocol
> > > error reporting is controlled only using this Devfn, but
> > > more generally there could be other stuff in later functions.
> > > So perhaps make the comment more specific.  
> > 
> > I actually mean CXL device in RCD mode here (seen as RCiEP in the PCI
> > hierarchy).
> > 
> > The spec says (cxl 3.0, 8.1.3):
> > 
> > """
> > In either case [(RCD and non-RCD)], the capability, status, and
> > control fields in Device 0, Function 0 DVSEC control the CXL
> > functionality of the entire device.
> 
> > """
> > 
> > So dev 0, func 0 must contain a CXL PCIe DVSEC. Thus it is a CXL
> > device and able to handle CXL AER errors. The limitation to the first
> > device prevents the handler from being run multiple times for the same
> > event.
> 
> Fine with limitation.  Text says "device is controlled only using".
> That is true for what you are controlling here, but other aspects of the
> device are controlled via whatever interface they like.
> 
> Perhaps just quote the specification as you have done in your reply. Then it
> is clear that we mean just these registers.

... and comments.

Thanks,

-Robert


Re: [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location

2023-04-17 Thread Mark Brown
On Mon, 03 Apr 2023 23:26:47 +0800, Liliang Ye wrote:
> of_node_put() should have been done directly after
> mqs_priv->regmap = syscon_node_to_regmap(gpr_np);
> otherwise it creates a reference leak on the success path.
> 
> To fix this, of_node_put() is moved to the correct location, and change
> all the gotos to direct returns.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: fsl_mqs: move of_node_put() to the correct location
  commit: 1c34890273a020d61d6127ade3f68ed1cb21c16a

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



Re: [PATCH 2/2] ASoC: fsl_mqs: call pm_runtime_disable() on error path

2023-04-17 Thread Mark Brown
On Mon, Apr 03, 2023 at 11:27:37PM +0800, Liliang Ye wrote:
> pm_runtime_disable was missed in cleanup operation, which corresponds to
> the earlier call to pm_runtime_enable.

This doesn't apply against current code, please check and resend.


signature.asc
Description: PGP signature


Re: [PATCH v3 5/6] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler

2023-04-17 Thread Jonathan Cameron
On Fri, 14 Apr 2023 16:35:05 +0200
Robert Richter  wrote:

> On 14.04.23 13:19:50, Jonathan Cameron wrote:
> > On Tue, 11 Apr 2023 13:03:01 -0500
> > Terry Bowman  wrote:
> >   
> > > From: Robert Richter 
> > > 
> > > In Restricted CXL Device (RCD) mode a CXL device is exposed as an
> > > RCiEP, but CXL downstream and upstream ports are not enumerated and
> > > not visible in the PCIe hierarchy. Protocol and link errors are sent
> > > to an RCEC.
> > > 
> > > Restricted CXL host (RCH) downstream port-detected errors are signaled
> > > as internal AER errors, either Uncorrectable Internal Error (UIE) or
> > > Corrected Internal Errors (CIE). The error source is the id of the
> > > RCEC. A CXL handler must then inspect the error status in various CXL
> > > registers residing in the dport's component register space (CXL RAS
> > > cap) or the dport's RCRB (AER ext cap). [1]
> > > 
> > > Errors showing up in the RCEC's error handler must be handled and
> > > connected to the CXL subsystem. Implement this by forwarding the error
> > > to all CXL devices below the RCEC. Since the entire CXL device is
> > > controlled only using PCIe Configuration Space of device 0, Function
> > > 0, only pass it there [2]. These devices have the Memory Device class
> > > code set (PCI_CLASS_MEMORY_CXL, 502h) and the existing cxl_pci driver
> > > can implement the handler.  
> > 
> > This comment implies only class code compliant drivers.  Sure we don't
> > have drivers for anything else yet, but we should try to avoid saying
> > there won't be any (which I think above implies).
> > 
> > You have a comment in the code, but maybe relaxing the description above
> > to "currently support devices have..."  
> 
> It is used here to identify CXL memory devices and limit the
> enablement to those. The spec requires this to be set for CXL mem devs
> (see cxl 3.0, 8.1.12.2).
> 
> There could be other CXL devices (e.g. cache), but other drivers are
> not yet implemented. That is what I am referring to. The check makes
> sure there is actually a driver with a handler for it (cxl_pci).

Understood on intent. My worry is that the above can be read as a
statement on hardware restrictions, rathe than on what software currently
implements.  Meh. Minor point so I don't care that much!
Unlikely anyone will read the patch description after it merges anyway ;)

> 
> >   
> > > In addition to errors directed to the CXL
> > > endpoint device, the handler must also inspect the CXL downstream
> > > port's CXL RAS and PCIe AER external capabilities that is connected to
> > > the device.
> > > 
> > > Since CXL downstream port errors are signaled using internal errors,
> > > the handler requires those errors to be unmasked. This is subject of a
> > > follow-on patch.
> > > 
> > > The reason for choosing this implementation is that a CXL RCEC device
> > > is bound to the AER port driver, but the driver does not allow it to
> > > register a custom specific handler to support CXL. Connecting the RCEC
> > > hard-wired with a CXL handler does not work, as the CXL subsystem
> > > might not be present all the time. The alternative to add an
> > > implementation to the portdrv to allow the registration of a custom
> > > RCEC error handler isn't worth doing it as CXL would be its only user.
> > > Instead, just check for an CXL RCEC and pass it down to the connected
> > > CXL device's error handler. With this approach the code can entirely
> > > be implemented in the PCIe AER driver and is independent of the CXL
> > > subsystem. The CXL driver only provides the handler.
> > > 
> > > [1] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
> > > [2] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices
> > > 
> > > Co-developed-by: Terry Bowman 
> > > Signed-off-by: Robert Richter 
> > > Signed-off-by: Terry Bowman 
> > > Cc: "Oliver O'Halloran" 
> > > Cc: Bjorn Helgaas 
> > > Cc: Mahesh J Salgaonkar 
> > > Cc: linuxppc-dev@lists.ozlabs.org
> > > Cc: linux-...@vger.kernel.org  
> > 
> > Generally looks good to me.  A few trivial comments inline.
> >   
> > > ---
> > >  drivers/pci/pcie/Kconfig |  8 ++
> > >  drivers/pci/pcie/aer.c   | 61 
> > >  2 files changed, 69 insertions(+)
> > > 
> > > diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
> > > index 228652a59f27..b0dbd864d3a3 100644
> > > --- a/drivers/pci/pcie/Kconfig
> > > +++ b/drivers/pci/pcie/Kconfig
> > > @@ -49,6 +49,14 @@ config PCIEAER_INJECT
> > > gotten from:
> > >
> > > https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/
> > >  
> > > +config PCIEAER_CXL
> > > + bool "PCI Express CXL RAS support"  
> > 
> > Description makes this sound too general. I'd mentioned restricted
> > hosts even in the menu option title.
> > 
> >   
> > > + default y
> > > + depends on PCIEAER && CXL_PCI
> > > + help
> > > +   This enables CXL error handling for Restricted CXL Hosts
> > > +   (RCHs).  
> > 
> > Spec term is probably fine 

Re: [PATCH 1/4] add generic builtin command line

2023-04-17 Thread Daniel Walker (danielwa)
On Mon, Apr 17, 2023 at 06:18:18PM +0200, Tomas Mudrunka wrote:
> This seems quite useful. Can you please merge it?

I need to re-send it before it can be merge. I'll try to update it soon.

Daniel


Re: [RFC PATCH 0/4] Remove some e500/MPC85xx evaluation platforms

2023-04-17 Thread Paul Gortmaker
[RE: [RFC PATCH 0/4] Remove some e500/MPC85xx evaluation platforms] On 
14/04/2023 (Fri 23:29) Leo Li wrote:

> 
> 
> > -Original Message-
> > From: Michael Ellerman 
> > Sent: Thursday, April 13, 2023 9:14 PM
> > To: Leo Li ; Paul Gortmaker
> > 
> > Cc: Scott Wood ; Paul Mackerras ;
> > Claudiu Manoil ; linuxppc-dev@lists.ozlabs.org;
> > Pali Roh??r 
> > Subject: Re: [RFC PATCH 0/4] Remove some e500/MPC85xx evaluation
> > platforms
> > 
> > Li Yang  writes:
> > > On Tue, Feb 21, 2023 at 1:52???PM Paul Gortmaker
> > >  wrote:
> > >>
> > >> [This RFC is proposed for v6.4 and hence is based off linux-next.]
> > >>
> > >> In a similar theme to the e300/MPC83xx evaluation platform
> > >> removal[1], this targets removal of some 13 --> 21 year old
> > >> e500/MPC85xx evaluation boards that were produced in limited numbers
> > >> and primarily made available to hardware/software developers to shape
> > their own boards and BSPs.
> > >
> > > These e500 platforms are similar to the e300 platforms that they are
> > > still being shipped, the targeting market probably caused it to have a
> > > longer life cycle.
> > >
> > ...
> > >
> > > The difference here from the e300 platforms is that MPC8540ADS,
> > > MPC8560ADS, MPC8548CDS, MPC8568-MDS are the only reference
> > platforms
> > > supplied by us for these SoCs.  We don't have a separation of
> > > evaluation platforms vs product-like platforms like we did later.
> > > That probably means even if they don't look like "hobbyist" friendly
> > > they are more likely to be still in use.
> > 
> > OK. But what is the chance anyone is booting upstream kernels on them?
> 
> We do still have these parts shipped, which means that there are definitely 
> active users of these silicons.  But it is really hard to say how many of 
> they are running latest upstream kernel.  IMO, if the nature of the 
> application is critical it is likely they will need to update the kernel to 
> get all the security fixes.  And the reference board will be helpful as a 
> starting point when they update the kernel.

I think the right thing to do here with this series is to remove the
super ancient 20+ year old MPC8540ADS and MPC8560ADS; and leave the
slightly more modern ones for another day in the future.

I don't think anyone can realistically argue against that?

Paul.
--

> 
> > 
> > I assume no one at NXP is testing upstream on those boards?
> 
> To be frank they are not included in the routine tests carried out by the 
> development team now which is not ideal to me.  But I think the support team 
> are probably willing to help on issues with latest kernel when needed.
> 
> Regards,
> Leo


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread John Paul Adrian Glaubitz
On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:
> Replace the architecture's fbdev helpers with the generic
> ones from . No functional changes.
> 
> v2:
>   * use default implementation for fb_pgprotect() (Arnd)
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: Yoshinori Sato 
> Cc: Rich Felker 
> Cc: John Paul Adrian Glaubitz 
> ---
>  arch/sh/include/asm/fb.h | 15 +--
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
> index 9a0bca2686fd..19df13ee9ca7 100644
> --- a/arch/sh/include/asm/fb.h
> +++ b/arch/sh/include/asm/fb.h
> @@ -2,19 +2,6 @@
>  #ifndef _ASM_FB_H_
>  #define _ASM_FB_H_
>  
> -#include 
> -#include 
> -#include 
> -
> -static inline void fb_pgprotect(struct file *file, struct vm_area_struct 
> *vma,
> - unsigned long off)
> -{
> - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
> -}
> -
> -static inline int fb_is_primary_device(struct fb_info *info)
> -{
> - return 0;
> -}
> +#include 
>  
>  #endif /* _ASM_FB_H_ */

Acked-by: John Paul Adrian Glaubitz 

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann

Hi

Am 17.04.23 um 16:13 schrieb John Paul Adrian Glaubitz:

Hi Thomas!

On Mon, 2023-04-17 at 16:06 +0200, Thomas Zimmermann wrote:

Hi

Am 17.04.23 um 15:02 schrieb John Paul Adrian Glaubitz:

Hi Thomas!

On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:

Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: John Paul Adrian Glaubitz 
---
   arch/sh/include/asm/fb.h | 15 +--
   1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
index 9a0bca2686fd..19df13ee9ca7 100644
--- a/arch/sh/include/asm/fb.h
+++ b/arch/sh/include/asm/fb.h
@@ -2,19 +2,6 @@
   #ifndef _ASM_FB_H_
   #define _ASM_FB_H_
   
-#include 

-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}


Looking at the macro in asm-generic/fb.h, fb_pgprotect() is being replaced with
a no-op function. Is that intentional? Can you briefly explain the background
for this change?


Patch 01 of this patchset changes the generic fb_pgprotect() to set
pgprot_writecombine(). So on SH, there should be no change at all.



Ah, I missed that, thanks for the explanation. Let me check and Ack your patch


Thanks!


then. I assume you will be taking this patch as part of the whole series through
your own tree?


Yes, I'd merge it through drm-misc-next ideally.

Best regards
Thomas



Thanks,
Adrian



--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread John Paul Adrian Glaubitz
Hi Thomas!

On Mon, 2023-04-17 at 16:06 +0200, Thomas Zimmermann wrote:
> Hi
> 
> Am 17.04.23 um 15:02 schrieb John Paul Adrian Glaubitz:
> > Hi Thomas!
> > 
> > On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:
> > > Replace the architecture's fbdev helpers with the generic
> > > ones from . No functional changes.
> > > 
> > > v2:
> > >   * use default implementation for fb_pgprotect() (Arnd)
> > > 
> > > Signed-off-by: Thomas Zimmermann 
> > > Cc: Yoshinori Sato 
> > > Cc: Rich Felker 
> > > Cc: John Paul Adrian Glaubitz 
> > > ---
> > >   arch/sh/include/asm/fb.h | 15 +--
> > >   1 file changed, 1 insertion(+), 14 deletions(-)
> > > 
> > > diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
> > > index 9a0bca2686fd..19df13ee9ca7 100644
> > > --- a/arch/sh/include/asm/fb.h
> > > +++ b/arch/sh/include/asm/fb.h
> > > @@ -2,19 +2,6 @@
> > >   #ifndef _ASM_FB_H_
> > >   #define _ASM_FB_H_
> > >   
> > > -#include 
> > > -#include 
> > > -#include 
> > > -
> > > -static inline void fb_pgprotect(struct file *file, struct vm_area_struct 
> > > *vma,
> > > - unsigned long off)
> > > -{
> > > - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
> > > -}
> > 
> > Looking at the macro in asm-generic/fb.h, fb_pgprotect() is being replaced 
> > with
> > a no-op function. Is that intentional? Can you briefly explain the 
> > background
> > for this change?
> 
> Patch 01 of this patchset changes the generic fb_pgprotect() to set 
> pgprot_writecombine(). So on SH, there should be no change at all.
> 

Ah, I missed that, thanks for the explanation. Let me check and Ack your patch
then. I assume you will be taking this patch as part of the whole series through
your own tree?

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH v3 00/19] arch: Consolidate

2023-04-17 Thread Arnd Bergmann
On Mon, Apr 17, 2023, at 14:56, Thomas Zimmermann wrote:
> Various architectures provide  with helpers for fbdev
> framebuffer devices. Share the contained code where possible. There
> is already , which implements generic (as in
> 'empty') functions of the fbdev helpers. The header was added in
> commit aafe4dbed0bf ("asm-generic: add generic versions of common
> headers"), but never used.
>
> Each per-architecture header file declares and/or implements fbdev
> helpers and defines a preprocessor token for each. The generic
> header then provides the remaining helpers. It works like the I/O
> helpers in .

Looks all good to me,

Acked-by: Arnd Bergmann 

 Arnd


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann



Am 17.04.23 um 16:06 schrieb Thomas Zimmermann:

Hi

Am 17.04.23 um 15:02 schrieb John Paul Adrian Glaubitz:

Hi Thomas!

On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:

Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: John Paul Adrian Glaubitz 
---
  arch/sh/include/asm/fb.h | 15 +--
  1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
index 9a0bca2686fd..19df13ee9ca7 100644
--- a/arch/sh/include/asm/fb.h
+++ b/arch/sh/include/asm/fb.h
@@ -2,19 +2,6 @@
  #ifndef _ASM_FB_H_
  #define _ASM_FB_H_
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,

-    unsigned long off)
-{
-    vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}


Looking at the macro in asm-generic/fb.h, fb_pgprotect() is being 
replaced with
a no-op function. Is that intentional? Can you briefly explain the 
background

for this change?


Patch 01 of this patchset changes the generic fb_pgprotect() to set 
pgprot_writecombine(). So on SH, there should be no change at all.


In case you didn't receive that patch:

  https://patchwork.freedesktop.org/patch/532493/?series=116157=3



Best regards
Thomas




-static inline int fb_is_primary_device(struct fb_info *info)
-{
-    return 0;
-}
+#include 
  #endif /* _ASM_FB_H_ */


Thanks,
Adrian





--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann

Hi

Am 17.04.23 um 15:02 schrieb John Paul Adrian Glaubitz:

Hi Thomas!

On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:

Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: John Paul Adrian Glaubitz 
---
  arch/sh/include/asm/fb.h | 15 +--
  1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
index 9a0bca2686fd..19df13ee9ca7 100644
--- a/arch/sh/include/asm/fb.h
+++ b/arch/sh/include/asm/fb.h
@@ -2,19 +2,6 @@
  #ifndef _ASM_FB_H_
  #define _ASM_FB_H_
  
-#include 

-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}


Looking at the macro in asm-generic/fb.h, fb_pgprotect() is being replaced with
a no-op function. Is that intentional? Can you briefly explain the background
for this change?


Patch 01 of this patchset changes the generic fb_pgprotect() to set 
pgprot_writecombine(). So on SH, there should be no change at all.


Best regards
Thomas




-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
  
  #endif /* _ASM_FB_H_ */


Thanks,
Adrian



--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH] Revert "powerpc/rtas: Implement reentrant rtas call"

2023-04-17 Thread Nathan Lynch
Michal Suchánek  writes:
> On Fri, Sep 16, 2022 at 04:56:18PM -0500, Nathan Lynch wrote:
>> "Nicholas Piggin"  writes:
>> > On Wed Sep 14, 2022 at 3:39 AM AEST, Leonardo Brás wrote:
>> >> On Mon, 2022-09-12 at 14:58 -0500, Nathan Lynch wrote:
>> >> > Leonardo Brás  writes:
>> >> > > On Fri, 2022-09-09 at 09:04 -0500, Nathan Lynch wrote:
>
>> >> > > > No, it means the premise of commit b664db8e3f97 ("powerpc/rtas:
>> >> > > > Implement reentrant rtas call") change is incorrect. The "reentrant"
>> >> > > > property described in the spec applies only to the individual RTAS
>> >> > > > functions. The OS can invoke (for example) ibm,set-xive on multiple 
>> >> > > > CPUs
>> >> > > > simultaneously, but it must adhere to the more general requirement 
>> >> > > > to
>> >> > > > serialize with other RTAS functions.
>> >> > > > 
>> >> > > 
>> >> > > I see. Thanks for explaining that part!
>> >> > > I agree: reentrant calls that way don't look as useful on Linux than I
>> >> > > previously thought.
>> >> > > 
>> >> > > OTOH, I think that instead of reverting the change, we could make use 
>> >> > > of the
>> >> > > correct information and fix the current implementation. (This could 
>> >> > > help when we
>> >> > > do the same rtas call in multiple cpus)
>> >> > 
>> >> > Hmm I'm happy to be mistaken here, but I doubt we ever really need to do
>> >> > that. I'm not seeing the need.
>> >> > 
>> >> > > I have an idea of a patch to fix this. 
>> >> > > Do you think it would be ok if I sent that, to prospect being an 
>> >> > > alternative to
>> >> > > this reversion?
>> >> > 
>> >> > It is my preference, and I believe it is more common, to revert to the
>> >> > well-understood prior state, imperfect as it may be. The revert can be
>> >> > backported to -stable and distros while development and review of
>> >> > another approach proceeds.
>> >>
>> >> Ok then, as long as you are aware of the kdump bug, I'm good.
>> >>
>> >> FWIW:
>> >> Reviewed-by: Leonardo Bras 
>> >
>> > A shame. I guess a reader/writer lock would not be much help because
>> > the crash is probably more likely to hit longer running rtas calls?
>> >
>> > Alternative is just cheat and do this...?
>> >
>> > Thanks,
>> > Nick
>> >
>> > diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
>> > index 693133972294..89728714a06e 100644
>> > --- a/arch/powerpc/kernel/rtas.c
>> > +++ b/arch/powerpc/kernel/rtas.c
>> > @@ -26,6 +26,7 @@
>> >  #include 
>> >  #include 
>> >  #include 
>> > +#include 
>> >  
>> >  #include 
>> >  #include 
>> > @@ -97,6 +98,19 @@ static unsigned long lock_rtas(void)
>> >  {
>> > unsigned long flags;
>> >  
>> > +   if (atomic_read(_cpu) == raw_smp_processor_id()) {
>> > +   /*
>> > +* Crash in progress on this CPU. Other CPUs should be
>> > +* stopped by now, so skip the lock in case it was being
>> > +* held, and is now needed for crashing e.g., kexec
>> > +* (machine_kexec_mask_interrupts) requires rtas calls.
>> > +*
>> > +* It's possible this could have caused rtas state
>> > breakage
>> > +* but the alternative is deadlock.
>> > +*/
>> > +   return 0;
>> > +   }
>> > +
>> > local_irq_save(flags);
>> > preempt_disable();
>> > arch_spin_lock();
>> > @@ -105,6 +119,9 @@ static unsigned long lock_rtas(void)
>> >  
>> >  static void unlock_rtas(unsigned long flags)
>> >  {
>> > +   if (atomic_read(_cpu) == raw_smp_processor_id())
>> > +   return;
>> > +
>> > arch_spin_unlock();
>> > local_irq_restore(flags);
>> > preempt_enable();
>> 
>> Looks correct.
>> 
>> I wonder - would it be worth making the panic path use a separate
>> "emergency" rtas_args buffer as well? If a CPU is actually "stuck" in
>> RTAS at panic time, then leaving rtas.args untouched might make the
>> ibm,int-off, ibm,set-xive, ibm,os-term, and any other RTAS calls we
>> incur on the panic path more likely to succeed.
>
> Was some fix for the case of crashing in rtas merged?
>
> Looks like there is none unless I missed something.

I'm not aware of any crashes in RTAS, but we do have an issue open to
track the issue I think you're referring to:

https://github.com/linuxppc/issues/issues/435

No progress yet. AFAIK only XICS guests are exposed; XIVE doesn't use
RTAS calls.


Re: [PATCH v3 1/1] of: fdt: Scan /memreserve/ last

2023-04-17 Thread Rob Herring
On Wed, Apr 12, 2023 at 5:46 PM Lucas Tanure  wrote:
>
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.

Please give some background details why we need to make this change.
As-is, sounds like some theoretical issue. IOW, incorporate some of
the details in the cover letter here. For single patches, you don't
need a cover letter anyways.

Powerpc folks, please comment and/or test. I worry there could be some
subtle differences with this change.

>
> Signed-off-by: Lucas Tanure 
> ---
>  drivers/of/fdt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..c28aedd7ae1f 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,6 +635,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> +   fdt_scan_reserved_mem();
> +   fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, , );
> @@ -643,8 +646,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
> memblock_reserve(base, size);
> }
>
> -   fdt_scan_reserved_mem();
> -   fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
>  }
>
> --
> 2.40.0
>


Re: [PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread John Paul Adrian Glaubitz
Hi Thomas!

On Mon, 2023-04-17 at 14:56 +0200, Thomas Zimmermann wrote:
> Replace the architecture's fbdev helpers with the generic
> ones from . No functional changes.
> 
> v2:
>   * use default implementation for fb_pgprotect() (Arnd)
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: Yoshinori Sato 
> Cc: Rich Felker 
> Cc: John Paul Adrian Glaubitz 
> ---
>  arch/sh/include/asm/fb.h | 15 +--
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
> index 9a0bca2686fd..19df13ee9ca7 100644
> --- a/arch/sh/include/asm/fb.h
> +++ b/arch/sh/include/asm/fb.h
> @@ -2,19 +2,6 @@
>  #ifndef _ASM_FB_H_
>  #define _ASM_FB_H_
>  
> -#include 
> -#include 
> -#include 
> -
> -static inline void fb_pgprotect(struct file *file, struct vm_area_struct 
> *vma,
> - unsigned long off)
> -{
> - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
> -}

Looking at the macro in asm-generic/fb.h, fb_pgprotect() is being replaced with
a no-op function. Is that intentional? Can you briefly explain the background
for this change?

> -static inline int fb_is_primary_device(struct fb_info *info)
> -{
> - return 0;
> -}
> +#include 
>  
>  #endif /* _ASM_FB_H_ */

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH 3/3] PCI/DPC: Disable DPC service on suspend when IRQ is shared with PME

2023-04-17 Thread Kai-Heng Feng
On Thu, Sep 29, 2022 at 5:24 AM Bjorn Helgaas  wrote:
>
> On Wed, Jul 27, 2022 at 09:32:52AM +0800, Kai-Heng Feng wrote:
> > PCIe service that shares IRQ with PME may cause spurious wakeup on
> > system suspend.
> >
> > Since AER is conditionally disabled in previous patch, also apply the
> > same condition to disable DPC which depends on AER to work.
> >
> > PCIe Base Spec 5.0, section 5.2 "Link State Power Management" states
> > that TLP and DLLP transmission is disabled for a Link in L2/L3 Ready
> > (D3hot), L2 (D3cold with aux power) and L3 (D3cold), so we don't lose
> > much here to disable DPC during system suspend.
> >
> > This is very similar to previous attempts to suspend AER and DPC [1],
> > but with a different reason.
> >
> > [1] 
> > https://lore.kernel.org/linux-pci/20220408153159.106741-1-kai.heng.f...@canonical.com/
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216295
> >
> > Signed-off-by: Kai-Heng Feng 
> > ---
> >  drivers/pci/pcie/dpc.c | 52 +-
> >  1 file changed, 41 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> > index 3e9afee02e8d1..542f282c43f75 100644
> > --- a/drivers/pci/pcie/dpc.c
> > +++ b/drivers/pci/pcie/dpc.c
> > @@ -343,13 +343,33 @@ void pci_dpc_init(struct pci_dev *pdev)
> >   }
> >  }
> >
> > +static void dpc_enable(struct pcie_device *dev)
> > +{
> > + struct pci_dev *pdev = dev->port;
> > + u16 ctl;
> > +
> > + pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, );
> > + ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_FATAL | 
> > PCI_EXP_DPC_CTL_INT_EN;
> > + pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl);
> > +}
>

Sorry for the belated response.

> I guess the reason we need this is because we disable interupts in
> pci_pm_suspend() first, then we call pci_save_dpc_state() from
> pci_pm_suspend_noirq(), so we save the *disabled* control register.
> Then when we resume, we restore that disabled control register so we
> need to enable DPC again.  Right?

Sorry for the belated response.

Yes, and the same logic applies to AER too.

>
> I think we should save a "dpc_enabled" bit in the pci_dev and
> conditionally set PCI_EXP_DPC_CTL_INT_EN here.  If we unconditionally
> set it here, we depend on portdrv *not* calling dpc_resume() if we
> didn't enable DPC at enumeration-time for some reason.

Does this scenario really happen?
Once the port is marked with PCIE_PORT_SERVICE_DPC, DPC will be
enabled by dpc_probe().
So an additional bit seems to be unnecessary.

>
> And I would leave PCI_EXP_DPC_CTL_EN_FATAL alone; see below.
>
> > +static void dpc_disable(struct pcie_device *dev)
> > +{
> > + struct pci_dev *pdev = dev->port;
> > + u16 ctl;
> > +
> > + pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, );
> > + ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN);
> > + pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl);
>
>   #define  PCI_EXP_DPC_CTL_EN_FATAL   0x0001
>   #define  PCI_EXP_DPC_CTL_INT_EN 0x0008
>
> Clearing PCI_EXP_DPC_CTL_INT_EN makes sense to me, but I don't
> understand the PCI_EXP_DPC_CTL_EN_FATAL part.
>
> PCI_EXP_DPC_CTL_EN_FATAL is one of the four values of the two-bit DPC
> Trigger Enable, so clearing that bit leaves the field as either 00b
> (DPC is disabled) or 10b (DPC enabled and triggered when the port
> detects an uncorrectable error or receives an ERR_NONFATAL or
> ERR_FATAL message).
>
> I think we should only clear PCI_EXP_DPC_CTL_INT_EN.

Yes, clearing PCI_EXP_DPC_CTL_INT_EN should be sufficient.

>
> > +}
> > +
> >  #define FLAG(x, y) (((x) & (y)) ? '+' : '-')
> >  static int dpc_probe(struct pcie_device *dev)
> >  {
> >   struct pci_dev *pdev = dev->port;
> >   struct device *device = >device;
> >   int status;
> > - u16 ctl, cap;
> > + u16 cap;
> >
> >   if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
> >   return -ENOTSUPP;
> > @@ -364,10 +384,7 @@ static int dpc_probe(struct pcie_device *dev)
> >   }
> >
> >   pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CAP, );
> > - pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, );
> > -
> > - ctl = (ctl & 0xfff4) | PCI_EXP_DPC_CTL_EN_FATAL | 
> > PCI_EXP_DPC_CTL_INT_EN;
> > - pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_CTL, ctl);
>
> I think we should keep the PCI_EXP_DPC_CTL_EN_FATAL part here. That
> just sets the desired trigger mode but AFAICT, has nothing to do with
> generating interrupts.

Agree. Will do it in next revision.

>
> > + dpc_enable(dev);
>
> Then dpc_enable() could be called something like dpc_enable_irq(), and
> it would *only* control interupt generation.

Will do.

Kai-Heng

>
> >   pci_info(pdev, "enabled with IRQ %d\n", dev->irq);
> >
> >   pci_info(pdev, "error containment capabilities: Int Msg #%d, RPExt%c 
> > PoisonedTLP%c SwTrigger%c RP PIO Log 

[PATCH v3 19/19] arch/x86: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Include  and set the required preprocessor tokens
correctly. x86 now implements its own set of fb helpers, but still
follows the overall pattern of the other  files.

v3:
* clarified commit message

Signed-off-by: Thomas Zimmermann 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: "H. Peter Anvin" 
---
 arch/x86/include/asm/fb.h | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/fb.h b/arch/x86/include/asm/fb.h
index ab4c960146e3..a3fb801f12f1 100644
--- a/arch/x86/include/asm/fb.h
+++ b/arch/x86/include/asm/fb.h
@@ -2,10 +2,11 @@
 #ifndef _ASM_X86_FB_H
 #define _ASM_X86_FB_H
 
-#include 
-#include 
 #include 
 
+struct fb_info;
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
 {
@@ -16,7 +17,11 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
pgprot_val(vma->vm_page_prot) =
prot | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
 }
+#define fb_pgprotect fb_pgprotect
+
+int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
 
-extern int fb_is_primary_device(struct fb_info *info);
+#include 
 
 #endif /* _ASM_X86_FB_H */
-- 
2.40.0



[PATCH v3 14/19] arch/parisc: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic ones
from . On PARISC, pgprot_writecombine() and
pgprot_noncached() are the same; hence no functional changes.

v3:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
---
 arch/parisc/include/asm/fb.h | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/arch/parisc/include/asm/fb.h b/arch/parisc/include/asm/fb.h
index 0b9a38ced5c8..658a8a7dc531 100644
--- a/arch/parisc/include/asm/fb.h
+++ b/arch/parisc/include/asm/fb.h
@@ -2,23 +2,13 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
-}
+struct fb_info;
 
 #if defined(CONFIG_STI_CORE)
 int fb_is_primary_device(struct fb_info *info);
-#else
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#define fb_is_primary_device fb_is_primary_device
 #endif
 
+#include 
+
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 15/19] arch/powerpc: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fb_is_primary_device() with the generic
one from . No functional changes.

Signed-off-by: Thomas Zimmermann 
Cc: Michael Ellerman 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Acked-by: Michael Ellerman 
---
 arch/powerpc/include/asm/fb.h | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/fb.h b/arch/powerpc/include/asm/fb.h
index 6541ab77c5b9..5f1a2e5f7654 100644
--- a/arch/powerpc/include/asm/fb.h
+++ b/arch/powerpc/include/asm/fb.h
@@ -2,8 +2,8 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
 #include 
+
 #include 
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
@@ -13,10 +13,8 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
 vma->vm_end - vma->vm_start,
 vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 13/19] arch/parisc: Implement fb_is_primary_device() under arch/parisc

2023-04-17 Thread Thomas Zimmermann
Move PARISC's implementation of fb_is_primary_device() into the
architecture directory. This the place of the declaration and
where other architectures implement this function. No functional
changes.

Signed-off-by: Thomas Zimmermann 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
---
 arch/parisc/Makefile |  2 ++
 arch/parisc/include/asm/fb.h |  2 +-
 arch/parisc/video/Makefile   |  3 +++
 arch/parisc/video/fbdev.c| 27 +++
 drivers/video/sticore.c  | 19 ---
 include/video/sticore.h  |  2 ++
 6 files changed, 35 insertions(+), 20 deletions(-)
 create mode 100644 arch/parisc/video/Makefile
 create mode 100644 arch/parisc/video/fbdev.c

diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 0d049a6f6a60..968ebe17494c 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -119,6 +119,8 @@ export LIBGCC
 
 libs-y += arch/parisc/lib/ $(LIBGCC)
 
+drivers-y += arch/parisc/video/
+
 boot   := arch/parisc/boot
 
 PALO := $(shell if (which palo 2>&1); then : ; \
diff --git a/arch/parisc/include/asm/fb.h b/arch/parisc/include/asm/fb.h
index 55d29c4f716e..0b9a38ced5c8 100644
--- a/arch/parisc/include/asm/fb.h
+++ b/arch/parisc/include/asm/fb.h
@@ -12,7 +12,7 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
 }
 
-#if defined(CONFIG_FB_STI)
+#if defined(CONFIG_STI_CORE)
 int fb_is_primary_device(struct fb_info *info);
 #else
 static inline int fb_is_primary_device(struct fb_info *info)
diff --git a/arch/parisc/video/Makefile b/arch/parisc/video/Makefile
new file mode 100644
index ..16a73cce4661
--- /dev/null
+++ b/arch/parisc/video/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_STI_CORE) += fbdev.o
diff --git a/arch/parisc/video/fbdev.c b/arch/parisc/video/fbdev.c
new file mode 100644
index ..4a0ae08fc75b
--- /dev/null
+++ b/arch/parisc/video/fbdev.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2000 Philipp Rumpf 
+ * Copyright (C) 2001-2020 Helge Deller 
+ * Copyright (C) 2001-2002 Thomas Bogendoerfer 
+ */
+
+#include 
+
+#include 
+
+#include 
+
+int fb_is_primary_device(struct fb_info *info)
+{
+   struct sti_struct *sti;
+
+   sti = sti_get_rom(0);
+
+   /* if no built-in graphics card found, allow any fb driver as default */
+   if (!sti)
+   return true;
+
+   /* return true if it's the default built-in framebuffer driver */
+   return (sti->info == info);
+}
+EXPORT_SYMBOL(fb_is_primary_device);
diff --git a/drivers/video/sticore.c b/drivers/video/sticore.c
index f8aaedea437d..7eb925f2ba9c 100644
--- a/drivers/video/sticore.c
+++ b/drivers/video/sticore.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -1148,24 +1147,6 @@ int sti_call(const struct sti_struct *sti, unsigned long 
func,
return ret;
 }
 
-#if defined(CONFIG_FB_STI)
-/* check if given fb_info is the primary device */
-int fb_is_primary_device(struct fb_info *info)
-{
-   struct sti_struct *sti;
-
-   sti = sti_get_rom(0);
-
-   /* if no built-in graphics card found, allow any fb driver as default */
-   if (!sti)
-   return true;
-
-   /* return true if it's the default built-in framebuffer driver */
-   return (sti->info == info);
-}
-EXPORT_SYMBOL(fb_is_primary_device);
-#endif
-
 MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
 MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP 
PARISC machines");
 MODULE_LICENSE("GPL v2");
diff --git a/include/video/sticore.h b/include/video/sticore.h
index c0879352cde4..fbb78d7e7565 100644
--- a/include/video/sticore.h
+++ b/include/video/sticore.h
@@ -2,6 +2,8 @@
 #ifndef STICORE_H
 #define STICORE_H
 
+struct fb_info;
+
 /* generic STI structures & functions */
 
 #define MAX_STI_ROMS 4 /* max no. of ROMs which this driver handles */
-- 
2.40.0



[PATCH v3 12/19] arch/parisc: Remove trailing whitespaces

2023-04-17 Thread Thomas Zimmermann
Fix trailing whitespaces. No functional changes.

Signed-off-by: Thomas Zimmermann 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
---
 arch/parisc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index a2d8600521f9..0d049a6f6a60 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -11,7 +11,7 @@
 # Copyright (C) 1994 by Linus Torvalds
 # Portions Copyright (C) 1999 The Puffin Group
 #
-# Modified for PA-RISC Linux by Paul Lahaie, Alex deVries, 
+# Modified for PA-RISC Linux by Paul Lahaie, Alex deVries,
 # Mike Shaver, Helge Deller and Martin K. Petersen
 #
 
-- 
2.40.0



[PATCH v3 18/19] arch/sparc: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace sparc64's fb_pgprotect() with the generic one
from . On sparc, pgprot_writecombine() and
pgprot_noncached() are the same; hence no functional changes

v3:
* use default implementation for fb_pgprotect() on
  sparc64 (Arnd)
v2:
* restore the original fb_pgprotect()

Signed-off-by: Thomas Zimmermann 
Cc: "David S. Miller" 
---
 arch/sparc/include/asm/fb.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index 28609f7a965c..689ee5c60054 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -2,20 +2,20 @@
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
 
-#include 
-
-#include 
-
 struct fb_info;
+struct file;
+struct vm_area_struct;
 
+#ifdef CONFIG_SPARC32
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
-{
-#ifdef CONFIG_SPARC64
-   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+{ }
+#define fb_pgprotect fb_pgprotect
 #endif
-}
 
 int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
+
+#include 
 
 #endif /* _SPARC_FB_H_ */
-- 
2.40.0



[PATCH v3 17/19] arch/sparc: Implement fb_is_primary_device() in source file

2023-04-17 Thread Thomas Zimmermann
Other architectures implment fb_is_primary_device() in a source
file. Do the same on sparc. No functional changes, but allows to
remove several include statement from .

v2:
* don't include  in header file

Signed-off-by: Thomas Zimmermann 
Cc: "David S. Miller" 
---
 arch/sparc/Makefile |  1 +
 arch/sparc/include/asm/fb.h | 23 +--
 arch/sparc/video/Makefile   |  3 +++
 arch/sparc/video/fbdev.c| 24 
 4 files changed, 33 insertions(+), 18 deletions(-)
 create mode 100644 arch/sparc/video/Makefile
 create mode 100644 arch/sparc/video/fbdev.c

diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index a4ea5b05f288..95a9211e48e3 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -60,6 +60,7 @@ libs-y += arch/sparc/prom/
 libs-y += arch/sparc/lib/
 
 drivers-$(CONFIG_PM) += arch/sparc/power/
+drivers-$(CONFIG_FB) += arch/sparc/video/
 
 boot := arch/sparc/boot
 
diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index f699962e9ddf..28609f7a965c 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -1,11 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
-#include 
-#include 
+
 #include 
+
 #include 
-#include 
+
+struct fb_info;
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
@@ -15,20 +16,6 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
 #endif
 }
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   struct device *dev = info->device;
-   struct device_node *node;
-
-   if (console_set_on_cmdline)
-   return 0;
-
-   node = dev->of_node;
-   if (node &&
-   node == of_console_device)
-   return 1;
-
-   return 0;
-}
+int fb_is_primary_device(struct fb_info *info);
 
 #endif /* _SPARC_FB_H_ */
diff --git a/arch/sparc/video/Makefile b/arch/sparc/video/Makefile
new file mode 100644
index ..6baddbd58e4d
--- /dev/null
+++ b/arch/sparc/video/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_FB) += fbdev.o
diff --git a/arch/sparc/video/fbdev.c b/arch/sparc/video/fbdev.c
new file mode 100644
index ..dadd5799fbb3
--- /dev/null
+++ b/arch/sparc/video/fbdev.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+int fb_is_primary_device(struct fb_info *info)
+{
+   struct device *dev = info->device;
+   struct device_node *node;
+
+   if (console_set_on_cmdline)
+   return 0;
+
+   node = dev->of_node;
+   if (node && node == of_console_device)
+   return 1;
+
+   return 0;
+}
+EXPORT_SYMBOL(fb_is_primary_device);
-- 
2.40.0



[PATCH v3 16/19] arch/sh: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: John Paul Adrian Glaubitz 
---
 arch/sh/include/asm/fb.h | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/sh/include/asm/fb.h b/arch/sh/include/asm/fb.h
index 9a0bca2686fd..19df13ee9ca7 100644
--- a/arch/sh/include/asm/fb.h
+++ b/arch/sh/include/asm/fb.h
@@ -2,19 +2,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 10/19] video: Remove trailing whitespaces

2023-04-17 Thread Thomas Zimmermann
Fix trailing whitespaces. No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/console/sticon.c  |   4 +-
 drivers/video/console/sticore.c | 102 ++---
 drivers/video/fbdev/sticore.h   |  14 +--
 drivers/video/fbdev/stifb.c | 156 
 4 files changed, 138 insertions(+), 138 deletions(-)

diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 2cea69418a83..89ad7ade6cf9 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -282,7 +282,7 @@ static void sticon_init(struct vc_data *c, int init)
 vc_cols = sti_onscreen_x(sti) / sti->font->width;
 vc_rows = sti_onscreen_y(sti) / sti->font->height;
 c->vc_can_do_color = 1;
-
+
 if (init) {
c->vc_cols = vc_cols;
c->vc_rows = vc_rows;
@@ -374,7 +374,7 @@ static const struct consw sti_con = {
.con_font_set   = sticon_font_set,
.con_font_default   = sticon_font_default,
.con_build_attr = sticon_build_attr,
-   .con_invert_region  = sticon_invert_region, 
+   .con_invert_region  = sticon_invert_region,
 };
 
 
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index db568f67e4dc..6ea9596a3c4b 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -6,12 +6,12 @@
  * Copyright (C) 2000 Philipp Rumpf 
  * Copyright (C) 2001-2020 Helge Deller 
  * Copyright (C) 2001-2002 Thomas Bogendoerfer 
- * 
+ *
  * TODO:
  * - call STI in virtual mode rather than in real mode
- * - screen blanking with state_mgmt() in text mode STI ? 
+ * - screen blanking with state_mgmt() in text mode STI ?
  * - try to make it work on m68k hp workstations ;)
- * 
+ *
  */
 
 #define pr_fmt(fmt) "%s: " fmt, KBUILD_MODNAME
@@ -66,12 +66,12 @@ static const u8 col_trans[8] = {
 #define c_index(sti, c) ((c) & 0xff)
 
 static const struct sti_init_flags default_init_flags = {
-   .wait   = STI_WAIT, 
+   .wait   = STI_WAIT,
.reset  = 1,
-   .text   = 1, 
+   .text   = 1,
.nontext = 1,
-   .no_chg_bet = 1, 
-   .no_chg_bei = 1, 
+   .no_chg_bet = 1,
+   .no_chg_bei = 1,
.init_cmap_tx = 1,
 };
 
@@ -104,7 +104,7 @@ static int sti_init_graph(struct sti_struct *sti)
pr_err("STI init_graph failed (ret %d, errno %d)\n", ret, err);
return -1;
}
-   
+
return 0;
 }
 
@@ -120,7 +120,7 @@ static void sti_inq_conf(struct sti_struct *sti)
s32 ret;
 
outptr->ext_ptr = STI_PTR(>sti_data->inq_outptr_ext);
-   
+
do {
spin_lock_irqsave(>lock, flags);
memset(inptr, 0, sizeof(*inptr));
@@ -162,9 +162,9 @@ sti_putc(struct sti_struct *sti, int c, int y, int x,
 }
 
 static const struct sti_blkmv_flags clear_blkmv_flags = {
-   .wait   = STI_WAIT, 
-   .color  = 1, 
-   .clear  = 1, 
+   .wait   = STI_WAIT,
+   .color  = 1,
+   .clear  = 1,
 };
 
 void
@@ -185,7 +185,7 @@ sti_set(struct sti_struct *sti, int src_y, int src_x,
struct sti_blkmv_outptr *outptr = >sti_data->blkmv_outptr;
s32 ret;
unsigned long flags;
-   
+
do {
spin_lock_irqsave(>lock, flags);
*inptr = inptr_default;
@@ -224,7 +224,7 @@ sti_clear(struct sti_struct *sti, int src_y, int src_x,
 }
 
 static const struct sti_blkmv_flags default_blkmv_flags = {
-   .wait = STI_WAIT, 
+   .wait = STI_WAIT,
 };
 
 void
@@ -291,14 +291,14 @@ static int __init sti_setup(char *str)
 {
if (str)
strscpy(default_sti_path, str, sizeof(default_sti_path));
-   
+
return 1;
 }
 
 /* Assuming the machine has multiple STI consoles (=graphic cards) which
  * all get detected by sticon, the user may define with the linux kernel
  * parameter sti= which of them will be the initial boot-console.
- *  is a number between 0 and MAX_STI_ROMS, with 0 as the default 
+ *  is a number between 0 and MAX_STI_ROMS, with 0 as the default
  * STI screen.
  */
 __setup("sti=", sti_setup);
@@ -341,13 +341,13 @@ static int sti_font_setup(char *str)
  * should be used by the sticon driver to draw characters to the screen.
  * Possible values are:
  * - sti_font=:
- *  is the name of one of the linux-kernel built-in 
- * framebuffer font names (e.g. VGA8x16, SUN22x18). 
- * This is only available if the fonts have been statically 
compiled 
+ *  is the name of one of the linux-kernel built-in
+ * framebuffer font names (e.g. VGA8x16, SUN22x18).
+ * This is only available if the fonts have been statically 
compiled
  * in with e.g. the CONFIG_FONT_8x16 or CONFIG_FONT_SUN12x22 
options.
  * - sti_font= ( = 1,2,3,...)
  * most STI ROMs have built-in HP specific fonts, which 

[PATCH v3 09/19] arch/mips: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fb_is_primary_device() with the generic
one from . No functional changes.

Signed-off-by: Thomas Zimmermann 
Cc: Thomas Bogendoerfer 
---
 arch/mips/include/asm/fb.h | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/mips/include/asm/fb.h b/arch/mips/include/asm/fb.h
index bd3f68c9ddfc..6bda0a81d8ca 100644
--- a/arch/mips/include/asm/fb.h
+++ b/arch/mips/include/asm/fb.h
@@ -1,19 +1,17 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
 #include 
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
 {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 07/19] arch/m68k: Merge variants of fb_pgprotect() into single function

2023-04-17 Thread Thomas Zimmermann
Merge all variants of fb_pgprotect() into a single function body.
There are two different cases for MMU systems. For non-MMU systems,
the function body will be empty. No functional changes, but this
will help with the switch to .

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Geert Uytterhoeven 
Acked-by: Geert Uytterhoeven 
---
 arch/m68k/include/asm/fb.h | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/m68k/include/asm/fb.h b/arch/m68k/include/asm/fb.h
index b86c6e2e26dd..4f96989922af 100644
--- a/arch/m68k/include/asm/fb.h
+++ b/arch/m68k/include/asm/fb.h
@@ -7,17 +7,13 @@
 #include 
 #include 
 
-#ifdef CONFIG_MMU
-#ifdef CONFIG_SUN3
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
 {
+#ifdef CONFIG_MMU
+#ifdef CONFIG_SUN3
pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
-}
 #else
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
if (CPU_IS_020_OR_030)
pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030;
if (CPU_IS_040_OR_060) {
@@ -25,11 +21,9 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
/* Use no-cache mode, serialized */
pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S;
}
-}
 #endif /* CONFIG_SUN3 */
-#else
-#define fb_pgprotect(...) do {} while (0)
 #endif /* CONFIG_MMU */
+}
 
 static inline int fb_is_primary_device(struct fb_info *info)
 {
-- 
2.40.0



[PATCH v3 04/19] arch/arm64: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Catalin Marinas 
Cc: Will Deacon 
---
 arch/arm64/include/asm/fb.h | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/arm64/include/asm/fb.h b/arch/arm64/include/asm/fb.h
index bdc735ee1f67..1a495d8fb2ce 100644
--- a/arch/arm64/include/asm/fb.h
+++ b/arch/arm64/include/asm/fb.h
@@ -5,19 +5,6 @@
 #ifndef __ASM_FB_H_
 #define __ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* __ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 03/19] arch/arm: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Russell King 
---
 arch/arm/include/asm/fb.h | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/arm/include/asm/fb.h b/arch/arm/include/asm/fb.h
index d92e99cd8c8a..ce20a43c3033 100644
--- a/arch/arm/include/asm/fb.h
+++ b/arch/arm/include/asm/fb.h
@@ -1,19 +1,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 08/19] arch/m68k: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fb_is_primary_device() with the generic
one from . No functional changes.

v2:
* provide empty fb_pgprotect() on non-MMU systems

Signed-off-by: Thomas Zimmermann 
Cc: Geert Uytterhoeven 
Acked-by: Geert Uytterhoeven 
---
 arch/m68k/include/asm/fb.h | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/m68k/include/asm/fb.h b/arch/m68k/include/asm/fb.h
index 4f96989922af..24273fc7ad91 100644
--- a/arch/m68k/include/asm/fb.h
+++ b/arch/m68k/include/asm/fb.h
@@ -2,11 +2,11 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
 #include 
 #include 
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
 {
@@ -24,10 +24,8 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
 #endif /* CONFIG_SUN3 */
 #endif /* CONFIG_MMU */
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 11/19] video: Move HP PARISC STI core code to shared location

2023-04-17 Thread Thomas Zimmermann
STI core files have been located in console and fbdev code. Move
the source code and header to the directories for video helpers.
Also update the config and build rules such that the code depends
on the config symbol CONFIG_STI_CORE, which STI console and STI
framebuffer select automatically.

Cleans up the console makefile and prepares PARISC to implement
fb_is_primary_device() within the arch/ directory. No functional
changes.

Signed-off-by: Thomas Zimmermann 
---
 drivers/video/Kconfig| 7 +++
 drivers/video/Makefile   | 1 +
 drivers/video/console/Kconfig| 1 +
 drivers/video/console/Makefile   | 4 +---
 drivers/video/console/sticon.c   | 2 +-
 drivers/video/fbdev/Kconfig  | 3 +--
 drivers/video/fbdev/stifb.c  | 2 +-
 drivers/video/{console => }/sticore.c| 2 +-
 {drivers/video/fbdev => include/video}/sticore.h | 0
 9 files changed, 14 insertions(+), 8 deletions(-)
 rename drivers/video/{console => }/sticore.c (99%)
 rename {drivers/video/fbdev => include/video}/sticore.h (100%)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index bf05363d8906..8b2b9ac37c3d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -11,6 +11,13 @@ config APERTURE_HELPERS
  Support tracking and hand-over of aperture ownership. Required
  by graphics drivers for firmware-provided framebuffers.
 
+config STI_CORE
+   bool
+   depends on PARISC
+   help
+ STI refers to the HP "Standard Text Interface" which is a set of
+ BIOS routines contained in a ROM chip in HP PA-RISC based machines.
+
 config VIDEO_CMDLINE
bool
 
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 831c9fa57a6c..6bbc03950899 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_APERTURE_HELPERS)+= aperture.o
+obj-$(CONFIG_STI_CORE)+= sticore.o
 obj-$(CONFIG_VGASTATE)+= vgastate.o
 obj-$(CONFIG_VIDEO_CMDLINE)   += cmdline.o
 obj-$(CONFIG_VIDEO_NOMODESET) += nomodeset.o
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 22cea5082ac4..a2a88d42edf0 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -141,6 +141,7 @@ config STI_CONSOLE
depends on PARISC && HAS_IOMEM
select FONT_SUPPORT
select CRC32
+   select STI_CORE
default y
help
  The STI console is the builtin display/keyboard on HP-PARISC
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index db07b784bd2c..fd79016a0d95 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -5,8 +5,6 @@
 
 obj-$(CONFIG_DUMMY_CONSOLE)   += dummycon.o
 obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o
-obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o
+obj-$(CONFIG_STI_CONSOLE) += sticon.o
 obj-$(CONFIG_VGA_CONSOLE) += vgacon.o
 obj-$(CONFIG_MDA_CONSOLE) += mdacon.o
-
-obj-$(CONFIG_FB_STI)  += sticore.o
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 89ad7ade6cf9..d11cfd2d68b5 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -50,7 +50,7 @@
 
 #include 
 
-#include "../fbdev/sticore.h"
+#include 
 
 /* switching to graphics mode */
 #define BLANK 0
diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 96e91570cdd3..485e8c35d5c6 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -551,10 +551,9 @@ config FB_STI
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
+   select STI_CORE
default y
help
- STI refers to the HP "Standard Text Interface" which is a set of
- BIOS routines contained in a ROM chip in HP PA-RISC based machines.
  Enabling this option will implement the linux framebuffer device
  using calls to the STI BIOS routines for initialisation.
 
diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
index 6bc7e6d9..baca6974e288 100644
--- a/drivers/video/fbdev/stifb.c
+++ b/drivers/video/fbdev/stifb.c
@@ -69,7 +69,7 @@
 #include   /* for HP-UX compatibility */
 #include 
 
-#include "sticore.h"
+#include 
 
 /* REGION_BASE(fb_info, index) returns the virtual address for region  
*/
 #define REGION_BASE(fb_info, index) \
diff --git a/drivers/video/console/sticore.c b/drivers/video/sticore.c
similarity index 99%
rename from drivers/video/console/sticore.c
rename to drivers/video/sticore.c
index 6ea9596a3c4b..f8aaedea437d 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/sticore.c
@@ -32,7 +32,7 @@
 #include 
 #include 
 
-#include "../fbdev/sticore.h"
+#include 
 
 #define STI_DRIVERVERSION "Version 

[PATCH v3 06/19] arch/loongarch: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic
ones from . No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Huacai Chen 
Cc: WANG Xuerui 
---
 arch/loongarch/include/asm/fb.h | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/loongarch/include/asm/fb.h b/arch/loongarch/include/asm/fb.h
index 3116bde8772d..ff82f20685c8 100644
--- a/arch/loongarch/include/asm/fb.h
+++ b/arch/loongarch/include/asm/fb.h
@@ -5,19 +5,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 02/19] arch/arc: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fbdev helpers with the generic ones from
. On arc, pgprot_writecombine() and pgprot_noncached()
are the same; hence no functional changes.

v3:
* use default implementation for fb_pgprotect() (Arnd)

Signed-off-by: Thomas Zimmermann 
Cc: Vineet Gupta 
---
 arch/arc/include/asm/fb.h | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/arch/arc/include/asm/fb.h b/arch/arc/include/asm/fb.h
index dc2e303cdbbb..9c2383d29cbb 100644
--- a/arch/arc/include/asm/fb.h
+++ b/arch/arc/include/asm/fb.h
@@ -1,20 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
-#include 
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-   unsigned long off)
-{
-   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 05/19] arch/ia64: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann
Replace the architecture's fb_is_primary_device() with the generic
one from . No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 arch/ia64/include/asm/fb.h | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
index 5f95782bfa46..0208f64a0da0 100644
--- a/arch/ia64/include/asm/fb.h
+++ b/arch/ia64/include/asm/fb.h
@@ -2,11 +2,12 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include 
-#include 
 #include 
+
 #include 
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
 {
@@ -15,10 +16,8 @@ static inline void fb_pgprotect(struct file *file, struct 
vm_area_struct *vma,
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-   return 0;
-}
+#include 
 
 #endif /* _ASM_FB_H_ */
-- 
2.40.0



[PATCH v3 01/19] fbdev: Prepare generic architecture helpers

2023-04-17 Thread Thomas Zimmermann
Generic implementations of fb_pgprotect() and fb_is_primary_device()
have been in the source code for a long time. Prepare the header file
to make use of them.

Improve the code by using an inline function for fb_pgprotect()
and by removing include statements. The default mode set by
fb_pgprotect() is now writecombine, which is what most platforms
want.

Symbols are protected by preprocessor guards. Architectures that
provide a symbol need to define a preprocessor token of the same
name and value. Otherwise the header file will provide a generic
implementation. This pattern has been taken from .

v3:
* include the correct header files
v2:
*  use writecombine mappings by default (Arnd)

Signed-off-by: Thomas Zimmermann 
Acked-by: Arnd Bergmann 
---
 include/asm-generic/fb.h | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
index f9f18101ed36..c8af99f5a535 100644
--- a/include/asm-generic/fb.h
+++ b/include/asm-generic/fb.h
@@ -1,13 +1,33 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef __ASM_GENERIC_FB_H_
 #define __ASM_GENERIC_FB_H_
-#include 
 
-#define fb_pgprotect(...) do {} while (0)
+/*
+ * Only include this header file from your architecture's .
+ */
+
+#include 
+#include 
+
+struct fb_info;
+struct file;
+
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+   unsigned long off)
+{
+   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+}
+#endif
 
+#ifndef fb_is_primary_device
+#define fb_is_primary_device fb_is_primary_device
 static inline int fb_is_primary_device(struct fb_info *info)
 {
return 0;
 }
+#endif
 
 #endif /* __ASM_GENERIC_FB_H_ */
-- 
2.40.0



[PATCH v3 00/19] arch: Consolidate

2023-04-17 Thread Thomas Zimmermann
Various architectures provide  with helpers for fbdev
framebuffer devices. Share the contained code where possible. There
is already , which implements generic (as in
'empty') functions of the fbdev helpers. The header was added in
commit aafe4dbed0bf ("asm-generic: add generic versions of common
headers"), but never used.

Each per-architecture header file declares and/or implements fbdev
helpers and defines a preprocessor token for each. The generic
header then provides the remaining helpers. It works like the I/O
helpers in .

For PARISC, the architecture helpers are mixed up with helpers
for the system's STI graphics firmware. We first move the STI code
to appropriate locations under video/ and then move the architecture
helper under arch/parisc.

For Sparc, there's an additional patch that moves the implementation
from the header into a source file. This allows to avoid some include
statements in the header file.

Built on arm, arm64, m68k, mips, parisc, powerpc, sparc and x86.

v3:
* use default fb_pgprotect() on arc, parisc, sparc64 (Arnd)
* fix includes in generic fb.h
v2:
* make writecombine the default mapping mode (Arnd)
* rework fb_pgprotect() on m68k

Thomas Zimmermann (19):
  fbdev: Prepare generic architecture helpers
  arch/arc: Implement  with generic helpers
  arch/arm: Implement  with generic helpers
  arch/arm64: Implement  with generic helpers
  arch/ia64: Implement  with generic helpers
  arch/loongarch: Implement  with generic helpers
  arch/m68k: Merge variants of fb_pgprotect() into single function
  arch/m68k: Implement  with generic helpers
  arch/mips: Implement  with generic helpers
  video: Remove trailing whitespaces
  video: Move HP PARISC STI core code to shared location
  arch/parisc: Remove trailing whitespaces
  arch/parisc: Implement fb_is_primary_device() under arch/parisc
  arch/parisc: Implement  with generic helpers
  arch/powerpc: Implement  with generic helpers
  arch/sh: Implement  with generic helpers
  arch/sparc: Implement fb_is_primary_device() in source file
  arch/sparc: Implement  with generic helpers
  arch/x86: Implement  with generic helpers

 arch/arc/include/asm/fb.h |  16 +-
 arch/arm/include/asm/fb.h |  15 +-
 arch/arm64/include/asm/fb.h   |  15 +-
 arch/ia64/include/asm/fb.h|  11 +-
 arch/loongarch/include/asm/fb.h   |  15 +-
 arch/m68k/include/asm/fb.h|  22 +--
 arch/mips/include/asm/fb.h|  10 +-
 arch/parisc/Makefile  |   4 +-
 arch/parisc/include/asm/fb.h  |  20 +--
 arch/parisc/video/Makefile|   3 +
 arch/parisc/video/fbdev.c |  27 +++
 arch/powerpc/include/asm/fb.h |   8 +-
 arch/sh/include/asm/fb.h  |  15 +-
 arch/sparc/Makefile   |   1 +
 arch/sparc/include/asm/fb.h   |  33 ++--
 arch/sparc/video/Makefile |   3 +
 arch/sparc/video/fbdev.c  |  24 +++
 arch/x86/include/asm/fb.h |  11 +-
 drivers/video/Kconfig |   7 +
 drivers/video/Makefile|   1 +
 drivers/video/console/Kconfig |   1 +
 drivers/video/console/Makefile|   4 +-
 drivers/video/console/sticon.c|   6 +-
 drivers/video/fbdev/Kconfig   |   3 +-
 drivers/video/fbdev/stifb.c   | 158 +-
 drivers/video/{console => }/sticore.c | 123 ++
 include/asm-generic/fb.h  |  24 ++-
 .../video/fbdev => include/video}/sticore.h   |  16 +-
 28 files changed, 285 insertions(+), 311 deletions(-)
 create mode 100644 arch/parisc/video/Makefile
 create mode 100644 arch/parisc/video/fbdev.c
 create mode 100644 arch/sparc/video/Makefile
 create mode 100644 arch/sparc/video/fbdev.c
 rename drivers/video/{console => }/sticore.c (95%)
 rename {drivers/video/fbdev => include/video}/sticore.h (99%)


base-commit: c7cfe0c7215db9556ffe7ce33d1f60f768336cfd
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: cbc453ee02fae02af22fbfdce56ab732c7a88c36
-- 
2.40.0



Re: [PATCH v3 6/7] mm/gup: remove vmas parameter from pin_user_pages()

2023-04-17 Thread Dennis Dalessandro


On 4/15/23 8:09 AM, Lorenzo Stoakes wrote:
> After the introduction of FOLL_SAME_FILE we no longer require vmas for any
> invocation of pin_user_pages(), so eliminate this parameter from the
> function and all callers.
> 
> This clears the way to removing the vmas parameter from GUP altogether.
> 
> Signed-off-by: Lorenzo Stoakes 
> ---
>  arch/powerpc/mm/book3s64/iommu_api.c   | 2 +-
>  drivers/infiniband/hw/qib/qib_user_pages.c | 2 +-
>  drivers/infiniband/hw/usnic/usnic_uiom.c   | 2 +-
>  drivers/infiniband/sw/siw/siw_mem.c| 2 +-
>  drivers/media/v4l2-core/videobuf-dma-sg.c  | 2 +-
>  drivers/vdpa/vdpa_user/vduse_dev.c | 2 +-
>  drivers/vhost/vdpa.c   | 2 +-
>  include/linux/mm.h | 3 +--
>  io_uring/rsrc.c| 2 +-
>  mm/gup.c   | 9 +++--
>  mm/gup_test.c  | 9 -
>  net/xdp/xdp_umem.c | 2 +-
>  12 files changed, 17 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c 
> b/drivers/infiniband/hw/qib/qib_user_pages.c
> index f693bc753b6b..1bb7507325bc 100644
> --- a/drivers/infiniband/hw/qib/qib_user_pages.c
> +++ b/drivers/infiniband/hw/qib/qib_user_pages.c
> @@ -111,7 +111,7 @@ int qib_get_user_pages(unsigned long start_page, size_t 
> num_pages,
>   ret = pin_user_pages(start_page + got * PAGE_SIZE,
>num_pages - got,
>FOLL_LONGTERM | FOLL_WRITE,
> -  p + got, NULL);
> +  p + got);
>   if (ret < 0) {
>   mmap_read_unlock(current->mm);
>   goto bail_release;

For Qib...

Acked-by: Dennis Dalessandro 



Re: [PATCH 2/3] PCI/AER: Disable AER service on suspend when IRQ is shared with PME

2023-04-17 Thread Kai-Heng Feng
On Thu, Sep 29, 2022 at 5:46 AM Bjorn Helgaas  wrote:
>
> On Wed, Jul 27, 2022 at 09:32:51AM +0800, Kai-Heng Feng wrote:
> > PCIe service that shares IRQ with PME may cause spurious wakeup on
> > system suspend.
> >
> > PCIe Base Spec 5.0, section 5.2 "Link State Power Management" states
> > that TLP and DLLP transmission is disabled for a Link in L2/L3 Ready
> > (D3hot), L2 (D3cold with aux power) and L3 (D3cold), so we don't lose
> > much here to disable AER during system suspend.
> >
> > This is very similar to previous attempts to suspend AER and DPC [1],
> > but with a different reason.
> >
> > [1] 
> > https://lore.kernel.org/linux-pci/20220408153159.106741-1-kai.heng.f...@canonical.com/
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216295
> >
> > Signed-off-by: Kai-Heng Feng 
> > ---
> >  drivers/pci/pcie/aer.c | 23 ++-
> >  1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> > index 7952e5efd6cf3..60cc373754af2 100644
> > --- a/drivers/pci/pcie/aer.c
> > +++ b/drivers/pci/pcie/aer.c
> > @@ -1372,6 +1372,26 @@ static int aer_probe(struct pcie_device *dev)
> >   return 0;
> >  }
> >
> > +static int aer_suspend(struct pcie_device *dev)
> > +{
> > + struct aer_rpc *rpc = get_service_data(dev);
> > +
> > + if (dev->shared_pme_irq)
> > + aer_disable_rootport(rpc);
>
> aer_disable_rootport() seems like it might be overkill.  IIUC, what
> we want to do here is disable AER interrupts, which should only
> require clearing ROOT_PORT_INTR_ON_MESG_MASK in PCI_ERR_ROOT_COMMAND.
>
> In addition to clearing ROOT_PORT_INTR_ON_MESG_MASK,
> aer_disable_rootport() traverses the whole hierarchy, clearing
> PCI_EXP_AER_FLAGS (CERE | NFERE | FERE | URRE) in PCI_EXP_DEVCTL.
> I don't think these DEVCTL bits control interrupt generation, so I
> don't know why we need to touch them.
>
> aer_disable_rootport() also clears PCI_ERR_ROOT_STATUS, which I think
> we should not do during suspend either.  We might want to clear it
> on resume (which we already do in pci_restore_state()), but I think
> generally we should preserve error information as long as it doesn't
> cause trouble.
>
> Your thoughts please :)

Sorry for the belated response.

Clearing ROOT_PORT_INTR_ON_MESG_MASK along to disable interrupt can
solve the issue too.
And I agree that the AER information should be preserved too.

Kai-Heng

>
> > +
> > + return 0;
> > +}
> > +
> > +static int aer_resume(struct pcie_device *dev)
> > +{
> > + struct aer_rpc *rpc = get_service_data(dev);
> > +
> > + if (dev->shared_pme_irq)
> > + aer_enable_rootport(rpc);
> > +
> > + return 0;
> > +}
> > +
> >  /**
> >   * aer_root_reset - reset Root Port hierarchy, RCEC, or RCiEP
> >   * @dev: pointer to Root Port, RCEC, or RCiEP
> > @@ -1441,8 +1461,9 @@ static struct pcie_port_service_driver aerdriver = {
> >   .name   = "aer",
> >   .port_type  = PCIE_ANY_PORT,
> >   .service= PCIE_PORT_SERVICE_AER,
> > -
> >   .probe  = aer_probe,
> > + .suspend= aer_suspend,
> > + .resume = aer_resume,
> >   .remove = aer_remove,
> >  };
> >
> > --
> > 2.36.1
> >


Re: [PATCH] ASoC: fsl: Simplify an error message

2023-04-17 Thread Iuliana Prodan

On 4/16/2023 9:29 AM, Christophe JAILLET wrote:

dev_err_probe() already display the error code. There is no need to
duplicate it explicitly in the error message.

Signed-off-by: Christophe JAILLET 


Reviewed-by: Iuliana Prodan 

Thanks,
Iulia


---
  sound/soc/fsl/fsl-asoc-card.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index bffa1048d31e..40870668ee24 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -858,7 +858,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
  
  	ret = devm_snd_soc_register_card(>dev, >card);

if (ret) {
-   dev_err_probe(>dev, ret, "snd_soc_register_card failed: 
%d\n", ret);
+   dev_err_probe(>dev, ret, "snd_soc_register_card 
failed\n");
goto asrc_fail;
}
  


Re: [PATCH v3 6/7] mm/gup: remove vmas parameter from pin_user_pages()

2023-04-17 Thread David Hildenbrand

On 15.04.23 14:09, Lorenzo Stoakes wrote:

After the introduction of FOLL_SAME_FILE we no longer require vmas for any
invocation of pin_user_pages(), so eliminate this parameter from the
function and all callers.

This clears the way to removing the vmas parameter from GUP altogether.

Signed-off-by: Lorenzo Stoakes 
---


Ideally, we'd avoid FOLL_SAME_FILE as well

Acked-by: David Hildenbrand 

--
Thanks,

David / dhildenb



Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

2023-04-17 Thread Arnd Bergmann
On Mon, Apr 17, 2023, at 11:03, Thomas Zimmermann wrote:
> Am 11.04.23 um 10:08 schrieb Geert Uytterhoeven:
>> On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann  wrote:

>>> +#ifndef fb_pgprotect
>>> +#define fb_pgprotect fb_pgprotect
>>> +static inline void fb_pgprotect(struct file *file, struct vm_area_struct 
>>> *vma,
>>> +   unsigned long off)
>> 
>> Does this affect any noMMU platforms that relied on fb_pgprotect()
>> doing nothing before?
>> Perhaps the body below should be protected by "#ifdef CONFIG_MMU"?
>
> I cannot conclusively answer this question, but I did some grep'ing 
> ('git grep ndef | grep CONFIG_MMU'):
>
> Only the architectures in this patchset provide  but nothing 
> anywhere uses  yet. And of those architectures, only 
> arm and m68k have !CONFIG_MMU cases. Those are handled in the rsp 
> patches. I think we're good.

Agreed. The generic version is just a more elaborate way to do
nothing here, as the 

 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);

line on nommu just turns into a self-assignment of the same member
that was set the line before.

 Arnd


Re: [PATCH v2 02/19] arch/arc: Implement with generic helpers

2023-04-17 Thread Thomas Zimmermann



Am 06.04.23 um 16:43 schrieb Arnd Bergmann:

On Thu, Apr 6, 2023, at 16:30, Thomas Zimmermann wrote:

+
  static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
  {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
  }
+#define fb_pgprotect fb_pgprotect


I still feel that for architectures like arc that don't have
pgprot_writecombine(), it would b best to go with the
generic implementation that currently behaves the exact
same way. If pgprot_writecombine() gets added in the future,
it would cause the architecture to behave as expected rather
than introducing the same bug that mips has.


OK, I'll change it.



   Arnd


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

2023-04-17 Thread Thomas Zimmermann

Hi Geert

Am 11.04.23 um 10:08 schrieb Geert Uytterhoeven:

Hi Thomas,

On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann  wrote:

Generic implementations of fb_pgprotect() and fb_is_primary_device()
have been in the source code for a long time. Prepare the header file
to make use of them.

Improve the code by using an inline function for fb_pgprotect()
and by removing include statements. The default mode set by
fb_pgprotect() is now writecombine, which is what most platforms
want.

Symbols are protected by preprocessor guards. Architectures that
provide a symbol need to define a preprocessor token of the same
name and value. Otherwise the header file will provide a generic
implementation. This pattern has been taken from .

v2:
 *  use writecombine mappings by default (Arnd)

Signed-off-by: Thomas Zimmermann 


Thanks for your patch!


--- a/include/asm-generic/fb.h
+++ b/include/asm-generic/fb.h
@@ -1,13 +1,32 @@
  /* SPDX-License-Identifier: GPL-2.0 */
+
  #ifndef __ASM_GENERIC_FB_H_
  #define __ASM_GENERIC_FB_H_
-#include 

-#define fb_pgprotect(...) do {} while (0)
+/*
+ * Only include this header file from your architecture's .
+ */
+
+#include 
+
+struct fb_info;
+struct file;
+
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+   unsigned long off)


Does this affect any noMMU platforms that relied on fb_pgprotect()
doing nothing before?
Perhaps the body below should be protected by "#ifdef CONFIG_MMU"?


I cannot conclusively answer this question, but I did some grep'ing 
('git grep ndef | grep CONFIG_MMU'):


Only the architectures in this patchset provide  but nothing 
anywhere uses  yet. And of those architectures, only 
arm and m68k have !CONFIG_MMU cases. Those are handled in the rsp 
patches. I think we're good.





+{
+   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);


Shouldn't this use the pgprot_val() wrapper?


No, I think. Grep'ing for vm_page_prot, I'm not seeing it being used in 
such assignments.


Best regards
Thomas




+}
+#endif


Gr{oetje,eeting}s,

 Geert



--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


OpenPGP_signature
Description: OpenPGP digital signature