Re: [PATCH v3] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Philipp Hortmann

On 6/25/24 18:33, Teddy Engel wrote:

Add a pre-declaration of struct net_device so the compiler is able to
use rtl_pci.h / rtl_cam.h.

Signed-off-by: Teddy Engel 
Reported-by: kernel test robot 
Closes: 
https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/
Fixes: 7dff0b27d9c8 ("staging: rtl8192e: Remove unnecessary pre-declaration of 
struct net_device")
---
v3: Replace ad-hoc commit id / subject by expected Fixes tag.
v2: Add commit id / commit subject  under description.

  drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 2 ++
  drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 2 ++
  2 files changed, 4 insertions(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3a5635494385..9deffdf96072 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -12,6 +12,8 @@
  
  #include 
  
+struct net_device;

+
  void rtl92e_cam_reset(struct net_device *dev);
  void rtl92e_enable_hw_security_config(struct net_device *dev);
  void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
index c645775b2150..3e39c4835ac8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
@@ -13,6 +13,8 @@
  #include 
  #include 
  
+struct net_device;

+
  bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev);
  
  #endif


Tested-by: Philipp Hortmann 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Teddy Engel
Add a pre-declaration of struct net_device so the compiler is able to
use rtl_pci.h / rtl_cam.h.

Signed-off-by: Teddy Engel 
Reported-by: kernel test robot 
Closes: 
https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/
Fixes: 7dff0b27d9c8 ("staging: rtl8192e: Remove unnecessary pre-declaration of 
struct net_device")
---
v3: Replace ad-hoc commit id / subject by expected Fixes tag.
v2: Add commit id / commit subject  under description.

 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 2 ++
 drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3a5635494385..9deffdf96072 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -12,6 +12,8 @@
 
 #include 
 
+struct net_device;
+
 void rtl92e_cam_reset(struct net_device *dev);
 void rtl92e_enable_hw_security_config(struct net_device *dev);
 void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
index c645775b2150..3e39c4835ac8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+struct net_device;
+
 bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev);
 
 #endif
-- 
2.39.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Greg Kroah-Hartman
On Tue, Jun 25, 2024 at 04:19:18PM +0100, Teddy Engel wrote:
> Add a pre-declaration of struct net_device so the compiler is able to
> use rtl_pci.h / rtl_cam.h.
> 
> Fix for commit: 7dff0b27d9c842f88149bf611cbc0b59be1dcd3c:
> [34/59] staging: rtl89192e: Remove unnecessary pre-declaration of struct
> net_device.
> 
> Signed-off-by: Teddy Engel 
> Reported-by: kernel test robot 
> Closes: 
> https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/
> ---
> v2: Add commit id that's being fixed.

You do that with a "Fixes:" tag, not the paragraph you wrote above :)

The documentation should explain how to do it, right?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Teddy Engel
Add a pre-declaration of struct net_device so the compiler is able to
use rtl_pci.h / rtl_cam.h.

Fix for commit: 7dff0b27d9c842f88149bf611cbc0b59be1dcd3c:
[34/59] staging: rtl89192e: Remove unnecessary pre-declaration of struct
net_device.

Signed-off-by: Teddy Engel 
Reported-by: kernel test robot 
Closes: 
https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/
---
v2: Add commit id that's being fixed.

 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 2 ++
 drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3a5635494385..9deffdf96072 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -12,6 +12,8 @@
 
 #include 
 
+struct net_device;
+
 void rtl92e_cam_reset(struct net_device *dev);
 void rtl92e_enable_hw_security_config(struct net_device *dev);
 void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
index c645775b2150..3e39c4835ac8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+struct net_device;
+
 bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev);
 
 #endif
-- 
2.39.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Greg Kroah-Hartman
On Tue, Jun 25, 2024 at 01:56:38PM +0100, Teddy Engel wrote:
> Add a pre-declaration of struct net_device so the compiler is able to
> use rtl_pci.h / rtl_cam.h.
> 
> Signed-off-by: Teddy Engel 
> Reported-by: kernel test robot 
> Closes: 
> https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/

What commit id does this fix?

Also note, your mailing list address is wrong for staging stuff, you
need to cc: the public one before I can take this.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192e: Fix conflicting types error with net_device.

2024-06-25 Thread Teddy Engel
Add a pre-declaration of struct net_device so the compiler is able to
use rtl_pci.h / rtl_cam.h.

Signed-off-by: Teddy Engel 
Reported-by: kernel test robot 
Closes: 
https://lore.kernel.org/oe-kbuild-all/202406250858.l8rjmhqm-...@intel.com/
---
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 2 ++
 drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3a5635494385..9deffdf96072 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -12,6 +12,8 @@
 
 #include 
 
+struct net_device;
+
 void rtl92e_cam_reset(struct net_device *dev);
 void rtl92e_enable_hw_security_config(struct net_device *dev);
 void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex,
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h 
b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
index c645775b2150..3e39c4835ac8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+struct net_device;
+
 bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev);
 
 #endif
-- 
2.39.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192e: Fixes a coding style error

2024-06-04 Thread Greg Kroah-Hartman
On Fri, May 17, 2024 at 12:01:40PM +0100, Mohamed Karaoui wrote:
> Adds a space before if statement's condition
> 
> Signed-off-by: Mohamed Karaoui 
> ---
>  drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c 
> b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> index 0cbf4a1a326b..b2af802b9451 100644
> --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> @@ -278,7 +278,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int 
> hdr_len, void *priv)
>   int aad_len, ret;
>  
>   req = aead_request_alloc(key->tfm, GFP_ATOMIC);
> - if(!req)
> + if (!req)
>   return -ENOMEM;
>  
>   aad_len = ccmp_init_iv_and_aad(hdr, pn, iv, aad);

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did not apply to any known trees that Greg is in control
  of.  Possibly this is because you made it against Linus's tree, not
  the linux-next tree, which is where all of the development for the
  next version of the kernel is at.  Please refresh your patch against
  the linux-next tree, or even better yet, the development tree
  specified in the MAINTAINERS file for the subsystem you are submitting
  a patch for, and resend it.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192e: Fixes a coding style error

2024-05-17 Thread Mohamed Karaoui
Adds a space before if statement's condition

Signed-off-by: Mohamed Karaoui 
---
 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c 
b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 0cbf4a1a326b..b2af802b9451 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -278,7 +278,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
int aad_len, ret;
 
req = aead_request_alloc(key->tfm, GFP_ATOMIC);
-   if(!req)
+   if (!req)
return -ENOMEM;
 
aad_len = ccmp_init_iv_and_aad(hdr, pn, iv, aad);
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH AUTOSEL 6.1 3/7] x86/hyperv: Use slow_virt_to_phys() in page transition hypervisor callback

2024-03-12 Thread Michael Kelley
From: Pavel Machek  Sent: Tuesday, March 12, 2024 1:35 PM
> 
> > In preparation for temporarily marking pages not present during a
> > transition between encrypted and decrypted, use slow_virt_to_phys()
> > in the hypervisor callback. As long as the PFN is correct,
> 
> This seems to be preparation for something we don't plan to do in
> -stable. Please drop.
> 

As the author of the patch, I agree.

Michael
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH AUTOSEL 6.1 3/7] x86/hyperv: Use slow_virt_to_phys() in page transition hypervisor callback

2024-03-12 Thread Pavel Machek
Hi!

> In preparation for temporarily marking pages not present during a
> transition between encrypted and decrypted, use slow_virt_to_phys()
> in the hypervisor callback. As long as the PFN is correct,

This seems to be preparation for something we don't plan to do in
-stable. Please drop.

Best regards,
Pavel
-- 
People of Russia, stop Putin before his war on Ukraine escalates.


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 6.1 3/7] x86/hyperv: Use slow_virt_to_phys() in page transition hypervisor callback

2024-03-11 Thread Sasha Levin
From: Michael Kelley 

[ Upstream commit 9fef276f9f416a1e85eb48d3bd38e6018a220bf5 ]

In preparation for temporarily marking pages not present during a
transition between encrypted and decrypted, use slow_virt_to_phys()
in the hypervisor callback. As long as the PFN is correct,
slow_virt_to_phys() works even if the leaf PTE is not present.
The existing functions that depend on vmalloc_to_page() all
require that the leaf PTE be marked present, so they don't work.

Update the comments for slow_virt_to_phys() to note this broader usage
and the requirement to work even if the PTE is not marked present.

