All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Connor McAdams" <conmanx360@gmail.com>
Cc: alsa-devel@alsa-project.org,
	"\"Jérémy Lefaure\"" <jeremy.lefaure@lse.epita.fr>,
	"Jaroslav Kysela" <perex@perex.cz>,
	o-takashi@sakamocchi.jp, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/9] Add PCI region2 iomap for SBZ
Date: Fri, 04 May 2018 11:26:56 +0200	[thread overview]
Message-ID: <s5ho9hvlqjj.wl-tiwai@suse.de> (raw)
In-Reply-To: <1525383771-11105-3-git-send-email-conmanx360@gmail.com>

On Thu, 03 May 2018 23:42:44 +0200,
Connor McAdams wrote:
> 
> @@ -4691,8 +4699,17 @@ static void ca0132_free(struct hda_codec *codec)
>  
>  	cancel_delayed_work_sync(&spec->unsol_hp_work);
>  	snd_hda_power_up(codec);
> -	snd_hda_sequence_write(codec, spec->base_exit_verbs);
> -	ca0132_exit_chip(codec);
> +	switch (spec->quirk) {
> +	case QUIRK_SBZ:
> +		iounmap(spec->mem_base);
> +		snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +		ca0132_exit_chip(codec);
> +		break;

Do you need to unmap before the rest procedure?
Usually the unmapping happens at the last, after all commands
finished.

> +	default:
> +		snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +		ca0132_exit_chip(codec);
> +		break;
> +	}
>  	snd_hda_power_down(codec);
>  	kfree(spec->spec_init_verbs);
>  	kfree(codec->spec);

So in this case, a cleaner way would be to add the conditional iounmap
like:

  	snd_hda_power_down(codec);
	if (spec->mem_base)
		iounmap(spec->mem_base);
  	kfree(spec->spec_init_verbs);
  	kfree(codec->spec);
	
> @@ -4909,6 +4926,15 @@ static int patch_ca0132(struct hda_codec *codec)
>  	else
>  		spec->quirk = QUIRK_NONE;
>  
> +	/* Setup BAR Region 2 for Sound Blaster Z */
> +	if (spec->quirk == QUIRK_SBZ) {
> +		spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20);
> +		if (spec->mem_base == NULL) {
> +			codec_dbg(codec, "pci_iomap failed!");
> +			codec_dbg(codec, "perhaps this is not an SBZ?");

This should be shown more explicitly, so better to be codec_warn() or
codec_info().


thanks,

Takashi

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Connor McAdams <conmanx360@gmail.com>
Cc: "\"Jérémy Lefaure\"" <jeremy.lefaure@lse.epita.fr>,
	alsa-devel@alsa-project.org, o-takashi@sakamocchi.jp,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/9] Add PCI region2 iomap for SBZ
Date: Fri, 04 May 2018 11:26:56 +0200	[thread overview]
Message-ID: <s5ho9hvlqjj.wl-tiwai@suse.de> (raw)
In-Reply-To: <1525383771-11105-3-git-send-email-conmanx360@gmail.com>

On Thu, 03 May 2018 23:42:44 +0200,
Connor McAdams wrote:
> 
> @@ -4691,8 +4699,17 @@ static void ca0132_free(struct hda_codec *codec)
>  
>  	cancel_delayed_work_sync(&spec->unsol_hp_work);
>  	snd_hda_power_up(codec);
> -	snd_hda_sequence_write(codec, spec->base_exit_verbs);
> -	ca0132_exit_chip(codec);
> +	switch (spec->quirk) {
> +	case QUIRK_SBZ:
> +		iounmap(spec->mem_base);
> +		snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +		ca0132_exit_chip(codec);
> +		break;

Do you need to unmap before the rest procedure?
Usually the unmapping happens at the last, after all commands
finished.

> +	default:
> +		snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +		ca0132_exit_chip(codec);
> +		break;
> +	}
>  	snd_hda_power_down(codec);
>  	kfree(spec->spec_init_verbs);
>  	kfree(codec->spec);

So in this case, a cleaner way would be to add the conditional iounmap
like:

  	snd_hda_power_down(codec);
	if (spec->mem_base)
		iounmap(spec->mem_base);
  	kfree(spec->spec_init_verbs);
  	kfree(codec->spec);
	
> @@ -4909,6 +4926,15 @@ static int patch_ca0132(struct hda_codec *codec)
>  	else
>  		spec->quirk = QUIRK_NONE;
>  
> +	/* Setup BAR Region 2 for Sound Blaster Z */
> +	if (spec->quirk == QUIRK_SBZ) {
> +		spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20);
> +		if (spec->mem_base == NULL) {
> +			codec_dbg(codec, "pci_iomap failed!");
> +			codec_dbg(codec, "perhaps this is not an SBZ?");

This should be shown more explicitly, so better to be codec_warn() or
codec_info().


thanks,

Takashi

  reply	other threads:[~2018-05-04  9:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 21:42 [PATCH 1/9] R3Di and SBZ quirk entires + alt firmware loading Connor McAdams
2018-05-03 21:42 ` Connor McAdams
2018-05-03 21:42 ` [PATCH 2/9] Add pincfg for SBZ + R3Di, add fp hp auto-detect Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 3/9] Add PCI region2 iomap for SBZ Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-04  9:26   ` Takashi Iwai [this message]
2018-05-04  9:26     ` Takashi Iwai
2018-05-03 21:42 ` [PATCH 4/9] Add extra exit functions for R3Di and SBZ Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 5/9] add/change helper " Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 6/9] add alt_select_in/out for R3Di + SBZ Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 7/9] Add DSP Volume set and New mixers for SBZ + R3Di Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 8/9] add ca0132_alt_set_vipsource Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-03 21:42 ` [PATCH 9/9] Add new control changes for SBZ + R3Di Connor McAdams
2018-05-03 21:42   ` Connor McAdams
2018-05-04  4:19 [PATCH 1/9] R3Di and SBZ quirk entires + alt firmware loading Connor McAdams
2018-05-04  4:19 ` [PATCH 3/9] Add PCI region2 iomap for SBZ Connor McAdams
2018-05-04  4:19   ` Connor McAdams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5ho9hvlqjj.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=conmanx360@gmail.com \
    --cc=jeremy.lefaure@lse.epita.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.