linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes
@ 2021-06-22  0:15 Dylan MacKenzie
  2021-06-22  0:15 ` [PATCH 1/2] HID: amd_sfh: Set correct DMA mask Dylan MacKenzie
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dylan MacKenzie @ 2021-06-22  0:15 UTC (permalink / raw)
  Cc: Nehal Shah, Sandeep Singh, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

While preparing to investigate
https://bugzilla.kernel.org/show_bug.cgi?id=212615, I read through the amd_sfh
driver and saw two (unrelated) bugs in the logic that sets the DMA mask.
Ultimately these are harmless, but they should probably get fixed.

FYI, this is my first time submitting a kernel patch. If I've done something
wrong in formatting this email, it is likely due to incompetence rather than
malice.

Dylan MacKenzie (2):
  HID: amd_sfh: Set correct DMA mask
  HID: amd_sfh: Continue if fallback DMA mask is accepted

 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] HID: amd_sfh: Set correct DMA mask
  2021-06-22  0:15 [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Dylan MacKenzie
@ 2021-06-22  0:15 ` Dylan MacKenzie
  2021-06-22  0:15 ` [PATCH 2/2] HID: amd_sfh: Continue if fallback DMA mask is accepted Dylan MacKenzie
  2021-07-28  9:28 ` [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Jiri Kosina
  2 siblings, 0 replies; 6+ messages in thread
From: Dylan MacKenzie @ 2021-06-22  0:15 UTC (permalink / raw)
  Cc: Nehal Shah, Sandeep Singh, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

The AMDSFH driver uses coherent DMA allocations, but only sets the
streaming DMA mask. As a result, the kernel can't make use of the full
address space supported by the device.

Signed-off-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index ddecc84fd6f..c2de650cd8e 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -155,9 +155,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	privdata->mmio = pcim_iomap_table(pdev)[2];
 	pci_set_master(pdev);
-	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+	rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
 	if (rc) {
-		rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+		rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
 		return rc;
 	}
 	rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] HID: amd_sfh: Continue if fallback DMA mask is accepted
  2021-06-22  0:15 [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Dylan MacKenzie
  2021-06-22  0:15 ` [PATCH 1/2] HID: amd_sfh: Set correct DMA mask Dylan MacKenzie
@ 2021-06-22  0:15 ` Dylan MacKenzie
  2021-07-28  9:28 ` [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Jiri Kosina
  2 siblings, 0 replies; 6+ messages in thread
From: Dylan MacKenzie @ 2021-06-22  0:15 UTC (permalink / raw)
  Cc: Nehal Shah, Sandeep Singh, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

Currently, if a call to `set_dma_mask(DMA_BIT_MASK(64))` fails, the
driver calls `set_dma_mask(DMA_BIT_MASK(32))` and immediately returns
regardless of the result. If that second call were to succeed, the SFH
would not get initialized (defeating the whole purpose of falling back
to a 32-bit address space) but the driver would remain registered
(since `probe` returned 0).

Signed-off-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index c2de650cd8e..a4f363d082c 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -155,11 +155,15 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	privdata->mmio = pcim_iomap_table(pdev)[2];
 	pci_set_master(pdev);
+
 	rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
-	if (rc) {
+	if (rc)
 		rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+	if (rc) {
+		pci_err(pdev, "Failed to set DMA mask");
 		return rc;
 	}
+
 	rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
 	if (rc)
 		return rc;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes
  2021-06-22  0:15 [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Dylan MacKenzie
  2021-06-22  0:15 ` [PATCH 1/2] HID: amd_sfh: Set correct DMA mask Dylan MacKenzie
  2021-06-22  0:15 ` [PATCH 2/2] HID: amd_sfh: Continue if fallback DMA mask is accepted Dylan MacKenzie
@ 2021-07-28  9:28 ` Jiri Kosina
  2021-07-28  9:33   ` Jiri Kosina
  2 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2021-07-28  9:28 UTC (permalink / raw)
  To: Dylan MacKenzie
  Cc: Nehal Shah, Sandeep Singh, Benjamin Tissoires, linux-input, linux-kernel

On Mon, 21 Jun 2021, Dylan MacKenzie wrote:

> While preparing to investigate
> https://bugzilla.kernel.org/show_bug.cgi?id=212615, I read through the amd_sfh
> driver and saw two (unrelated) bugs in the logic that sets the DMA mask.
> Ultimately these are harmless, but they should probably get fixed.
> 
> FYI, this is my first time submitting a kernel patch. If I've done something
> wrong in formatting this email, it is likely due to incompetence rather than
> malice.
> 
> Dylan MacKenzie (2):
>   HID: amd_sfh: Set correct DMA mask
>   HID: amd_sfh: Continue if fallback DMA mask is accepted
> 
>  drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Nehal, Sandeep, could you please provide your Ack to this series? Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes
  2021-07-28  9:28 ` [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Jiri Kosina
@ 2021-07-28  9:33   ` Jiri Kosina
  2021-07-28 19:22     ` Basavaraj Natikar
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2021-07-28  9:33 UTC (permalink / raw)
  To: Dylan MacKenzie
  Cc: Nehal Shah, Basavaraj Natikar, Benjamin Tissoires, linux-input,
	linux-kernel


[ dropping Sandeep, CCing Basavaraj ]

On Wed, 28 Jul 2021, Jiri Kosina wrote:

> On Mon, 21 Jun 2021, Dylan MacKenzie wrote:
> 
> > While preparing to investigate
> > https://bugzilla.kernel.org/show_bug.cgi?id=212615, I read through the amd_sfh
> > driver and saw two (unrelated) bugs in the logic that sets the DMA mask.
> > Ultimately these are harmless, but they should probably get fixed.
> > 
> > FYI, this is my first time submitting a kernel patch. If I've done something
> > wrong in formatting this email, it is likely due to incompetence rather than
> > malice.
> > 
> > Dylan MacKenzie (2):
> >   HID: amd_sfh: Set correct DMA mask
> >   HID: amd_sfh: Continue if fallback DMA mask is accepted
> > 
> >  drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> Nehal, Sandeep, could you please provide your Ack to this series? Thanks,
> 
> -- 
> Jiri Kosina
> SUSE Labs
> 
> 

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes
  2021-07-28  9:33   ` Jiri Kosina
@ 2021-07-28 19:22     ` Basavaraj Natikar
  0 siblings, 0 replies; 6+ messages in thread
From: Basavaraj Natikar @ 2021-07-28 19:22 UTC (permalink / raw)
  To: Jiri Kosina, Dylan MacKenzie
  Cc: Nehal Shah, Basavaraj Natikar, Benjamin Tissoires, linux-input,
	linux-kernel

On 7/28/2021 3:03 PM, Jiri Kosina wrote:
> [CAUTION: External Email]
>
> [ dropping Sandeep, CCing Basavaraj ]
>
> On Wed, 28 Jul 2021, Jiri Kosina wrote:
>
>> On Mon, 21 Jun 2021, Dylan MacKenzie wrote:
>>
>>> While preparing to investigate
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.kernel.org%2Fshow_bug.cgi%3Fid%3D212615&amp;data=04%7C01%7Cbasavaraj.natikar%40amd.com%7C2dff45d8dc964dbc5b1c08d951aab806%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637630615935776199%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=hGpNFpr6BjVg8dvfUTNF8Td1SOdtN5T8c2WACGAZWUo%3D&amp;reserved=0, I read through the amd_sfh
>>> driver and saw two (unrelated) bugs in the logic that sets the DMA mask.
>>> Ultimately these are harmless, but they should probably get fixed.
>>>
>>> FYI, this is my first time submitting a kernel patch. If I've done something
>>> wrong in formatting this email, it is likely due to incompetence rather than
>>> malice.
>>>
>>> Dylan MacKenzie (2):
>>>   HID: amd_sfh: Set correct DMA mask
>>>   HID: amd_sfh: Continue if fallback DMA mask is accepted
>>>
>>>  drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 8 ++++++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>> Nehal, Sandeep, could you please provide your Ack to this series? Thanks,

I think, you can merge both of them together as it addresses a single problem. 
can you please respin a v2 with the changes something like this?

        privdata->mmio = pcim_iomap_table(pdev)[2];
        pci_set_master(pdev);
-       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+
+       rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
        if (rc) {
-               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
-               return rc;
+               rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+               if (rc) {
+                       pci_err(pdev, "Failed to set DMA mask");
+                       return rc;
                 }
        }

Thanks,
Basavaraj


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-28 19:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22  0:15 [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Dylan MacKenzie
2021-06-22  0:15 ` [PATCH 1/2] HID: amd_sfh: Set correct DMA mask Dylan MacKenzie
2021-06-22  0:15 ` [PATCH 2/2] HID: amd_sfh: Continue if fallback DMA mask is accepted Dylan MacKenzie
2021-07-28  9:28 ` [PATCH 0/2] HID: amd_sfh: Minor DMA mapping bugfixes Jiri Kosina
2021-07-28  9:33   ` Jiri Kosina
2021-07-28 19:22     ` Basavaraj Natikar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).