Signed-off-by: Michael Kelley 
Acked-by: Kirill A. Shutemov 
Reviewed-by: Rick Edgecombe 
Link: https://lore.kernel.org/r/20240116022008.1023398-2-mhkli...@outlook.com
Signed-off-by: Wei Liu 
Message-ID: <20240116022008.1023398-2-mhkli...@outlook.com>
Signed-off-by: Sasha Levin 
---
 arch/x86/hyperv/ivm.c| 12 +++-
 arch/x86/mm/pat/set_memory.c | 12 
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index 1dbcbd9da74d4..fd08270dd7946 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -332,6 +332,8 @@ int hv_set_mem_host_visibility(unsigned long kbuffer, int 
pagecount, bool visibl
enum hv_mem_host_visibility visibility = visible ?
VMBUS_PAGE_VISIBLE_READ_WRITE : VMBUS_PAGE_NOT_VISIBLE;
u64 *pfn_array;
+   phys_addr_t paddr;
+   void *vaddr;
int ret = 0;
int i, pfn;
 
@@ -343,7 +345,15 @@ int hv_set_mem_host_visibility(unsigned long kbuffer, int 
pagecount, bool visibl
return -ENOMEM;
 
for (i = 0, pfn = 0; i < pagecount; i++) {
-   pfn_array[pfn] = virt_to_hvpfn((void *)kbuffer + i * 
HV_HYP_PAGE_SIZE);
+   /*
+* Use slow_virt_to_phys() because the PRESENT bit has been
+* temporarily cleared in the PTEs.  slow_virt_to_phys() works
+* without the PRESENT bit while virt_to_hvpfn() or similar
+* does not.
+*/
+   vaddr = (void *)kbuffer + (i * HV_HYP_PAGE_SIZE);
+   paddr = slow_virt_to_phys(vaddr);
+   pfn_array[pfn] = paddr >> HV_HYP_PAGE_SHIFT;
pfn++;
 
if (pfn == HV_MAX_MODIFY_GPA_REP_COUNT || i == pagecount - 1) {
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 5f0ce77a259d8..fcc0d0f16be3f 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -723,10 +723,14 @@ pmd_t *lookup_pmd_address(unsigned long address)
  * areas on 32-bit NUMA systems.  The percpu areas can
  * end up in this kind of memory, for instance.
  *
- * This could be optimized, but it is only intended to be
- * used at initialization time, and keeping it
- * unoptimized should increase the testing coverage for
- * the more obscure platforms.
+ * Note that as long as the PTEs are well-formed with correct PFNs, this
+ * works without checking the PRESENT bit in the leaf PTE.  This is unlike
+ * the similar vmalloc_to_page() and derivatives.  Callers may depend on
+ * this behavior.
+ *
+ * This could be optimized, but it is only used in paths that are not perf
+ * sensitive, and keeping it unoptimized should increase the testing coverage
+ * for the more obscure platforms.
  */
 phys_addr_t slow_virt_to_phys(void *__virt_addr)
 {
-- 
2.43.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 6.6 04/12] x86/hyperv: Allow 15-bit APIC IDs for VTL platforms

2024-03-11 Thread Sasha Levin
From: Saurabh Sengar 

[ Upstream commit 0d63e4c0ebc2b5c329babde44fd61d3f08db814d ]

The current method for signaling the compatibility of a Hyper-V host
with MSIs featuring 15-bit APIC IDs relies on a synthetic cpuid leaf.
However, for higher VTLs, this leaf is not reported, due to the absence
of an IO-APIC.

As an alternative, assume that when running at a high VTL, the host
supports 15-bit APIC IDs. This assumption is safe, as Hyper-V does not
employ any architectural MSIs at higher VTLs

This unblocks startup of VTL2 environments with more than 256 CPUs.

Signed-off-by: Saurabh Sengar 
Reviewed-by: Michael Kelley 
Link: 
https://lore.kernel.org/r/1705341460-18394-1-git-send-email-ssen...@linux.microsoft.com
Signed-off-by: Wei Liu 
Message-ID: <1705341460-18394-1-git-send-email-ssen...@linux.microsoft.com>
Signed-off-by: Sasha Levin 
---
 arch/x86/hyperv/hv_vtl.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c
index 999f5ac82fe90..53b309d41b3b9 100644
--- a/arch/x86/hyperv/hv_vtl.c
+++ b/arch/x86/hyperv/hv_vtl.c
@@ -16,6 +16,11 @@
 extern struct boot_params boot_params;
 static struct real_mode_header hv_vtl_real_mode_header;
 
+static bool __init hv_vtl_msi_ext_dest_id(void)
+{
+   return true;
+}
+
 void __init hv_vtl_init_platform(void)
 {
pr_info("Linux runs in Hyper-V Virtual Trust Level\n");
@@ -38,6 +43,8 @@ void __init hv_vtl_init_platform(void)
x86_platform.legacy.warm_reset = 0;
x86_platform.legacy.reserve_bios_regions = 0;
x86_platform.legacy.devices.pnpbios = 0;
+
+   x86_init.hyper.msi_ext_dest_id = hv_vtl_msi_ext_dest_id;
 }
 
 static inline u64 hv_vtl_system_desc_base(struct ldttss_desc *desc)
-- 
2.43.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 6.6 03/12] x86/hyperv: Use slow_virt_to_phys() in page transition hypervisor callback

2024-03-11 Thread Sasha Levin
From: Michael Kelley 

[ Upstream commit 9fef276f9f416a1e85eb48d3bd38e6018a220bf5 ]

In preparation for temporarily marking pages not present during a
transition between encrypted and decrypted, use slow_virt_to_phys()
in the hypervisor callback. As long as the PFN is correct,
slow_virt_to_phys() works even if the leaf PTE is not present.
The existing functions that depend on vmalloc_to_page() all
require that the leaf PTE be marked present, so they don't work.

Update the comments for slow_virt_to_phys() to note this broader usage
and the requirement to work even if the PTE is not marked present.

Signed-off-by: Michael Kelley 
Acked-by: Kirill A. Shutemov 
Reviewed-by: Rick Edgecombe 
Link: https://lore.kernel.org/r/20240116022008.1023398-2-mhkli...@outlook.com
Signed-off-by: Wei Liu 
Message-ID: <20240116022008.1023398-2-mhkli...@outlook.com>
Signed-off-by: Sasha Levin 
---
 arch/x86/hyperv/ivm.c| 12 +++-
 arch/x86/mm/pat/set_memory.c | 12 
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index 8c6bf07f7d2b8..4bf3805aa8ab5 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -515,6 +515,8 @@ static bool hv_vtom_set_host_visibility(unsigned long 
kbuffer, int pagecount, bo
enum hv_mem_host_visibility visibility = enc ?
VMBUS_PAGE_NOT_VISIBLE : VMBUS_PAGE_VISIBLE_READ_WRITE;
u64 *pfn_array;
+   phys_addr_t paddr;
+   void *vaddr;
int ret = 0;
bool result = true;
int i, pfn;
@@ -524,7 +526,15 @@ static bool hv_vtom_set_host_visibility(unsigned long 
kbuffer, int pagecount, bo
return false;
 
for (i = 0, pfn = 0; i < pagecount; i++) {
-   pfn_array[pfn] = virt_to_hvpfn((void *)kbuffer + i * 
HV_HYP_PAGE_SIZE);
+   /*
+* Use slow_virt_to_phys() because the PRESENT bit has been
+* temporarily cleared in the PTEs.  slow_virt_to_phys() works
+* without the PRESENT bit while virt_to_hvpfn() or similar
+* does not.
+*/
+   vaddr = (void *)kbuffer + (i * HV_HYP_PAGE_SIZE);
+   paddr = slow_virt_to_phys(vaddr);
+   pfn_array[pfn] = paddr >> HV_HYP_PAGE_SHIFT;
pfn++;
 
if (pfn == HV_MAX_MODIFY_GPA_REP_COUNT || i == pagecount - 1) {
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index bda9f129835e9..355dc8f5cb7dd 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -755,10 +755,14 @@ pmd_t *lookup_pmd_address(unsigned long address)
  * areas on 32-bit NUMA systems.  The percpu areas can
  * end up in this kind of memory, for instance.
  *
- * This could be optimized, but it is only intended to be
- * used at initialization time, and keeping it
- * unoptimized should increase the testing coverage for
- * the more obscure platforms.
+ * Note that as long as the PTEs are well-formed with correct PFNs, this
+ * works without checking the PRESENT bit in the leaf PTE.  This is unlike
+ * the similar vmalloc_to_page() and derivatives.  Callers may depend on
+ * this behavior.
+ *
+ * This could be optimized, but it is only used in paths that are not perf
+ * sensitive, and keeping it unoptimized should increase the testing coverage
+ * for the more obscure platforms.
  */
 phys_addr_t slow_virt_to_phys(void *__virt_addr)
 {
-- 
2.43.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 6.7 04/14] x86/hyperv: Allow 15-bit APIC IDs for VTL platforms

2024-03-11 Thread Sasha Levin
From: Saurabh Sengar 

[ Upstream commit 0d63e4c0ebc2b5c329babde44fd61d3f08db814d ]

The current method for signaling the compatibility of a Hyper-V host
with MSIs featuring 15-bit APIC IDs relies on a synthetic cpuid leaf.
However, for higher VTLs, this leaf is not reported, due to the absence
of an IO-APIC.

As an alternative, assume that when running at a high VTL, the host
supports 15-bit APIC IDs. This assumption is safe, as Hyper-V does not
employ any architectural MSIs at higher VTLs

This unblocks startup of VTL2 environments with more than 256 CPUs.

Signed-off-by: Saurabh Sengar 
Reviewed-by: Michael Kelley 
Link: 
https://lore.kernel.org/r/1705341460-18394-1-git-send-email-ssen...@linux.microsoft.com
Signed-off-by: Wei Liu 
Message-ID: <1705341460-18394-1-git-send-email-ssen...@linux.microsoft.com>
Signed-off-by: Sasha Levin 
---
 arch/x86/hyperv/hv_vtl.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c
index 96e6c51515f50..cf1b78cb2d043 100644
--- a/arch/x86/hyperv/hv_vtl.c
+++ b/arch/x86/hyperv/hv_vtl.c
@@ -16,6 +16,11 @@
 extern struct boot_params boot_params;
 static struct real_mode_header hv_vtl_real_mode_header;
 
+static bool __init hv_vtl_msi_ext_dest_id(void)
+{
+   return true;
+}
+
 void __init hv_vtl_init_platform(void)
 {
pr_info("Linux runs in Hyper-V Virtual Trust Level\n");
@@ -38,6 +43,8 @@ void __init hv_vtl_init_platform(void)
x86_platform.legacy.warm_reset = 0;
x86_platform.legacy.reserve_bios_regions = 0;
x86_platform.legacy.devices.pnpbios = 0;
+
+   x86_init.hyper.msi_ext_dest_id = hv_vtl_msi_ext_dest_id;
 }
 
 static inline u64 hv_vtl_system_desc_base(struct ldttss_desc *desc)
-- 
2.43.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 6.7 03/14] x86/hyperv: Use slow_virt_to_phys() in page transition hypervisor callback

2024-03-11 Thread Sasha Levin
From: Michael Kelley 

[ Upstream commit 9fef276f9f416a1e85eb48d3bd38e6018a220bf5 ]

In preparation for temporarily marking pages not present during a
transition between encrypted and decrypted, use slow_virt_to_phys()
in the hypervisor callback. As long as the PFN is correct,
slow_virt_to_phys() works even if the leaf PTE is not present.
The existing functions that depend on vmalloc_to_page() all
require that the leaf PTE be marked present, so they don't work.

Update the comments for slow_virt_to_phys() to note this broader usage
and the requirement to work even if the PTE is not marked present.

Signed-off-by: Michael Kelley 
Acked-by: Kirill A. Shutemov 
Reviewed-by: Rick Edgecombe 
Link: https://lore.kernel.org/r/20240116022008.1023398-2-mhkli...@outlook.com
Signed-off-by: Wei Liu 
Message-ID: <20240116022008.1023398-2-mhkli...@outlook.com>
Signed-off-by: Sasha Levin 
---
 arch/x86/hyperv/ivm.c| 12 +++-
 arch/x86/mm/pat/set_memory.c | 12 
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index 02e55237d919a..851107c77f4db 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -515,6 +515,8 @@ static bool hv_vtom_set_host_visibility(unsigned long 
kbuffer, int pagecount, bo
enum hv_mem_host_visibility visibility = enc ?
VMBUS_PAGE_NOT_VISIBLE : VMBUS_PAGE_VISIBLE_READ_WRITE;
u64 *pfn_array;
+   phys_addr_t paddr;
+   void *vaddr;
int ret = 0;
bool result = true;
int i, pfn;
@@ -524,7 +526,15 @@ static bool hv_vtom_set_host_visibility(unsigned long 
kbuffer, int pagecount, bo
return false;
 
for (i = 0, pfn = 0; i < pagecount; i++) {
-   pfn_array[pfn] = virt_to_hvpfn((void *)kbuffer + i * 
HV_HYP_PAGE_SIZE);
+   /*
+* Use slow_virt_to_phys() because the PRESENT bit has been
+* temporarily cleared in the PTEs.  slow_virt_to_phys() works
+* without the PRESENT bit while virt_to_hvpfn() or similar
+* does not.
+*/
+   vaddr = (void *)kbuffer + (i * HV_HYP_PAGE_SIZE);
+   paddr = slow_virt_to_phys(vaddr);
+   pfn_array[pfn] = paddr >> HV_HYP_PAGE_SHIFT;
pfn++;
 
if (pfn == HV_MAX_MODIFY_GPA_REP_COUNT || i == pagecount - 1) {
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index bda9f129835e9..355dc8f5cb7dd 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -755,10 +755,14 @@ pmd_t *lookup_pmd_address(unsigned long address)
  * areas on 32-bit NUMA systems.  The percpu areas can
  * end up in this kind of memory, for instance.
  *
- * This could be optimized, but it is only intended to be
- * used at initialization time, and keeping it
- * unoptimized should increase the testing coverage for
- * the more obscure platforms.
+ * Note that as long as the PTEs are well-formed with correct PFNs, this
+ * works without checking the PRESENT bit in the leaf PTE.  This is unlike
+ * the similar vmalloc_to_page() and derivatives.  Callers may depend on
+ * this behavior.
+ *
+ * This could be optimized, but it is only used in paths that are not perf
+ * sensitive, and keeping it unoptimized should increase the testing coverage
+ * for the more obscure platforms.
  */
 phys_addr_t slow_virt_to_phys(void *__virt_addr)
 {
-- 
2.43.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: pi433: Updated bitrate range from datasheet

2024-03-03 Thread Greg KH
On Mon, Mar 04, 2024 at 02:28:02AM +0530, Aman Sharma wrote:
> From a0528708b209739f0d566401bdd428e215abf366 Mon Sep 17 00:00:00 2001
> From: Aman Sharma 
> Date: Mon, 4 Mar 2024 00:44:06 +0530
> Subject: [PATCH] Staging: pi433: Updated bitrate range from datasheet

Why is this all here in the changelog?  Also, please use
scripts/get_maintainer.pl, you have sent this to an obsolete email list.

> 
> Updated bitrate range for FSK and OOK modulation from datasheet.
> 
> Signed-off-by: Aman Sharma
> ---
>  drivers/staging/pi433/Documentation/pi433.txt | 6 --
>  drivers/staging/pi433/TODO| 1 -
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/pi433/Documentation/pi433.txt
> b/drivers/staging/pi433/Documentation/pi433.txt
> index 4a0d34b4ad37..9ce7282ef6f8 100644
> --- a/drivers/staging/pi433/Documentation/pi433.txt
> +++ b/drivers/staging/pi433/Documentation/pi433.txt
> @@ -78,7 +78,8 @@ rf params:
>   Allowed values: 43305...43479
>   bit_rate
>   bit rate used for transmission.
> - Allowed values: #
> + Allowed values (For FSK): 1200...32
> + Allowed values (For OOK): 1200...32768
>   dev_frequency
>   frequency deviation in case of FSK.
>   Allowed values: 600...50
> @@ -169,7 +170,8 @@ rf params:
>   Allowed values: 43305...43479
>   bit_rate
>   bit rate used for transmission.
> - Allowed values: #
> + Allowed values (For FSK): 1200...32
> + Allowed values (For OOK): 1200...32768

Where did these values come from?  If you can explain that in the
changelog text when you resend a v2, that would be great.

thanks,
greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: pi433: Updated bitrate range from datasheet

2024-03-03 Thread Aman Sharma

From a0528708b209739f0d566401bdd428e215abf366 Mon Sep 17 00:00:00 2001
From: Aman Sharma 
Date: Mon, 4 Mar 2024 00:44:06 +0530
Subject: [PATCH] Staging: pi433: Updated bitrate range from datasheet

Updated bitrate range for FSK and OOK modulation from datasheet.

Signed-off-by: Aman Sharma
---
 drivers/staging/pi433/Documentation/pi433.txt | 6 --
 drivers/staging/pi433/TODO| 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt

index 4a0d34b4ad37..9ce7282ef6f8 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -78,7 +78,8 @@ rf params:
Allowed values: 43305...43479
bit_rate
bit rate used for transmission.
-   Allowed values: #
+   Allowed values (For FSK): 1200...32
+   Allowed values (For OOK): 1200...32768
dev_frequency
frequency deviation in case of FSK.
Allowed values: 600...50
@@ -169,7 +170,8 @@ rf params:
Allowed values: 43305...43479
bit_rate
bit rate used for transmission.
-   Allowed values: #
+   Allowed values (For FSK): 1200...32
+   Allowed values (For OOK): 1200...32768
dev_frequency
frequency deviation in case of FSK.
Allowed values: 600...50
diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO
index 63a40bfcc67e..61ed3a1578bc 100644
--- a/drivers/staging/pi433/TODO
+++ b/drivers/staging/pi433/TODO
@@ -2,4 +2,3 @@
 * still TODOs, annotated in the code
 * currently the code introduces new IOCTLs. I'm afraid this is a bad 
idea.

   -> Replace this with another interface, hints are welcome!
-* Some missing data (marked with ###) needs to be added in the 
documentation

--
2.34.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] Bluetooth: Fix for ACL disconnect when pairing fails

2023-08-17 Thread Muhammad Usama Anjum
On 6/17/14 4:04 PM, Lukasz Rymanowski wrote:
> When pairing fails hci_conn refcnt drops below zero. This cause that
> ACL link is not disconnected when disconnect timeout fires.
> 
> Probably this is because l2cap_conn_del calls l2cap_chan_del for each
> channel, and inside l2cap_chan_del conn is dropped. After that loop
> hci_chan_del is called which also drops conn.
> 
> Anyway, as it is desrcibed in hci_core.h, it is known that refcnt
> drops below 0 sometimes and it should be fine. If so, let disconnect
> link when hci_conn_timeout fires and refcnt is 0 or below. This patch
> does it.
> 
> This affects PTS test SM_TC_JW_BV_05_C
> 
> Logs from scenario:
> 
> [69713.706227] [6515] pair_device:
> [69713.706230] [6515] hci_conn_add: hci0 dst 00:1b:dc:06:06:22
> [69713.706233] [6515] hci_dev_hold: hci0 orig refcnt 8
> [69713.706235] [6515] hci_conn_init_sysfs: conn 88021f65a000
> [69713.706239] [6515] hci_req_add_ev: hci0 opcode 0x200d plen 25
> [69713.706242] [6515] hci_prepare_cmd: skb len 28
> [69713.706243] [6515] hci_req_run: length 1
> [69713.706248] [6515] hci_conn_hold: hcon 88021f65a000 orig refcnt 0
> [69713.706251] [6515] hci_dev_put: hci0 orig refcnt 9
> [69713.706281] [8909] hci_cmd_work: hci0 cmd_cnt 1 cmd queued 1
> [69713.706288] [8909] hci_send_frame: hci0 type 1 len 28
> [69713.706290] [8909] hci_send_to_monitor: hdev 88021f0c7000 len 28
> [69713.706316] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.706382] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.711664] [8909] hci_rx_work: hci0
> [69713.711668] [8909] hci_send_to_monitor: hdev 88021f0c7000 len 6
> [69713.711680] [8909] hci_rx_work: hci0 Event packet
> [69713.711683] [8909] hci_cs_le_create_conn: hci0 status 0x00
> [69713.711685] [8909] hci_sent_cmd_data: hci0 opcode 0x200d
> [69713.711688] [8909] hci_req_cmd_complete: opcode 0x200d status 0x00
> [69713.711690] [8909] hci_sent_cmd_data: hci0 opcode 0x200d
> [69713.711695] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.711744] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.818875] [8909] hci_rx_work: hci0
> [69713.818889] [8909] hci_send_to_monitor: hdev 88021f0c7000 len 21
> [69713.818913] [8909] hci_rx_work: hci0 Event packet
> [69713.818917] [8909] hci_le_conn_complete_evt: hci0 status 0x00
> [69713.818922] [8909] hci_send_to_control: len 19
> [69713.818927] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.818938] [8909] hci_conn_add_sysfs: conn 88021f65a000
> [69713.818975] [6450] bt_sock_poll: sock 88005e758500, sk 88010323b800
> [69713.818981] [6515] hci_sock_recvmsg: sock 88005e75a080, sk 
> 88010323ac00
> ...
> [69713.819021] [8909] hci_dev_hold: hci0 orig refcnt 10
> [69713.819025] [8909] l2cap_connect_cfm: hcon 88021f65a000 bdaddr 
> 00:1b:dc:06:06:22 status 0
> [69713.819028] [8909] hci_chan_create: hci0 hcon 88021f65a000
> [69713.819031] [8909] l2cap_conn_add: hcon 88021f65a000 conn 
> 880221005c00 hchan 88020d60b1c0
> [69713.819034] [8909] l2cap_conn_ready: conn 880221005c00
> [69713.819036] [5949] hci_sock_recvmsg: sock 8800941a9680, sk 
> 88012bf4d000
> [69713.819037] [8909] smp_conn_security: conn 880221005c00 hcon 
> 88021f65a000 level 0x02
> [69713.819039] [8909] smp_chan_create:
> [69713.819041] [8909] hci_conn_hold: hcon 88021f65a000 orig refcnt 1
> [69713.819043] [8909] smp_send_cmd: code 0x01
> [69713.819045] [8909] hci_send_acl: hci0 chan 88020d60b1c0 flags 0x
> [69713.819046] [5949] hci_sock_recvmsg: sock 8800941a9900, sk 
> 88012bf4e800
> [69713.819049] [8909] hci_queue_acl: hci0 nonfrag skb 88005157c100 len 15
> [69713.819055] [5949] hci_sock_recvmsg: sock 8800941a9900, sk 
> 88012bf4e800
> [69713.819057] [8909] l2cap_le_conn_ready:
> [69713.819064] [8909] l2cap_chan_create: chan 88005ede2c00
> [69713.819066] [8909] l2cap_chan_hold: chan 88005ede2c00 orig refcnt 1
> [69713.819069] [8909] l2cap_sock_init: sk 88005ede5800
> [69713.819072] [8909] bt_accept_enqueue: parent 880160356000, sk 
> 88005ede5800
> [69713.819074] [8909] __l2cap_chan_add: conn 880221005c00, psm 0x00, dcid 
> 0x0004
> [69713.819076] [8909] l2cap_chan_hold: chan 88005ede2c00 orig refcnt 2
> [69713.819078] [8909] hci_conn_hold: hcon 88021f65a000 orig refcnt 2
> [69713.819080] [8909] smp_conn_security: conn 880221005c00 hcon 
> 88021f65a000 level 0x01
> [69713.819082] [8909] l2cap_sock_ready_cb: sk 88005ede5800, parent 
> 880160356000
> [69713.819086] [8909] le_pairing_complete_cb: status 0
> [697

Re: [PATCH] staging: media: usbvision: Remove comparision to NULL

2023-05-23 Thread Hans Verkuil
Hi Anup,

On 02/05/2023 03:05, Anup Sharma wrote:
> Remove comparison to null in file usbvision-core.c and usbvision-i2c.c.
> 
> Signed-off-by: Anup Sharma 
> ---
>  drivers/staging/media/usbvision/usbvision-core.c | 8 
>  drivers/staging/media/usbvision/usbvision-i2c.c  | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)

The usbvision driver has been removed almost 2 years ago, so this patch is for
a really old kernel.

Rather odd, but in any case, I'm rejecting this patch for obvious reasons...

Regards,

Hans

> 
> diff --git a/drivers/staging/media/usbvision/usbvision-core.c 
> b/drivers/staging/media/usbvision/usbvision-core.c
> index e35dee35b068..a38104b2a0f9 100644
> --- a/drivers/staging/media/usbvision/usbvision-core.c
> +++ b/drivers/staging/media/usbvision/usbvision-core.c
> @@ -349,7 +349,7 @@ int usbvision_scratch_alloc(struct usb_usbvision 
> *usbvision)
>  {
>   usbvision->scratch = vmalloc_32(scratch_buf_size);
>   scratch_reset(usbvision);
> - if (usbvision->scratch == NULL) {
> + if (!usbvision->scratch) {
>   dev_err(>dev->dev,
>   "%s: unable to allocate %d bytes for scratch\n",
>   __func__, scratch_buf_size);
> @@ -374,7 +374,7 @@ int usbvision_decompress_alloc(struct usb_usbvision 
> *usbvision)
>   int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2;
>  
>   usbvision->intra_frame_buffer = vmalloc_32(IFB_size);
> - if (usbvision->intra_frame_buffer == NULL) {
> + if (!usbvision->intra_frame_buffer) {
>   dev_err(>dev->dev,
>   "%s: unable to allocate %d for compr. frame buffer\n",
>   __func__, IFB_size);
> @@ -2284,7 +2284,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
>   struct urb *urb;
>  
>   urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
> - if (urb == NULL)
> + if (!urb)
>   return -ENOMEM;
>   usbvision->sbuf[buf_idx].urb = urb;
>   usbvision->sbuf[buf_idx].data =
> @@ -2343,7 +2343,7 @@ void usbvision_stop_isoc(struct usb_usbvision 
> *usbvision)
>   int buf_idx, err_code, reg_value;
>   int sb_size = USBVISION_URB_FRAMES * usbvision->isoc_packet_size;
>  
> - if ((usbvision->streaming == stream_off) || (usbvision->dev == NULL))
> + if ((usbvision->streaming == stream_off) || (!usbvision->dev))
>   return;
>  
>   /* Unschedule all of the iso td's */
> diff --git a/drivers/staging/media/usbvision/usbvision-i2c.c 
> b/drivers/staging/media/usbvision/usbvision-i2c.c
> index 6e4df3335b1b..3bba93293463 100644
> --- a/drivers/staging/media/usbvision/usbvision-i2c.c
> +++ b/drivers/staging/media/usbvision/usbvision-i2c.c
> @@ -233,7 +233,7 @@ int usbvision_i2c_register(struct usb_usbvision 
> *usbvision)
>   >i2c_adap,
>   "tuner", 0, v4l2_i2c_tuner_addrs(type));
>  
> - if (sd == NULL)
> + if (!sd)
>   return -ENODEV;
>   if (usbvision->tuner_type != -1) {
>   tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] Add new uio device for PCI with dynamic memory allocation

2023-05-17 Thread Hongren Zheng
On Wed, Apr 29, 2020 at 01:53:02PM +, Stahl, Manuel wrote:
> On Mi, 2020-04-29 at 11:41 +0200, gre...@linuxfoundation.org wrote:
> > On Wed, Apr 29, 2020 at 07:51:01AM +, Stahl, Manuel wrote:
> > > On Di, 2020-04-28 at 15:54 +0200, gregkh @ linuxfoundation . org wrote:
> > > > On Thu, Apr 16, 2020 at 06:38:30PM +0200, Manuel Stahl wrote:
> > > > > 
> > > > > + *
> > > > > + * Since the driver does not declare any device ids, you must 
> > > > > allocate
> > > > > + * id and bind the device to the driver yourself.  For example:
> > > > > + *
> > > > > + * # echo "8086 10f5" > 
> > > > > /sys/bus/pci/drivers/uio_pci_dmem_genirq/new_id
> > > > > + * # echo -n :00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
> > > > > + * # echo -n :00:19.0 > 
> > > > > /sys/bus/pci/drivers/uio_pci_dmem_genirq/bind
> > > > > + * # ls -l /sys/bus/pci/devices/:00:19.0/driver
> > > > > + * .../:00:19.0/driver -> 
> > > > > ../../../bus/pci/drivers/uio_pci_dmem_genirq
> > > > > + *
> > > > > + * Or use a modprobe alias:
> > > > > + * # alias pci:v10EEd1000sv*sd*sc*i* uio_pci_dmem_genirq
> > > > > + *
> > > > > + * Driver won't bind to devices which do not support the Interrupt 
> > > > > Disable Bit
> > > > > + * in the command register. All devices compliant to PCI 2.3 (circa 
> > > > > 2002) and
> > > > > + * all compliant PCI Express devices should support this bit.
> > > > > + *
> > > > > + * The DMA mask bits and sizes of dynamic regions are derived from 
> > > > > module
> > > > > + * parameters.
> > > > > + *
> > > > > + * The format for specifying dynamic region sizes in module 
> > > > > parameters
> > > > > + * is as follows:
> > > > > + *
> > > > > + * uio_pci_dmem_genirq.dmem_sizes := 
> > > > > [;]
> > > > > + *:= :[,]
> > > > > + *:= :
> > > > > + *  := standard linux memsize
> > > > > + *
> > > > > + * Examples:
> > > > > + *
> > > > > + * 1) UIO dmem device with 3 dynamic regions:
> > > > > + * uio_pci_dmem_genirq.dmem_sizes=8086:10f5:4K,16K,4M
> > > > > + *
> > > > > + * 2) Two UIO dmem devices with different number of dynamic regions:
> > > > > + * uio_pci_dmem_genirq.dmem_sizes=8086:10f5:4K,16K,4M;1234:0001:8K
> > > > 
> > > > Module parameters are horrid, are you sure there is no other way?
> > > 
> > > You're right, seemed to be the simplest solution back when we started 
> > > developing this driver. I will try to change it to sysfs, so that one can 
> > > add regions while the module is already loaded.
> > 
> > /me hands you some \n characters...
> > 
> > Anyway, configfs is for configuring stuff, don't make a sysfs file that
> > you have to somehow "parse" please.
> 
> Looking back at this driver after some years I realized again the reason
> for using kernel parameters:
> 
> The current UIO API needs the information about available memory maps when
> registering a new UIO device with __uio_register_device(), which obviously
> needs to be called during probe() in uio_pci_dmem_genirq. Otherwise there
> is no device file in /dev to open for user space applications.
> 
> After that there is no function to update the uio_map info. So we can either
> keep the module parameters and allocate the DMA memory during probe() or
> allocate the DMA memory during mmap() and
>   a) replicate parts of uio_dev_add_attributes() in this driver to update 
> sysfs
>   b) add a function in uio.c to allow updates to the uio_map
> 
> Which way would you go?
> 
> Best regards,
> Manuel Stahl

I have similar need for our FPGA project where DMA to
userspace is wanted, how could this be moved forward?

Cc'ed my collaborator here.

It seems that there is not enough maintainance bandwidth for the UIO driver.
I'm willing to be a reviewer, and I assume after handling some of the
patches I can manage to do it. I wonder what else should be done.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: media: usbvision: Remove comparision to NULL

2023-05-01 Thread Anup Sharma
Remove comparison to null in file usbvision-core.c and usbvision-i2c.c.

Signed-off-by: Anup Sharma 
---
 drivers/staging/media/usbvision/usbvision-core.c | 8 
 drivers/staging/media/usbvision/usbvision-i2c.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/usbvision/usbvision-core.c 
b/drivers/staging/media/usbvision/usbvision-core.c
index e35dee35b068..a38104b2a0f9 100644
--- a/drivers/staging/media/usbvision/usbvision-core.c
+++ b/drivers/staging/media/usbvision/usbvision-core.c
@@ -349,7 +349,7 @@ int usbvision_scratch_alloc(struct usb_usbvision *usbvision)
 {
usbvision->scratch = vmalloc_32(scratch_buf_size);
scratch_reset(usbvision);
-   if (usbvision->scratch == NULL) {
+   if (!usbvision->scratch) {
dev_err(>dev->dev,
"%s: unable to allocate %d bytes for scratch\n",
__func__, scratch_buf_size);
@@ -374,7 +374,7 @@ int usbvision_decompress_alloc(struct usb_usbvision 
*usbvision)
int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2;
 
usbvision->intra_frame_buffer = vmalloc_32(IFB_size);
-   if (usbvision->intra_frame_buffer == NULL) {
+   if (!usbvision->intra_frame_buffer) {
dev_err(>dev->dev,
"%s: unable to allocate %d for compr. frame buffer\n",
__func__, IFB_size);
@@ -2284,7 +2284,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
struct urb *urb;
 
urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
-   if (urb == NULL)
+   if (!urb)
return -ENOMEM;
usbvision->sbuf[buf_idx].urb = urb;
usbvision->sbuf[buf_idx].data =
@@ -2343,7 +2343,7 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
int buf_idx, err_code, reg_value;
int sb_size = USBVISION_URB_FRAMES * usbvision->isoc_packet_size;
 
-   if ((usbvision->streaming == stream_off) || (usbvision->dev == NULL))
+   if ((usbvision->streaming == stream_off) || (!usbvision->dev))
return;
 
/* Unschedule all of the iso td's */
diff --git a/drivers/staging/media/usbvision/usbvision-i2c.c 
b/drivers/staging/media/usbvision/usbvision-i2c.c
index 6e4df3335b1b..3bba93293463 100644
--- a/drivers/staging/media/usbvision/usbvision-i2c.c
+++ b/drivers/staging/media/usbvision/usbvision-i2c.c
@@ -233,7 +233,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
>i2c_adap,
"tuner", 0, v4l2_i2c_tuner_addrs(type));
 
-   if (sd == NULL)
+   if (!sd)
return -ENODEV;
if (usbvision->tuner_type != -1) {
tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: remove unnecesary parentheses

2023-03-30 Thread Greg KH
On Fri, Mar 31, 2023 at 01:04:59AM +0800, Joel C. Chang wrote:
> On Thu, Mar 30, 2023 at 02:49:54PM +0200, Greg KH wrote:
> > On Thu, Mar 30, 2023 at 08:44:35PM +0800, Joel Camilo Chang Gonzalez wrote:
> > > Remove parentheses not needed in if statement
> > > 
> > > Signed-off-by: Joel Camilo Chang Gonzalez 
> > > ---
> > >  drivers/staging/ks7010/ks_hostif.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/staging/ks7010/ks_hostif.c 
> > > b/drivers/staging/ks7010/ks_hostif.c
> > > index af3825578d85..8bded7e88ce7 100644
> > > --- a/drivers/staging/ks7010/ks_hostif.c
> > > +++ b/drivers/staging/ks7010/ks_hostif.c
> > > @@ -129,7 +129,7 @@ int get_current_ap(struct ks_wlan_private *priv, 
> > > struct link_ap_info *ap_info)
> > >   size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
> > >   ap_info->rsn.size : RSN_IE_BODY_MAX;
> > >   if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
> > > - (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
> > > + priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
> > 
> > If you look in the archives, you will see that I reject this type of
> > patch all the time.
> > 
> > Also, please use scripts/get_maintainer.pl to determine who to send this
> > to, you used a very old mailing list address that is long dead.
> > 
> > thanks,
> > 
> > greg k-h
> 
> Thanks for the input. I wasn't sure who to send it to, since the TODO in
> the driver and the script have different email addresses.
> 
> Is there a place to check for inactive mailing lists?

Just trust the get_maintainer.pl script, it knows what to do.

thanks,
greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: remove unnecesary parentheses

2023-03-30 Thread Joel C. Chang
On Thu, Mar 30, 2023 at 02:49:54PM +0200, Greg KH wrote:
> On Thu, Mar 30, 2023 at 08:44:35PM +0800, Joel Camilo Chang Gonzalez wrote:
> > Remove parentheses not needed in if statement
> > 
> > Signed-off-by: Joel Camilo Chang Gonzalez 
> > ---
> >  drivers/staging/ks7010/ks_hostif.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/ks7010/ks_hostif.c 
> > b/drivers/staging/ks7010/ks_hostif.c
> > index af3825578d85..8bded7e88ce7 100644
> > --- a/drivers/staging/ks7010/ks_hostif.c
> > +++ b/drivers/staging/ks7010/ks_hostif.c
> > @@ -129,7 +129,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
> > link_ap_info *ap_info)
> > size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
> > ap_info->rsn.size : RSN_IE_BODY_MAX;
> > if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
> > -   (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
> > +   priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
> 
> If you look in the archives, you will see that I reject this type of
> patch all the time.
> 
> Also, please use scripts/get_maintainer.pl to determine who to send this
> to, you used a very old mailing list address that is long dead.
> 
> thanks,
> 
> greg k-h

Thanks for the input. I wasn't sure who to send it to, since the TODO in
the driver and the script have different email addresses.

Is there a place to check for inactive mailing lists?

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: remove unnecessary parentheses

2023-03-30 Thread Greg KH
On Thu, Mar 30, 2023 at 08:48:28PM +0800, Joel Camilo Chang Gonzalez wrote:
> Remove redundant parentheses
> 
> Signed-off-by: Joel Camilo Chang Gonzalez 
> ---
>  drivers/staging/ks7010/ks_wlan_net.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
> b/drivers/staging/ks7010/ks_wlan_net.c
> index e03c87f0bfe7..eef1a1e70088 100644
> --- a/drivers/staging/ks7010/ks_wlan_net.c
> +++ b/drivers/staging/ks7010/ks_wlan_net.c
> @@ -193,14 +193,14 @@ static int ks_wlan_set_freq(struct net_device *dev,
>   fwrq->freq.m = c + 1;
>   }
>   /* Setting by channel number */
> - if ((fwrq->freq.m > 1000) || (fwrq->freq.e > 0))
> + if (fwrq->freq.m > 1000 || fwrq->freq.e > 0)

Do you want to have to remember the precidence order between "||" and
">"?  I don't, so please don't make this change.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: remove unnecesary parentheses

2023-03-30 Thread Greg KH
On Thu, Mar 30, 2023 at 08:44:35PM +0800, Joel Camilo Chang Gonzalez wrote:
> Remove parentheses not needed in if statement
> 
> Signed-off-by: Joel Camilo Chang Gonzalez 
> ---
>  drivers/staging/ks7010/ks_hostif.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/ks7010/ks_hostif.c 
> b/drivers/staging/ks7010/ks_hostif.c
> index af3825578d85..8bded7e88ce7 100644
> --- a/drivers/staging/ks7010/ks_hostif.c
> +++ b/drivers/staging/ks7010/ks_hostif.c
> @@ -129,7 +129,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
> link_ap_info *ap_info)
>   size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
>   ap_info->rsn.size : RSN_IE_BODY_MAX;
>   if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
> - (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
> + priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {

If you look in the archives, you will see that I reject this type of
patch all the time.

Also, please use scripts/get_maintainer.pl to determine who to send this
to, you used a very old mailing list address that is long dead.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ks7010: remove unnecessary parentheses

2023-03-30 Thread Joel Camilo Chang Gonzalez
Remove redundant parentheses

Signed-off-by: Joel Camilo Chang Gonzalez 
---
 drivers/staging/ks7010/ks_wlan_net.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index e03c87f0bfe7..eef1a1e70088 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -193,14 +193,14 @@ static int ks_wlan_set_freq(struct net_device *dev,
fwrq->freq.m = c + 1;
}
/* Setting by channel number */
-   if ((fwrq->freq.m > 1000) || (fwrq->freq.e > 0))
+   if (fwrq->freq.m > 1000 || fwrq->freq.e > 0)
return -EOPNOTSUPP;
 
channel = fwrq->freq.m;
/* We should do a better check than that,
 * based on the card capability !!!
 */
-   if ((channel < 1) || (channel > 14)) {
+   if (channel < 1 || channel > 14) {
netdev_dbg(dev, "%s: New channel value of %d is invalid!\n",
   dev->name, fwrq->freq.m);
return -EINVAL;
@@ -663,7 +663,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct 
iw_request_info *info,
/* for SLEEP MODE */
if (vwrq->rts.disabled)
rthr = 2347;
-   if ((rthr < 0) || (rthr > 2347))
+   if (rthr < 0 || rthr > 2347)
return -EINVAL;
 
priv->reg.rts = rthr;
@@ -701,7 +701,7 @@ static int ks_wlan_set_frag(struct net_device *dev,
/* for SLEEP MODE */
if (vwrq->frag.disabled)
fthr = 2346;
-   if ((fthr < 256) || (fthr > 2346))
+   if (fthr < 256 || fthr > 2346)
return -EINVAL;
 
fthr &= ~0x1;   /* Get an even value - is it really needed ??? */
@@ -780,7 +780,7 @@ static int ks_wlan_set_encode(struct net_device *dev,
return -EINVAL;
 
/* for SLEEP MODE */
-   if ((index < 0) || (index > 4))
+   if (index < 0 || index > 4)
return -EINVAL;
 
index = (index == 0) ? priv->reg.wep_index : (index - 1);
@@ -881,7 +881,7 @@ static int ks_wlan_get_encode(struct net_device *dev,
}
 
/* Which key do we want ? -1 -> tx index */
-   if ((index < 0) || (index >= 4))
+   if (index < 0 || index >= 4)
index = priv->reg.wep_index;
if (priv->reg.privacy_invoked) {
enc->flags &= ~IW_ENCODE_DISABLED;
-- 
2.37.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ks7010: remove unnecesary parentheses

2023-03-30 Thread Joel Camilo Chang Gonzalez
Remove parentheses not needed in if statement

Signed-off-by: Joel Camilo Chang Gonzalez 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index af3825578d85..8bded7e88ce7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -129,7 +129,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
ap_info->rsn.size : RSN_IE_BODY_MAX;
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
-   (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
+   priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
ap->rsn_ie.id = RSN_INFO_ELEM_ID;
ap->rsn_ie.size = size;
memcpy(ap->rsn_ie.body, ap_info->rsn.body, size);
-- 
2.37.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6] staging: sm750: Rename sm750_hw_cursor_* functions to snake_case

2023-03-29 Thread Fabio M. De Francesco
On mercoledì 29 marzo 2023 13:27:04 CEST Kloudifold wrote:
> sm750 driver has sm750_hw_cursor_* functions, which are named in
> camelcase. Rename them to snake case to follow the function naming
> convention.
> 
> - sm750_hw_cursor_setSize  => sm750_hw_cursor_set_size
> - sm750_hw_cursor_setPos   => sm750_hw_cursor_set_pos
> - sm750_hw_cursor_setColor => sm750_hw_cursor_set_color
> - sm750_hw_cursor_setData  => sm750_hw_cursor_set_data
> - sm750_hw_cursor_setData2 => sm750_hw_cursor_set_data2
> 
> Reported-by: kernel test robot 
> Link:
> https://lore.kernel.org/oe-kbuild-all/202303110849.x24wnhnm-...@intel.com/

Delete the last two lines.

As Greg made you notice, it was not the Kernel Test Robot that had reported 
you an issue for which you decided to make a patch to fix it.

The reason you made this patch is because you know that the Linux kernel style 
guide wants developers to avoid camel-case symbols.

Before your "Signed-off-by" tag, you should only credit those tools and/or 
services (checkpatch.pl, Coccinelle, Smatch, Syzkaller/Syzbot, GCC, Clang, and 
so on) that had noticed that Linux has a problem that predates the first 
version of your patch and that your first version has the purpose to fix that 
problem.

You made this patch because _checkpatch_ had reported issues with camel-case 
improper use, so you decided to convert some names to snake-case. You are 
invited to credit only _checkpatch_ for you patch ("Reported by 
checkpatch.pl.").

That credit is part of the commit message so, when you credit that tool, put a 
blank line after the credit and before the "Signed-off-by" tag. 

> Signed-off-by: Kloudifold 
> 

Instead, you should delete this blank line after your sign.

> ---
> Changes in v6:
> - Include missed recipients in v5, no functional change to the code
> 
> Changes in v5:
> - Include missed recipients in v4, no functional change to the code
> 
> Changes in v4:
> - Update the commit msg (Deepak)
> - Use tabs replace 8 spaces
> 
> This v4 patch was prompted by 2 errors, 2 warnings and 1 checks reported
> by the scripts/checkpatch.pl, which detected the style problem.
> 
> Changes in v3:
> - Add this changelog (Philipp)
> - Move lkp tags and link to the correct location in commit log (Alison)
> - Update the commit msg (Philip)
> - Update the commit log (Bagas, Julia)
> 
> Changes in v2:
> - Use new function names in call sites (LKP)

This is the place to credit the Kernel Test Robot for noticing that you made 
mistakes with v1 and that v2 is for fixing them.

Therefore, give credit here to the Robot:

Reported-by: kernel test robot 
> Link:
> https://lore.kernel.org/oe-kbuild-all/202303110849.x24wnhnm-...@intel.com/

Thanks,

Fabio

P.S.: Someone suggested to drop the "sm750_" prefix. I don't think you should 
do anything like this because I don't see "static" functions prefixed by 
"sm750_" in your patch. However, later you may check if they can be "static" 
and, if so, drop the prefix and make them "static" (in a follow up patch).  



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6] staging: sm750: Rename sm750_hw_cursor_* functions to snake_case

2023-03-29 Thread Kloudifold
On Wed, 29 Mar 2023 at 19:42, Greg Kroah-Hartman
 wrote:
>
> On Wed, Mar 29, 2023 at 07:27:04PM +0800, Kloudifold wrote:
> > sm750 driver has sm750_hw_cursor_* functions, which are named in
> > camelcase. Rename them to snake case to follow the function naming
> > convention.
> >
> > - sm750_hw_cursor_setSize  => sm750_hw_cursor_set_size
> > - sm750_hw_cursor_setPos   => sm750_hw_cursor_set_pos
> > - sm750_hw_cursor_setColor => sm750_hw_cursor_set_color
> > - sm750_hw_cursor_setData  => sm750_hw_cursor_set_data
> > - sm750_hw_cursor_setData2 => sm750_hw_cursor_set_data2
> >
> > Reported-by: kernel test robot 
>
> The test robot did not report that the names were incorrect :(
>
> > Link: 
> > https://lore.kernel.org/oe-kbuild-all/202303110849.x24wnhnm-...@intel.com/
> > Signed-off-by: Kloudifold 
>
>  Is that the name you use to sign documents?

Yes.

>
> thanks,
>
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v6] staging: sm750: Rename sm750_hw_cursor_* functions to snake_case

2023-03-29 Thread Greg Kroah-Hartman
On Wed, Mar 29, 2023 at 07:27:04PM +0800, Kloudifold wrote:
> sm750 driver has sm750_hw_cursor_* functions, which are named in
> camelcase. Rename them to snake case to follow the function naming
> convention.
> 
> - sm750_hw_cursor_setSize  => sm750_hw_cursor_set_size
> - sm750_hw_cursor_setPos   => sm750_hw_cursor_set_pos
> - sm750_hw_cursor_setColor => sm750_hw_cursor_set_color
> - sm750_hw_cursor_setData  => sm750_hw_cursor_set_data
> - sm750_hw_cursor_setData2 => sm750_hw_cursor_set_data2
> 
> Reported-by: kernel test robot 

The test robot did not report that the names were incorrect :(

> Link: 
> https://lore.kernel.org/oe-kbuild-all/202303110849.x24wnhnm-...@intel.com/
> Signed-off-by: Kloudifold 

Is that the name you use to sign documents?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v6] staging: sm750: Rename sm750_hw_cursor_* functions to snake_case

2023-03-29 Thread Kloudifold
sm750 driver has sm750_hw_cursor_* functions, which are named in
camelcase. Rename them to snake case to follow the function naming
convention.

- sm750_hw_cursor_setSize  => sm750_hw_cursor_set_size
- sm750_hw_cursor_setPos   => sm750_hw_cursor_set_pos
- sm750_hw_cursor_setColor => sm750_hw_cursor_set_color
- sm750_hw_cursor_setData  => sm750_hw_cursor_set_data
- sm750_hw_cursor_setData2 => sm750_hw_cursor_set_data2

Reported-by: kernel test robot 
Link: https://lore.kernel.org/oe-kbuild-all/202303110849.x24wnhnm-...@intel.com/
Signed-off-by: Kloudifold 

---
Changes in v6:
- Include missed recipients in v5, no functional change to the code

Changes in v5:
- Include missed recipients in v4, no functional change to the code

Changes in v4:
- Update the commit msg (Deepak)
- Use tabs replace 8 spaces

This v4 patch was prompted by 2 errors, 2 warnings and 1 checks reported
by the scripts/checkpatch.pl, which detected the style problem.

Changes in v3:
- Add this changelog (Philipp)
- Move lkp tags and link to the correct location in commit log (Alison)
- Update the commit msg (Philip)
- Update the commit log (Bagas, Julia)

Changes in v2:
- Use new function names in call sites (LKP)

 drivers/staging/sm750fb/sm750.c| 22 +++---
 drivers/staging/sm750fb/sm750_cursor.c | 14 +++---
 drivers/staging/sm750fb/sm750_cursor.h | 12 ++--
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index effc7fcc3..5d7249e82 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -121,14 +121,14 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct 
fb_cursor *fbcursor)
 
sm750_hw_cursor_disable(cursor);
if (fbcursor->set & FB_CUR_SETSIZE)
-   sm750_hw_cursor_setSize(cursor,
-   fbcursor->image.width,
-   fbcursor->image.height);
+   sm750_hw_cursor_set_size(cursor,
+fbcursor->image.width,
+fbcursor->image.height);
 
if (fbcursor->set & FB_CUR_SETPOS)
-   sm750_hw_cursor_setPos(cursor,
-  fbcursor->image.dx - info->var.xoffset,
-  fbcursor->image.dy - info->var.yoffset);
+   sm750_hw_cursor_set_pos(cursor,
+   fbcursor->image.dx - info->var.xoffset,
+   fbcursor->image.dy - info->var.yoffset);
 
if (fbcursor->set & FB_CUR_SETCMAP) {
/* get the 16bit color of kernel means */
@@ -142,14 +142,14 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct 
fb_cursor *fbcursor)
 ((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 
5) |
 ((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 
11);
 
-   sm750_hw_cursor_setColor(cursor, fg, bg);
+   sm750_hw_cursor_set_color(cursor, fg, bg);
}
 
if (fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
-   sm750_hw_cursor_setData(cursor,
-   fbcursor->rop,
-   fbcursor->image.data,
-   fbcursor->mask);
+   sm750_hw_cursor_set_data(cursor,
+fbcursor->rop,
+fbcursor->image.data,
+fbcursor->mask);
}
 
if (fbcursor->enable)
diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 43e6f52c2..ff643e33f 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -58,13 +58,13 @@ void sm750_hw_cursor_disable(struct lynx_cursor *cursor)
poke32(HWC_ADDRESS, 0);
 }
 
-void sm750_hw_cursor_setSize(struct lynx_cursor *cursor, int w, int h)
+void sm750_hw_cursor_set_size(struct lynx_cursor *cursor, int w, int h)
 {
cursor->w = w;
cursor->h = h;
 }
 
-void sm750_hw_cursor_setPos(struct lynx_cursor *cursor, int x, int y)
+void sm750_hw_cursor_set_pos(struct lynx_cursor *cursor, int x, int y)
 {
u32 reg;
 
@@ -73,7 +73,7 @@ void sm750_hw_cursor_setPos(struct lynx_cursor *cursor, int 
x, int y)
poke32(HWC_LOCATION, reg);
 }
 
-void sm750_hw_cursor_setColor(struct lynx_cursor *cursor, u32 fg, u32 bg)
+void sm750_hw_cursor_set_color(struct lynx_cursor *cursor, u32 fg, u32 bg)
 {
u32 reg = (fg << HWC_COLOR_12_2_RGB565_SHIFT) &
HWC_COLOR_12_2_RGB565_MASK;
@@ -82,8 +82,8 @@ void sm750_hw_cursor_setColor(stru

Re: [PATCH] staging: android: ashmem.c: Declared file operation with const keyword

2023-03-09 Thread Greg Kroah-Hartman
On Mon, Mar 06, 2023 at 12:30:57AM +0530, Santosh Mahto wrote:
> Warning found by checkpatch.pl script.
> 
> Signed-off-by: Santosh Mahto 
> ---
>  drivers/staging/android/ashmem.c | 2 +-

What kernel did you make this against?  This is not in my tree anymore.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: android: ashmem.c: Declared file operation with const keyword

2023-03-05 Thread Santosh Mahto
Warning found by checkpatch.pl script.

Signed-off-by: Santosh Mahto 
---
 drivers/staging/android/ashmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index c05a214191da..f9cfa15b785f 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned 
long addr,
 
 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
-   static struct file_operations vmfile_fops;
+   static const struct file_operations vmfile_fops;
struct ashmem_area *asma = file->private_data;
int ret = 0;
 
-- 
2.25.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 1/1] binder: return pending info for frozen async txns

2022-11-23 Thread Carlos Llamas
On Wed, Nov 23, 2022 at 12:16:54PM -0800, Li Li wrote:
> From: Li Li 
> 
> An async transaction to a frozen process will still be successfully
> put in the queue. But this pending async transaction won't be processed
> until the target process is unfrozen at an unspecified time in the
> future. Pass this important information back to the user space caller
> by returning BR_TRANSACTION_PENDING_FROZEN.
> 
> Signed-off-by: Li Li 
> ---
>  drivers/android/binder.c| 32 +++--
>  drivers/android/binder_internal.h   |  3 ++-
>  include/uapi/linux/android/binder.h |  7 ++-
>  3 files changed, 34 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 880224ec6abb..acd53147d5d1 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
> binder_transaction *t,
>   *
>   * Return:   0 if the transaction was successfully queued
>   *   BR_DEAD_REPLY if the target process or thread is dead
> - *   BR_FROZEN_REPLY if the target process or thread is frozen
> + *   BR_FROZEN_REPLY if the target process or thread is frozen and
> + *   the sync transaction was rejected
> + *   BR_TRANSACTION_PENDING_FROZEN if the target process is frozen
> + *   and the async transaction was successfully queued
>   */
>  static int binder_proc_transaction(struct binder_transaction *t,
>   struct binder_proc *proc,
> @@ -2738,6 +2741,7 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   bool oneway = !!(t->flags & TF_ONE_WAY);
>   bool pending_async = false;
>   struct binder_transaction *t_outdated = NULL;
> + bool frozen = false;
>  
>   BUG_ON(!node);
>   binder_node_lock(node);
> @@ -2751,15 +2755,16 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>  
>   binder_inner_proc_lock(proc);
>   if (proc->is_frozen) {
> + frozen = true;
>   proc->sync_recv |= !oneway;
>   proc->async_recv |= oneway;
>   }
>  
> - if ((proc->is_frozen && !oneway) || proc->is_dead ||
> + if ((frozen && !oneway) || proc->is_dead ||
>   (thread && thread->is_dead)) {
>   binder_inner_proc_unlock(proc);
>   binder_node_unlock(node);
> - return proc->is_frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
> + return frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
>   }
>  
>   if (!thread && !pending_async)
> @@ -2770,7 +2775,7 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   } else if (!pending_async) {
>   binder_enqueue_work_ilocked(>work, >todo);
>   } else {
> - if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
> + if ((t->flags & TF_UPDATE_TXN) && frozen) {
>   t_outdated = binder_find_outdated_transaction_ilocked(t,
> 
> >async_todo);
>   if (t_outdated) {
> @@ -2807,6 +2812,9 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   binder_stats_deleted(BINDER_STAT_TRANSACTION);
>   }
>  
> + if (oneway && frozen)
> + return BR_TRANSACTION_PENDING_FROZEN;
> +
>   return 0;
>  }
>  
> @@ -3607,9 +3615,17 @@ static void binder_transaction(struct binder_proc 
> *proc,
>   } else {
>   BUG_ON(target_node == NULL);
>   BUG_ON(t->buffer->async_transaction != 1);
> - binder_enqueue_thread_work(thread, tcomplete);
>   return_error = binder_proc_transaction(t, target_proc, NULL);
> - if (return_error)
> + /*
> +  * Let the caller know when async transaction reaches a frozen
> +  * process and is put in a pending queue, waiting for the target
> +  * process to be unfrozen.
> +  */
> + if (return_error == BR_TRANSACTION_PENDING_FROZEN)
> + tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
> + binder_enqueue_thread_work(thread, tcomplete);
> + if (return_error &&
> + return_error != BR_TRANSACTION_PENDING_FROZEN)
>   goto err_dead_proc_or_thread;
>   }
>   if (target_thread)
> @@ -4440,10 +4456,13 @@ static int binder_thread_read(struct binder_proc 
> *proc,
>   binder_stat_br(proc, thread, cmd);
>   } break;
>   case BINDER_WORK_TRANSACTION_COMPLETE:
> + case BINDER_WORK_TRANSACTION_PENDING:
>   case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
>   if (proc->oneway_spam_detection_enabled &&
>  w->type == 
> 

Re: [PATCH v2 1/1] binder: return pending info for frozen async txns

2022-11-23 Thread Li Li
On Wed, Nov 23, 2022 at 10:58 AM Carlos Llamas  wrote:
>
> This looks good. Could you rename the new op to signify the frozen
> scenario though? We might have some other instances of pending
> transactions in the future so might as well be specific here.

Done [1].

v3: rename BR_TRANSACTION_PENDING to BR_TRANSACTION_PENDING_FROZEN to
signify the frozen scenario and avoid potential confusion

[1] https://lkml.org/lkml/2022/11/23/1472
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/1] binder: return pending info for frozen async txns

2022-11-23 Thread Li Li
From: Li Li 

An async transaction to a frozen process will still be successfully
put in the queue. But this pending async transaction won't be processed
until the target process is unfrozen at an unspecified time in the
future. Pass this important information back to the user space caller
by returning BR_TRANSACTION_PENDING_FROZEN.

Signed-off-by: Li Li 
---
 drivers/android/binder.c| 32 +++--
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 880224ec6abb..acd53147d5d1 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
binder_transaction *t,
  *
  * Return: 0 if the transaction was successfully queued
  * BR_DEAD_REPLY if the target process or thread is dead
- * BR_FROZEN_REPLY if the target process or thread is frozen
+ * BR_FROZEN_REPLY if the target process or thread is frozen and
+ * the sync transaction was rejected
+ * BR_TRANSACTION_PENDING_FROZEN if the target process is frozen
+ * and the async transaction was successfully queued
  */
 static int binder_proc_transaction(struct binder_transaction *t,
struct binder_proc *proc,
@@ -2738,6 +2741,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
struct binder_transaction *t_outdated = NULL;
+   bool frozen = false;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2751,15 +2755,16 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
 
binder_inner_proc_lock(proc);
if (proc->is_frozen) {
+   frozen = true;
proc->sync_recv |= !oneway;
proc->async_recv |= oneway;
}
 
-   if ((proc->is_frozen && !oneway) || proc->is_dead ||
+   if ((frozen && !oneway) || proc->is_dead ||
(thread && thread->is_dead)) {
binder_inner_proc_unlock(proc);
binder_node_unlock(node);
-   return proc->is_frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
+   return frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
}
 
if (!thread && !pending_async)
@@ -2770,7 +2775,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
} else if (!pending_async) {
binder_enqueue_work_ilocked(>work, >todo);
} else {
-   if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
+   if ((t->flags & TF_UPDATE_TXN) && frozen) {
t_outdated = binder_find_outdated_transaction_ilocked(t,
  
>async_todo);
if (t_outdated) {
@@ -2807,6 +2812,9 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
 
+   if (oneway && frozen)
+   return BR_TRANSACTION_PENDING_FROZEN;
+
return 0;
 }
 
@@ -3607,9 +3615,17 @@ static void binder_transaction(struct binder_proc *proc,
} else {
BUG_ON(target_node == NULL);
BUG_ON(t->buffer->async_transaction != 1);
-   binder_enqueue_thread_work(thread, tcomplete);
return_error = binder_proc_transaction(t, target_proc, NULL);
-   if (return_error)
+   /*
+* Let the caller know when async transaction reaches a frozen
+* process and is put in a pending queue, waiting for the target
+* process to be unfrozen.
+*/
+   if (return_error == BR_TRANSACTION_PENDING_FROZEN)
+   tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
+   binder_enqueue_thread_work(thread, tcomplete);
+   if (return_error &&
+   return_error != BR_TRANSACTION_PENDING_FROZEN)
goto err_dead_proc_or_thread;
}
if (target_thread)
@@ -4440,10 +4456,13 @@ static int binder_thread_read(struct binder_proc *proc,
binder_stat_br(proc, thread, cmd);
} break;
case BINDER_WORK_TRANSACTION_COMPLETE:
+   case BINDER_WORK_TRANSACTION_PENDING:
case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
if (proc->oneway_spam_detection_enabled &&
   w->type == 
BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
cmd = BR_ONEWAY_SPAM_SUSPECT;
+   else if (w->type == BINDER_WORK_TRANSACTION_PENDING)
+ 

[PATCH v3 0/1] binder: return pending info for frozen async txns

2022-11-23 Thread Li Li
From: Li Li 

User applications need to know if their binder transactions reach a
frozen process or not. For sync binder calls, Linux kernel already
has a dedicated return value BR_FROZEN_REPLY, indicating this sync
binder transaction will be rejected (similar to BR_DEAD_REPLY) as the
target process is frozen. But for async binder calls, the user space
application doesn't have a way to know if the target process is frozen.

This patch adds a new return value, BR_TRANSACTION_PENDING_FROZEN, to
fix this issue. Similar to BR_TRANSACTION_COMPLETE, it means the async
binder transaction has been put in the queue of the target process, but
it's waiting for the target process to be unfrozen.

v1: checkpatch.pl --strict passed
v2: protect proc->is_frozen with lock, fix typo in comments
v3: rename BR_TRANSACTION_PENDING to BR_TRANSACTION_PENDING_FROZEN to
signify the frozen scenario and avoid potential confusion

Li Li (1):
  binder: return pending info for frozen async txns

 drivers/android/binder.c| 32 +++--
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 34 insertions(+), 8 deletions(-)

-- 
2.38.1.584.g0f3c55d4c2-goog

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/1] binder: return pending info for frozen async txns

2022-11-23 Thread Carlos Llamas
On Thu, Nov 10, 2022 at 12:34:05PM -0800, Li Li wrote:
> From: Li Li 
> 
> An async transaction to a frozen process will still be successfully
> put in the queue. But this pending async transaction won't be processed
> until the target process is unfrozen at an unspecified time in the
> future. Pass this important information back to the user space caller
> by returning BR_TRANSACTION_PENDING.
> 
> Signed-off-by: Li Li 
> ---
>  drivers/android/binder.c| 31 +++--
>  drivers/android/binder_internal.h   |  3 ++-
>  include/uapi/linux/android/binder.h |  7 ++-
>  3 files changed, 33 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 880224ec6abb..a798f6661488 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
> binder_transaction *t,
>   *
>   * Return:   0 if the transaction was successfully queued
>   *   BR_DEAD_REPLY if the target process or thread is dead
> - *   BR_FROZEN_REPLY if the target process or thread is frozen
> + *   BR_FROZEN_REPLY if the target process or thread is frozen and
> + *   the sync transaction was rejected
> + *   BR_TRANSACTION_PENDING if the target process is frozen and the
> + *   async transaction was successfully queued
>   */
>  static int binder_proc_transaction(struct binder_transaction *t,
>   struct binder_proc *proc,
> @@ -2738,6 +2741,7 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   bool oneway = !!(t->flags & TF_ONE_WAY);
>   bool pending_async = false;
>   struct binder_transaction *t_outdated = NULL;
> + bool frozen = false;
>  
>   BUG_ON(!node);
>   binder_node_lock(node);
> @@ -2751,15 +2755,16 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>  
>   binder_inner_proc_lock(proc);
>   if (proc->is_frozen) {
> + frozen = true;
>   proc->sync_recv |= !oneway;
>   proc->async_recv |= oneway;
>   }
>  
> - if ((proc->is_frozen && !oneway) || proc->is_dead ||
> + if ((frozen && !oneway) || proc->is_dead ||
>   (thread && thread->is_dead)) {
>   binder_inner_proc_unlock(proc);
>   binder_node_unlock(node);
> - return proc->is_frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
> + return frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
>   }
>  
>   if (!thread && !pending_async)
> @@ -2770,7 +2775,7 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   } else if (!pending_async) {
>   binder_enqueue_work_ilocked(>work, >todo);
>   } else {
> - if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
> + if ((t->flags & TF_UPDATE_TXN) && frozen) {
>   t_outdated = binder_find_outdated_transaction_ilocked(t,
> 
> >async_todo);
>   if (t_outdated) {
> @@ -2807,6 +2812,9 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   binder_stats_deleted(BINDER_STAT_TRANSACTION);
>   }
>  
> + if (oneway && frozen)
> + return BR_TRANSACTION_PENDING;
> +
>   return 0;
>  }
>  
> @@ -3607,9 +3615,16 @@ static void binder_transaction(struct binder_proc 
> *proc,
>   } else {
>   BUG_ON(target_node == NULL);
>   BUG_ON(t->buffer->async_transaction != 1);
> - binder_enqueue_thread_work(thread, tcomplete);
>   return_error = binder_proc_transaction(t, target_proc, NULL);
> - if (return_error)
> + /*
> +  * Let the caller know when async transaction reaches a frozen
> +  * process and is put in a pending queue, waiting for the target
> +  * process to be unfrozen.
> +  */
> + if (return_error == BR_TRANSACTION_PENDING)
> + tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
> + binder_enqueue_thread_work(thread, tcomplete);
> + if (return_error && return_error != BR_TRANSACTION_PENDING)
>   goto err_dead_proc_or_thread;
>   }
>   if (target_thread)
> @@ -4440,10 +4455,13 @@ static int binder_thread_read(struct binder_proc 
> *proc,
>   binder_stat_br(proc, thread, cmd);
>   } break;
>   case BINDER_WORK_TRANSACTION_COMPLETE:
> + case BINDER_WORK_TRANSACTION_PENDING:
>   case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
>   if (proc->oneway_spam_detection_enabled &&
>  w->type == 
> BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
>   cmd = 

[PATCH] staging: rts5208: Added value check

2022-11-18 Thread Denis Arefev
Added value check.
Return value of a function 'ms_set_rw_reg_addr'
called at ms.c:1770 is not checked,
but it is usually checked for this function

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Denis Arefev 
---
 drivers/staging/rts5208/ms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c
index 9001570a8c94..e884ee5da317 100644
--- a/drivers/staging/rts5208/ms.c
+++ b/drivers/staging/rts5208/ms.c
@@ -1769,6 +1769,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 
old_blk, u16 new_blk,
 
retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE,
SYSTEM_PARAM, (6 + MS_EXTRA_SIZE));
+   if (retval != STATUS_SUCCESS)
+   return STATUS_FAIL;
 
ms_set_err_code(chip, MS_NO_ERROR);
 
-- 
2.25.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/1] binder: return pending info for frozen async txns

2022-11-10 Thread Li Li
From: Li Li 

An async transaction to a frozen process will still be successfully
put in the queue. But this pending async transaction won't be processed
until the target process is unfrozen at an unspecified time in the
future. Pass this important information back to the user space caller
by returning BR_TRANSACTION_PENDING.

Signed-off-by: Li Li 
---
 drivers/android/binder.c| 31 +++--
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 880224ec6abb..a798f6661488 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
binder_transaction *t,
  *
  * Return: 0 if the transaction was successfully queued
  * BR_DEAD_REPLY if the target process or thread is dead
- * BR_FROZEN_REPLY if the target process or thread is frozen
+ * BR_FROZEN_REPLY if the target process or thread is frozen and
+ * the sync transaction was rejected
+ * BR_TRANSACTION_PENDING if the target process is frozen and the
+ * async transaction was successfully queued
  */
 static int binder_proc_transaction(struct binder_transaction *t,
struct binder_proc *proc,
@@ -2738,6 +2741,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
struct binder_transaction *t_outdated = NULL;
+   bool frozen = false;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2751,15 +2755,16 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
 
binder_inner_proc_lock(proc);
if (proc->is_frozen) {
+   frozen = true;
proc->sync_recv |= !oneway;
proc->async_recv |= oneway;
}
 
-   if ((proc->is_frozen && !oneway) || proc->is_dead ||
+   if ((frozen && !oneway) || proc->is_dead ||
(thread && thread->is_dead)) {
binder_inner_proc_unlock(proc);
binder_node_unlock(node);
-   return proc->is_frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
+   return frozen ? BR_FROZEN_REPLY : BR_DEAD_REPLY;
}
 
if (!thread && !pending_async)
@@ -2770,7 +2775,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
} else if (!pending_async) {
binder_enqueue_work_ilocked(>work, >todo);
} else {
-   if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
+   if ((t->flags & TF_UPDATE_TXN) && frozen) {
t_outdated = binder_find_outdated_transaction_ilocked(t,
  
>async_todo);
if (t_outdated) {
@@ -2807,6 +2812,9 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
 
+   if (oneway && frozen)
+   return BR_TRANSACTION_PENDING;
+
return 0;
 }
 
@@ -3607,9 +3615,16 @@ static void binder_transaction(struct binder_proc *proc,
} else {
BUG_ON(target_node == NULL);
BUG_ON(t->buffer->async_transaction != 1);
-   binder_enqueue_thread_work(thread, tcomplete);
return_error = binder_proc_transaction(t, target_proc, NULL);
-   if (return_error)
+   /*
+* Let the caller know when async transaction reaches a frozen
+* process and is put in a pending queue, waiting for the target
+* process to be unfrozen.
+*/
+   if (return_error == BR_TRANSACTION_PENDING)
+   tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
+   binder_enqueue_thread_work(thread, tcomplete);
+   if (return_error && return_error != BR_TRANSACTION_PENDING)
goto err_dead_proc_or_thread;
}
if (target_thread)
@@ -4440,10 +4455,13 @@ static int binder_thread_read(struct binder_proc *proc,
binder_stat_br(proc, thread, cmd);
} break;
case BINDER_WORK_TRANSACTION_COMPLETE:
+   case BINDER_WORK_TRANSACTION_PENDING:
case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
if (proc->oneway_spam_detection_enabled &&
   w->type == 
BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
cmd = BR_ONEWAY_SPAM_SUSPECT;
+   else if (w->type == BINDER_WORK_TRANSACTION_PENDING)
+   cmd = 

[PATCH v2 0/1] binder: return pending info for frozen async txns

2022-11-10 Thread Li Li
From: Li Li 

User applications need to know if their binder transactions reach a
frozen process or not. For sync binder calls, Linux kernel already
has a dedicated return value BR_FROZEN_REPLY, indicating this sync
binder transaction will be rejected (similar to BR_DEAD_REPLY) as the
target process is frozen. But for async binder calls, the user space
application doesn't have a way to know if the target process is frozen.

This patch adds a new return value, BR_TRANSACTION_PENDING, to fix this
issue. Similar to BR_TRANSACTION_COMPLETE, it means the async binder
transaction has been put in the queue of the target process, but it's
waiting for the target process to be unfrozen.

v1: checkpatch.pl --strict passed
v2: protect proc->is_frozen with lock, fix typo in comments

Li Li (1):
  binder: return pending info for frozen async txns

 drivers/android/binder.c| 31 +++--
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 33 insertions(+), 8 deletions(-)

-- 
2.38.1.431.g37b22c650d-goog

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1 1/1] binder: return pending info for frozen async txns

2022-11-10 Thread Li Li
On Wed, Nov 9, 2022 at 2:43 PM Carlos Llamas  wrote:
>
> On Thu, Nov 03, 2022 at 12:05:49PM -0700, Li Li wrote:
> > From: Li Li 
> >
> > An async transaction to a frozen process will still be successsfully
>
> nit: sucessfully typo

Nice catch! Will remove the extra 's' in v2.

>
> > put in the queue. But this pending async transaction won't be processed
> > until the target process is unfrozen at an unspecified time in the
> > future. Pass this important information back to the user space caller
> > by returning BR_TRANSACTION_PENDING.
> >
> > Signed-off-by: Li Li 
> > ---
> >  drivers/android/binder.c| 23 ---
> >  drivers/android/binder_internal.h   |  3 ++-
> >  include/uapi/linux/android/binder.h |  7 ++-
> >  3 files changed, 28 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > index 880224ec6abb..a097b89f6a7a 100644
> > --- a/drivers/android/binder.c
> > +++ b/drivers/android/binder.c
> > @@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
> > binder_transaction *t,
> >   *
> >   * Return:   0 if the transaction was successfully queued
> >   *   BR_DEAD_REPLY if the target process or thread is dead
> > - *   BR_FROZEN_REPLY if the target process or thread is frozen
> > + *   BR_FROZEN_REPLY if the target process or thread is frozen and
> > + *   the sync transaction was rejected
> > + *   BR_TRANSACTION_PENDING if the target process is frozen and the
> > + *   async transaction was successfully queued
> >   */
> >  static int binder_proc_transaction(struct binder_transaction *t,
> >   struct binder_proc *proc,
> > @@ -2807,6 +2810,9 @@ static int binder_proc_transaction(struct 
> > binder_transaction *t,
> >   binder_stats_deleted(BINDER_STAT_TRANSACTION);
> >   }
> >
> > + if (oneway && proc->is_frozen)
>
> Do you need the inner lock here for proc->is_frozen?

You're right. I'll add a new local variable and set it between the existing
binder_inner_proc_lock() and binder_inner_proc_unlock().

>
> > + return BR_TRANSACTION_PENDING;
> > +
> >   return 0;
> >  }
> >
> > @@ -3607,9 +3613,16 @@ static void binder_transaction(struct binder_proc 
> > *proc,
> >   } else {
> >   BUG_ON(target_node == NULL);
> >   BUG_ON(t->buffer->async_transaction != 1);
> > - binder_enqueue_thread_work(thread, tcomplete);
> >   return_error = binder_proc_transaction(t, target_proc, NULL);
> > - if (return_error)
> > + /*
> > +  * Let the caller know its async transaction reaches a frozen
>
> nit: I believe you meant s/its/when or similar?

Will change it in v2. Thanks!

>
> > +  * process and is put in a pending queue, waiting for the 
> > target
> > +  * process to be unfrozen.
> > +  */
> > + if (return_error == BR_TRANSACTION_PENDING)
> > + tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
> > + binder_enqueue_thread_work(thread, tcomplete);
>
> I wonder if switching the order of queuing the tcomplete here and waking
> up the target thread inside binder_proc_transaction() will have any
> performance implications if this task gets scheduled out.

Eventually the sender has to wait this whole function finish and then
call another
ioctl to actually read tcomplete back. If this task gets cheduled out,
it won't have
a chance to perform that reading operation even without this change. So there's
no difference.

>
> > + if (return_error && return_error != BR_TRANSACTION_PENDING)
> >   goto err_dead_proc_or_thread;
> >   }
> >   if (target_thread)
> > @@ -4440,10 +4453,13 @@ static int binder_thread_read(struct binder_proc 
> > *proc,
> >   binder_stat_br(proc, thread, cmd);
> >   } break;
> >   case BINDER_WORK_TRANSACTION_COMPLETE:
> > + case BINDER_WORK_TRANSACTION_PENDING:
> >   case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
> >   if (proc->oneway_spam_detection_enabled &&
> >  w->type == 
> > BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
> >   cmd = BR_ONEWAY_SPAM_SUSPECT;
> > + else if (w->type == BINDER_WORK_TRANSACTION_PENDING)
> > + cmd = BR_TRANSACTION_PENDING;
> >   else
> >   cmd = BR_TRANSACTION_COMPLETE;
> >   binder_inner_proc_unlock(proc);
> > @@ -6170,6 +6186,7 @@ static const char * const binder_return_strings[] = {
> >   "BR_FAILED_REPLY",
> >   "BR_FROZEN_REPLY",
> >   "BR_ONEWAY_SPAM_SUSPECT",
> > + "BR_TRANSACTION_PENDING"
> >  };
> >
> >  static const char * const 

Re: [PATCH v1 1/1] binder: return pending info for frozen async txns

2022-11-09 Thread Carlos Llamas
On Thu, Nov 03, 2022 at 12:05:49PM -0700, Li Li wrote:
> From: Li Li 
> 
> An async transaction to a frozen process will still be successsfully

nit: sucessfully typo

> put in the queue. But this pending async transaction won't be processed
> until the target process is unfrozen at an unspecified time in the
> future. Pass this important information back to the user space caller
> by returning BR_TRANSACTION_PENDING.
> 
> Signed-off-by: Li Li 
> ---
>  drivers/android/binder.c| 23 ---
>  drivers/android/binder_internal.h   |  3 ++-
>  include/uapi/linux/android/binder.h |  7 ++-
>  3 files changed, 28 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 880224ec6abb..a097b89f6a7a 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
> binder_transaction *t,
>   *
>   * Return:   0 if the transaction was successfully queued
>   *   BR_DEAD_REPLY if the target process or thread is dead
> - *   BR_FROZEN_REPLY if the target process or thread is frozen
> + *   BR_FROZEN_REPLY if the target process or thread is frozen and
> + *   the sync transaction was rejected
> + *   BR_TRANSACTION_PENDING if the target process is frozen and the
> + *   async transaction was successfully queued
>   */
>  static int binder_proc_transaction(struct binder_transaction *t,
>   struct binder_proc *proc,
> @@ -2807,6 +2810,9 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   binder_stats_deleted(BINDER_STAT_TRANSACTION);
>   }
>  
> + if (oneway && proc->is_frozen)

Do you need the inner lock here for proc->is_frozen?

> + return BR_TRANSACTION_PENDING;
> +
>   return 0;
>  }
>  
> @@ -3607,9 +3613,16 @@ static void binder_transaction(struct binder_proc 
> *proc,
>   } else {
>   BUG_ON(target_node == NULL);
>   BUG_ON(t->buffer->async_transaction != 1);
> - binder_enqueue_thread_work(thread, tcomplete);
>   return_error = binder_proc_transaction(t, target_proc, NULL);
> - if (return_error)
> + /*
> +  * Let the caller know its async transaction reaches a frozen

nit: I believe you meant s/its/when or similar?

> +  * process and is put in a pending queue, waiting for the target
> +  * process to be unfrozen.
> +  */
> + if (return_error == BR_TRANSACTION_PENDING)
> + tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
> + binder_enqueue_thread_work(thread, tcomplete);

I wonder if switching the order of queuing the tcomplete here and waking
up the target thread inside binder_proc_transaction() will have any
performance implications if this task gets scheduled out.

> + if (return_error && return_error != BR_TRANSACTION_PENDING)
>   goto err_dead_proc_or_thread;
>   }
>   if (target_thread)
> @@ -4440,10 +4453,13 @@ static int binder_thread_read(struct binder_proc 
> *proc,
>   binder_stat_br(proc, thread, cmd);
>   } break;
>   case BINDER_WORK_TRANSACTION_COMPLETE:
> + case BINDER_WORK_TRANSACTION_PENDING:
>   case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
>   if (proc->oneway_spam_detection_enabled &&
>  w->type == 
> BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
>   cmd = BR_ONEWAY_SPAM_SUSPECT;
> + else if (w->type == BINDER_WORK_TRANSACTION_PENDING)
> + cmd = BR_TRANSACTION_PENDING;
>   else
>   cmd = BR_TRANSACTION_COMPLETE;
>   binder_inner_proc_unlock(proc);
> @@ -6170,6 +6186,7 @@ static const char * const binder_return_strings[] = {
>   "BR_FAILED_REPLY",
>   "BR_FROZEN_REPLY",
>   "BR_ONEWAY_SPAM_SUSPECT",
> + "BR_TRANSACTION_PENDING"
>  };
>  
>  static const char * const binder_command_strings[] = {
> diff --git a/drivers/android/binder_internal.h 
> b/drivers/android/binder_internal.h
> index abe19d88c6ec..6c51325a826f 100644
> --- a/drivers/android/binder_internal.h
> +++ b/drivers/android/binder_internal.h
> @@ -133,7 +133,7 @@ enum binder_stat_types {
>  };
>  
>  struct binder_stats {
> - atomic_t br[_IOC_NR(BR_ONEWAY_SPAM_SUSPECT) + 1];
> + atomic_t br[_IOC_NR(BR_TRANSACTION_PENDING) + 1];
>   atomic_t bc[_IOC_NR(BC_REPLY_SG) + 1];
>   atomic_t obj_created[BINDER_STAT_COUNT];
>   atomic_t obj_deleted[BINDER_STAT_COUNT];
> @@ -152,6 +152,7 @@ struct binder_work {
>   enum binder_work_type {
>   BINDER_WORK_TRANSACTION = 1,
>   

[PATCH v1 1/1] binder: return pending info for frozen async txns

2022-11-03 Thread Li Li
From: Li Li 

An async transaction to a frozen process will still be successsfully
put in the queue. But this pending async transaction won't be processed
until the target process is unfrozen at an unspecified time in the
future. Pass this important information back to the user space caller
by returning BR_TRANSACTION_PENDING.

Signed-off-by: Li Li 
---
 drivers/android/binder.c| 23 ---
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 880224ec6abb..a097b89f6a7a 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2728,7 +2728,10 @@ binder_find_outdated_transaction_ilocked(struct 
binder_transaction *t,
  *
  * Return: 0 if the transaction was successfully queued
  * BR_DEAD_REPLY if the target process or thread is dead
- * BR_FROZEN_REPLY if the target process or thread is frozen
+ * BR_FROZEN_REPLY if the target process or thread is frozen and
+ * the sync transaction was rejected
+ * BR_TRANSACTION_PENDING if the target process is frozen and the
+ * async transaction was successfully queued
  */
 static int binder_proc_transaction(struct binder_transaction *t,
struct binder_proc *proc,
@@ -2807,6 +2810,9 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
 
+   if (oneway && proc->is_frozen)
+   return BR_TRANSACTION_PENDING;
+
return 0;
 }
 
@@ -3607,9 +3613,16 @@ static void binder_transaction(struct binder_proc *proc,
} else {
BUG_ON(target_node == NULL);
BUG_ON(t->buffer->async_transaction != 1);
-   binder_enqueue_thread_work(thread, tcomplete);
return_error = binder_proc_transaction(t, target_proc, NULL);
-   if (return_error)
+   /*
+* Let the caller know its async transaction reaches a frozen
+* process and is put in a pending queue, waiting for the target
+* process to be unfrozen.
+*/
+   if (return_error == BR_TRANSACTION_PENDING)
+   tcomplete->type = BINDER_WORK_TRANSACTION_PENDING;
+   binder_enqueue_thread_work(thread, tcomplete);
+   if (return_error && return_error != BR_TRANSACTION_PENDING)
goto err_dead_proc_or_thread;
}
if (target_thread)
@@ -4440,10 +4453,13 @@ static int binder_thread_read(struct binder_proc *proc,
binder_stat_br(proc, thread, cmd);
} break;
case BINDER_WORK_TRANSACTION_COMPLETE:
+   case BINDER_WORK_TRANSACTION_PENDING:
case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT: {
if (proc->oneway_spam_detection_enabled &&
   w->type == 
BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
cmd = BR_ONEWAY_SPAM_SUSPECT;
+   else if (w->type == BINDER_WORK_TRANSACTION_PENDING)
+   cmd = BR_TRANSACTION_PENDING;
else
cmd = BR_TRANSACTION_COMPLETE;
binder_inner_proc_unlock(proc);
@@ -6170,6 +6186,7 @@ static const char * const binder_return_strings[] = {
"BR_FAILED_REPLY",
"BR_FROZEN_REPLY",
"BR_ONEWAY_SPAM_SUSPECT",
+   "BR_TRANSACTION_PENDING"
 };
 
 static const char * const binder_command_strings[] = {
diff --git a/drivers/android/binder_internal.h 
b/drivers/android/binder_internal.h
index abe19d88c6ec..6c51325a826f 100644
--- a/drivers/android/binder_internal.h
+++ b/drivers/android/binder_internal.h
@@ -133,7 +133,7 @@ enum binder_stat_types {
 };
 
 struct binder_stats {
-   atomic_t br[_IOC_NR(BR_ONEWAY_SPAM_SUSPECT) + 1];
+   atomic_t br[_IOC_NR(BR_TRANSACTION_PENDING) + 1];
atomic_t bc[_IOC_NR(BC_REPLY_SG) + 1];
atomic_t obj_created[BINDER_STAT_COUNT];
atomic_t obj_deleted[BINDER_STAT_COUNT];
@@ -152,6 +152,7 @@ struct binder_work {
enum binder_work_type {
BINDER_WORK_TRANSACTION = 1,
BINDER_WORK_TRANSACTION_COMPLETE,
+   BINDER_WORK_TRANSACTION_PENDING,
BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT,
BINDER_WORK_RETURN_ERROR,
BINDER_WORK_NODE,
diff --git a/include/uapi/linux/android/binder.h 
b/include/uapi/linux/android/binder.h
index e72e4de8f452..c21b3b3eb4e4 100644
--- a/include/uapi/linux/android/binder.h
+++ b/include/uapi/linux/android/binder.h
@@ -450,7 +450,7 @@ enum binder_driver_return_protocol {
 

[PATCH v1 0/1] binder: return pending info for frozen async txns

2022-11-03 Thread Li Li
From: Li Li 

User applications need to know if their binder transactions reach a
frozen process or not. For sync binder calls, Linux kernel already
has a dedicated return value BR_FROZEN_REPLY, indicating this sync
binder transaction will be rejected (similar to BR_DEAD_REPLY) as the
target process is frozen. But for async binder calls, the user space
application doesn't have a way to know if the target process is frozen.

This patch add a new return value, BR_TRANSACTION_PENDING, to fix this
issue. Similar to BR_TRANSACTION_COMPLETE, it means the async binder
transaction has been put in the queue of the target process, but it's
waiting for the target process to be unfrozen.

v1: checkpatch.pl --strict passed

Li Li (1):
  binder: return pending info for frozen async txns

 drivers/android/binder.c| 23 ---
 drivers/android/binder_internal.h   |  3 ++-
 include/uapi/linux/android/binder.h |  7 ++-
 3 files changed, 28 insertions(+), 5 deletions(-)

-- 
2.38.1.431.g37b22c650d-goog

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-10-31 Thread lichenyang
From: Chenyang Li 

This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v13:
- Delete allow_fb_modifiers.

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  23 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 242 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 273 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 130 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  58 
 drivers/gpu/drm/loongson/loongson_plane.c |  96 ++
 11 files changed, 889 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 34f5a092c99e..0335e62377d9 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -400,6 +400,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 0b283e46f28b..a775f536b3cb 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -139,6 +139,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   he

[PATCH v8 3/4] drm/loongson: Add interrupt driver for LS7A.

2022-10-31 Thread lichenyang
Add LS7A DC vsync interrupt enable and close function, and
register irq_handler function interface.
Add vbrank event processing flow.

v4:
- Replace drm_irq_install with devm_request_irq.
- Delete the irq_ hooks in drm_driver.

v3:
- Improve code readability.
- Use the to_pci_dev function to get pci_dev.

v2:
- Added error handling in the loongson_drm_load function.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile|  1 +
 drivers/gpu/drm/loongson/loongson_crtc.c | 37 +++
 drivers/gpu/drm/loongson/loongson_drv.c  |  9 ++-
 drivers/gpu/drm/loongson/loongson_drv.h  | 10 +++
 drivers/gpu/drm/loongson/loongson_irq.c  | 82 
 5 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_irq.c

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 4a5fab7d000b..b083854d789b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -10,5 +10,6 @@ loongson-y := loongson_connector.o \
loongson_drv.o \
loongson_encoder.o \
loongson_i2c.o \
+   loongson_irq.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_crtc.c 
b/drivers/gpu/drm/loongson/loongson_crtc.c
index a9735fbb1c2e..10d6f9a16f4e 100644
--- a/drivers/gpu/drm/loongson/loongson_crtc.c
+++ b/drivers/gpu/drm/loongson/loongson_crtc.c
@@ -3,6 +3,7 @@
 
 #include 
 #include 
+#include 
 
 #include "loongson_drv.h"
 
@@ -165,8 +166,14 @@ static void loongson_crtc_atomic_enable(struct drm_crtc 
*crtc,
struct loongson_crtc *lcrtc = to_loongson_crtc(crtc);
u32 reg_offset = lcrtc->reg_offset;
 
+   if (lcrtc->cfg_reg & CFG_ENABLE)
+   goto vblank_on;
+
lcrtc->cfg_reg |= CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+vblank_on:
+   drm_crtc_vblank_on(crtc);
 }
 
 static void loongson_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -179,6 +186,33 @@ static void loongson_crtc_atomic_disable(struct drm_crtc 
*crtc,
 
lcrtc->cfg_reg &= ~CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+   spin_lock_irq(>dev->event_lock);
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+   spin_unlock_irq(>dev->event_lock);
+
+   drm_crtc_vblank_off(crtc);
+}
+
+static void loongson_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_atomic_state *state)
+{
+   struct drm_pending_vblank_event *event = crtc->state->event;
+
+   if (!event)
+   return;
+
+   crtc->state->event = NULL;
+
+   spin_lock_irq(>dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(>dev->event_lock);
 }
 
 static enum drm_mode_status loongson_mode_valid(struct drm_crtc *crtc,
@@ -198,6 +232,7 @@ static enum drm_mode_status loongson_mode_valid(struct 
drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs loongson_crtc_helper_funcs = {
.mode_valid = loongson_mode_valid,
+   .atomic_flush = loongson_crtc_atomic_flush,
.atomic_enable = loongson_crtc_atomic_enable,
.atomic_disable = loongson_crtc_atomic_disable,
.mode_set_nofb = loongson_crtc_mode_set_nofb,
@@ -209,6 +244,8 @@ static const struct drm_crtc_funcs loongson_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = loongson_crtc_enable_vblank,
+   .disable_vblank = loongson_crtc_disable_vblank,
 };
 
 int loongson_crtc_init(struct loongson_device *ldev, int index)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 9120d8188ddf..c9702970a037 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -21,9 +21,10 @@
 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
+ * 0.3 - Vblank and vsync interrupt support.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 2
+#define DRIVER_MINOR 3
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -165,6 +166,12 @@ static int loongson_driver_init(struct drm_device *dev)
goto err;
}
 
+   ret = loongson_irq_init(ldev);
+   if (ret) {
+   dev_err(dev->dev, "Fatal error during irq init: %d\n", ret);
+   goto err;
+   }
+
drm_kms_helper_poll_init(dev);
drm_mode_config_reset(dev);
 
diff --git 

[PATCH v8 4/4] drm/loongson: Use acpi to get video bios.

2022-10-31 Thread lichenyang
Add get video bios from the ACPI table.
Define new acpi table "VIAT" for loongson video bios.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile |  3 +-
 drivers/gpu/drm/loongson/loongson_drv.c   | 21 +++-
 drivers/gpu/drm/loongson/loongson_drv.h   |  1 +
 drivers/gpu/drm/loongson/loongson_vbios.c | 62 +++
 drivers/gpu/drm/loongson/loongson_vbios.h | 29 +++
 5 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index b083854d789b..b774a91003d9 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -11,5 +11,6 @@ loongson-y := loongson_connector.o \
loongson_encoder.o \
loongson_i2c.o \
loongson_irq.o \
-   loongson_plane.o
+   loongson_plane.o \
+   loongson_vbios.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index c9702970a037..1e777f4c1753 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -17,14 +17,28 @@
 #include 
 
 #include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+/*
+ * Completed
+ * 1.Displays controller device initialization and display funcitons
+ * 2.I2c bus driver and DDC functions
+ * 3.Vblank and vsync interrupt support
+ * 4.Use acpi to get video bios
+ * Todo
+ * 1.Video bios parse functions
+ * 2.Hardware cursor driver
+ * 3.New device support as well as Loongson GPU
+ */
 
 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
  * 0.3 - Vblank and vsync interrupt support.
+ * 0.4 - Use acpi to get vbios.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 3
+#define DRIVER_MINOR 4
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -86,7 +100,10 @@ static int loongson_device_init(struct drm_device *dev)
if (!ldev->io)
return -ENOMEM;
 
-   ldev->num_crtc = 2;
+   if (!loongson_vbios_init(ldev)) {
+   DRM_WARN("Get vbios failed, enable two crtc\n");
+   ldev->num_crtc = 2;
+   }
 
ret = loongson_dc_gpio_init(ldev);
if (ret)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index ec22dff89e88..eb13f2f68a17 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -107,6 +107,7 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+   void *vbios;
 
struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.c 
b/drivers/gpu/drm/loongson/loongson_vbios.c
new file mode 100644
index ..66f64f038d1f
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+#ifdef CONFIG_ACPI
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   void *vaddr;
+   struct acpi_table_header *hdr;
+   struct acpi_viat_table *viat;
+   acpi_size tbl_size;
+
+   if (!ACPI_SUCCESS(acpi_get_table("VIAT", 1, )))
+   return false;
+
+   tbl_size = hdr->length;
+   if (tbl_size != sizeof(struct acpi_viat_table)) {
+   DRM_WARN("ACPI viat table present but broken(too short #1)\n");
+   return false;
+   }
+
+   viat = (struct acpi_viat_table *)hdr;
+   ldev->vbios = kmalloc(VBIOS_SIZE, GFP_KERNEL);
+   if (!ldev->vbios) {
+   kfree(ldev->vbios);
+   return false;
+   }
+
+   vaddr = phys_to_virt(viat->vbios_addr);
+   memcpy(ldev->vbios, vaddr, VBIOS_SIZE);
+   DRM_INFO("Get vbios from ACPI success!\n");
+
+   return true;
+}
+#else
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   return false;
+}
+#endif
+
+bool loongson_vbios_init(struct loongson_device *ldev)
+{
+   int ret;
+   struct loongson_vbios *header;
+
+   ret = read_bios_from_acpi(ldev);
+   if (!ret)
+   return ret;
+
+   header = ldev->vbios;
+   ldev->num_crtc = header->crtc_num;
+
+   DRM_INFO("Loongson vbios version %d.%d crtc num %d.\n",
+header->version_major, header->version_minor, ldev->num_crtc);
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.h 
b/drivers/gpu/drm/loongson/loongson_vbios.h
new file mode 100644
index ..339498577395
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.h
@@ -0,0 

[PATCH v8 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-10-31 Thread lichenyang
Implement use GPIO and I2C driver to detect connector
and fetch EDID via DDC.

v5:
- Use braidge->ddc to get EDID and detect connector.

v4:
- Delete the gpio_chip subsystem call.
- Delete some redundant prints.

v3:
- Change some driver log to the drm_ version.

v2:
- Optimize the error handling process.
- Delete loongson_i2c_bus_match and loongson_i2c_add function.
- Optimize part of the code flow.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile   |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c |  11 +-
 drivers/gpu/drm/loongson/loongson_drv.h |   7 +
 drivers/gpu/drm/loongson/loongson_encoder.c |  31 +++-
 drivers/gpu/drm/loongson/loongson_i2c.c | 189 
 drivers/gpu/drm/loongson/loongson_i2c.h |  31 
 6 files changed, 261 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 534a64047fb6..4a5fab7d000b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -9,5 +9,6 @@ loongson-y := loongson_connector.o \
loongson_device.o \
loongson_drv.o \
loongson_encoder.o \
+   loongson_i2c.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 3db298293865..9120d8188ddf 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -20,9 +20,10 @@
 
 /* Interface history:
  * 0.1 - original.
+ * 0.2 - add i2c and connector detect.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 1
+#define DRIVER_MINOR 2
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -86,6 +87,14 @@ static int loongson_device_init(struct drm_device *dev)
 
ldev->num_crtc = 2;
 
+   ret = loongson_dc_gpio_init(ldev);
+   if (ret)
+   return ret;
+
+   ret = loongson_i2c_init(ldev);
+   if (ret)
+   return ret;
+
drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 mmio_base, mmio_size, *(u64 *)ldev->io);
drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index feb254ae8c32..e8ca0eac827c 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -8,6 +8,8 @@
 #include 
 #include 
 
+#include "loongson_i2c.h"
+
 /* General customization:
  */
 #define DRIVER_AUTHOR "Loongson graphics driver team"
@@ -100,6 +102,8 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+
+   struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
 
 static inline struct loongson_device *to_loongson_device(struct drm_device 
*dev)
@@ -119,6 +123,9 @@ int loongson_encoder_init(struct loongson_device *ldev, int 
index);
 /* plane */
 struct loongson_plane *loongson_plane_init(struct drm_device *dev, int index);
 
+/* i2c */
+int loongson_dc_gpio_init(struct loongson_device *ldev);
+
 /* device */
 u32 loongson_gpu_offset(struct drm_plane_state *state,
struct loongson_device *dev);
diff --git a/drivers/gpu/drm/loongson/loongson_encoder.c 
b/drivers/gpu/drm/loongson/loongson_encoder.c
index 0645a645cb9d..f07c39e1713b 100644
--- a/drivers/gpu/drm/loongson/loongson_encoder.c
+++ b/drivers/gpu/drm/loongson/loongson_encoder.c
@@ -6,19 +6,31 @@
 
 #include "loongson_drv.h"
 
-static int loongson_bridge_get_modes(struct drm_bridge *bridge,
-struct drm_connector *connector)
+enum drm_connector_status loongson_bridge_detect(struct drm_bridge *bridge)
 {
-   int count;
+   unsigned char start = 0x0;
+   struct i2c_msg msgs = {
+   .addr = DDC_ADDR,
+   .flags = 0,
+   .len = 1,
+   .buf = ,
+   };
 
-   count = drm_add_modes_noedid(connector, 1920, 1080);
-   drm_set_preferred_mode(connector, 1024, 768);
+   if (i2c_transfer(bridge->ddc, , 1) != 1)
+   return connector_status_disconnected;
+   else
+   return connector_status_connected;
+}
 
-   return count;
+static struct edid *loongson_bridge_get_edid(struct drm_bridge *bridge,
+struct drm_connector *connector)
+{
+   return drm_get_edid(connector, bridge->ddc);
 }
 
 static const struct drm_bridge_funcs loongson_encoder_bridge_funcs = {
-   .get_modes = loongson_bridge_get_modes,
+   .detect = loongson_bridge_detect,
+   .get_edid = loongson_bridge_get_edid,
.atomic_duplicate_state = 

Re: Missing patch for Partial crash when loading driver rtl8192e

2022-10-11 Thread Greg KH
On Tue, Oct 11, 2022 at 09:43:46PM +0200, Philipp Hortmann wrote:
> Hi,
> 
> yesterday I did a git pull.
> 
> when I tried to load the driver rtl8192e I had the below partial crash.
> 
> I was able to fix it with this patch:
> 
> https://lore.kernel.org/netdev/20220926233458.5316-1-yin31...@gmail.com/
> 
> Thanks for your support.
> 
> Bye Philipp
> 
> 
> This has worked before. But now I get this in my dmesg
> [  224.792852] [ cut here ]
> [  224.792856] memcpy: detected field-spanning write (size 8) of single
> field "_event->pointer" at net/wireless/wext-core.c:623 (size 4)

Turn this option off, or apply the above patch :)

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Missing patch for Partial crash when loading driver rtl8192e

2022-10-11 Thread Philipp Hortmann

Hi,

yesterday I did a git pull.

when I tried to load the driver rtl8192e I had the below partial crash.

I was able to fix it with this patch:

https://lore.kernel.org/netdev/20220926233458.5316-1-yin31...@gmail.com/

Thanks for your support.

Bye Philipp


This has worked before. But now I get this in my dmesg
[  224.792852] [ cut here ]
[  224.792856] memcpy: detected field-spanning write (size 8) of single 
field "_event->pointer" at net/wireless/wext-core.c:623 (size 4)
[  224.792869] WARNING: CPU: 3 PID: 1408 at net/wireless/wext-core.c:623 
wireless_send_event+0x41f/0x470
[  224.792876] Modules linked in: r8192e_pci(COE) rtllib(COE) lib80211 
xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink xfrm_user 
xfrm_algo xt_addrtype iptable_filter iptable_nat nf_nat nf_conntrack 
nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c bpfilter br_netfilter bridge stp 
llc overlay nls_iso8859_1 snd_hda_codec_hdmi snd_hda_codec_conexant 
snd_hda_codec_generic ledtrig_audio intel_rapl_msr intel_rapl_common 
x86_pkg_temp_thermal intel_powerclamp coretemp sch5627 mei_hdcp 
kvm_intel i915 kvm rtl8192se snd_hda_intel rtl_pci snd_intel_dspcfg 
rtlwifi snd_intel_sdw_acpi snd_hda_codec snd_hda_core mac80211 
crct10dif_pclmul ghash_clmulni_intel drm_buddy snd_hwdep aesni_intel ttm 
snd_pcm crypto_simd drm_display_helper cryptd snd_seq_midi cec rapl 
sch56xx_common snd_seq_midi_event intel_cstate input_leds rc_core 
snd_rawmidi cfg80211 joydev drm_kms_helper serio_raw at24 efi_pstore 
snd_seq i2c_algo_bit fb_sys_fops snd_seq_device mei_me libarc4 
syscopyarea snd_timer sysfillrect mei snd sysimgblt
[  224.792925]  soundcore mac_hid tpm_infineon sch_fq_codel ipmi_devintf 
ipmi_msghandler msr parport_pc ppdev drm lp parport ip_tables x_tables 
autofs4 hid_generic usbhid hid e1000e crc32_pclmul i2c_i801 i2c_smbus 
xhci_pci lpc_ich ahci libahci xhci_pci_renesas video wmi
[  224.792943] CPU: 3 PID: 1408 Comm: wpa_supplicant Tainted: G C OE 
6.0.0+ #13
[  224.792945] Hardware name: FUJITSU ESPRIMO P710/D3161-A1, BIOS 
V4.6.5.3 R1.16.0 for D3161-A1x 10/29/2012

[  224.792947] RIP: 0010:wireless_send_event+0x41f/0x470
[  224.792950] Code: 13 fe ff ff b9 04 00 00 00 4c 89 ee 4c 89 4d c0 48 
c7 c2 f0 c1 2d 9f 48 c7 c7 d0 13 1c 9f c6 05 62 99 e9 00 01 e8 c8 4d 04 
00 <0f> 0b 4c 8b 4d c0 e9 e2 fd ff ff 0f 0b be 01 00 00 00 4c 89 e7 e8

[  224.792952] RSP: 0018:b93f40aebd10 EFLAGS: 00010282
[  224.792954] RAX:  RBX: 9ef60d70 RCX: 

[  224.792955] RDX: 0001 RSI: 9f1ec889 RDI: 

[  224.792956] RBP: b93f40aebd90 R08:  R09: 
b93f40aebb78
[  224.792957] R10: 0001 R11: 0001 R12: 
a0a5ed55b900
[  224.792958] R13: 0008 R14: a0a5ed55b400 R15: 
000c
[  224.792959] FS:  7fef3baf5140() GS:a0a61638() 
knlGS:

[  224.792961] CS:  0010 DS:  ES:  CR0: 80050033
[  224.792962] CR2: 56196d1dc400 CR3: 00010891a003 CR4: 
001706e0

[  224.792963] Call Trace:
[  224.792965]  
[  224.792969]  ? _rtl92e_wx_set_freq+0x65/0x7b [r8192e_pci]
[  224.792978]  ioctl_standard_call+0x76/0xe0
[  224.792981]  ? iw_handler_get_private+0x70/0x70
[  224.792982]  ? call_commit_handler+0x50/0x50
[  224.792985]  wireless_process_ioctl+0x13f/0x1a0
[  224.792989]  wext_handle_ioctl+0x9e/0x100
[  224.792991]  ? __switch_to+0x11d/0x440
[  224.792995]  sock_ioctl+0x1da/0x300
[  224.792999]  ? debug_smp_processor_id+0x17/0x20
[  224.793002]  __x64_sys_ioctl+0x95/0xd0
[  224.793007]  do_syscall_64+0x3b/0x90
[  224.793010]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
[  224.793013] RIP: 0033:0x7fef3b7223ab
[  224.793015] Code: 0f 1e fa 48 8b 05 e5 7a 0d 00 64 c7 00 26 00 00 00 
48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 
05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d b5 7a 0d 00 f7 d8 64 89 01 48
[  224.793016] RSP: 002b:7ffe37cb5818 EFLAGS: 0246 ORIG_RAX: 
0010
[  224.793018] RAX: ffda RBX: 0e774ee0 RCX: 
7fef3b7223ab
[  224.793019] RDX: 7ffe37cb5820 RSI: 8b04 RDI: 
0009
[  224.793020] RBP: 56196f303db0 R08:  R09: 
56196f329210
[  224.793021] R10: 56196f328c98 R11: 0246 R12: 
7ffe37cb5820
[  224.793022] R13:  R14: 0001 R15: 
56196f303dc8

[  224.793025]  
[  224.793026] ---[ end trace  ]---
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: Android: ashmem.c: Fixed missing const modifier

2022-09-15 Thread Greg KH
On Thu, Sep 15, 2022 at 08:58:27PM +1200, Jonathan Bergh wrote:
> Fixed missing const modifier line 370
> 
> Signed-off-by: Jonathan Bergh 
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c 
> b/drivers/staging/android/ashmem.c
> index c05a214191da..a04488efd5f2 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, 
> unsigned long addr,
>  
>  static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
>  {
> - static struct file_operations vmfile_fops;
> + static struct const file_operations vmfile_fops;
>   struct ashmem_area *asma = file->private_data;
>   int ret = 0;
>  
> -- 
> 2.34.1
> 

Always test-build your patches before sending them out so you don't get
grumpy emails from maintainers asking you to test-build your patches
before sending them out.

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: Android: ashmem.c: Fixed missing const modifier

2022-09-15 Thread Jonathan Bergh
Fixed missing const modifier line 370

Signed-off-by: Jonathan Bergh 
---
 drivers/staging/android/ashmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index c05a214191da..a04488efd5f2 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -367,7 +367,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned 
long addr,
 
 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
-   static struct file_operations vmfile_fops;
+   static struct const file_operations vmfile_fops;
struct ashmem_area *asma = file->private_data;
int ret = 0;
 
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 3/4] drm/loongson: Add interrupt driver for LS7A.

2022-09-06 Thread 李晨阳
Add LS7A DC vsync interrupt enable and close function, and
register irq_handler function interface.
Add vbrank event processing flow.

v4:
- Replace drm_irq_install with devm_request_irq.
- Delete the irq_ hooks in drm_driver.

v3:
- Improve code readability.
- Use the to_pci_dev function to get pci_dev.

v2:
- Added error handling in the loongson_drm_load function.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile|  1 +
 drivers/gpu/drm/loongson/loongson_crtc.c | 37 +++
 drivers/gpu/drm/loongson/loongson_drv.c  |  9 ++-
 drivers/gpu/drm/loongson/loongson_drv.h  | 10 +++
 drivers/gpu/drm/loongson/loongson_irq.c  | 84 
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_irq.c

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 4a5fab7d000b..b083854d789b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -10,5 +10,6 @@ loongson-y := loongson_connector.o \
loongson_drv.o \
loongson_encoder.o \
loongson_i2c.o \
+   loongson_irq.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_crtc.c 
b/drivers/gpu/drm/loongson/loongson_crtc.c
index 611378cef8e8..6a31ff911ce1 100644
--- a/drivers/gpu/drm/loongson/loongson_crtc.c
+++ b/drivers/gpu/drm/loongson/loongson_crtc.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 
 #include "loongson_drv.h"
 
@@ -167,8 +168,14 @@ static void loongson_crtc_atomic_enable(struct drm_crtc 
*crtc,
struct loongson_crtc *lcrtc = to_loongson_crtc(crtc);
u32 reg_offset = lcrtc->reg_offset;
 
+   if (lcrtc->cfg_reg & CFG_ENABLE)
+   goto vblank_on;
+
lcrtc->cfg_reg |= CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+vblank_on:
+   drm_crtc_vblank_on(crtc);
 }
 
 static void loongson_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -181,6 +188,33 @@ static void loongson_crtc_atomic_disable(struct drm_crtc 
*crtc,
 
lcrtc->cfg_reg &= ~CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+   spin_lock_irq(>dev->event_lock);
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+   spin_unlock_irq(>dev->event_lock);
+
+   drm_crtc_vblank_off(crtc);
+}
+
+static void loongson_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_atomic_state *state)
+{
+   struct drm_pending_vblank_event *event = crtc->state->event;
+
+   if (!event)
+   return;
+
+   crtc->state->event = NULL;
+
+   spin_lock_irq(>dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(>dev->event_lock);
 }
 
 static enum drm_mode_status loongson_mode_valid(struct drm_crtc *crtc,
@@ -200,6 +234,7 @@ static enum drm_mode_status loongson_mode_valid(struct 
drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs loongson_crtc_helper_funcs = {
.mode_valid = loongson_mode_valid,
+   .atomic_flush = loongson_crtc_atomic_flush,
.atomic_enable = loongson_crtc_atomic_enable,
.atomic_disable = loongson_crtc_atomic_disable,
.mode_set_nofb = loongson_crtc_mode_set_nofb,
@@ -211,6 +246,8 @@ static const struct drm_crtc_funcs loongson_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = loongson_crtc_enable_vblank,
+   .disable_vblank = loongson_crtc_disable_vblank,
 };
 
 int loongson_crtc_init(struct loongson_device *ldev, int index)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 2e3ef6193767..1d6f35e78813 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -23,9 +23,10 @@
 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
+ * 0.3 - Vblank and vsync interrupt support.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 2
+#define DRIVER_MINOR 3
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -167,6 +168,12 @@ static int loongson_driver_init(struct drm_device *dev)
goto err;
}
 
+   ret = loongson_irq_init(ldev);
+   if (ret) {
+   dev_err(dev->dev, "Fatal error during irq init: %d\n", ret);
+   goto err;
+   }
+
drm_kms_helper_poll_init(dev);
drm_mode_config_reset(dev);
 
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 

[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-09-06 Thread 李晨阳
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a 

[PATCH v7 4/4] drm/loongson: Use acpi to get video bios.

2022-09-06 Thread 李晨阳
Add get video bios from the ACPI table.
Define new acpi table "VIAT" for loongson video bios.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile |  3 +-
 drivers/gpu/drm/loongson/loongson_drv.c   | 21 +++-
 drivers/gpu/drm/loongson/loongson_drv.h   |  1 +
 drivers/gpu/drm/loongson/loongson_vbios.c | 62 +++
 drivers/gpu/drm/loongson/loongson_vbios.h | 29 +++
 5 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index b083854d789b..b774a91003d9 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -11,5 +11,6 @@ loongson-y := loongson_connector.o \
loongson_encoder.o \
loongson_i2c.o \
loongson_irq.o \
-   loongson_plane.o
+   loongson_plane.o \
+   loongson_vbios.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 1d6f35e78813..1c212200f088 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -19,14 +19,28 @@
 #include 

 #include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+/*
+ * Completed
+ * 1.Displays controller device initialization and display funcitons
+ * 2.I2c bus driver and DDC functions
+ * 3.Vblank and vsync interrupt support
+ * 4.Use acpi to get video bios
+ * Todo
+ * 1.Video bios parse functions
+ * 2.Hardware cursor driver
+ * 3.New device support as well as Loongson GPU
+ */

 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
  * 0.3 - Vblank and vsync interrupt support.
+ * 0.4 - Use acpi to get vbios.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 3
+#define DRIVER_MINOR 4

 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,7 +102,10 @@ static int loongson_device_init(struct drm_device *dev)
if (!ldev->io)
return -ENOMEM;

-   ldev->num_crtc = 2;
+   if (!loongson_vbios_init(ldev)) {
+   DRM_WARN("Get vbios failed, enable two crtc\n");
+   ldev->num_crtc = 2;
+   }

ret = loongson_dc_gpio_init(ldev);
if (ret)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index af47e68487fd..4e5cb5977c9a 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -109,6 +109,7 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+   void *vbios;

struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.c 
b/drivers/gpu/drm/loongson/loongson_vbios.c
new file mode 100644
index ..2b3a2757102a
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+#ifdef CONFIG_ACPI
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   void *vaddr;
+   struct acpi_table_header *hdr;
+   struct acpi_viat_table *viat;
+   acpi_size tbl_size;
+
+   if (!ACPI_SUCCESS(acpi_get_table("VIAT", 1, )))
+   return false;
+
+   tbl_size = hdr->length;
+   if (tbl_size != sizeof(struct acpi_viat_table)) {
+   DRM_WARN("ACPI viat table present but broken(too short #1)\n");
+   return false;
+   }
+
+   viat = (struct acpi_viat_table *)hdr;
+   ldev->vbios = kmalloc(VBIOS_SIZE, GFP_KERNEL);
+   if (!ldev->vbios) {
+   kfree(ldev->vbios);
+   return false;
+   }
+
+   vaddr = phys_to_virt(viat->vbios_addr);
+   memcpy(ldev->vbios, vaddr, VBIOS_SIZE);
+   DRM_INFO("Get vbios from ACPI success!\n");
+
+   return true;
+}
+#else
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   return false;
+}
+#endif
+
+bool loongson_vbios_init(struct loongson_device *ldev)
+{
+   int ret;
+   struct loongson_vbios *header;
+
+   ret = read_bios_from_acpi(ldev);
+   if (!ret)
+   return ret;
+
+   header = ldev->vbios;
+   ldev->num_crtc = header->crtc_num;
+
+   DRM_INFO("Loongson vbios version %d.%d crtc num %d.\n",
+header->version_major, header->version_minor, ldev->num_crtc);
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.h 
b/drivers/gpu/drm/loongson/loongson_vbios.h
new file mode 100644
index ..b7d8ce15c6c5
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.h
@@ -0,0 +1,29 

[PATCH v7 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-09-06 Thread 李晨阳
Implement use GPIO and I2C driver to detect connector
and fetch EDID via DDC.

v5:
- Use braidge->ddc to get EDID and detect connector.

v4:
- Delete the gpio_chip subsystem call.
- Delete some redundant prints.

v3:
- Change some driver log to the drm_ version.

v2:
- Optimize the error handling process.
- Delete loongson_i2c_bus_match and loongson_i2c_add function.
- Optimize part of the code flow.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile   |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c |  13 +-
 drivers/gpu/drm/loongson/loongson_drv.h |   7 +
 drivers/gpu/drm/loongson/loongson_encoder.c |  31 +++-
 drivers/gpu/drm/loongson/loongson_i2c.c | 191 
 drivers/gpu/drm/loongson/loongson_i2c.h |  33 
 6 files changed, 266 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 534a64047fb6..4a5fab7d000b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -9,5 +9,6 @@ loongson-y := loongson_connector.o \
loongson_device.o \
loongson_drv.o \
loongson_encoder.o \
+   loongson_i2c.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 4993b8d9e8ca..2e3ef6193767 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -22,9 +22,10 @@
 
 /* Interface history:
  * 0.1 - original.
+ * 0.2 - add i2c and connector detect.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 1
+#define DRIVER_MINOR 2
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,6 +89,14 @@ static int loongson_device_init(struct drm_device *dev)
 
ldev->num_crtc = 2;
 
+   ret = loongson_dc_gpio_init(ldev);
+   if (ret)
+   return ret;
+
+   ret = loongson_i2c_init(ldev);
+   if (ret)
+   return ret;
+
drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 mmio_base, mmio_size, *(u64 *)ldev->io);
drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
@@ -96,7 +105,7 @@ static int loongson_device_init(struct drm_device *dev)
return 0;
 }
 
-int loongson_modeset_init(struct loongson_device *ldev)
+static int loongson_modeset_init(struct loongson_device *ldev)
 {
int i;
int ret;
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index e9e97db00110..5be29d2d1a49 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#include "loongson_i2c.h"
+
 /* General customization:
  */
 #define DRIVER_AUTHOR "Loongson graphics driver team"
@@ -102,6 +104,8 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+
+   struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
 
 static inline struct loongson_device *to_loongson_device(struct drm_device 
*dev)
@@ -121,6 +125,9 @@ int loongson_encoder_init(struct loongson_device *ldev, int 
index);
 /* plane */
 struct loongson_plane *loongson_plane_init(struct drm_device *dev, int index);
 
+/* i2c */
+int loongson_dc_gpio_init(struct loongson_device *ldev);
+
 /* device */
 u32 loongson_gpu_offset(struct drm_plane_state *state,
struct loongson_device *dev);
diff --git a/drivers/gpu/drm/loongson/loongson_encoder.c 
b/drivers/gpu/drm/loongson/loongson_encoder.c
index 5b94f707f1a0..accf144479f8 100644
--- a/drivers/gpu/drm/loongson/loongson_encoder.c
+++ b/drivers/gpu/drm/loongson/loongson_encoder.c
@@ -7,19 +7,31 @@
 
 #include "loongson_drv.h"
 
-static int loongson_bridge_get_modes(struct drm_bridge *bridge,
-struct drm_connector *connector)
+enum drm_connector_status loongson_bridge_detect(struct drm_bridge *bridge)
 {
-   int count;
+   unsigned char start = 0x0;
+   struct i2c_msg msgs = {
+   .addr = DDC_ADDR,
+   .flags = 0,
+   .len = 1,
+   .buf = ,
+   };
 
-   count = drm_add_modes_noedid(connector, 1920, 1080);
-   drm_set_preferred_mode(connector, 1024, 768);
+   if (i2c_transfer(bridge->ddc, , 1) != 1)
+   return connector_status_disconnected;
+   else
+   return connector_status_connected;
+}
 
-   return count;
+static struct edid *loongson_bridge_get_edid(struct drm_bridge *bridge,
+struct drm_connector *connector)
+{
+   return drm_get_edid(connector, bridge->ddc);
 }
 
 static const struct 

Re: [PATCH] usb: Improves USB2.0 write performance

2022-08-30 Thread Alan Stern
On Tue, Aug 30, 2022 at 04:43:25PM +0800, Hu Xiaoying wrote:
> USB external storage device(0x0b05:1932), use gnome-disk-utility tools
> to test usb write  < 30MB/s. if does not to load module of uas for this device
> , can increase the write speed from 20MB/s to more than 40MB/s.
> 
> Signed-off-by: Hu Xiaoying 

This email address "@gmail.com" is different from the address you used 
when you submitted the patch "@kylinos.cn".  The two addresses must be 
the same.

> ---

You should put here (just after the "---" line) a description of how 
this patch version is different from all the earlier versions.  Do that 
and submit it as [PATCH v4], and make sure you explain how it is 
different from versions 1, 2, and 3.

There are lots of examples of patches like this in the mailing list 
archives.  Look at some of them to see what they do.

Alan Stern

>  drivers/usb/storage/unusual_uas.h | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/storage/unusual_uas.h 
> b/drivers/usb/storage/unusual_uas.h
> index 4051c8cd0cd8..3925c7c67915 100644
> --- a/drivers/usb/storage/unusual_uas.h
> +++ b/drivers/usb/storage/unusual_uas.h
> @@ -62,6 +62,13 @@ UNUSUAL_DEV(0x0984, 0x0301, 0x0128, 0x0128,
>   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
>   US_FL_IGNORE_UAS),
>  
> +/* Reported-by: Tom Hu  */
> +UNUSUAL_DEV(0x0b05, 0x1932, 0x, 0x,
> + "ASUS",
> + "External HDD",
> + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
> + US_FL_IGNORE_UAS),
> +
>  /* Reported-by: David Webb  */
>  UNUSUAL_DEV(0x0bc2, 0x331a, 0x, 0x,
>   "Seagate",
> -- 
> 2.25.1
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] usb: Improves USB2.0 write performance

2022-08-30 Thread Hu Xiaoying
USB external storage device(0x0b05:1932), use gnome-disk-utility tools
to test usb write  < 30MB/s. if does not to load module of uas for this device
, can increase the write speed from 20MB/s to more than 40MB/s.

Signed-off-by: Hu Xiaoying 
---
 drivers/usb/storage/unusual_uas.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/storage/unusual_uas.h 
b/drivers/usb/storage/unusual_uas.h
index 4051c8cd0cd8..3925c7c67915 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -62,6 +62,13 @@ UNUSUAL_DEV(0x0984, 0x0301, 0x0128, 0x0128,
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_UAS),
 
+/* Reported-by: Tom Hu  */
+UNUSUAL_DEV(0x0b05, 0x1932, 0x, 0x,
+   "ASUS",
+   "External HDD",
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_IGNORE_UAS),
+
 /* Reported-by: David Webb  */
 UNUSUAL_DEV(0x0bc2, 0x331a, 0x, 0x,
"Seagate",
-- 
2.25.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 3/4] drm/loongson: Add interrupt driver for LS7A.

2022-07-11 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v5.19-rc6 next-20220708]
[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/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
config: arm64-allmodconfig 
(https://download.01.org/0day-ci/archive/20220712/202207120454.pjbs1e9p-...@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
77a38f6839980bfac61babb40d83772c51427011)
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
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# 
https://github.com/intel-lab-lkp/linux/commit/7cad653ee3a3b83188e2d91335269753e134b808
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
git checkout 7cad653ee3a3b83188e2d91335269753e134b808
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/loongson/loongson_irq.c:24:11: warning: variable 'lcrtc' is 
>> used uninitialized whenever 'if' condition is false 
>> [-Wsometimes-uninitialized]
   else if (val & FB_VSYNC1_INT)
^~~
   drivers/gpu/drm/loongson/loongson_irq.c:27:26: note: uninitialized use 
occurs here
   drm_crtc_handle_vblank(>base);
   ^
   drivers/gpu/drm/loongson/loongson_irq.c:24:7: note: remove the 'if' if its 
condition is always true
   else if (val & FB_VSYNC1_INT)
^~~~
   drivers/gpu/drm/loongson/loongson_irq.c:16:29: note: initialize the variable 
'lcrtc' to silence this warning
   struct loongson_crtc *lcrtc;
  ^
   = NULL
   1 warning generated.


vim +24 drivers/gpu/drm/loongson/loongson_irq.c

11  
12  static irqreturn_t loongson_irq_handler(int irq, void *arg)
13  {
14  struct drm_device *dev = (struct drm_device *) arg;
15  struct loongson_device *ldev = to_loongson_device(dev);
16  struct loongson_crtc *lcrtc;
17  u32 val;
18  
19  val = ls7a_mm_rreg(ldev, FB_INT_REG);
20  ls7a_mm_wreg(ldev, FB_INT_REG, val & (0x << 16));
21  
22  if (val & FB_VSYNC0_INT)
23  lcrtc = ldev->mode_info[0].crtc;
  > 24  else if (val & FB_VSYNC1_INT)
25  lcrtc = ldev->mode_info[1].crtc;
26  
27  drm_crtc_handle_vblank(>base);
28  
29  return IRQ_HANDLED;
30  }
31  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] wfx: add antenna configuration files

2022-07-08 Thread Jérôme Pouiller
On Thursday 7 July 2022 19:40:27 CEST Josh Boyer wrote:
> On Thu, Jul 7, 2022 at 1:04 PM Ben Brown  wrote:
> > On 21/02/2022 16:37, Jerome Pouiller wrote:
> > > From: Jérôme Pouiller 
> > 
> > > diff --git a/WHENCE b/WHENCE
> > > index 0a6cb15..96f67f7 100644
> > > --- a/WHENCE
> > > +++ b/WHENCE
> > > @@ -5845,8 +5845,18 @@ Driver: wfx - Silicon Labs Wi-Fi Transceiver
> > >  File: wfx/wfm_wf200_C0.sec
> > >  Version: 3.12.1
> > >
> > > +File: wfx/brd4001a.pds not listed in WHENCE
> > > +File: wfx/brd8022a.pds not listed in WHENCE
> > > +File: wfx/brd8023a.pds not listed in WHENCE
> >
> > This format does not appear to be correct. While this will seemingly
> > pass the `check_whence.py` check, it will be completely ignored by
> > `copy-firmware.sh`, as that takes the full line after 'File: ' (e.g.
> > 'wfx/brd4001a.pds not listed in WHENCE', which of course does not exist).
> 
> Oh, indeed.
> 
> > I'm assuming the trailing ' not listed in WHENCE' needs to be removed
> > from each of these lines. Otherwise these are likely not being picked up
> > by distros (they are missing from Arch, for example). This may have been
> > the intention, but that seems odd (and unclear if so).
> 
> I doubt that was the intention.  I'll correct WHENCE in a separate
> commit.  Thank you for reporting the issue.

It seems I had copy-pasted the output of check_whence.py. I was probably not
very awake. Sorry for the disturb.

Do you think the change below could be useful?

-8<-8<

diff --git i/check_whence.py w/check_whence.py
index 8805e99..8244288 100755
--- i/check_whence.py
+++ w/check_whence.py
@@ -6,11 +6,11 @@
 def list_whence():
 with open('WHENCE', encoding='utf-8') as whence:
 for line in whence:
-match = re.match(r'(?:File|Source):\s*"(.*)"', line)
+match = re.match(r'(?:File|Source):\s*"(.*)"\s*$', line)
 if match:
 yield match.group(1)
 continue
-match = re.match(r'(?:File|Source):\s*(\S*)', line)
+match = re.match(r'(?:File|Source):\s*(\S*)\s*$', line)
 if match:
 yield match.group(1)
 continue



-- 
Jérôme Pouiller


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] wfx: add antenna configuration files

2022-07-07 Thread Josh Boyer
On Thu, Jul 7, 2022 at 1:04 PM Ben Brown  wrote:
>
> On 21/02/2022 16:37, Jerome Pouiller wrote:
> > From: Jérôme Pouiller 
> 
> > diff --git a/WHENCE b/WHENCE
> > index 0a6cb15..96f67f7 100644
> > --- a/WHENCE
> > +++ b/WHENCE
> > @@ -5845,8 +5845,18 @@ Driver: wfx - Silicon Labs Wi-Fi Transceiver
> >  File: wfx/wfm_wf200_C0.sec
> >  Version: 3.12.1
> >
> > +File: wfx/brd4001a.pds not listed in WHENCE
> > +File: wfx/brd8022a.pds not listed in WHENCE
> > +File: wfx/brd8023a.pds not listed in WHENCE
>
> This format does not appear to be correct. While this will seemingly
> pass the `check_whence.py` check, it will be completely ignored by
> `copy-firmware.sh`, as that takes the full line after 'File: ' (e.g.
> 'wfx/brd4001a.pds not listed in WHENCE', which of course does not exist).

Oh, indeed.

> I'm assuming the trailing ' not listed in WHENCE' needs to be removed
> from each of these lines. Otherwise these are likely not being picked up
> by distros (they are missing from Arch, for example). This may have been
> the intention, but that seems odd (and unclear if so).

I doubt that was the intention.  I'll correct WHENCE in a separate
commit.  Thank you for reporting the issue.

josh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] wfx: add antenna configuration files

2022-07-07 Thread Ben Brown
On 21/02/2022 16:37, Jerome Pouiller wrote:
> From: Jérôme Pouiller 

> diff --git a/WHENCE b/WHENCE
> index 0a6cb15..96f67f7 100644
> --- a/WHENCE
> +++ b/WHENCE
> @@ -5845,8 +5845,18 @@ Driver: wfx - Silicon Labs Wi-Fi Transceiver
>  File: wfx/wfm_wf200_C0.sec
>  Version: 3.12.1
>  
> +File: wfx/brd4001a.pds not listed in WHENCE
> +File: wfx/brd8022a.pds not listed in WHENCE
> +File: wfx/brd8023a.pds not listed in WHENCE

This format does not appear to be correct. While this will seemingly
pass the `check_whence.py` check, it will be completely ignored by
`copy-firmware.sh`, as that takes the full line after 'File: ' (e.g.
'wfx/brd4001a.pds not listed in WHENCE', which of course does not exist).

I'm assuming the trailing ' not listed in WHENCE' needs to be removed
from each of these lines. Otherwise these are likely not being picked up
by distros (they are missing from Arch, for example). This may have been
the intention, but that seems odd (and unclear if so).


Regards,
Ben
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-06-25 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v5.19-rc3 next-20220624]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
config: powerpc-allmodconfig
compiler: powerpc-linux-gcc (GCC) 11.3.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/3af56da81352153b38e05c082b8f2bf8c9fc0320
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
git checkout 3af56da81352153b38e05c082b8f2bf8c9fc0320
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/loongson/loongson_encoder.c:10:27: warning: no previous 
>> prototype for 'loongson_bridge_detect' [-Wmissing-prototypes]
  10 | enum drm_connector_status loongson_bridge_detect(struct drm_bridge 
*bridge)
 |   ^~


vim +/loongson_bridge_detect +10 drivers/gpu/drm/loongson/loongson_encoder.c

 9  
  > 10  enum drm_connector_status loongson_bridge_detect(struct drm_bridge 
*bridge)
11  {
12  unsigned char start = 0x0;
13  struct i2c_msg msgs = {
14  .addr = DDC_ADDR,
15  .flags = 0,
16  .len = 1,
17  .buf = ,
18  };
19  
20  if (i2c_transfer(bridge->ddc, , 1) != 1)
21  return connector_status_disconnected;
22  else
23  return connector_status_connected;
24  }
25  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-06-25 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v5.19-rc3 next-20220624]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
config: powerpc-allmodconfig
compiler: powerpc-linux-gcc (GCC) 11.3.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/438d0791edb6352903bf09dfe214453526081075
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220625-171037
git checkout 438d0791edb6352903bf09dfe214453526081075
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

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

   drivers/gpu/drm/loongson/loongson_crtc.c: In function 
'loongson_crtc_mode_set_nofb':
>> drivers/gpu/drm/loongson/loongson_crtc.c:128:42: error: invalid use of 
>> undefined type 'struct drm_framebuffer'
 128 | format = crtc->primary->state->fb->format;
 |  ^~
--
   drivers/gpu/drm/loongson/loongson_device.c: In function 
'loongson_gpu_offset':
>> drivers/gpu/drm/loongson/loongson_device.c:14:44: error: invalid use of 
>> undefined type 'struct drm_framebuffer'
  14 | gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
 |^~
--
   In file included from include/linux/device.h:15,
from include/linux/pci.h:37,
from drivers/gpu/drm/loongson/loongson_drv.c:14:
   drivers/gpu/drm/loongson/loongson_drv.c: In function 'loongson_device_init':
>> include/drm/drm_print.h:425:39: warning: format '%llx' expects argument of 
>> type 'long long unsigned int', but argument 3 has type 'resource_size_t' 
>> {aka 'unsigned int'} [-Wformat=]
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 |   ^~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 
'dev_printk_index_wrap'
 110 | _p_func(dev, fmt, ##__VA_ARGS__);
   \
 |  ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
 150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, 
dev_fmt(fmt), ##__VA_ARGS__)
 |  ^~~
   include/drm/drm_print.h:425:9: note: in expansion of macro 'dev_info'
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 | ^~~~
   include/drm/drm_print.h:429:9: note: in expansion of macro '__drm_printk'
 429 | __drm_printk((drm), info,, fmt, ##__VA_ARGS__)
 | ^~~~
   drivers/gpu/drm/loongson/loongson_drv.c:91:9: note: in expansion of macro 
'drm_info'
  91 | drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 | ^~~~
   include/drm/drm_print.h:425:39: warning: format '%llx' expects argument of 
type 'long long unsigned int', but argument 4 has type 'resource_size_t' {aka 
'unsigned int'} [-Wformat=]
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 |   ^~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 
'dev_printk_index_wrap'
 110 | _p_func(dev, fmt, ##__VA_ARGS__);
   \
 |  ^~~
   include/linux/dev_printk.h:150:58: note: in expansion of macro 'dev_fmt'
 150 | dev_printk_index_wrap(_dev_info, KERN_INFO, dev, 
dev_fmt(fmt), ##__VA_ARGS__)
 |  ^~~
   include/drm/drm_print.h:425:9: note: in expansion of macro 'dev_info'
 425 | dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 | ^~~~
   include/drm/drm_print.h:429:9: note: in expansion of macro '__drm_printk'

[PATCH v7 3/4] drm/loongson: Add interrupt driver for LS7A.

2022-06-25 Thread Chenyang Li
Add LS7A DC vsync interrupt enable and close function, and
register irq_handler function interface.
Add vbrank event processing flow.

v4:
- Replace drm_irq_install with devm_request_irq.
- Delete the irq_ hooks in drm_driver.

v3:
- Improve code readability.
- Use the to_pci_dev function to get pci_dev.

v2:
- Added error handling in the loongson_drm_load function.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile|  1 +
 drivers/gpu/drm/loongson/loongson_crtc.c | 37 +++
 drivers/gpu/drm/loongson/loongson_drv.c  |  9 ++-
 drivers/gpu/drm/loongson/loongson_drv.h  | 10 +++
 drivers/gpu/drm/loongson/loongson_irq.c  | 84 
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_irq.c

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 4a5fab7d000b..b083854d789b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -10,5 +10,6 @@ loongson-y := loongson_connector.o \
loongson_drv.o \
loongson_encoder.o \
loongson_i2c.o \
+   loongson_irq.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_crtc.c 
b/drivers/gpu/drm/loongson/loongson_crtc.c
index 611378cef8e8..6a31ff911ce1 100644
--- a/drivers/gpu/drm/loongson/loongson_crtc.c
+++ b/drivers/gpu/drm/loongson/loongson_crtc.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 
 #include "loongson_drv.h"
 
@@ -167,8 +168,14 @@ static void loongson_crtc_atomic_enable(struct drm_crtc 
*crtc,
struct loongson_crtc *lcrtc = to_loongson_crtc(crtc);
u32 reg_offset = lcrtc->reg_offset;
 
+   if (lcrtc->cfg_reg & CFG_ENABLE)
+   goto vblank_on;
+
lcrtc->cfg_reg |= CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+vblank_on:
+   drm_crtc_vblank_on(crtc);
 }
 
 static void loongson_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -181,6 +188,33 @@ static void loongson_crtc_atomic_disable(struct drm_crtc 
*crtc,
 
lcrtc->cfg_reg &= ~CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+   spin_lock_irq(>dev->event_lock);
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+   spin_unlock_irq(>dev->event_lock);
+
+   drm_crtc_vblank_off(crtc);
+}
+
+static void loongson_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_atomic_state *state)
+{
+   struct drm_pending_vblank_event *event = crtc->state->event;
+
+   if (!event)
+   return;
+
+   crtc->state->event = NULL;
+
+   spin_lock_irq(>dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(>dev->event_lock);
 }
 
 static enum drm_mode_status loongson_mode_valid(struct drm_crtc *crtc,
@@ -200,6 +234,7 @@ static enum drm_mode_status loongson_mode_valid(struct 
drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs loongson_crtc_helper_funcs = {
.mode_valid = loongson_mode_valid,
+   .atomic_flush = loongson_crtc_atomic_flush,
.atomic_enable = loongson_crtc_atomic_enable,
.atomic_disable = loongson_crtc_atomic_disable,
.mode_set_nofb = loongson_crtc_mode_set_nofb,
@@ -211,6 +246,8 @@ static const struct drm_crtc_funcs loongson_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = loongson_crtc_enable_vblank,
+   .disable_vblank = loongson_crtc_disable_vblank,
 };
 
 int loongson_crtc_init(struct loongson_device *ldev, int index)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 2e3ef6193767..1d6f35e78813 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -23,9 +23,10 @@
 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
+ * 0.3 - Vblank and vsync interrupt support.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 2
+#define DRIVER_MINOR 3
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -167,6 +168,12 @@ static int loongson_driver_init(struct drm_device *dev)
goto err;
}
 
+   ret = loongson_irq_init(ldev);
+   if (ret) {
+   dev_err(dev->dev, "Fatal error during irq init: %d\n", ret);
+   goto err;
+   }
+
drm_kms_helper_poll_init(dev);
drm_mode_config_reset(dev);
 
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 

[PATCH v7 4/4] drm/loongson: Use acpi to get video bios.

2022-06-25 Thread Chenyang Li
Add get video bios from the ACPI table.
Define new acpi table "VIAT" for loongson video bios.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile |  3 +-
 drivers/gpu/drm/loongson/loongson_drv.c   | 21 +++-
 drivers/gpu/drm/loongson/loongson_drv.h   |  1 +
 drivers/gpu/drm/loongson/loongson_vbios.c | 62 +++
 drivers/gpu/drm/loongson/loongson_vbios.h | 29 +++
 5 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index b083854d789b..b774a91003d9 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -11,5 +11,6 @@ loongson-y := loongson_connector.o \
loongson_encoder.o \
loongson_i2c.o \
loongson_irq.o \
-   loongson_plane.o
+   loongson_plane.o \
+   loongson_vbios.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 1d6f35e78813..1c212200f088 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -19,14 +19,28 @@
 #include 

 #include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+/*
+ * Completed
+ * 1.Displays controller device initialization and display funcitons
+ * 2.I2c bus driver and DDC functions
+ * 3.Vblank and vsync interrupt support
+ * 4.Use acpi to get video bios
+ * Todo
+ * 1.Video bios parse functions
+ * 2.Hardware cursor driver
+ * 3.New device support as well as Loongson GPU
+ */

 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
  * 0.3 - Vblank and vsync interrupt support.
+ * 0.4 - Use acpi to get vbios.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 3
+#define DRIVER_MINOR 4

 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,7 +102,10 @@ static int loongson_device_init(struct drm_device *dev)
if (!ldev->io)
return -ENOMEM;

-   ldev->num_crtc = 2;
+   if (!loongson_vbios_init(ldev)) {
+   DRM_WARN("Get vbios failed, enable two crtc\n");
+   ldev->num_crtc = 2;
+   }

ret = loongson_dc_gpio_init(ldev);
if (ret)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index af47e68487fd..4e5cb5977c9a 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -109,6 +109,7 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+   void *vbios;

struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.c 
b/drivers/gpu/drm/loongson/loongson_vbios.c
new file mode 100644
index ..2b3a2757102a
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+#ifdef CONFIG_ACPI
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   void *vaddr;
+   struct acpi_table_header *hdr;
+   struct acpi_viat_table *viat;
+   acpi_size tbl_size;
+
+   if (!ACPI_SUCCESS(acpi_get_table("VIAT", 1, )))
+   return false;
+
+   tbl_size = hdr->length;
+   if (tbl_size != sizeof(struct acpi_viat_table)) {
+   DRM_WARN("ACPI viat table present but broken(too short #1)\n");
+   return false;
+   }
+
+   viat = (struct acpi_viat_table *)hdr;
+   ldev->vbios = kmalloc(VBIOS_SIZE, GFP_KERNEL);
+   if (!ldev->vbios) {
+   kfree(ldev->vbios);
+   return false;
+   }
+
+   vaddr = phys_to_virt(viat->vbios_addr);
+   memcpy(ldev->vbios, vaddr, VBIOS_SIZE);
+   DRM_INFO("Get vbios from ACPI success!\n");
+
+   return true;
+}
+#else
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   return false;
+}
+#endif
+
+bool loongson_vbios_init(struct loongson_device *ldev)
+{
+   int ret;
+   struct loongson_vbios *header;
+
+   ret = read_bios_from_acpi(ldev);
+   if (!ret)
+   return ret;
+
+   header = ldev->vbios;
+   ldev->num_crtc = header->crtc_num;
+
+   DRM_INFO("Loongson vbios version %d.%d crtc num %d.\n",
+header->version_major, header->version_minor, ldev->num_crtc);
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.h 
b/drivers/gpu/drm/loongson/loongson_vbios.h
new file mode 100644
index ..b7d8ce15c6c5
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.h
@@ -0,0 +1,29 

[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-06-25 Thread Chenyang Li
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a 

[PATCH v7 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-06-25 Thread Chenyang Li
Implement use GPIO and I2C driver to detect connector
and fetch EDID via DDC.

v5:
- Use braidge->ddc to get EDID and detect connector.

v4:
- Delete the gpio_chip subsystem call.
- Delete some redundant prints.

v3:
- Change some driver log to the drm_ version.

v2:
- Optimize the error handling process.
- Delete loongson_i2c_bus_match and loongson_i2c_add function.
- Optimize part of the code flow.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile   |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c |  13 +-
 drivers/gpu/drm/loongson/loongson_drv.h |   7 +
 drivers/gpu/drm/loongson/loongson_encoder.c |  31 +++-
 drivers/gpu/drm/loongson/loongson_i2c.c | 191 
 drivers/gpu/drm/loongson/loongson_i2c.h |  33 
 6 files changed, 266 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 534a64047fb6..4a5fab7d000b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -9,5 +9,6 @@ loongson-y := loongson_connector.o \
loongson_device.o \
loongson_drv.o \
loongson_encoder.o \
+   loongson_i2c.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 4993b8d9e8ca..2e3ef6193767 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -22,9 +22,10 @@
 
 /* Interface history:
  * 0.1 - original.
+ * 0.2 - add i2c and connector detect.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 1
+#define DRIVER_MINOR 2
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,6 +89,14 @@ static int loongson_device_init(struct drm_device *dev)
 
ldev->num_crtc = 2;
 
+   ret = loongson_dc_gpio_init(ldev);
+   if (ret)
+   return ret;
+
+   ret = loongson_i2c_init(ldev);
+   if (ret)
+   return ret;
+
drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 mmio_base, mmio_size, *(u64 *)ldev->io);
drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
@@ -96,7 +105,7 @@ static int loongson_device_init(struct drm_device *dev)
return 0;
 }
 
-int loongson_modeset_init(struct loongson_device *ldev)
+static int loongson_modeset_init(struct loongson_device *ldev)
 {
int i;
int ret;
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index e9e97db00110..5be29d2d1a49 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#include "loongson_i2c.h"
+
 /* General customization:
  */
 #define DRIVER_AUTHOR "Loongson graphics driver team"
@@ -102,6 +104,8 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+
+   struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
 
 static inline struct loongson_device *to_loongson_device(struct drm_device 
*dev)
@@ -121,6 +125,9 @@ int loongson_encoder_init(struct loongson_device *ldev, int 
index);
 /* plane */
 struct loongson_plane *loongson_plane_init(struct drm_device *dev, int index);
 
+/* i2c */
+int loongson_dc_gpio_init(struct loongson_device *ldev);
+
 /* device */
 u32 loongson_gpu_offset(struct drm_plane_state *state,
struct loongson_device *dev);
diff --git a/drivers/gpu/drm/loongson/loongson_encoder.c 
b/drivers/gpu/drm/loongson/loongson_encoder.c
index 5b94f707f1a0..accf144479f8 100644
--- a/drivers/gpu/drm/loongson/loongson_encoder.c
+++ b/drivers/gpu/drm/loongson/loongson_encoder.c
@@ -7,19 +7,31 @@
 
 #include "loongson_drv.h"
 
-static int loongson_bridge_get_modes(struct drm_bridge *bridge,
-struct drm_connector *connector)
+enum drm_connector_status loongson_bridge_detect(struct drm_bridge *bridge)
 {
-   int count;
+   unsigned char start = 0x0;
+   struct i2c_msg msgs = {
+   .addr = DDC_ADDR,
+   .flags = 0,
+   .len = 1,
+   .buf = ,
+   };
 
-   count = drm_add_modes_noedid(connector, 1920, 1080);
-   drm_set_preferred_mode(connector, 1024, 768);
+   if (i2c_transfer(bridge->ddc, , 1) != 1)
+   return connector_status_disconnected;
+   else
+   return connector_status_connected;
+}
 
-   return count;
+static struct edid *loongson_bridge_get_edid(struct drm_bridge *bridge,
+struct drm_connector *connector)
+{
+   return drm_get_edid(connector, bridge->ddc);
 }
 
 static const struct 

Re: [RESEND PATCH v3 0/1] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-06-15 Thread Greg KH
On Wed, Jun 15, 2022 at 11:05:23AM -0700, Li Li wrote:
> On Thu, May 26, 2022 at 10:50 PM Greg KH  wrote:
> >
> > On Thu, May 26, 2022 at 03:00:17PM -0700, Li Li wrote:
> > > From: Li Li 
> > >
> > > Resend [Patch v3] with cover letter in case my previous email failed
> > > to reach the maillist (no comments for 2 weeks).
> > >
> > > The previous comments of the old patch can be found at the following link:
> > > https://lore.kernel.org/lkml/canbpypjknwso94nug1tkr1dgk2w2kbxijtriyvb7s3czhtz...@mail.gmail.com/
> > >
> > > I copy and paste the key information here for your convenience.
> > >
> > > * Question #1
> > >
> > > Note, your subject does not say what TF_UPDATE_TXN is, so it's a bit
> > > hard to determine what is happening here.  Can you clean that up a bit
> > > and sumarize what this new addition does?
> > > How was this tested?
> > >
> > > * Answer #1 ===
> > >
> > > A more descriptive summary has been added to the new version of patch.
> > >
> > > *  Question #2
> > >
> > > How was this tested?
> > >
> > > * Answer #2
> > >
> > > Old kernel: without this TF_UPDATE_TXN patch
> > > New kernel: with this TF_UPDATE_TXN patch
> > > Old apps: without setting TF_UPDATE_TXN
> > > New apps: if (flags & TF_ONE_WAY) flags |= TF_UPDATE_TXN;
> > >
> > > 1. Compatibility: New kernel + Old apps, to verify the original
> > > behavior doesn't change;
> > >
> > > 2. Compatibility: Old kernel + New apps, to verify the original
> > > behavior doesn't change;
> > >
> > > 3. Unit test: New kernel + New apps, to verify the outdated oneway
> > > binder transaction is actually superseded by the latest one (by
> > > enabling BINDER_DEBUG logs);
> > >
> > > 4. Stress test: New kernel + New apps sending oneway binder
> > > transactions repeatedly, to verify the size of the available async
> > > binder buffer over time, and if the transactions fail as before
> > > (due to async buffer running out).
> > >
> > > * Question #3
> > >
> > > Did checkpatch pass this?  Please always use --strict and fix up all the
> > > issues that it reports as this is not a normal kernel coding style.
> > >
> > > * Answer #3
> > >
> > > Yes, the latest version has passed "./scripts/checkpatch.pl --strict"
> > >
> > > * Changelog
> > >
> > > v3:
> > >   - Add this changelog required by "The canonical patch format"
> > > v2:
> > >   - Fix alignment warnings reported by checkpatch --strict
> > >   - Add descriptive summary in patch subject
> > >
> > > Li Li (1):
> > >   Binder: add TF_UPDATE_TXN to replace outdated txn
> > >
> > >  drivers/android/binder.c| 85 ++++-
> > >  drivers/android/binder_trace.h  |  4 ++
> > >  include/uapi/linux/android/binder.h |  1 +
> > >  3 files changed, 87 insertions(+), 3 deletions(-)
> > >
> > > --
> > > 2.36.1.124.g0e6072fb45-goog
> > >
> > > ___
> > > devel mailing list
> > > de...@linuxdriverproject.org
> > > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> >
> >
> > Hi,
> >
> > This is the friendly semi-automated patch-bot of Greg Kroah-Hartman.
> > You have sent him a patch that has triggered this response.
> >
> > Right now, the development tree you have sent a patch for is "closed"
> > due to the timing of the merge window.  Don't worry, the patch(es) you
> > have sent are not lost, and will be looked at after the merge window is
> > over (after the -rc1 kernel is released by Linus).
> >
> > So thank you for your patience and your patches will be reviewed at this
> > later time, you do not have to do anything further, this is just a short
> > note to let you know the patch status and so you don't worry they didn't
> > make it through.
> 
> Hi Greg and all reviewers,
> 
> The rc-1 has been released for some days. Do I need to resend the patch
> v3 [1] again to the maillist? Please let me know what I should do next to
> have it reviewed. Thanks!

If it still applies, no need to resend.

I'm waiting for the other binder maintainers to review it before doing
anything with it.

thanks

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH v3 0/1] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-06-15 Thread Li Li
On Thu, May 26, 2022 at 10:50 PM Greg KH  wrote:
>
> On Thu, May 26, 2022 at 03:00:17PM -0700, Li Li wrote:
> > From: Li Li 
> >
> > Resend [Patch v3] with cover letter in case my previous email failed
> > to reach the maillist (no comments for 2 weeks).
> >
> > The previous comments of the old patch can be found at the following link:
> > https://lore.kernel.org/lkml/canbpypjknwso94nug1tkr1dgk2w2kbxijtriyvb7s3czhtz...@mail.gmail.com/
> >
> > I copy and paste the key information here for your convenience.
> >
> > * Question #1
> >
> > Note, your subject does not say what TF_UPDATE_TXN is, so it's a bit
> > hard to determine what is happening here.  Can you clean that up a bit
> > and sumarize what this new addition does?
> > How was this tested?
> >
> > * Answer #1 ===
> >
> > A more descriptive summary has been added to the new version of patch.
> >
> > *  Question #2
> >
> > How was this tested?
> >
> > * Answer #2
> >
> > Old kernel: without this TF_UPDATE_TXN patch
> > New kernel: with this TF_UPDATE_TXN patch
> > Old apps: without setting TF_UPDATE_TXN
> > New apps: if (flags & TF_ONE_WAY) flags |= TF_UPDATE_TXN;
> >
> > 1. Compatibility: New kernel + Old apps, to verify the original
> > behavior doesn't change;
> >
> > 2. Compatibility: Old kernel + New apps, to verify the original
> > behavior doesn't change;
> >
> > 3. Unit test: New kernel + New apps, to verify the outdated oneway
> > binder transaction is actually superseded by the latest one (by
> > enabling BINDER_DEBUG logs);
> >
> > 4. Stress test: New kernel + New apps sending oneway binder
> > transactions repeatedly, to verify the size of the available async
> > binder buffer over time, and if the transactions fail as before
> > (due to async buffer running out).
> >
> > * Question #3
> >
> > Did checkpatch pass this?  Please always use --strict and fix up all the
> > issues that it reports as this is not a normal kernel coding style.
> >
> > * Answer #3
> >
> > Yes, the latest version has passed "./scripts/checkpatch.pl --strict"
> >
> > * Changelog
> >
> > v3:
> >   - Add this changelog required by "The canonical patch format"
> > v2:
> >   - Fix alignment warnings reported by checkpatch --strict
> >   - Add descriptive summary in patch subject
> >
> > Li Li (1):
> >   Binder: add TF_UPDATE_TXN to replace outdated txn
> >
> >  drivers/android/binder.c| 85 ++++-
> >  drivers/android/binder_trace.h  |  4 ++
> >  include/uapi/linux/android/binder.h |  1 +
> >  3 files changed, 87 insertions(+), 3 deletions(-)
> >
> > --
> > 2.36.1.124.g0e6072fb45-goog
> >
> > ___
> > devel mailing list
> > de...@linuxdriverproject.org
> > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
>
>
> Hi,
>
> This is the friendly semi-automated patch-bot of Greg Kroah-Hartman.
> You have sent him a patch that has triggered this response.
>
> Right now, the development tree you have sent a patch for is "closed"
> due to the timing of the merge window.  Don't worry, the patch(es) you
> have sent are not lost, and will be looked at after the merge window is
> over (after the -rc1 kernel is released by Linus).
>
> So thank you for your patience and your patches will be reviewed at this
> later time, you do not have to do anything further, this is just a short
> note to let you know the patch status and so you don't worry they didn't
> make it through.

Hi Greg and all reviewers,

The rc-1 has been released for some days. Do I need to resend the patch
v3 [1] again to the maillist? Please let me know what I should do next to
have it reviewed. Thanks!

[1]:
[RESEND PATCH v3 0/1] Binder: add TF_UPDATE_TXN to replace outdated txn
https://lore.kernel.org/lkml/20220526220018.3334775-1-dua...@chromium.org/

>
> thanks,
>
> greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: comedi: comedi_fops: fixed a spacing coding style issue

2022-06-09 Thread Ian Abbott

On 09/06/2022 05:53, Agam Kohli wrote:

Fixed a coding style issue.

Signed-off-by: Agam Kohli 
---
  drivers/staging/comedi/comedi_fops.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index e85a99b68f31..3f70e5dfac39 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c


comedi moved out of "drivers/staging" in the 5.13 kernel.

--
-=( Ian Abbott  || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: comedi: comedi_fops: fixed a spacing coding style issue

2022-06-08 Thread Agam Kohli
Fixed a coding style issue.

Signed-off-by: Agam Kohli 
---
 drivers/staging/comedi/comedi_fops.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index e85a99b68f31..3f70e5dfac39 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2169,6 +2169,7 @@ static long comedi_unlocked_ioctl(struct file *file, 
unsigned int cmd,
break;
case COMEDI_CHANINFO: {
struct comedi_chaninfo it;
+
if (copy_from_user(, (void __user *)arg, sizeof(it)))
rc = -EFAULT;
else
@@ -2177,6 +2178,7 @@ static long comedi_unlocked_ioctl(struct file *file, 
unsigned int cmd,
}
case COMEDI_RANGEINFO: {
struct comedi_rangeinfo it;
+
if (copy_from_user(, (void __user *)arg, sizeof(it)))
rc = -EFAULT;
else
@@ -2249,6 +2251,7 @@ static long comedi_unlocked_ioctl(struct file *file, 
unsigned int cmd,
}
case COMEDI_INSN: {
struct comedi_insn insn;
+
if (copy_from_user(, (void __user *)arg, sizeof(insn)))
rc = -EFAULT;
else

2.36.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH v3 1/1] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-05-26 Thread Li Li
From: Li Li 

When the target process is busy, incoming oneway transactions are
queued in the async_todo list. If the clients continue sending extra
oneway transactions while the target process is frozen, this queue can
become too large to accommodate new transactions. That's why binder
driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
helpful to debug the async binder buffer exhausting issue, but the
issue itself isn't solved directly.

In real cases applications are designed to send oneway transactions
repeatedly, delivering updated inforamtion to the target process.
Typical examples are Wi-Fi signal strength and some real time sensor
data. Even if the apps might only care about the lastet information,
all outdated oneway transactions are still accumulated there until the
frozen process is thawed later. For this kind of situations, there's
no existing method to skip those outdated transactions and deliver the
latest one only.

This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
use apps can set this new flag along with TF_ONE_WAY. When such an
oneway transaction is to be queued into the async_todo list of a frozen
process, binder driver will check if any previous pending transactions
can be superseded by comparing their code, flags and target node. If
such an outdated pending transaction is found, the latest transaction
will supersede that outdated one. This effectively prevents the async
binder buffer running out and saves unnecessary binder read workloads.

Signed-off-by: Li Li 
---
v3:
  - Add this changelog required by "The canonical patch format"
v2:
  - Fix alignment warnings reported by checkpatch --strict
  - Add descriptive summary in patch subject

 drivers/android/binder.c| 85 -
 drivers/android/binder_trace.h  |  4 ++
 include/uapi/linux/android/binder.h |  1 +
 3 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f3b639e89dd8..bb968cf2f9ec 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2594,6 +2594,56 @@ static int binder_fixup_parent(struct list_head *pf_head,
return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
 }
 
+/**
+ * binder_can_update_transaction() - Can a txn be superseded by an updated one?
+ * @t1: the pending async txn in the frozen process
+ * @t2: the new async txn to supersede the outdated pending one
+ *
+ * Return:  true if t2 can supersede t1
+ *  false if t2 can not supersede t1
+ */
+static bool binder_can_update_transaction(struct binder_transaction *t1,
+ struct binder_transaction *t2)
+{
+   if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN)) !=
+   (TF_ONE_WAY | TF_UPDATE_TXN) || !t1->to_proc || !t2->to_proc)
+   return false;
+   if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code &&
+   t1->flags == t2->flags && t1->buffer->pid == t2->buffer->pid &&
+   t1->buffer->target_node->ptr == t2->buffer->target_node->ptr &&
+   t1->buffer->target_node->cookie == t2->buffer->target_node->cookie)
+   return true;
+   return false;
+}
+
+/**
+ * binder_find_outdated_transaction_ilocked() - Find the outdated transaction
+ * @t:  new async transaction
+ * @target_list: list to find outdated transaction
+ *
+ * Return: the outdated transaction if found
+ * NULL if no outdated transacton can be found
+ *
+ * Requires the proc->inner_lock to be held.
+ */
+static struct binder_transaction *
+binder_find_outdated_transaction_ilocked(struct binder_transaction *t,
+struct list_head *target_list)
+{
+   struct binder_work *w;
+
+   list_for_each_entry(w, target_list, entry) {
+   struct binder_transaction *t_queued;
+
+   if (w->type != BINDER_WORK_TRANSACTION)
+   continue;
+   t_queued = container_of(w, struct binder_transaction, work);
+   if (binder_can_update_transaction(t_queued, t))
+   return t_queued;
+   }
+   return NULL;
+}
+
 /**
  * binder_proc_transaction() - sends a transaction to a process and wakes it up
  * @t: transaction to send
@@ -2619,6 +2669,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
struct binder_node *node = t->buffer->target_node;
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
+   struct binder_transaction *t_outdated = NULL;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2646,12 +2697,24 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
if (!thread && !pending_asyn

[RESEND PATCH v3 0/1] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-05-26 Thread Li Li
From: Li Li 

Resend [Patch v3] with cover letter in case my previous email failed
to reach the maillist (no comments for 2 weeks).

The previous comments of the old patch can be found at the following link:
https://lore.kernel.org/lkml/canbpypjknwso94nug1tkr1dgk2w2kbxijtriyvb7s3czhtz...@mail.gmail.com/

I copy and paste the key information here for your convenience.

* Question #1

Note, your subject does not say what TF_UPDATE_TXN is, so it's a bit
hard to determine what is happening here.  Can you clean that up a bit
and sumarize what this new addition does?
How was this tested?

* Answer #1 ===

A more descriptive summary has been added to the new version of patch.

*  Question #2

How was this tested?

* Answer #2

Old kernel: without this TF_UPDATE_TXN patch
New kernel: with this TF_UPDATE_TXN patch
Old apps: without setting TF_UPDATE_TXN
New apps: if (flags & TF_ONE_WAY) flags |= TF_UPDATE_TXN;

1. Compatibility: New kernel + Old apps, to verify the original
behavior doesn't change;

2. Compatibility: Old kernel + New apps, to verify the original
behavior doesn't change;

3. Unit test: New kernel + New apps, to verify the outdated oneway
binder transaction is actually superseded by the latest one (by
enabling BINDER_DEBUG logs);

4. Stress test: New kernel + New apps sending oneway binder
transactions repeatedly, to verify the size of the available async
binder buffer over time, and if the transactions fail as before
(due to async buffer running out).

* Question #3

Did checkpatch pass this?  Please always use --strict and fix up all the
issues that it reports as this is not a normal kernel coding style.

* Answer #3

Yes, the latest version has passed "./scripts/checkpatch.pl --strict"

* Changelog

v3:
  - Add this changelog required by "The canonical patch format"
v2:
  - Fix alignment warnings reported by checkpatch --strict
  - Add descriptive summary in patch subject

Li Li (1):
  Binder: add TF_UPDATE_TXN to replace outdated txn

 drivers/android/binder.c| 85 -
 drivers/android/binder_trace.h  |  4 ++
 include/uapi/linux/android/binder.h |  1 +
 3 files changed, 87 insertions(+), 3 deletions(-)

-- 
2.36.1.124.g0e6072fb45-goog

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-05-19 Thread Li Li
From: Li Li 

When the target process is busy, incoming oneway transactions are
queued in the async_todo list. If the clients continue sending extra
oneway transactions while the target process is frozen, this queue can
become too large to accommodate new transactions. That's why binder
driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
helpful to debug the async binder buffer exhausting issue, but the
issue itself isn't solved directly.

In real cases applications are designed to send oneway transactions
repeatedly, delivering updated inforamtion to the target process.
Typical examples are Wi-Fi signal strength and some real time sensor
data. Even if the apps might only care about the lastet information,
all outdated oneway transactions are still accumulated there until the
frozen process is thawed later. For this kind of situations, there's
no existing method to skip those outdated transactions and deliver the
latest one only.

This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
use apps can set this new flag along with TF_ONE_WAY. When such an
oneway transaction is to be queued into the async_todo list of a frozen
process, binder driver will check if any previous pending transactions
can be superseded by comparing their code, flags and target node. If
such an outdated pending transaction is found, the latest transaction
will supersede that outdated one. This effectively prevents the async
binder buffer running out and saves unnecessary binder read workloads.

Signed-off-by: Li Li 
---
v3:
  - Add this changelog required by "The canonical patch format"
v2:
  - Fix alignment warnings reported by checkpatch --strict
  - Add descriptive summary in patch subject

 drivers/android/binder.c| 85 -
 drivers/android/binder_trace.h  |  4 ++
 include/uapi/linux/android/binder.h |  1 +
 3 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f3b639e89dd8..bb968cf2f9ec 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2594,6 +2594,56 @@ static int binder_fixup_parent(struct list_head *pf_head,
return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
 }
 
+/**
+ * binder_can_update_transaction() - Can a txn be superseded by an updated one?
+ * @t1: the pending async txn in the frozen process
+ * @t2: the new async txn to supersede the outdated pending one
+ *
+ * Return:  true if t2 can supersede t1
+ *  false if t2 can not supersede t1
+ */
+static bool binder_can_update_transaction(struct binder_transaction *t1,
+ struct binder_transaction *t2)
+{
+   if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN)) !=
+   (TF_ONE_WAY | TF_UPDATE_TXN) || !t1->to_proc || !t2->to_proc)
+   return false;
+   if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code &&
+   t1->flags == t2->flags && t1->buffer->pid == t2->buffer->pid &&
+   t1->buffer->target_node->ptr == t2->buffer->target_node->ptr &&
+   t1->buffer->target_node->cookie == t2->buffer->target_node->cookie)
+   return true;
+   return false;
+}
+
+/**
+ * binder_find_outdated_transaction_ilocked() - Find the outdated transaction
+ * @t:  new async transaction
+ * @target_list: list to find outdated transaction
+ *
+ * Return: the outdated transaction if found
+ * NULL if no outdated transacton can be found
+ *
+ * Requires the proc->inner_lock to be held.
+ */
+static struct binder_transaction *
+binder_find_outdated_transaction_ilocked(struct binder_transaction *t,
+struct list_head *target_list)
+{
+   struct binder_work *w;
+
+   list_for_each_entry(w, target_list, entry) {
+   struct binder_transaction *t_queued;
+
+   if (w->type != BINDER_WORK_TRANSACTION)
+   continue;
+   t_queued = container_of(w, struct binder_transaction, work);
+   if (binder_can_update_transaction(t_queued, t))
+   return t_queued;
+   }
+   return NULL;
+}
+
 /**
  * binder_proc_transaction() - sends a transaction to a process and wakes it up
  * @t: transaction to send
@@ -2619,6 +2669,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
struct binder_node *node = t->buffer->target_node;
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
+   struct binder_transaction *t_outdated = NULL;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2646,12 +2697,24 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
if (!thread && !pending_asyn

Re: [PATCH v2] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-05-19 Thread Greg KH
On Thu, May 19, 2022 at 11:34:54AM -0700, Li Li wrote:
> From: Li Li 
> 
> When the target process is busy, incoming oneway transactions are
> queued in the async_todo list. If the clients continue sending extra
> oneway transactions while the target process is frozen, this queue can
> become too large to accommodate new transactions. That's why binder
> driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
> helpful to debug the async binder buffer exhausting issue, but the
> issue itself isn't solved directly.
> 
> In real cases applications are designed to send oneway transactions
> repeatedly, delivering updated inforamtion to the target process.
> Typical examples are Wi-Fi signal strength and some real time sensor
> data. Even if the apps might only care about the lastet information,
> all outdated oneway transactions are still accumulated there until the
> frozen process is thawed later. For this kind of situations, there's
> no existing method to skip those outdated transactions and deliver the
> latest one only.
> 
> This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
> use apps can set this new flag along with TF_ONE_WAY. When such an
> oneway transaction is to be queued into the async_todo list of a frozen
> process, binder driver will check if any previous pending transactions
> can be superseded by comparing their code, flags and target node. If
> such an outdated pending transaction is found, the latest transaction
> will supersede that outdated one. This effectively prevents the async
> binder buffer running out and saves unnecessary binder read workloads.
> 
> Signed-off-by: Li Li 
> ---
>  drivers/android/binder.c| 85 -
>  drivers/android/binder_trace.h  |  4 ++
>  include/uapi/linux/android/binder.h |  1 +
>  3 files changed, 87 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index f3b639e89dd8..bb968cf2f9ec 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2594,6 +2594,56 @@ static int binder_fixup_parent(struct list_head 
> *pf_head,
>   return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
>  }
>  
> +/**
> + * binder_can_update_transaction() - Can a txn be superseded by an updated 
> one?
> + * @t1: the pending async txn in the frozen process
> + * @t2: the new async txn to supersede the outdated pending one
> + *
> + * Return:  true if t2 can supersede t1
> + *  false if t2 can not supersede t1
> + */
> +static bool binder_can_update_transaction(struct binder_transaction *t1,
> +   struct binder_transaction *t2)
> +{
> + if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN)) !=
> + (TF_ONE_WAY | TF_UPDATE_TXN) || !t1->to_proc || !t2->to_proc)
> + return false;
> + if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code &&
> + t1->flags == t2->flags && t1->buffer->pid == t2->buffer->pid &&
> + t1->buffer->target_node->ptr == t2->buffer->target_node->ptr &&
> + t1->buffer->target_node->cookie == t2->buffer->target_node->cookie)
> + return true;
> + return false;
> +}
> +
> +/**
> + * binder_find_outdated_transaction_ilocked() - Find the outdated transaction
> + * @t:new async transaction
> + * @target_list: list to find outdated transaction
> + *
> + * Return: the outdated transaction if found
> + * NULL if no outdated transacton can be found
> + *
> + * Requires the proc->inner_lock to be held.
> + */
> +static struct binder_transaction *
> +binder_find_outdated_transaction_ilocked(struct binder_transaction *t,
> +  struct list_head *target_list)
> +{
> + struct binder_work *w;
> +
> + list_for_each_entry(w, target_list, entry) {
> + struct binder_transaction *t_queued;
> +
> + if (w->type != BINDER_WORK_TRANSACTION)
> + continue;
> + t_queued = container_of(w, struct binder_transaction, work);
> + if (binder_can_update_transaction(t_queued, t))
> + return t_queued;
> + }
> + return NULL;
> +}
> +
>  /**
>   * binder_proc_transaction() - sends a transaction to a process and wakes it 
> up
>   * @t:   transaction to send
> @@ -2619,6 +2669,7 @@ static int binder_proc_transaction(struct 
> binder_transaction *t,
>   struct binder_node *node = t->buffe

[PATCH v2] Binder: add TF_UPDATE_TXN to replace outdated txn

2022-05-19 Thread Li Li
From: Li Li 

When the target process is busy, incoming oneway transactions are
queued in the async_todo list. If the clients continue sending extra
oneway transactions while the target process is frozen, this queue can
become too large to accommodate new transactions. That's why binder
driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
helpful to debug the async binder buffer exhausting issue, but the
issue itself isn't solved directly.

In real cases applications are designed to send oneway transactions
repeatedly, delivering updated inforamtion to the target process.
Typical examples are Wi-Fi signal strength and some real time sensor
data. Even if the apps might only care about the lastet information,
all outdated oneway transactions are still accumulated there until the
frozen process is thawed later. For this kind of situations, there's
no existing method to skip those outdated transactions and deliver the
latest one only.

This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
use apps can set this new flag along with TF_ONE_WAY. When such an
oneway transaction is to be queued into the async_todo list of a frozen
process, binder driver will check if any previous pending transactions
can be superseded by comparing their code, flags and target node. If
such an outdated pending transaction is found, the latest transaction
will supersede that outdated one. This effectively prevents the async
binder buffer running out and saves unnecessary binder read workloads.

Signed-off-by: Li Li 
---
 drivers/android/binder.c| 85 -
 drivers/android/binder_trace.h  |  4 ++
 include/uapi/linux/android/binder.h |  1 +
 3 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f3b639e89dd8..bb968cf2f9ec 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2594,6 +2594,56 @@ static int binder_fixup_parent(struct list_head *pf_head,
return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
 }
 
+/**
+ * binder_can_update_transaction() - Can a txn be superseded by an updated one?
+ * @t1: the pending async txn in the frozen process
+ * @t2: the new async txn to supersede the outdated pending one
+ *
+ * Return:  true if t2 can supersede t1
+ *  false if t2 can not supersede t1
+ */
+static bool binder_can_update_transaction(struct binder_transaction *t1,
+ struct binder_transaction *t2)
+{
+   if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN)) !=
+   (TF_ONE_WAY | TF_UPDATE_TXN) || !t1->to_proc || !t2->to_proc)
+   return false;
+   if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code &&
+   t1->flags == t2->flags && t1->buffer->pid == t2->buffer->pid &&
+   t1->buffer->target_node->ptr == t2->buffer->target_node->ptr &&
+   t1->buffer->target_node->cookie == t2->buffer->target_node->cookie)
+   return true;
+   return false;
+}
+
+/**
+ * binder_find_outdated_transaction_ilocked() - Find the outdated transaction
+ * @t:  new async transaction
+ * @target_list: list to find outdated transaction
+ *
+ * Return: the outdated transaction if found
+ * NULL if no outdated transacton can be found
+ *
+ * Requires the proc->inner_lock to be held.
+ */
+static struct binder_transaction *
+binder_find_outdated_transaction_ilocked(struct binder_transaction *t,
+struct list_head *target_list)
+{
+   struct binder_work *w;
+
+   list_for_each_entry(w, target_list, entry) {
+   struct binder_transaction *t_queued;
+
+   if (w->type != BINDER_WORK_TRANSACTION)
+   continue;
+   t_queued = container_of(w, struct binder_transaction, work);
+   if (binder_can_update_transaction(t_queued, t))
+   return t_queued;
+   }
+   return NULL;
+}
+
 /**
  * binder_proc_transaction() - sends a transaction to a process and wakes it up
  * @t: transaction to send
@@ -2619,6 +2669,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
struct binder_node *node = t->buffer->target_node;
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
+   struct binder_transaction *t_outdated = NULL;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2646,12 +2697,24 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
if (!thread && !pending_async)
thread = binder_select_thread_ilocked(proc);
 
-   if (thread)
+   if (thread) {
binder_enqueue_thread_work_ilocked(thread, >work);
-   else if 

Re: [PATCH v1] Binder: add TF_UPDATE_TXN

2022-05-19 Thread Li Li
On Thu, May 19, 2022 at 8:50 AM Greg KH  wrote:
>
> On Wed, May 18, 2022 at 05:06:23PM -0700, Li Li wrote:
> > From: Li Li 
>
> Note, your subject does not say what TF_UPDATE_TXN is, so it's a bit
> hard to determine what is happening here.  Can you clean that up a bit
> and sumarize what this new addition does?

Sure, I'll add a brief summary there.

>
> >
> > When the target process is busy, incoming oneway transactions are
> > queued in the async_todo list. If the clients continue sending extra
> > oneway transactions while the target process is frozen, this queue can
> > become too large to accommodate new transactions. That's why binder
> > driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
> > helpful to debug the async binder buffer exhausting issue, but the
> > issue itself isn't solved directly.
> >
> > In real cases applications are designed to send oneway transactions
> > repeatedly, delivering updated inforamtion to the target process.
> > Typical examples are Wi-Fi signal strength and some real time sensor
> > data. Even if the apps might only care about the lastet information,
> > all outdated oneway transactions are still accumulated there until the
> > frozen process is thawed later. For this kind of situations, there's
> > no existing method to skip those outdated transactions and deliver the
> > latest one only.
> >
> > This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
> > use apps can set this new flag along with TF_ONE_WAY. When such an
> > oneway transaction is to be queued into the async_todo list of a frozen
> > process, binder driver will check if any previous pending transactions
> > can be superseded by comparing their code, flags and target node. If
> > such an outdated pending transaction is found, the latest transaction
> > will supersede that outdated one. This effectively prevents the async
> > binder buffer running out and saves unnecessary binder read workloads.
> >
> > Signed-off-by: Li Li 
> > ---
> >  drivers/android/binder.c    | 90 ++++-
> >  drivers/android/binder_trace.h  |  4 ++
> >  include/uapi/linux/android/binder.h |  1 +
>
> How was this tested?

Old kernel: without this TF_UPDATE_TXN patch
New kernel: with this TF_UPDATE_TXN patch
Old apps: without setting TF_UPDATE_TXN
New apps: if (flags & TF_ONE_WAY) flags |= TF_UPDATE_TXN;

1. Compatibility: New kernel + Old apps, to verify the original
behavior doesn't change;

2. Compatibility: Old kernel + New apps, to verify the original
behavior doesn't change;

3. Unit test: New kernel + New apps, to verify the outdated oneway
binder transaction is actually superseded by the latest one (by
enabling BINDER_DEBUG logs);

4. Stress test: New kernel + New apps sending oneway binder
transactions repeatedly, to verify the size of the available async
binder buffer over time, and if the transactions fail as before
(due to async buffer running out).

>
> >  3 files changed, 92 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > index f3b639e89dd8..153486a32d69 100644
> > --- a/drivers/android/binder.c
> > +++ b/drivers/android/binder.c
> > @@ -2594,6 +2594,60 @@ static int binder_fixup_parent(struct list_head 
> > *pf_head,
> >   return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
> >  }
> >
> > +/**
> > + * binder_can_update_transaction() - Can a txn be superseded by an updated 
> > one?
> > + * @t1: the pending async txn in the frozen process
> > + * @t2: the new async txn to supersede the outdated pending one
> > + *
> > + * Return:  true if t2 can supersede t1
> > + *  false if t2 can not supersede t1
> > + */
> > +static bool binder_can_update_transaction(struct binder_transaction *t1,
> > +   struct binder_transaction *t2)
> > +{
> > + if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN))
> > + != (TF_ONE_WAY | TF_UPDATE_TXN)
> > + || t1->to_proc == NULL || t2->to_proc == NULL)
> > + return false;
> > + if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code
> > + && t1->flags == t2->flags
> > + && t1->buffer->pid == t2->buffer->pid
> > + && t1->buffer->target_node->ptr
> > + == t2->buffer->target_node->ptr
> > + && 

Re: [PATCH v1] Binder: add TF_UPDATE_TXN

2022-05-19 Thread Greg KH
On Wed, May 18, 2022 at 05:06:23PM -0700, Li Li wrote:
> From: Li Li 

Note, your subject does not say what TF_UPDATE_TXN is, so it's a bit
hard to determine what is happening here.  Can you clean that up a bit
and sumarize what this new addition does?

> 
> When the target process is busy, incoming oneway transactions are
> queued in the async_todo list. If the clients continue sending extra
> oneway transactions while the target process is frozen, this queue can
> become too large to accommodate new transactions. That's why binder
> driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
> helpful to debug the async binder buffer exhausting issue, but the
> issue itself isn't solved directly.
> 
> In real cases applications are designed to send oneway transactions
> repeatedly, delivering updated inforamtion to the target process.
> Typical examples are Wi-Fi signal strength and some real time sensor
> data. Even if the apps might only care about the lastet information,
> all outdated oneway transactions are still accumulated there until the
> frozen process is thawed later. For this kind of situations, there's
> no existing method to skip those outdated transactions and deliver the
> latest one only.
> 
> This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
> use apps can set this new flag along with TF_ONE_WAY. When such an
> oneway transaction is to be queued into the async_todo list of a frozen
> process, binder driver will check if any previous pending transactions
> can be superseded by comparing their code, flags and target node. If
> such an outdated pending transaction is found, the latest transaction
> will supersede that outdated one. This effectively prevents the async
> binder buffer running out and saves unnecessary binder read workloads.
> 
> Signed-off-by: Li Li 
> ---
>  drivers/android/binder.c| 90 -
>  drivers/android/binder_trace.h  |  4 ++
>  include/uapi/linux/android/binder.h |  1 +

How was this tested? 

>  3 files changed, 92 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index f3b639e89dd8..153486a32d69 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2594,6 +2594,60 @@ static int binder_fixup_parent(struct list_head 
> *pf_head,
>   return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
>  }
>  
> +/**
> + * binder_can_update_transaction() - Can a txn be superseded by an updated 
> one?
> + * @t1: the pending async txn in the frozen process
> + * @t2: the new async txn to supersede the outdated pending one
> + *
> + * Return:  true if t2 can supersede t1
> + *  false if t2 can not supersede t1
> + */
> +static bool binder_can_update_transaction(struct binder_transaction *t1,
> +   struct binder_transaction *t2)
> +{
> + if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN))
> + != (TF_ONE_WAY | TF_UPDATE_TXN)
> + || t1->to_proc == NULL || t2->to_proc == NULL)
> + return false;
> + if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code
> + && t1->flags == t2->flags
> + && t1->buffer->pid == t2->buffer->pid
> + && t1->buffer->target_node->ptr
> + == t2->buffer->target_node->ptr
> + && t1->buffer->target_node->cookie
> + == t2->buffer->target_node->cookie)

Did checkpatch pass this?  Please always use --strict and fix up all the
issues that it reports as this is not a normal kernel coding style,
sorry.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1] Binder: add TF_UPDATE_TXN

2022-05-18 Thread Li Li
From: Li Li 

When the target process is busy, incoming oneway transactions are
queued in the async_todo list. If the clients continue sending extra
oneway transactions while the target process is frozen, this queue can
become too large to accommodate new transactions. That's why binder
driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's
helpful to debug the async binder buffer exhausting issue, but the
issue itself isn't solved directly.

In real cases applications are designed to send oneway transactions
repeatedly, delivering updated inforamtion to the target process.
Typical examples are Wi-Fi signal strength and some real time sensor
data. Even if the apps might only care about the lastet information,
all outdated oneway transactions are still accumulated there until the
frozen process is thawed later. For this kind of situations, there's
no existing method to skip those outdated transactions and deliver the
latest one only.

This patch introduces a new transaction flag TF_UPDATE_TXN. To use it,
use apps can set this new flag along with TF_ONE_WAY. When such an
oneway transaction is to be queued into the async_todo list of a frozen
process, binder driver will check if any previous pending transactions
can be superseded by comparing their code, flags and target node. If
such an outdated pending transaction is found, the latest transaction
will supersede that outdated one. This effectively prevents the async
binder buffer running out and saves unnecessary binder read workloads.

Signed-off-by: Li Li 
---
 drivers/android/binder.c| 90 -
 drivers/android/binder_trace.h  |  4 ++
 include/uapi/linux/android/binder.h |  1 +
 3 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f3b639e89dd8..153486a32d69 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2594,6 +2594,60 @@ static int binder_fixup_parent(struct list_head *pf_head,
return binder_add_fixup(pf_head, buffer_offset, bp->buffer, 0);
 }
 
+/**
+ * binder_can_update_transaction() - Can a txn be superseded by an updated one?
+ * @t1: the pending async txn in the frozen process
+ * @t2: the new async txn to supersede the outdated pending one
+ *
+ * Return:  true if t2 can supersede t1
+ *  false if t2 can not supersede t1
+ */
+static bool binder_can_update_transaction(struct binder_transaction *t1,
+ struct binder_transaction *t2)
+{
+   if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN))
+   != (TF_ONE_WAY | TF_UPDATE_TXN)
+   || t1->to_proc == NULL || t2->to_proc == NULL)
+   return false;
+   if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code
+   && t1->flags == t2->flags
+   && t1->buffer->pid == t2->buffer->pid
+   && t1->buffer->target_node->ptr
+   == t2->buffer->target_node->ptr
+   && t1->buffer->target_node->cookie
+   == t2->buffer->target_node->cookie)
+   return true;
+   return false;
+}
+
+/**
+ * binder_find_outdated_transaction_ilocked() - Find the outdated transaction
+ * @t:  new async transaction
+ * @target_list: list to find outdated transaction
+ *
+ * Return: the outdated transaction if found
+ * NULL if no outdated transacton can be found
+ *
+ * Requires the proc->inner_lock to be held.
+ */
+static struct binder_transaction *
+binder_find_outdated_transaction_ilocked(struct binder_transaction *t,
+struct list_head *target_list)
+{
+   struct binder_work *w;
+
+   list_for_each_entry(w, target_list, entry) {
+   struct binder_transaction *t_queued;
+
+   if (w->type != BINDER_WORK_TRANSACTION)
+   continue;
+   t_queued = container_of(w, struct binder_transaction, work);
+   if (binder_can_update_transaction(t_queued, t))
+   return t_queued;
+   }
+   return NULL;
+}
+
 /**
  * binder_proc_transaction() - sends a transaction to a process and wakes it up
  * @t: transaction to send
@@ -2619,6 +2673,7 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
struct binder_node *node = t->buffer->target_node;
bool oneway = !!(t->flags & TF_ONE_WAY);
bool pending_async = false;
+   struct binder_transaction *t_outdated = NULL;
 
BUG_ON(!node);
binder_node_lock(node);
@@ -2646,12 +2701,25 @@ static int binder_proc_transaction(struct 
binder_transaction *t,
if (!thread && !pending_async)
thread

Re: [PATCH RFT/RFC v2 01/47] staging: media: Revert "media: zoran: remove deprecated driver"

2022-05-07 Thread Laurent Pinchart
On Sat, May 07, 2022 at 10:58:39AM -0500, Sergey Meirovich wrote:
> Sergey Meirovich has sent you an email via Gmail confidential mode:
> 
> Gmail logoRe: [PATCH RFT/RFC v2 01/47] staging: media: Revert "media: zoran:
> remove deprecated driver"
> 
> This message was sent on May 7, 2022 at 8:58:50 AM PDT
> You can open it by clicking the link below. This link will only work for
> laurent.pinch...@ideasonboard.com.

Please don't use this feature when posting to public mailing lists. Such
messages will be totally ignored.

> View the email
> 
> Gmail confidential mode gives you more control over the messages you send. The
> sender may have chosen to set an expiration time, disable printing or
> forwarding, or track access to this message. Learn more
> 
> Gmail: Email by Google
> Use is subject to the Google Privacy PolicyGoogle
> Google LLC, 1600 Amphitheatre Parkway, Mountain View, CA 94043, USAlogo
> You have received this message because someone sent you an email via
> Gmail confidential mode.
> 

-- 
Regards,

Laurent Pinchart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-04-22 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v5.18-rc3 next-20220422]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: arm-randconfig-s031-20220422 
(https://download.01.org/0day-ci/archive/20220423/202204230030.kzgmtgoq-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# 
https://github.com/intel-lab-lkp/linux/commit/e9a9964d58e6cc797a113fa47f54583c10908d63
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
git checkout e9a9964d58e6cc797a113fa47f54583c10908d63
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm 
SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/loongson/loongson_drv.c:91:9: sparse: sparse: cast removes 
>> address space '__iomem' of expression
   drivers/gpu/drm/loongson/loongson_drv.c:99:5: sparse: sparse: symbol 
'loongson_modeset_init' was not declared. Should it be static?

vim +/__iomem +91 drivers/gpu/drm/loongson/loongson_drv.c

36  
37  static int loongson_device_init(struct drm_device *dev)
38  {
39  struct loongson_device *ldev = to_loongson_device(dev);
40  struct pci_dev *pdev = to_pci_dev(dev->dev);
41  struct pci_dev *gpu_pdev;
42  resource_size_t aper_base;
43  resource_size_t aper_size;
44  resource_size_t mmio_base;
45  resource_size_t mmio_size;
46  int ret;
47  
48  /* GPU MEM */
49  /* We need get 7A-gpu pci device information for ldev->gpu_pdev 
*/
50  /* dev->pdev save 7A-dc pci device information */
51  gpu_pdev = pci_get_device(PCI_VENDOR_ID_LOONGSON,
52PCI_DEVICE_ID_LOONGSON_GPU, NULL);
53  ret = pci_enable_device(gpu_pdev);
54  if (ret)
55  return ret;
56  pci_set_drvdata(gpu_pdev, dev);
57  
58  aper_base = pci_resource_start(gpu_pdev, 2);
59  aper_size = pci_resource_len(gpu_pdev, 2);
60  ldev->vram_start = aper_base;
61  ldev->vram_size = aper_size;
62  
63  if (!devm_request_mem_region(dev->dev, ldev->vram_start,
64   ldev->vram_size, "loongson_vram")) 
{
65  drm_err(dev, "Can't reserve VRAM\n");
66  return -ENXIO;
67  }
68  
69  /* DC MEM */
70  mmio_base = pci_resource_start(pdev, 0);
71  mmio_size = pci_resource_len(pdev, 0);
72  ldev->mmio = devm_ioremap(dev->dev, mmio_base, mmio_size);
73  if (!ldev->mmio) {
74  drm_err(dev, "Cannot map mmio region\n");
75  return -ENOMEM;
76  }
77  
78  if (!devm_request_mem_region(dev->dev, mmio_base,
79   mmio_size, "loongson_mmio")) {
80  drm_err(dev, "Can't reserve mmio registers\n");
81  return -ENOMEM;
82  }
83  
84  /* DC IO */
85  ldev->io = devm_ioremap(dev->dev, LS7A_CHIPCFG_REG_BASE, 0xf);
86  if (!ldev->io)
87  return -ENOMEM;
88  
89  ldev->num_crtc = 2;
90  
  > 91  drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
92   mmio_base, mmio_size, *(u64 *)ldev->io);
93  drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
94   ldev->vram_start, ldev->vram_size);
95  
96  return 0;
97  }
98  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v7 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-04-22 Thread kernel test robot
Hi Chenyang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v5.18-rc3 next-20220422]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: riscv-allmodconfig 
(https://download.01.org/0day-ci/archive/20220423/202204230046.2fbntjrk-...@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 11.2.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/4a5b6ac99c37617e030a054ca431c5c9aab227b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Chenyang-Li/drm-loongson-Add-DRM-Driver-for-Loongson-7A1000-bridge-chip/20220422-161914
git checkout 4a5b6ac99c37617e030a054ca431c5c9aab227b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross W=1 
O=build_dir ARCH=riscv SHELL=/bin/bash drivers/gpu/drm/loongson/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/loongson/loongson_encoder.c:10:27: warning: no previous 
>> prototype for 'loongson_bridge_detect' [-Wmissing-prototypes]
  10 | enum drm_connector_status loongson_bridge_detect(struct drm_bridge 
*bridge)
 |   ^~


vim +/loongson_bridge_detect +10 drivers/gpu/drm/loongson/loongson_encoder.c

 9  
  > 10  enum drm_connector_status loongson_bridge_detect(struct drm_bridge 
*bridge)
11  {
12  unsigned char start = 0x0;
13  struct i2c_msg msgs = {
14  .addr = DDC_ADDR,
15  .flags = 0,
16  .len = 1,
17  .buf = ,
18  };
19  
20  if (i2c_transfer(bridge->ddc, , 1) != 1)
21  return connector_status_disconnected;
22  else
23  return connector_status_connected;
24  }
25  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 4/4] drm/loongson: Use acpi to get video bios.

2022-04-22 Thread Chenyang Li
Add get video bios from the ACPI table.
Define new acpi table "VIAT" for loongson video bios.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile |  3 +-
 drivers/gpu/drm/loongson/loongson_drv.c   | 21 +++-
 drivers/gpu/drm/loongson/loongson_drv.h   |  1 +
 drivers/gpu/drm/loongson/loongson_vbios.c | 62 +++
 drivers/gpu/drm/loongson/loongson_vbios.h | 29 +++
 5 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_vbios.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index b083854d789b..b774a91003d9 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -11,5 +11,6 @@ loongson-y := loongson_connector.o \
loongson_encoder.o \
loongson_i2c.o \
loongson_irq.o \
-   loongson_plane.o
+   loongson_plane.o \
+   loongson_vbios.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 1d6f35e78813..1c212200f088 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -19,14 +19,28 @@
 #include 

 #include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+/*
+ * Completed
+ * 1.Displays controller device initialization and display funcitons
+ * 2.I2c bus driver and DDC functions
+ * 3.Vblank and vsync interrupt support
+ * 4.Use acpi to get video bios
+ * Todo
+ * 1.Video bios parse functions
+ * 2.Hardware cursor driver
+ * 3.New device support as well as Loongson GPU
+ */

 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
  * 0.3 - Vblank and vsync interrupt support.
+ * 0.4 - Use acpi to get vbios.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 3
+#define DRIVER_MINOR 4

 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,7 +102,10 @@ static int loongson_device_init(struct drm_device *dev)
if (!ldev->io)
return -ENOMEM;

-   ldev->num_crtc = 2;
+   if (!loongson_vbios_init(ldev)) {
+   DRM_WARN("Get vbios failed, enable two crtc\n");
+   ldev->num_crtc = 2;
+   }

ret = loongson_dc_gpio_init(ldev);
if (ret)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index af47e68487fd..4e5cb5977c9a 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -109,6 +109,7 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+   void *vbios;

struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.c 
b/drivers/gpu/drm/loongson/loongson_vbios.c
new file mode 100644
index ..2b3a2757102a
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#include "loongson_drv.h"
+#include "loongson_vbios.h"
+
+#ifdef CONFIG_ACPI
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   void *vaddr;
+   struct acpi_table_header *hdr;
+   struct acpi_viat_table *viat;
+   acpi_size tbl_size;
+
+   if (!ACPI_SUCCESS(acpi_get_table("VIAT", 1, )))
+   return false;
+
+   tbl_size = hdr->length;
+   if (tbl_size != sizeof(struct acpi_viat_table)) {
+   DRM_WARN("ACPI viat table present but broken(too short #1)\n");
+   return false;
+   }
+
+   viat = (struct acpi_viat_table *)hdr;
+   ldev->vbios = kmalloc(VBIOS_SIZE, GFP_KERNEL);
+   if (!ldev->vbios) {
+   kfree(ldev->vbios);
+   return false;
+   }
+
+   vaddr = phys_to_virt(viat->vbios_addr);
+   memcpy(ldev->vbios, vaddr, VBIOS_SIZE);
+   DRM_INFO("Get vbios from ACPI success!\n");
+
+   return true;
+}
+#else
+static bool read_bios_from_acpi(struct loongson_device *ldev)
+{
+   return false;
+}
+#endif
+
+bool loongson_vbios_init(struct loongson_device *ldev)
+{
+   int ret;
+   struct loongson_vbios *header;
+
+   ret = read_bios_from_acpi(ldev);
+   if (!ret)
+   return ret;
+
+   header = ldev->vbios;
+   ldev->num_crtc = header->crtc_num;
+
+   DRM_INFO("Loongson vbios version %d.%d crtc num %d.\n",
+header->version_major, header->version_minor, ldev->num_crtc);
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/loongson/loongson_vbios.h 
b/drivers/gpu/drm/loongson/loongson_vbios.h
new file mode 100644
index ..b7d8ce15c6c5
--- /dev/null
+++ b/drivers/gpu/drm/loongson/loongson_vbios.h
@@ -0,0 +1,29 

[PATCH v7 3/4] drm/loongson: Add interrupt driver for LS7A.

2022-04-22 Thread Chenyang Li
Add LS7A DC vsync interrupt enable and close function, and
register irq_handler function interface.
Add vbrank event processing flow.

v4:
- Replace drm_irq_install with devm_request_irq.
- Delete the irq_ hooks in drm_driver.

v3:
- Improve code readability.
- Use the to_pci_dev function to get pci_dev.

v2:
- Added error handling in the loongson_drm_load function.

Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile|  1 +
 drivers/gpu/drm/loongson/loongson_crtc.c | 37 +++
 drivers/gpu/drm/loongson/loongson_drv.c  |  9 ++-
 drivers/gpu/drm/loongson/loongson_drv.h  | 10 +++
 drivers/gpu/drm/loongson/loongson_irq.c  | 84 
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_irq.c

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 4a5fab7d000b..b083854d789b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -10,5 +10,6 @@ loongson-y := loongson_connector.o \
loongson_drv.o \
loongson_encoder.o \
loongson_i2c.o \
+   loongson_irq.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_crtc.c 
b/drivers/gpu/drm/loongson/loongson_crtc.c
index 611378cef8e8..6a31ff911ce1 100644
--- a/drivers/gpu/drm/loongson/loongson_crtc.c
+++ b/drivers/gpu/drm/loongson/loongson_crtc.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 
 #include "loongson_drv.h"
 
@@ -167,8 +168,14 @@ static void loongson_crtc_atomic_enable(struct drm_crtc 
*crtc,
struct loongson_crtc *lcrtc = to_loongson_crtc(crtc);
u32 reg_offset = lcrtc->reg_offset;
 
+   if (lcrtc->cfg_reg & CFG_ENABLE)
+   goto vblank_on;
+
lcrtc->cfg_reg |= CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+vblank_on:
+   drm_crtc_vblank_on(crtc);
 }
 
 static void loongson_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -181,6 +188,33 @@ static void loongson_crtc_atomic_disable(struct drm_crtc 
*crtc,
 
lcrtc->cfg_reg &= ~CFG_ENABLE;
ls7a_mm_wreg(ldev, FB_CFG_REG + reg_offset, lcrtc->cfg_reg);
+
+   spin_lock_irq(>dev->event_lock);
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+   spin_unlock_irq(>dev->event_lock);
+
+   drm_crtc_vblank_off(crtc);
+}
+
+static void loongson_crtc_atomic_flush(struct drm_crtc *crtc,
+  struct drm_atomic_state *state)
+{
+   struct drm_pending_vblank_event *event = crtc->state->event;
+
+   if (!event)
+   return;
+
+   crtc->state->event = NULL;
+
+   spin_lock_irq(>dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(>dev->event_lock);
 }
 
 static enum drm_mode_status loongson_mode_valid(struct drm_crtc *crtc,
@@ -200,6 +234,7 @@ static enum drm_mode_status loongson_mode_valid(struct 
drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs loongson_crtc_helper_funcs = {
.mode_valid = loongson_mode_valid,
+   .atomic_flush = loongson_crtc_atomic_flush,
.atomic_enable = loongson_crtc_atomic_enable,
.atomic_disable = loongson_crtc_atomic_disable,
.mode_set_nofb = loongson_crtc_mode_set_nofb,
@@ -211,6 +246,8 @@ static const struct drm_crtc_funcs loongson_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = loongson_crtc_enable_vblank,
+   .disable_vblank = loongson_crtc_disable_vblank,
 };
 
 int loongson_crtc_init(struct loongson_device *ldev, int index)
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 2e3ef6193767..1d6f35e78813 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -23,9 +23,10 @@
 /* Interface history:
  * 0.1 - original.
  * 0.2 - add i2c and connector detect.
+ * 0.3 - Vblank and vsync interrupt support.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 2
+#define DRIVER_MINOR 3
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -167,6 +168,12 @@ static int loongson_driver_init(struct drm_device *dev)
goto err;
}
 
+   ret = loongson_irq_init(ldev);
+   if (ret) {
+   dev_err(dev->dev, "Fatal error during irq init: %d\n", ret);
+   goto err;
+   }
+
drm_kms_helper_poll_init(dev);
drm_mode_config_reset(dev);
 
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 

[PATCH v7 2/4] drm/loongson: Add GPIO and I2C driver for loongson drm.

2022-04-22 Thread Chenyang Li
Implement use GPIO and I2C driver to detect connector
and fetch EDID via DDC.

v5:
- Use braidge->ddc to get EDID and detect connector.

v4:
- Delete the gpio_chip subsystem call.
- Delete some redundant prints.

v3:
- Change some driver log to the drm_ version.

v2:
- Optimize the error handling process.
- Delete loongson_i2c_bus_match and loongson_i2c_add function.
- Optimize part of the code flow.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/loongson/Makefile   |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c |  13 +-
 drivers/gpu/drm/loongson/loongson_drv.h |   7 +
 drivers/gpu/drm/loongson/loongson_encoder.c |  31 +++-
 drivers/gpu/drm/loongson/loongson_i2c.c | 191 
 drivers/gpu/drm/loongson/loongson_i2c.h |  33 
 6 files changed, 266 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_i2c.h

diff --git a/drivers/gpu/drm/loongson/Makefile 
b/drivers/gpu/drm/loongson/Makefile
index 534a64047fb6..4a5fab7d000b 100644
--- a/drivers/gpu/drm/loongson/Makefile
+++ b/drivers/gpu/drm/loongson/Makefile
@@ -9,5 +9,6 @@ loongson-y := loongson_connector.o \
loongson_device.o \
loongson_drv.o \
loongson_encoder.o \
+   loongson_i2c.o \
loongson_plane.o
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
diff --git a/drivers/gpu/drm/loongson/loongson_drv.c 
b/drivers/gpu/drm/loongson/loongson_drv.c
index 4993b8d9e8ca..2e3ef6193767 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.c
+++ b/drivers/gpu/drm/loongson/loongson_drv.c
@@ -22,9 +22,10 @@
 
 /* Interface history:
  * 0.1 - original.
+ * 0.2 - add i2c and connector detect.
  */
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 1
+#define DRIVER_MINOR 2
 
 static const struct drm_mode_config_funcs loongson_mode_funcs = {
.fb_create = drm_gem_fb_create,
@@ -88,6 +89,14 @@ static int loongson_device_init(struct drm_device *dev)
 
ldev->num_crtc = 2;
 
+   ret = loongson_dc_gpio_init(ldev);
+   if (ret)
+   return ret;
+
+   ret = loongson_i2c_init(ldev);
+   if (ret)
+   return ret;
+
drm_info(dev, "DC mmio base 0x%llx size 0x%llx io 0x%llx\n",
 mmio_base, mmio_size, *(u64 *)ldev->io);
drm_info(dev, "GPU vram start = 0x%x size = 0x%x\n",
@@ -96,7 +105,7 @@ static int loongson_device_init(struct drm_device *dev)
return 0;
 }
 
-int loongson_modeset_init(struct loongson_device *ldev)
+static int loongson_modeset_init(struct loongson_device *ldev)
 {
int i;
int ret;
diff --git a/drivers/gpu/drm/loongson/loongson_drv.h 
b/drivers/gpu/drm/loongson/loongson_drv.h
index e9e97db00110..5be29d2d1a49 100644
--- a/drivers/gpu/drm/loongson/loongson_drv.h
+++ b/drivers/gpu/drm/loongson/loongson_drv.h
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#include "loongson_i2c.h"
+
 /* General customization:
  */
 #define DRIVER_AUTHOR "Loongson graphics driver team"
@@ -102,6 +104,8 @@ struct loongson_device {
u32 num_crtc;
struct loongson_mode_info mode_info[2];
struct pci_dev *gpu_pdev; /* LS7A gpu device info */
+
+   struct loongson_i2c i2c_bus[DC_MAX_I2C_BUS];
 };
 
 static inline struct loongson_device *to_loongson_device(struct drm_device 
*dev)
@@ -121,6 +125,9 @@ int loongson_encoder_init(struct loongson_device *ldev, int 
index);
 /* plane */
 struct loongson_plane *loongson_plane_init(struct drm_device *dev, int index);
 
+/* i2c */
+int loongson_dc_gpio_init(struct loongson_device *ldev);
+
 /* device */
 u32 loongson_gpu_offset(struct drm_plane_state *state,
struct loongson_device *dev);
diff --git a/drivers/gpu/drm/loongson/loongson_encoder.c 
b/drivers/gpu/drm/loongson/loongson_encoder.c
index 5b94f707f1a0..accf144479f8 100644
--- a/drivers/gpu/drm/loongson/loongson_encoder.c
+++ b/drivers/gpu/drm/loongson/loongson_encoder.c
@@ -7,19 +7,31 @@
 
 #include "loongson_drv.h"
 
-static int loongson_bridge_get_modes(struct drm_bridge *bridge,
-struct drm_connector *connector)
+enum drm_connector_status loongson_bridge_detect(struct drm_bridge *bridge)
 {
-   int count;
+   unsigned char start = 0x0;
+   struct i2c_msg msgs = {
+   .addr = DDC_ADDR,
+   .flags = 0,
+   .len = 1,
+   .buf = ,
+   };
 
-   count = drm_add_modes_noedid(connector, 1920, 1080);
-   drm_set_preferred_mode(connector, 1024, 768);
+   if (i2c_transfer(bridge->ddc, , 1) != 1)
+   return connector_status_disconnected;
+   else
+   return connector_status_connected;
+}
 
-   return count;
+static struct edid *loongson_bridge_get_edid(struct drm_bridge *bridge,
+struct drm_connector *connector)
+{
+   return drm_get_edid(connector, bridge->ddc);
 }
 
 static const struct 

[PATCH v7 1/4] drm/loongson: Add DRM Driver for Loongson 7A1000 bridge chip

2022-04-22 Thread Chenyang Li
This patch adds an initial DRM driver for the Loongson LS7A1000
bridge chip(LS7A). The Loongson 7A1000 bridge chip is Loongson’s
first dedicated chipset product, providing north-south bridge functionality
for Loongson processors. The bridge chip is connected to the Loongson
Series 3 processor via the HT high-speed bus interface and has an
integrated DisplayController, DDR3 SDRAM memory controller,
and PCIE, SATA, USB, GMAC, I2C, UART, GPIO, and other interfaces.
The display controller supports dual DVO signal output,dual routability
frame buffer. Each display supports up to 1920x1080@60Hz, RGB888 and
RGB565 color depths. And supports hardware cursor, gamma correction,
interrupt, soft reset, etc. The video memory interface uses 16-bit DDR3
SDRAM interface with a maximum data rate of 1333 Mbps.
At present, DC device detection and DRM driver registration are
completed, the crtc/plane/encoder/connector objects has been
implemented.
On Loongson 3A4000 CPU and 7A1000 system, we have achieved the use
of dual screen, and support dual screen clone mode and expansion
mode.
Link: 
https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html#display-controller

v12:
- Use drm_bridge_connector in driver.

v11:
- Remove a lot of useless code.
- Add help information.
- Delete unnecessary header files.

v10:
- Replace the drmm_ version functions.
- Replace the simple_encoder version function.
- Alphabetize file names.

v9:
- Optimize the error handling process.
- Remove the useless flags parameter.
- Fix some incorrect use of variables and constructs.

v8:
- Update the atomic_update function interface.

v7:
- The pixel clock is limited to less than 173000.

v6:
- Remove spin_lock in mmio reg read and write.
- TO_UNCAC is replac with ioremap.
- Fix error arguments in crtc_atomic_enable/disable/mode_valid.

v5:
- Change the name of the chip to LS7A.
- Change magic value in crtc to macros.
- Correct mistakes words.
- Change the register operation function prefix to ls7a.

v4:
- Move the mode_valid function to the crtc.

v3:
- Move the mode_valid function to the connector and optimize it.
- Fix num_crtc calculation method.

v2:
- Complete the case of 32-bit color in CRTC.

Signed-off-by: Yi Li 
Signed-off-by: Chenyang Li 
---
 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/loongson/Kconfig  |  13 +
 drivers/gpu/drm/loongson/Makefile |  13 +
 drivers/gpu/drm/loongson/loongson_connector.c |  25 ++
 drivers/gpu/drm/loongson/loongson_crtc.c  | 244 
 drivers/gpu/drm/loongson/loongson_device.c|  38 +++
 drivers/gpu/drm/loongson/loongson_drv.c   | 275 ++
 drivers/gpu/drm/loongson/loongson_drv.h   | 132 +
 drivers/gpu/drm/loongson/loongson_encoder.c   |  59 
 drivers/gpu/drm/loongson/loongson_plane.c |  97 ++
 11 files changed, 899 insertions(+)
 create mode 100644 drivers/gpu/drm/loongson/Kconfig
 create mode 100644 drivers/gpu/drm/loongson/Makefile
 create mode 100644 drivers/gpu/drm/loongson/loongson_connector.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_crtc.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_device.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_encoder.c
 create mode 100644 drivers/gpu/drm/loongson/loongson_plane.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f1422bee3dcc..d5547e492a3f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -392,6 +392,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig"
 
 source "drivers/gpu/drm/lima/Kconfig"
 
+source "drivers/gpu/drm/loongson/Kconfig"
+
 source "drivers/gpu/drm/panfrost/Kconfig"
 
 source "drivers/gpu/drm/aspeed/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index c2ef5f9fce54..173b967e2884 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -125,6 +125,7 @@ obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
 obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
 obj-$(CONFIG_DRM_LIMA)  += lima/
+obj-$(CONFIG_DRM_LOONGSON) += loongson/
 obj-$(CONFIG_DRM_PANFROST) += panfrost/
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
 obj-$(CONFIG_DRM_MCDE) += mcde/
diff --git a/drivers/gpu/drm/loongson/Kconfig b/drivers/gpu/drm/loongson/Kconfig
new file mode 100644
index ..2484824fb50b
--- /dev/null
+++ b/drivers/gpu/drm/loongson/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_LOONGSON
+   tristate "DRM support for LS7A bridge chipset"
+   depends on DRM && PCI
+   depends on CPU_LOONGSON64 || COMPILE_TEST
+   select DRM_KMS_HELPER
+   select DRM_VRAM_HELPER
+   help
+ The loongson 7A bridge chip (LS7A) is a 

Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-12 Thread Kalle Valo
+ stephen

Greg Kroah-Hartman  writes:

> On Wed, Apr 06, 2022 at 10:06:33AM +0300, Kalle Valo wrote:
>> Jakub Kicinski  writes:
>> 
>> > On Tue, 05 Apr 2022 10:16:58 +0300 Kalle Valo wrote:
>> >> Sure, that would technically work. But I just think it's cleaner to use
>> >> -rc1 (or later) as the baseline for an immutable branch. If the baseline
>> >> is an arbitrary commit somewhere within merge windows commits, it's more
>> >> work for everyone to verify the branch is suitable.
>> >> 
>> >> Also in general I would also prefer to base -next trees to -rc1 or newer
>> >> to make the bisect cleaner. The less we need to test kernels from the
>> >> merge window (ie. commits after the final release and before -rc1) the
>> >> better.
>> >> 
>> >> But this is just a small wish from me, I fully understand that it might
>> >> be too much changes to your process. Wanted to point out this anyway.
>> >
>> > Forwarded!
>> 
>> Awesome, thank you Jakub!
>> 
>> Greg, I now created an immutable branch for moving wfx from
>> drivers/staging to drivers/net/wireless/silabs:
>> 
>> git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git
>> wfx-move-out-of-staging
>> 
>> The baseline for this branch is v5.18-rc1. If you think the branch is
>> ok, please pull it to staging-next and let me know. I can then pull the
>> branch to wireless-next and the transition should be complete. And do
>> let me know if there are any problems.
>
> Looks great to me!  I've pulled it into staging-next now.  And will not
> take any more patches to the driver (some happened before the merge but
> git handled the move just fine.)

Great, thanks Greg! I now merged the immutable branch also to
wireless-next:

79649041edc8 Merge branch 'wfx-move-out-of-staging'
4a5fb1bbcdf1 wfx: get out from the staging area

So from now on wfx patches should be submitted for wireless-next via the
linux-wireless mailing list, instructions in the wiki link below.

Stephen, I want to warn you in advance about this driver move but
hopefully everything goes smoothly.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-07 Thread Greg Kroah-Hartman
On Wed, Apr 06, 2022 at 10:06:33AM +0300, Kalle Valo wrote:
> Jakub Kicinski  writes:
> 
> > On Tue, 05 Apr 2022 10:16:58 +0300 Kalle Valo wrote:
> >> Sure, that would technically work. But I just think it's cleaner to use
> >> -rc1 (or later) as the baseline for an immutable branch. If the baseline
> >> is an arbitrary commit somewhere within merge windows commits, it's more
> >> work for everyone to verify the branch is suitable.
> >> 
> >> Also in general I would also prefer to base -next trees to -rc1 or newer
> >> to make the bisect cleaner. The less we need to test kernels from the
> >> merge window (ie. commits after the final release and before -rc1) the
> >> better.
> >> 
> >> But this is just a small wish from me, I fully understand that it might
> >> be too much changes to your process. Wanted to point out this anyway.
> >
> > Forwarded!
> 
> Awesome, thank you Jakub!
> 
> Greg, I now created an immutable branch for moving wfx from
> drivers/staging to drivers/net/wireless/silabs:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 
> wfx-move-out-of-staging
> 
> The baseline for this branch is v5.18-rc1. If you think the branch is
> ok, please pull it to staging-next and let me know. I can then pull the
> branch to wireless-next and the transition should be complete. And do
> let me know if there are any problems.

Looks great to me!  I've pulled it into staging-next now.  And will not
take any more patches to the driver (some happened before the merge but
git handled the move just fine.)

thanks!

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-06 Thread Kalle Valo
Jakub Kicinski  writes:

> On Tue, 05 Apr 2022 10:16:58 +0300 Kalle Valo wrote:
>> Sure, that would technically work. But I just think it's cleaner to use
>> -rc1 (or later) as the baseline for an immutable branch. If the baseline
>> is an arbitrary commit somewhere within merge windows commits, it's more
>> work for everyone to verify the branch is suitable.
>> 
>> Also in general I would also prefer to base -next trees to -rc1 or newer
>> to make the bisect cleaner. The less we need to test kernels from the
>> merge window (ie. commits after the final release and before -rc1) the
>> better.
>> 
>> But this is just a small wish from me, I fully understand that it might
>> be too much changes to your process. Wanted to point out this anyway.
>
> Forwarded!

Awesome, thank you Jakub!

Greg, I now created an immutable branch for moving wfx from
drivers/staging to drivers/net/wireless/silabs:

git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 
wfx-move-out-of-staging

The baseline for this branch is v5.18-rc1. If you think the branch is
ok, please pull it to staging-next and let me know. I can then pull the
branch to wireless-next and the transition should be complete. And do
let me know if there are any problems.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-05 Thread Jakub Kicinski
On Tue, 05 Apr 2022 10:16:58 +0300 Kalle Valo wrote:
> Sure, that would technically work. But I just think it's cleaner to use
> -rc1 (or later) as the baseline for an immutable branch. If the baseline
> is an arbitrary commit somewhere within merge windows commits, it's more
> work for everyone to verify the branch is suitable.
> 
> Also in general I would also prefer to base -next trees to -rc1 or newer
> to make the bisect cleaner. The less we need to test kernels from the
> merge window (ie. commits after the final release and before -rc1) the
> better.
> 
> But this is just a small wish from me, I fully understand that it might
> be too much changes to your process. Wanted to point out this anyway.

Forwarded!
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-05 Thread Kalle Valo
Jakub Kicinski  writes:

> On Mon, 4 Apr 2022 23:22:47 -0700 Jakub Kicinski wrote:
>> On Mon, 04 Apr 2022 13:49:18 +0300 Kalle Valo wrote:
>> > Dave, once you guys open net-next will it be based on -rc1?  
>> 
>> Not normally. We usually let net feed net-next so it'd get -rc1 this
>> Thursday. But we should be able to fast-forward, let me confirm with
>> Dave.
>
> Wait, why is -rc1 magic? If you based the branch on whatever
> the merge-base of net-next and staging-next is, would that be
> an aberration?

Sure, that would technically work. But I just think it's cleaner to use
-rc1 (or later) as the baseline for an immutable branch. If the baseline
is an arbitrary commit somewhere within merge windows commits, it's more
work for everyone to verify the branch is suitable.

Also in general I would also prefer to base -next trees to -rc1 or newer
to make the bisect cleaner. The less we need to test kernels from the
merge window (ie. commits after the final release and before -rc1) the
better.

But this is just a small wish from me, I fully understand that it might
be too much changes to your process. Wanted to point out this anyway.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-05 Thread Jakub Kicinski
On Mon, 4 Apr 2022 23:22:47 -0700 Jakub Kicinski wrote:
> On Mon, 04 Apr 2022 13:49:18 +0300 Kalle Valo wrote:
> > Dave, once you guys open net-next will it be based on -rc1?  
> 
> Not normally. We usually let net feed net-next so it'd get -rc1 this
> Thursday. But we should be able to fast-forward, let me confirm with
> Dave.

Wait, why is -rc1 magic? If you based the branch on whatever
the merge-base of net-next and staging-next is, would that be
an aberration?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-05 Thread Jakub Kicinski
On Mon, 04 Apr 2022 13:49:18 +0300 Kalle Valo wrote:
> Dave, once you guys open net-next will it be based on -rc1?

Not normally. We usually let net feed net-next so it'd get -rc1 this
Thursday. But we should be able to fast-forward, let me confirm with
Dave.

> That would make it easier for me to create an immutable branch between
> staging-next and wireless-next.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-04 Thread Kalle Valo
Jérôme Pouiller  writes:

> On Saturday 26 February 2022 14:15:33 CEST Kalle Valo wrote:
>> Greg Kroah-Hartman  writes:
>> 
>> > That sounds great to me, let's plan on that happening after 5.18-rc1 is
>> > out.
>> 
>> Very good, we have a plan then. I marked the patch as deferred in
>> patchwork:
>> 
>> https://patchwork.kernel.org/project/linux-wireless/patch/20220226092142.10164-2-jerome.pouil...@silabs.com/
>> 
>> Jerome, feel free to remind me about this after v5.18-rc1 is released.
>
> v5.18-rc1 is released :)

Thanks for the reminder :) Once we open wireless-next I'll start
preparing the branch.

Dave, once you guys open net-next will it be based on -rc1? That
would make it easier for me to create an immutable branch between
staging-next and wireless-next.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v10 0/1] wfx: get out from the staging area

2022-04-04 Thread Jérôme Pouiller
Hi Kalle,

On Saturday 26 February 2022 14:15:33 CEST Kalle Valo wrote:
> Greg Kroah-Hartman  writes:
> 
> > On Sat, Feb 26, 2022 at 12:41:41PM +0200, Kalle Valo wrote:
> >> + jakub
> >>
> >> Jerome Pouiller  writes:
> >>
> >> > The firmware and the PDS files (= antenna configurations) are now a part 
> >> > of
> >> > the linux-firmware repository.
> >> >
> >> > All the issues have been fixed in staging tree. I think we are ready to 
> >> > get
> >> > out from the staging tree for the kernel 5.18.
> >>
> >> [...]
> >>
> >> >  rename Documentation/devicetree/bindings/{staging =>
> >> > }/net/wireless/silabs,wfx.yaml (98%)
> >>
> >> I lost track, is this file acked by the DT maintainers now?
> >>
> >> What I suggest is that we queue this for v5.19. After v5.18-rc1 is
> >> released I could create an immutable branch containing this one commit.
> >> Then I would merge the branch to wireless-next and Greg could merge it
> >> to the staging tree, that way we would minimise the chance of conflicts
> >> between trees.
> >>
> >> Greg, what do you think? Would this work for you? IIRC we did the same
> >> with wilc1000 back in 2020 and I recall it went without hiccups.
> >
> > That sounds great to me, let's plan on that happening after 5.18-rc1 is
> > out.
> 
> Very good, we have a plan then. I marked the patch as deferred in
> patchwork:
> 
> https://patchwork.kernel.org/project/linux-wireless/patch/20220226092142.10164-2-jerome.pouil...@silabs.com/
> 
> Jerome, feel free to remind me about this after v5.18-rc1 is released.

v5.18-rc1 is released :)

-- 
Jérôme Pouiller


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Re: [PATCH v1] pinctrl: ralink: rt2880: Check for return value of devm_kcalloc()

2022-04-01 Thread Andy Shevchenko
On Fri, Apr 1, 2022 at 6:06 AM unSimple  wrote:

>
> The main consideration of the 'continue' in the patch is that those 
> statements are inner a loop.
>
> The next allocation may be successful so I think it is better to use 
> 'continue' here.

Please, do not top-post!

What you explained is logical from APIs point of view, what I was
asking is about functional point of view.
Why do you think the skipping iteration is fine?

You need to explain this in the code/commit message.

> At 2022-03-29 19:45:50, "Andy Shevchenko"  wrote:
> >On Tue, Mar 29, 2022 at 11:36 AM QintaoShen  wrote:
> >>
> >> The memory allocation function devm_kcalloc() may return NULL pointer,
> >
> >may --> might
> >
> >> so it is better to add a check for 'p->func[i]->pins' to avoid possible
> >> NULL pointer dereference.

...

> >> @@ -266,6 +266,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p)
> >> p->func[i]->pin_count,
> >> sizeof(int),
> >> GFP_KERNEL);
> >
> >> +
> >
> >Stray change. Also it seems it has trailing space character(s).
> >
> >> +if (!p->func[i]->pins)
> >
> >> +continue;
> >
> >Why is 'continue' the proper choice here? No clarification is given in
> >the commit message.
> >
> >> for (j = 0; j < p->func[i]->pin_count; j++)
> >> p->func[i]->pins[j] = p->func[i]->pin_first + j;

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 36/37] media: atomisp: fix bad usage at error handling logic

2022-03-30 Thread Sasha Levin
From: Mauro Carvalho Chehab 

[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]

As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'

The acc_fw interactor is used outside the loop, at the error handling
logic. On most cases, this is actually safe there, but, if
atomisp_css_set_acc_parameters() has an error, an attempt to use it
will pick an invalid value for acc_fw.

Reported-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../staging/media/atomisp/pci/atomisp_acc.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index f638d0bd09fe..b1614cce2dfb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device 
*asd,
return 0;
 }
 
+static void atomisp_acc_unload_some_extensions(struct atomisp_sub_device *asd,
+ int i,
+ struct atomisp_acc_fw *acc_fw)
+{
+   while (--i >= 0) {
+   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
+   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
+
acc_flag_to_pipe[i].pipe_id);
+   }
+   }
+}
+
 /*
  * Appends the loaded acceleration binary extensions to the
  * current ISP mode. Must be called just before sh_css_start().
@@ -477,16 +489,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
 acc_fw->fw,
 
acc_flag_to_pipe[i].pipe_id,
 
acc_fw->type);
-   if (ret)
+   if (ret) {
+   atomisp_acc_unload_some_extensions(asd, 
i, acc_fw);
goto error;
+   }
 
ext_loaded = true;
}
}
 
ret = atomisp_css_set_acc_parameters(acc_fw);
-   if (ret < 0)
+   if (ret < 0) {
+   atomisp_acc_unload_some_extensions(asd, i, acc_fw);
goto error;
+   }
}
 
if (!ext_loaded)
@@ -495,6 +511,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
ret = atomisp_css_update_stream(asd);
if (ret) {
dev_err(isp->dev, "%s: update stream failed.\n", __func__);
+   atomisp_acc_unload_extensions(asd);
goto error;
}
 
@@ -502,13 +519,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
return 0;
 
 error:
-   while (--i >= 0) {
-   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-
acc_flag_to_pipe[i].pipe_id);
-   }
-   }
-
list_for_each_entry_continue_reverse(acc_fw, >acc.fw, list) {
if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 14/37] media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

2022-03-30 Thread Sasha Levin
From: Tsuchiya Yuto 

[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[  140.230662] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:03.0/active_bo'
[  140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE
 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[  140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 
03/09/2015
[  140.230678] Call Trace:
[  140.230687]  dump_stack_lvl+0x46/0x5a
[  140.230702]  sysfs_warn_dup.cold+0x17/0x24
[  140.230710]  sysfs_add_file_mode_ns+0x160/0x170
[  140.230717]  internal_create_group+0x126/0x390
[  140.230723]  hmm_init+0x5c/0x70 [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230811]  atomisp_pci_probe.cold+0x1136/0x148e [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230875]  local_pci_probe+0x45/0x80
[  140.230882]  ? pci_match_device+0xd7/0x130
[  140.230887]  pci_device_probe+0xfa/0x1b0
[  140.230892]  really_probe+0x1f5/0x3f0
[  140.230899]  __driver_probe_device+0xfe/0x180
[  140.230903]  driver_probe_device+0x1e/0x90
[  140.230908]  __driver_attach+0xc0/0x1c0
[  140.230912]  ? __device_attach_driver+0xe0/0xe0
[  140.230915]  ? __device_attach_driver+0xe0/0xe0
[  140.230919]  bus_for_each_dev+0x89/0xd0
[  140.230924]  bus_add_driver+0x12b/0x1e0
[  140.230929]  driver_register+0x8f/0xe0
[  140.230933]  ? 0xc153f000
[  140.230937]  do_one_initcall+0x57/0x220
[  140.230945]  do_init_module+0x5c/0x260
[  140.230952]  load_module+0x24bd/0x26a0
[  140.230962]  ? __do_sys_finit_module+0xae/0x110
[  140.230966]  __do_sys_finit_module+0xae/0x110
[  140.230972]  do_syscall_64+0x5c/0x80
[  140.230979]  ? syscall_exit_to_user_mode+0x23/0x40
[  140.230983]  ? do_syscall_64+0x69/0x80
[  140.230988]  ? exc_page_fault+0x72/0x170
[  140.230991]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  140.230997] RIP: 0033:0x7f7fd5d8718d
[  140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 
48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 
3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[  140.231006] RSP: 002b:7ffefc25f0e8 EFLAGS: 0246 ORIG_RAX: 
0139
[  140.231012] RAX: ffda RBX: 55ac3edcd7f0 RCX: 
7f7fd5d8718d
[  140.231015] RDX:  RSI: 55ac3d723270 RDI: 
0003
[  140.231017] RBP:  R08:  R09: 
7f7fd5e52380
[  140.231019] R10: 0003 R11: 0246 R12: 
55ac3d723270
[  140.231021] R13:  R14: 55ac3edd06e0 R15: 

[  140.231038] atomisp-isp2 :00:03.0: hmm_init Failed to create 
sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: 
https://lore.kernel.org/linux-media/20211017162337.44860-3-kita...@gmail.com

Signed-off-by: Tsuchiya Yuto 
Co-developed-by: Mauro Carvalho Chehab 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 6a5ee4607089..c1cda16f2dc0 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -39,7 +39,7 @@
 struct hmm_bo_device bo_device;
 struct hmm_pooldynamic_pool;
 struct hmm_poolreserved_pool;
-static ia_css_ptr dummy_ptr;
+static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;
 static bool hmm_initialized;
 struct _hmm_mem_stat hmm_mem_stat;
 
@@ -209,7 +209,7 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
-   if (!dummy_ptr)
+   if (dummy_ptr == mmgr_EXCEPTION)
return;
sysfs_remove_group(_dev->kobj, atomisp_attribute_group);
 
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)
 
dev_dbg(atomisp_dev, "%s: free 

  1   2   3   4   5   6   7   8   9   10   >